Changeset 314
- Timestamp:
- Jul 19, 2018, 9:18:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ddt/ddt
r313 r314 1431 1431 1432 1432 control_exist_domainset($computer_db, $domainset) or exit; 1433 if ($ip ne '') { 1433 if ($ip ne '') { # delete by IP 1434 1434 if ( control_exist_ip($computer_db, $ip) == 1 ) { 1435 1435 die "Error: Unkown IP address: $ip\n"; 1436 1436 } 1437 my $computer_index=0; 1438 for my $value (@{$computer_db->{$domainset}}) {1439 for my $id (keys %{$value}) { 1440 if ($value->{$id}->{'ip'} eq $ip) {1441 my $timestamp = time;1442 splice(@{$computer_db->{$domainset}}, $computer_index => 1);1443 print "La machine $ip a été supprimer du domaine $domainset\n"; 1444 ipamdb_save("$COMPUTER_YAML", $computer_db);1445 exit;1446 }1447 }1448 $computer_index++;1449 }1450 #print "La machine $ip n'existe pas sur le domaine $domainset.\n";1437 1438 my $computer_index = 0; 1439 1440 LOOP_ON_COMPUTER: 1441 for my $computer (@{$computer_db->{$domainset}}) { 1442 my ($mac_address, $attribute) = %{$computer}; 1443 1444 $computer_index++ and next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip; 1445 1446 splice(@{$computer_db->{$domainset}}, $computer_index => 1); 1447 ipamdb_save("$COMPUTER_YAML", $computer_db); 1448 print "Info: Host $ip has been removed from the domain set $domainset [OK]\n"; 1449 exit; 1450 } 1451 1451 } 1452 1452 else { … … 1454 1454 die "Error: Unkown host: $hostname, in domain set: $domainset\n"; 1455 1455 } 1456 my $computer_index=0; 1457 for my $value (@{$computer_db->{$domainset}}) { 1458 for my $id (keys %{$value}) { 1459 if (($value->{$id}->{'hostname'} eq $hostname) and ($value->{$id}->{'address_type'} ne 'pool-dhcp')) { 1460 my $timestamp = time; 1461 splice(@{$computer_db->{$domainset}}, $computer_index => 1); 1462 print "La machine $hostname a été supprimer du domaine $domainset\n"; 1463 ipamdb_save("$COMPUTER_YAML", $computer_db); 1464 exit; 1456 1457 my $computer_index = 0; 1458 1459 LOOP_ON_COMPUTER: 1460 for my $computer (@{$computer_db->{$domainset}}) { 1461 my ($mac_address, $attribute) = %{$computer}; 1462 1463 $computer_index++ and next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname; 1464 1465 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1466 die "Error: Host remove $hostname from the domain set $domainset [FAILED]" . 1467 " ... The host $hostname belongs to a DHCP pool.\n"; 1465 1468 } 1466 1469 1467 if (($value->{$id}->{'hostname'} eq $hostname) and ($value->{$id}->{'address_type'} eq 'pool-dhcp')) { 1468 print "Suppression de la machine $hostname sur le domaine $domainset [FAILED]\n"; 1469 print "La machine $hostname fait partie du pool DHCP $hostname.\n"; 1470 exit; 1471 } 1472 } 1473 $computer_index++; 1474 } 1475 #print "La machine $hostname n'existe pas sur le domaine $domainset.\n"; 1470 splice(@{$computer_db->{$domainset}}, $computer_index => 1); 1471 ipamdb_save("$COMPUTER_YAML", $computer_db); 1472 print "Info: Host $hostname has been removed from the domain set $domainset [OK]\n"; 1473 exit; 1474 } 1475 } 1476 1476 } 1477 1477 } … … 1887 1887 } 1888 1888 1889 my $computer_index = 0; 1890 for my $value (@{$computer_db->{$domainset}}) { 1891 for my $id (keys %{$value}) { 1892 if (($value->{$id}->{'hostname'} eq $hostname) and ($value->{$id}->{'address_type'} ne 'pool-dhcp')) { 1893 my $timestamp = time; 1894 $computer_db->{$domainset}[$computer_index]->{$id}->{'modify_time'} = $timestamp; 1895 $computer_db->{$domainset}[$computer_index]->{$id}->{'pxe_config'} = $pxe_config; 1896 print "Host $hostname ($domainset), PXE enabled in config: $pxe_config\n"; 1897 ipamdb_save("$COMPUTER_YAML", $computer_db); 1898 exit; 1899 } 1900 1901 if (($value->{$id}->{'hostname'} eq $hostname) and ($value->{$id}->{'address_type'} eq 'pool-dhcp')) { 1902 die "Error. Host $hostname ($domainset) in a pool. No PXE possible\n"; 1903 } 1904 } 1905 $computer_index++; 1889 LOOP_ON_COMPUTER: 1890 for my $computer (@{$computer_db->{$domainset}}) { 1891 my ($mac_address, $attribute) = %{$computer}; 1892 next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname; 1893 1894 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1895 die "Error. Host $hostname ($domainset) in a pool. No PXE possible [FAILED]\n"; 1896 } 1897 1898 $attribute->{'modify_time'} = time; 1899 $attribute->{'pxe_config'} = $pxe_config; 1900 ipamdb_save("$COMPUTER_YAML", $computer_db); 1901 print "Info: Host $hostname ($domainset), PXE enabled in config: $pxe_config [OK]\n"; 1902 exit; 1906 1903 } 1907 1904 } … … 1948 1945 next if $domainset_current eq 'version'; 1949 1946 1950 my $computer_index = 0;1947 LOOP_ON_COMPUTER: 1951 1948 for my $computer (@{$computer_db->{$domainset_current}}) { 1952 for my $id (keys %{$computer}) { 1953 if ($computer->{$id}->{'ip'} eq $ip) { 1954 next if not exists $computer_db->{$domainset_current}[$computer_index]->{$id}->{'pxe_config'}; 1955 1956 my $pxe_config = $computer_db->{$domainset_current}[$computer_index]->{$id}->{'pxe_config'}; 1957 my $timestamp = time; 1958 $computer_db->{$domainset_current}[$computer_index]->{$id}->{'modify_time'} = $timestamp; 1959 delete $computer_db->{$domainset_current}[$computer_index]->{$id}->{'pxe_config'}; 1960 print "IP Address: $ip, PXE disable from config: $pxe_config\n"; 1961 ipamdb_save("$COMPUTER_YAML", $computer_db); 1962 exit; 1963 } 1964 $computer_index++; 1965 } 1949 my ($mac_address, $attribute) = %{$computer}; 1950 1951 next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip; 1952 next LOOP_ON_COMPUTER if not exists $attribute->{'pxe_config'}; 1953 1954 my $pxe_config = $attribute->{'pxe_config'}; 1955 $attribute->{'modify_time'} = time; 1956 delete $attribute->{'pxe_config'}; 1957 ipamdb_save("$COMPUTER_YAML", $computer_db); 1958 print "Info: IP Address: $ip, PXE disable from config: $pxe_config [OK]\n"; 1959 exit; 1966 1960 } 1967 1961 } … … 1972 1966 } 1973 1967 1974 my $computer_index = 0; 1975 for my $value (@{$computer_db->{$domainset}}) { 1976 for my $id (keys %{$value}) { 1977 if (($value->{$id}->{'hostname'} eq $hostname) and ($value->{$id}->{'address_type'} ne 'pool-dhcp')) { 1978 next if not exists $value->{$id}->{'pxe_config'}; 1979 1980 my $pxe_config = $computer_db->{$domainset}[$computer_index]->{$id}->{'pxe_config'}; 1981 my $timestamp = time; 1982 $computer_db->{$domainset}[$computer_index]->{$id}->{'modify_time'} = $timestamp; 1983 delete $computer_db->{$domainset}[$computer_index]->{$id}->{'pxe_config'}; 1984 print "Host $hostname ($domainset), PXE disable from config: $pxe_config\n"; 1985 ipamdb_save("$COMPUTER_YAML", $computer_db); 1986 exit; 1987 } 1988 1989 if (($value->{$id}->{'hostname'} eq $hostname) and ($value->{$id}->{'address_type'} eq 'pool-dhcp')) { 1990 die "Error. Host $hostname ($domainset) in a pool. No PXE possible\n"; 1991 } 1992 } 1993 $computer_index++; 1968 LOOP_ON_COMPUTER: 1969 for my $computer (@{$computer_db->{$domainset}}) { 1970 my ($mac_address, $attribute) = %{$computer}; 1971 1972 next LOOP_ON_COMPUTER if $attribute->{'hostname'} eq $hostname; 1973 1974 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1975 die "Error. Host $hostname ($domainset) in a pool. No PXE possible [FAILED]\n"; 1976 } 1977 1978 next LOOP_ON_COMPUTER if not exists $attribute->{'pxe_config'}; 1979 1980 my $pxe_config = $attribute->{'pxe_config'}; 1981 $attribute->{'modify_time'} = time; 1982 delete $attribute->{'pxe_config'}; 1983 ipamdb_save("$COMPUTER_YAML", $computer_db); 1984 print "Info: Host $hostname ($domainset), PXE disable from config: $pxe_config [OK]\n"; 1985 exit; 1994 1986 } 1995 1987 }
Note: See TracChangeset
for help on using the changeset viewer.