Changeset 1318
- Timestamp:
- 04/07/15 16:42:41 (9 years ago)
- Location:
- trunk/LATMOS-Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-sql-switch-cname
r1280 r1318 52 52 pod2usage(1); 53 53 } 54 54 55 55 my ($to, $from) = ($ARGV[-1], $ARGV[-2]); 56 56 … … 72 72 warn "CNAME $cname: $nhost => $to\n"; 73 73 74 { 75 my @name = grep { $_ && $_ ne $cname } $onhost->get_attributes('cname'); 76 $onhost->set_c_fields(cname => @name ? [ @name ] : undef) or die "Cannot set $cname to $nhost\n"; 77 } 78 79 { 80 my @name = $cname, $oto->get_attributes('cname'); 81 $oto->set_c_fields(cname => [ grep { $_ } @name ]) or die "Cannot add $cname to $to\n"; 82 } 74 $onhost->delAttributeValue('cname', $cname) or die "Cannot remove $cname from $nhost\n"; 75 $oto->addAttributeValue ('cname', $cname) or die "Cannot add $cname to $to\n"; 83 76 } 77 84 78 foreach my $aname (@arecords) { 85 79 my @listhost = $labase->search_objects('nethost', "otherName=$aname"); … … 97 91 warn "CNAME $aname: $nhost => $to"; 98 92 99 { 100 my @name = grep { $_ && $_ ne $aname } $onhost->get_attributes('otherName'); 101 $onhost->set_c_fields(otherName => @name ? [ @name ] : undef) or die "Cannot set $aname to $nhost\n"; 102 } 103 104 { 105 my @name = $aname, $oto->get_attributes('otherName'); 106 $oto->set_c_fields(otherName => [ grep { $_ } @name ]) or die "Cannot add $aname to $to\n"; 107 } 93 $onhost->delAttributeValue('otherName', $aname) or die "Cannot remove $aname from $nhost\n"; 94 $oto->addAttributeValue ('otherName', $aname) or die "Cannot add $aname to $to\n"; 108 95 } 109 96 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm
r1311 r1318 356 356 { 357 357 my $obj = $self->get_object('nethost', $nethostname); 358 my @cname = grep { $_ && $_ ne $to} 359 $obj->get_attributes('cname'); 360 $obj->set_c_fields(cname => [ @cname ]) or return; 358 $obj->_delAttributeValue(cname => $to); 361 359 } 362 360 $self->rename_object('nethost', $nethostname, $to) or return; 363 361 if ($config{'addcname'}) { 364 362 my $obj = $self->get_object('nethost', $to); 365 my @cname = grep { $_ } $obj->get_attributes('cname'); 366 $obj->set_c_fields(cname => [ @cname, $nethostname ]); 363 $obj->_addAttributeValue(cname => $nethostname); 367 364 } 368 365 return 1; … … 381 378 $obj1 = $self->get_object('nethost', $host1); 382 379 } else { 383 $self->l a_log(LA_ERR, "Cannot find host having $ip1");380 $self->log(LA_ERR, "Cannot find host having $ip1"); 384 381 return; 385 382 } … … 387 384 $obj2 = $self->get_object('nethost', $host2); 388 385 } else { 389 $self->l a_log(LA_ERR, "Cannot find host having $ip2");386 $self->log(LA_ERR, "Cannot find host having $ip2"); 390 387 return; 391 388 } 392 389 if ($obj1->id eq $obj2->id) { 393 $self->l a_log(LA_ERR, "Both ip belong to same host (%s)", $obj1->id);390 $self->log(LA_ERR, "Both ip belong to same host (%s)", $obj1->id); 394 391 return; 395 392 } 396 393 397 my @ip1 = grep { $_ && $_ ne $ip1 } $obj1->get_attributes('ip');398 $obj1-> set_c_fields(ip => [ @ip1 ]);399 my @ip2 = grep { $_ && $_ ne $ip2 } $obj2->get_attributes('ip');400 $obj 2->set_c_fields(ip => [ @ip2, $ip1 ]) or return;401 $obj 1->set_c_fields(ip => [ @ip1, $ip2 ]) or return;394 $self->log(LA_NOTICE, "Exchanging IP between %s and %s", $obj1->id, $obj2->id); 395 $obj1->delAttributeValue('ip', $ip1) or return; 396 $obj2->delAttributeValue('ip', $ip2) or return; 397 $obj1->addAttributeValue('ip', $ip2) or return; 398 $obj2->addAttributeValue('ip', $ip1) or return; 402 399 return 1; 403 400 }
Note: See TracChangeset
for help on using the changeset viewer.