Changeset 302


Ignore:
Timestamp:
Jul 18, 2018, 2:21:02 PM (6 years ago)
Author:
g7moreau
Message:
  • Rewrite disable_float with more modern style
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ddt/ddt

    r301 r302  
    11941194      my @domainsetdb = @{$computer_db->{$domainset_current}};
    11951195
    1196       #$cpt_mac=0;
     1196      LOOP_ON_COMPUTER:
    11971197      for my $computer (@domainsetdb) {
    1198          for my $mac_current (keys %{$computer}) {
    1199             if ($mac_current eq $mac) {
    1200                if ($computer->{$mac}{'ip'} eq $pool) {
    1201                   #splice(@{$computer_db->($domainset_current)} , $cpt_mac => 1);
    1202                   my $timestamp = time;
    1203                   $computer->{$mac}{'modify_time'} = $timestamp;
    1204                   $computer->{$mac}{'enabled'}     = 'no';
    1205                   ipamdb_save("$COMPUTER_YAML", $computer_db);
    1206                   print "Disabling machine $mac from pool $pool [OK]\n";
    1207                   print "+-> Status:" . $computer->{$mac}{'enabled'} . "\n";
    1208                   exit;
    1209                   }
    1210                else {
    1211                   print "Computer disable $mac [FAILED]\n";
    1212                   print "+-> The computer $mac does not belong to the $pool pool.\n";
    1213                   exit;
    1214                   }
    1215                }
    1216             #$cpt_mac++;
     1198         my ($mac_address, $attribute) = %{$computer};
     1199         next LOOP_ON_COMPUTER if $mac_address ne $mac;
     1200
     1201         if ($attribute->{'ip'} eq $pool) {
     1202            my $timestamp = time;
     1203            $attribute->{'modify_time'} = $timestamp;
     1204            $attribute->{'enabled'}     = 'no';
     1205            ipamdb_save("$COMPUTER_YAML", $computer_db);
     1206            print "Disabling machine $mac from pool $pool [OK]\n";
     1207            print "+-> Status:" . $attribute->{'enabled'} . "\n";
     1208            exit;
     1209            }
     1210         else {
     1211            print "Computer disable $mac [FAILED]\n";
     1212            print "+-> The computer $mac does not belong to the $pool pool.\n";
     1213            exit;
    12171214            }
    12181215         }
Note: See TracChangeset for help on using the changeset viewer.