hi Christopher,

add sub-command doesn't support sortorder, nameserver will be added at the
end of the list.

can you send me (or to Chuck)
out if the list a domain name, so I will look
into server log on our side what was wrong.


E.Pirogov
OpenSRS Developer

On Mon, 4 Mar 2002, Christopher Hicks wrote:

> I've been working on a script to update the name servers for all of our
> domains.  Fixing a few problems along the way I thought I had things
> working until I tried to run it again today.  The subroutine is:
>
> sub fixns {
>         my $sql = "select * from domain where opensrs=1 and dead=0";
>         my $sth = $dbh->prepare($sql) or die "bad << $sql >>";
>         $sth->execute or die;
>
>       my %attr = %defattr;
>       $attr{type} = 'nameservers';
>
>       my $row;
>       while ($row = $sth->fetchrow_hashref) {
>               my $domain = $row->{name};
>               my $nssetid = $row->{nssetid};
>
>               print "processing $domain...";
>
>               my @ns_shouldbe;
>               $sql = "select * from nameserversetitem
>                               where nssetid=$nssetid
>                               order by lookorder
>               ";
>               $sth2 = $dbh->prepare($sql) or die "bad << $sql >>";
>               $sth2->execute or die;
>               if ($sth2->rows == 0) {
>                       print "no nssetitems\n";
>                       next;
>               }
>               while (my $nsrow = $sth2->fetchrow_hashref) {
>                       push(@ns_shouldbe,$nsrow->{name});
>               }
>
>               my $rv = $XCP->send({
>                       action => 'set',
>                       object => 'cookie',
>                       attributes => {
>                               domain => $domain,
>                               reg_username => $defattr{reg_username},
>                               reg_password => $defattr{reg_password}
>                       },
>               });
>
>               if ($rv->{is_success}) {
>                       print "login...";
>               } else {
>                       die $rv->{response_text};
>               }
>
>               $cookie = $rv->{attributes}{cookie};
>
>               %attr = %defattr;
>               $attr{type} = 'nameservers';
>
>               $rv = $XCP->send({
>                       action => 'get',
>                       object => 'domain',
>                       cookie => $cookie,
>                       attributes => \%attr,
>               });
>
>               if ($rv->{is_success}) {
>                       print "got curr domains,";
>               } else {
>                       die $rv->{response_text};
>               }
>
>               my @ns_is;
>               foreach my $listent (@{$rv->{attributes}->{nameserver_list}}) {
>                       push(@ns_is,$listent->{name});
>               }
>
>               #print Dumper(\@ns_is,\@ns_shouldbe),"\n";die;
>
>               my $x = 0;
>               foreach my $is (@ns_is) {
>                       my $sb = $ns_shouldbe[$x];
>                       if ($is eq $sb) {
>                               $x++;
>                               next;
>                       } else {
>                               print "ns[$x] mismatch,";
>                               #print "\n\t($is<>$sb),";
>                               last;
>                       }
>               }
>
>               if ($x == scalar(@ns_shouldbe)) {
>                       print " good.  :-)\n";
>                       next;
>               #} else {
>               #       print "\n\tx=$x, snsb=",scalar(@ns_shouldbe),"\n";
>               }
>
>               if (0) {
>                       print "need to fix!!!!\n";
>                       next;
>               }
>
>               print "fixing...";
>
>               my $nslist;
>               my $y=1;
>               foreach my $sb (@ns_shouldbe) {
>                       my $action = 'update';
>                       if ($y > scalar @ns_is) {
>                               $action = 'add';
>                       }
>                       #$sb = uc $sb;
>                       my $racedom = $UTIL->do_race($sb);
>                       push(@$nslist, {
>                                       name => $racedom->{ConvertedDomain},
>                                       sortorder => $y,
>                                       action => $action,
>                               });
>                       $y++;
>               }
>               while ($y <= scalar @ns_is) {
>                       push(@$nslist, {
>                                       sortorder => $y,
>                                       action => 'remove',
>                               });
>                       $y++;
>               }
>               #print Dumper($nslist),"\n";die;
>
>               %attr = ();
>               $attr{data} = 'nameserver_list';
>               $attr{nameserver_list} = $nslist;
>               $rv = $XCP->send({
>                       action => 'modify',
>                       object => 'domain',
>                       cookie => $cookie,
>                       attributes => \%attr,
>               });
>
>               if ($rv->{is_success}) {
>                       print "done."
>               } else {
>                       die "\nOpenSRS: $rv->{response_text}\n"
>                               . Dumper($rv)
>                               . Dumper(\%attr)
>                               . ' ';
>               }
>
>               print "\n";
>       }
>         $sth->finish if defined($sth);
> }
>
> And here's what it's giving me today:
>
>       processing chicks.net...login...got curr domains,ns[0] mismatch,fixing...
>       OpenSRS: Fatal Server Error Occured
>       $VAR1 = {
>                 'is_success' => '0',
>                 '_OPS_msg_type' => undef,
>                 'protocol' => 'XCP',
>                 'object' => 'DOMAIN',
>                 '_OPS_msg_id' => undef,
>                 'attributes' => {
>                                   'external_client' => '1',
>                                   'command_rate' => '0'
>                                 },
>                 'response_text' => 'Fatal Server Error Occured',
>                 'response_code' => '400',
>                 'action' => 'REPLY'
>               };
>       $VAR1 = {
>                 'data' => 'nameserver_list',
>                 'nameserver_list' => [
>                                        {
>                                          'sortorder' => 1,
>                                          'action' => 'update',
>                                          'name' => 'va0.fini.net'
>                                        },
>                                        {
>                                          'sortorder' => '2',
>                                          'action' => 'update',
>                                          'name' => 'va1.fini.net'
>                                        },
>                                        {
>                                          'sortorder' => '3',
>                                          'action' => 'update',
>                                          'name' => 'va2.fini.net'
>                                        },
>                                                {
>                                          'sortorder' => '4',
>                                          'action' => 'update',
>                                          'name' => 'va3.fini.net'
>                                        },
>                                        {
>                                          'sortorder' => '5',
>                                          'action' => 'update',
>                                          'name' => 'ca0.fini.net'
>                                        },
>                                        {
>                                          'sortorder' => '6',
>                                          'action' => 'add',
>                                          'name' => 'ca1.fini.net'
>                                        }
>                                      ]
>               };
>         at ./testsf line 193, <GEN6> line 12.
>
> I've run the exact same code within the last three weeks several times and
> it worked.  Today's error message is NOT helpful.
>
> There was a problem at one point where it wouldn't take nameservers that
> weren't in use somewhere (even if they were defined on the
> manage.opensrs.net for the domain), but that gave a different error.
>
> There are 140 domains to update and I've done it once through manage and
> I'd rather pull teeth than do it that way again.  I know I could define a
> given set of name servers and just change the IP's, but we're expecting
> some situations where that would be suboptimal.
>
> Any suggestions would be greatly appreciated.
>
> --
> </chris>
>
> "Outside of a dog, a man's best friend is a good book.
> Inside of a dog, it's too dark to read."   -  Groucho Marx
>
>

Reply via email to