- Timestamp:
- Aug 30, 2018, 4:25:34 PM (6 years ago)
- Location:
- trunk/ddt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ddt/ddt
r344 r345 21 21 use strict; 22 22 #use warnings; 23 use version; our $VERSION = version->declare('0.1 0.5');23 use version; our $VERSION = version->declare('0.11.0'); 24 24 25 25 use Getopt::Long qw(GetOptions); … … 41 41 'add-virtual' => \&cmd_add_virtual, 42 42 'change-comment' => \&cmd_change_comment, 43 'change- domainset' => \&cmd_change_domainset,43 'change-sector' => \&cmd_change_sector, 44 44 'change-host' => \&cmd_change_host, 45 45 'change-ip' => \&cmd_change_ip, … … 47 47 'change-tag' => \&cmd_change_tag, 48 48 'check-dns' => \&cmd_check_dns, 49 'create- domainset' => \&cmd_create_domainset,49 'create-sector' => \&cmd_create_sector, 50 50 'create-pool' => \&cmd_create_pool, 51 51 'create-pxe' => \&cmd_create_pxe, … … 67 67 'search-mac' => \&cmd_search_mac, 68 68 'show' => \&cmd_show_host, 69 'show- domainset' => \&cmd_show_domainset,69 'show-sector' => \&cmd_show_sector, 70 70 'show-pool' => \&cmd_show_pool, 71 71 'show-pxe' => \&cmd_show_pxe, … … 165 165 166 166 #------------------------------------------------------------------------------- 167 #Nom: control_exist_ domainset168 #Description: controle l'existence d'un domain setdans le fichier YAML167 #Nom: control_exist_sector 168 #Description: controle l'existence d'un sector dans le fichier YAML 169 169 # return 0 (faux) ou 1 (vrai) 170 170 171 sub control_exist_ domainset{172 my ($computer_db, $ domainset) = @_;173 174 return 1 if exists $computer_db->{$ domainset};175 176 print {*STDERR} "Error: domain set $domainsetnot found\n";171 sub control_exist_sector { 172 my ($computer_db, $sector) = @_; 173 174 return 1 if exists $computer_db->{$sector}; 175 176 print {*STDERR} "Error: sector $sector not found\n"; 177 177 return 0; 178 178 } … … 184 184 185 185 sub control_exist_hostname { 186 my ($computer_db, $ domainset, $hostname) = @_;187 188 if ($computer_db->{$ domainset} eq '') {186 my ($computer_db, $sector, $hostname) = @_; 187 188 if ($computer_db->{$sector} eq '') { 189 189 return 1; 190 190 } 191 191 192 my @ domainsetdb = @{$computer_db->{$domainset}};193 194 for my $computer (@ domainsetdb) {192 my @sectordb = @{$computer_db->{$sector}}; 193 194 for my $computer (@sectordb) { 195 195 my ($mac_address, $attribute) = %{$computer}; 196 196 return 0 if $attribute->{'hostname'} eq $hostname; … … 207 207 my ($computer_db, $mac) = @_; 208 208 209 for my $ domainset_current (keys %{$computer_db}) {210 next if $ domainset_current eq 'dset';211 next if $ domainset_current eq 'pool';212 next if $ domainset_current eq 'pxe';213 next if $ domainset_current eq 'tag';214 next if $ domainset_current eq 'version';215 216 my @ domainsetdb = @{$computer_db->{$domainset_current}};209 for my $sector_current (keys %{$computer_db}) { 210 next if $sector_current eq 'dset'; 211 next if $sector_current eq 'pool'; 212 next if $sector_current eq 'pxe'; 213 next if $sector_current eq 'tag'; 214 next if $sector_current eq 'version'; 215 216 my @sectordb = @{$computer_db->{$sector_current}}; 217 217 218 218 LOOP_ON_COMPUTER: 219 for my $computer (@ domainsetdb) {219 for my $computer (@sectordb) { 220 220 my ($mac_address, $attribute) = %{$computer}; 221 221 return 0 if $mac_address eq $mac; … … 233 233 my ($computer_db, $ip) = @_; 234 234 235 for my $ domainset_current (keys %{$computer_db}) {236 next if $ domainset_current eq 'dset';237 next if $ domainset_current eq 'pool';238 next if $ domainset_current eq 'pxe';239 next if $ domainset_current eq 'tag';240 next if $ domainset_current eq 'version';235 for my $sector_current (keys %{$computer_db}) { 236 next if $sector_current eq 'dset'; 237 next if $sector_current eq 'pool'; 238 next if $sector_current eq 'pxe'; 239 next if $sector_current eq 'tag'; 240 next if $sector_current eq 'version'; 241 241 242 242 LOOP_ON_COMPUTER: 243 for my $computer (@{$computer_db->{$ domainset_current}}) {243 for my $computer (@{$computer_db->{$sector_current}}) { 244 244 my ($mac_address, $attribute) = %{$computer}; 245 245 #print "Erreur: cette adresse IP $ip existe déjà\n"; … … 357 357 358 358 sub get_mac_from_hostname { 359 my ($computer_db, $ domainset, $hostname, $mac) = @_;359 my ($computer_db, $sector, $hostname, $mac) = @_; 360 360 361 361 return $mac if $mac ne ''; … … 363 363 364 364 LOOP_ON_COMPUTER: 365 for my $computer (@{$computer_db->{$ domainset}}) {365 for my $computer (@{$computer_db->{$sector}}) { 366 366 my ($mac_address, $attribute) = %{$computer}; 367 367 … … 375 375 376 376 sub get_mac_from_ip { 377 my ($computer_db, $ domainset, $ip, $mac) = @_;377 my ($computer_db, $sector, $ip, $mac) = @_; 378 378 379 379 return $mac if $mac ne ''; … … 381 381 382 382 LOOP_ON_COMPUTER: 383 for my $computer (@{$computer_db->{$ domainset}}) {383 for my $computer (@{$computer_db->{$sector}}) { 384 384 my ($mac_address, $attribute) = %{$computer}; 385 385 … … 394 394 395 395 sub get_computer_from_mac { 396 my ($computer_db, $ domainset, $mac) = @_;396 my ($computer_db, $sector, $mac) = @_; 397 397 398 398 LOOP_ON_COMPUTER: 399 for my $computer (@{$computer_db->{$ domainset}}) {399 for my $computer (@{$computer_db->{$sector}}) { 400 400 my ($mac_address, $attribute) = %{$computer}; 401 401 … … 416 416 417 417 sub add_alias { 418 my ($computer_db, $hostname, $ domainset, $alias) = @_;419 420 control_exist_ domainset($computer_db, $domainset) or exit;421 control_exist_hostname($computer_db, $ domainset, $hostname) or die "Error: host already exist in domain set $domainset: $hostname\n";422 423 my @ domainsetdb = @{$computer_db->{$domainset}};418 my ($computer_db, $hostname, $sector, $alias) = @_; 419 420 control_exist_sector($computer_db, $sector) or exit; 421 control_exist_hostname($computer_db, $sector, $hostname) or die "Error: host already exist in sector $sector: $hostname\n"; 422 423 my @sectordb = @{$computer_db->{$sector}}; 424 424 425 425 LOOP_ON_COMPUTER: 426 for my $computer (@ domainsetdb) {426 for my $computer (@sectordb) { 427 427 my ($mac_address, $attribute) = %{$computer}; 428 428 … … 443 443 444 444 sub add_static { 445 my ($computer_db, $hostname, $ domainset, $ip, $mac, $comment) = @_;445 my ($computer_db, $hostname, $sector, $ip, $mac, $comment) = @_; 446 446 447 447 $mac = normalize_mac_address($mac); 448 448 $comment = normalize_comment($comment); 449 control_exist_hostname($computer_db, $ domainset, $hostname) or die "Error: host already exist in domain set $domainset: $hostname\n";449 control_exist_hostname($computer_db, $sector, $hostname) or die "Error: host already exist in sector $sector: $hostname\n"; 450 450 control_syntax_mac_address($mac) or exit; 451 451 control_exist_mac($computer_db, $mac) or die "Error: physical MAC address already exists: $mac\n"; 452 452 control_syntax_ip($ip) or exit; 453 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in domain set $domainset: $ip\n";453 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in sector $sector: $ip\n"; 454 454 control_syntax_comment($comment) or exit; 455 455 my $timestamp = time; 456 push @{$computer_db->{$ domainset}}, { $mac => {456 push @{$computer_db->{$sector}}, { $mac => { 457 457 'hostname' => $hostname, 458 458 'ip' => $ip, … … 464 464 'alias' => '', 465 465 }}; 466 print "Info: add the host: $hostname, IP: $ip, MAC: $mac, domain set: $domainset[OK]\n";466 print "Info: add the host: $hostname, IP: $ip, MAC: $mac, sector: $sector [OK]\n"; 467 467 468 468 ipamdb_save("$COMPUTER_YAML", $computer_db); … … 476 476 477 477 sub add_dhcp { 478 my ($computer_db, $hostname, $ domainset, $ip, $mac, $comment) = @_;478 my ($computer_db, $hostname, $sector, $ip, $mac, $comment) = @_; 479 479 480 480 my $timestamp = time; 481 481 $mac = normalize_mac_address($mac); 482 482 $comment = normalize_comment($comment); 483 control_exist_ domainset($computer_db, $domainset) or exit;484 control_exist_hostname($computer_db, $ domainset, $hostname) or die "Error: host already exist in domain set $domainset: $hostname\n";483 control_exist_sector($computer_db, $sector) or exit; 484 control_exist_hostname($computer_db, $sector, $hostname) or die "Error: host already exist in sector $sector: $hostname\n"; 485 485 control_syntax_mac_address($mac) or exit; 486 486 control_exist_mac($computer_db, $mac) or die "Error: physical MAC address already exists: $mac\n"; 487 487 control_syntax_ip($ip) or exit; 488 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in domain set $domainset: $ip.\n";488 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in sector $sector: $ip.\n"; 489 489 control_syntax_comment($comment) or exit; 490 490 491 push @{$computer_db->{$ domainset}}, { $mac => {491 push @{$computer_db->{$sector}}, { $mac => { 492 492 'hostname' => $hostname, 493 493 'ip' => $ip, … … 499 499 'alias' => '', 500 500 }}; 501 print "Add the computer: $hostname, IP: $ip, MAC: $mac, domain set: $domainset\n";501 print "Add the computer: $hostname, IP: $ip, MAC: $mac, sector: $sector\n"; 502 502 503 503 ipamdb_save("$COMPUTER_YAML", $computer_db); … … 508 508 509 509 sub add_float { 510 my ($computer_db, $pool, $ domainset, $mac, $comment) = @_;510 my ($computer_db, $pool, $sector, $mac, $comment) = @_; 511 511 512 512 my $timestamp = time; 513 513 $mac = normalize_mac_address($mac); 514 514 $comment = normalize_comment($comment); 515 control_exist_ domainset($computer_db, $domainset) or exit;515 control_exist_sector($computer_db, $sector) or exit; 516 516 control_syntax_mac_address($mac) or exit; 517 517 control_exist_mac($computer_db, $mac) or die "Error: physical MAC address already exists: $mac\n"; 518 518 control_exist_pool($computer_db, $pool) or die "Error: the pool doesn't exists: $pool\n"; 519 519 control_syntax_comment($comment) or exit; 520 push @{$computer_db->{$ domainset}}, { $mac => {520 push @{$computer_db->{$sector}}, { $mac => { 521 521 'hostname' => $pool, 522 522 'ip' => $pool, … … 527 527 'comment' => $comment, 528 528 }}; 529 print "Info: add the computer in pool MAC: $mac, domain set: $domainset, Pool: $pool [OK]\n";529 print "Info: add the computer in pool MAC: $mac, sector: $sector, Pool: $pool [OK]\n"; 530 530 531 531 ipamdb_save("$COMPUTER_YAML", $computer_db); … … 540 540 541 541 my $help = get_cmd_name(); 542 my ($hostname, $ domainset, $alias);542 my ($hostname, $sector, $alias); 543 543 544 544 GetOptions( 545 545 'hostname|h=s' => \$hostname, 546 ' domainset|d=s' => \$domainset,546 'sector|d=s' => \$sector, 547 547 'alias|a=s' => \$alias, 548 548 ); 549 549 550 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;550 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 551 551 exit_on_error_option($help) 552 552 if $hostname eq '' 553 or $ domainseteq ''553 or $sector eq '' 554 554 or $alias eq ''; 555 555 556 556 my $computer_db = ipamdb_load($COMPUTER_YAML); 557 add_alias($computer_db, $hostname, $ domainset, $alias);557 add_alias($computer_db, $hostname, $sector, $alias); 558 558 } 559 559 … … 564 564 565 565 my $help = get_cmd_name(); 566 my ($hostname, $ domainset, $ip, $mac, $comment);566 my ($hostname, $sector, $ip, $mac, $comment); 567 567 568 568 GetOptions( 569 569 'hostname|h=s' => \$hostname, 570 ' domainset|d=s' => \$domainset,570 'sector|d=s' => \$sector, 571 571 'ip|i=s' => \$ip, 572 572 'mac|m=s' => \$mac, … … 574 574 ); 575 575 576 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;576 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 577 577 exit_on_error_option($help) 578 578 if $hostname eq '' 579 or $ domainseteq ''579 or $sector eq '' 580 580 or $ip eq '' 581 581 or $mac eq '' … … 583 583 584 584 my $computer_db = ipamdb_load($COMPUTER_YAML); 585 add_dhcp($computer_db, $hostname, $ domainset, $ip, $mac, $comment);585 add_dhcp($computer_db, $hostname, $sector, $ip, $mac, $comment); 586 586 } 587 587 … … 592 592 593 593 my $help = get_cmd_name(); 594 my ($pool, $ domainset, $mac, $comment);594 my ($pool, $sector, $mac, $comment); 595 595 596 596 GetOptions( 597 597 'pool|p=s' => \$pool, 598 ' domainset|d=s' => \$domainset,598 'sector|d=s' => \$sector, 599 599 'mac|m=s' => \$mac, 600 600 'comment|c=s' => \$comment, 601 601 ); 602 602 603 ($pool, $ domainset) = split /\./, $pool, 2 if $pool =~ m/\./;603 ($pool, $sector) = split /\./, $pool, 2 if $pool =~ m/\./; 604 604 exit_on_error_option($help) 605 605 if $pool eq '' 606 or $ domainseteq ''606 or $sector eq '' 607 607 or $mac eq '' 608 608 or $comment eq ''; 609 609 610 610 my $computer_db = ipamdb_load($COMPUTER_YAML); 611 add_float($computer_db, $pool, $ domainset, $mac, $comment);611 add_float($computer_db, $pool, $sector, $mac, $comment); 612 612 } 613 613 … … 618 618 619 619 my $help = get_cmd_name(); 620 my ($hostname, $ domainset, $ip, $mac, $comment);620 my ($hostname, $sector, $ip, $mac, $comment); 621 621 622 622 GetOptions( 623 623 'hostname|h=s' => \$hostname, 624 ' domainset|d=s' => \$domainset,624 'sector|d=s' => \$sector, 625 625 'ip|i=s' => \$ip, 626 626 'mac|m=s' => \$mac, … … 628 628 ); 629 629 630 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;630 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 631 631 exit_on_error_option($help) 632 632 if $hostname eq '' 633 or $ domainseteq ''633 or $sector eq '' 634 634 or $ip eq '' 635 635 or $mac eq '' … … 637 637 638 638 my $computer_db = ipamdb_load($COMPUTER_YAML); 639 add_static($computer_db, $hostname, $ domainset, $ip, $mac, $comment);639 add_static($computer_db, $hostname, $sector, $ip, $mac, $comment); 640 640 } 641 641 … … 647 647 648 648 my $help = get_cmd_name(); 649 my ($hostname, $ domainset, $ip, $comment);649 my ($hostname, $sector, $ip, $comment); 650 650 651 651 GetOptions( 652 652 'hostname|h=s' => \$hostname, 653 ' domainset|d=s' => \$domainset,653 'sector|d=s' => \$sector, 654 654 'ip|i=s' => \$ip, 655 655 'comment|c=s' => \$comment, 656 656 ); 657 657 658 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;658 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 659 659 exit_on_error_option($help) 660 660 if $hostname eq '' 661 or $ domainseteq ''661 or $sector eq '' 662 662 or $ip eq '' 663 663 or $comment eq ''; … … 668 668 my $timestamp = time; 669 669 670 control_exist_ domainset($computer_db, $domainset) or exit;671 control_exist_hostname($computer_db, $ domainset, $hostname) or die "Error: host already exist in domain set $domainset: $hostname\n";670 control_exist_sector($computer_db, $sector) or exit; 671 control_exist_hostname($computer_db, $sector, $hostname) or die "Error: host already exist in sector $sector: $hostname\n"; 672 672 control_syntax_ip($ip) or exit; 673 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in domain set $domainset: $ip.\n";673 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in sector $sector: $ip.\n"; 674 674 control_syntax_comment($comment) or exit; 675 675 … … 678 678 control_exist_mac($computer_db, $mac) or die "Error: virtual physical MAC address already exists: $mac\n"; 679 679 680 push @{$computer_db->{$ domainset}}, { $mac => {680 push @{$computer_db->{$sector}}, { $mac => { 681 681 'hostname' => $hostname, 682 682 'ip' => $ip, … … 687 687 'comment' => $comment, 688 688 }}; 689 print "Add the virtual computer: $hostname, IP: $ip, domain set: $domainset\n";689 print "Add the virtual computer: $hostname, IP: $ip, sector: $sector\n"; 690 690 691 691 ipamdb_save("$COMPUTER_YAML", $computer_db); … … 704 704 705 705 sub change_mac { 706 my ($hostname, $ domainset, $ip, $mac) = @_;706 my ($hostname, $sector, $ip, $mac) = @_; 707 707 708 708 my $computer_db = ipamdb_load($COMPUTER_YAML); 709 709 710 710 $mac = normalize_mac_address($mac); 711 control_exist_ domainset($computer_db, $domainset) or exit;711 control_exist_sector($computer_db, $sector) or exit; 712 712 control_syntax_mac_address($mac) or exit; 713 713 control_exist_mac($computer_db, $mac) or die "Error: physical MAC address already exists: $mac\n"; … … 718 718 exit; 719 719 } 720 my @ domainsetdb = @{$computer_db->{$domainset}};720 my @sectordb = @{$computer_db->{$sector}}; 721 721 LOOP_ON_COMPUTER: 722 for my $computer (@ domainsetdb) {722 for my $computer (@sectordb) { 723 723 my ($mac_address, $attribute) = %{$computer}; 724 die "Error: physical MAC address $mac already exists in domain set $domainset\n" if $mac_address eq $mac;724 die "Error: physical MAC address $mac already exists in sector $sector\n" if $mac_address eq $mac; 725 725 726 726 next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip; … … 731 731 732 732 ipamdb_save("$COMPUTER_YAML", $computer_db); 733 print "Info: update host $attribute->{'hostname'}, domain set $domainset, MAC $mac, IP $attribute->{'ip'} [OK]\n";733 print "Info: update host $attribute->{'hostname'}, sector $sector, MAC $mac, IP $attribute->{'ip'} [OK]\n"; 734 734 exit; 735 735 } 736 736 } 737 737 elsif ($hostname ne '') { 738 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {739 die "Error: unkown Host: $hostname, in Domain Set: $domainset\n";740 } 741 my @ domainsetdb = @{$computer_db->{$domainset}};738 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 739 die "Error: unkown host $hostname, sector $sector\n"; 740 } 741 my @sectordb = @{$computer_db->{$sector}}; 742 742 LOOP_ON_COMPUTER: 743 for my $computer (@ domainsetdb) {743 for my $computer (@sectordb) { 744 744 my ($mac_address, $attribute) = %{$computer}; 745 die "Error: physical MAC address $mac already exists in domain set $domainset\n" if $mac_address eq $mac;745 die "Error: physical MAC address $mac already exists in sector $sector\n" if $mac_address eq $mac; 746 746 747 747 next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname; … … 752 752 753 753 ipamdb_save("$COMPUTER_YAML", $computer_db); 754 print "Info: update host $attribute->{'hostname'}, domain set $domainset, MAC $mac, IP $attribute->{'ip'} [OK]\n";754 print "Info: update host $attribute->{'hostname'}, sector $sector, MAC $mac, IP $attribute->{'ip'} [OK]\n"; 755 755 exit; 756 756 } … … 764 764 765 765 sub change_ip { 766 my ($hostname, $ domainset, $ip) = @_;767 768 my $computer_db = ipamdb_load($COMPUTER_YAML); 769 770 control_exist_ domainset($computer_db, $domainset) or exit;771 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {772 die "Error: unkown host: $hostname, in domain set: $domainset\n";766 my ($hostname, $sector, $ip) = @_; 767 768 my $computer_db = ipamdb_load($COMPUTER_YAML); 769 770 control_exist_sector($computer_db, $sector) or exit; 771 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 772 die "Error: unkown host: $hostname, in sector: $sector\n"; 773 773 } 774 774 control_syntax_ip($ip) or exit; 775 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in domain set $domainset: $ip\n";776 777 my @ domainsetdb = @{$computer_db->{$domainset}};775 control_exist_ip($computer_db, $ip) or die "Error: IP address already exist in sector $sector: $ip\n"; 776 777 my @sectordb = @{$computer_db->{$sector}}; 778 778 779 779 LOOP_ON_COMPUTER: 780 for my $computer (@ domainsetdb) {780 for my $computer (@sectordb) { 781 781 my ($mac_address, $attribute) = %{$computer}; 782 782 … … 784 784 785 785 if ($attribute->{'address_type'} eq 'pool-dhcp') { 786 die "Error: host $hostname from domain set $domainsetbelongs to a a pool [FAILED]" .786 die "Error: host $hostname from sector $sector belongs to a a pool [FAILED]" . 787 787 " ... use 'del-float' command before"; 788 788 } … … 801 801 802 802 sub change_host { 803 my ($hostname, $ domainset, $ip) = @_;804 805 my $computer_db = ipamdb_load($COMPUTER_YAML); 806 807 control_exist_ domainset($computer_db, $domainset) or exit;803 my ($hostname, $sector, $ip) = @_; 804 805 my $computer_db = ipamdb_load($COMPUTER_YAML); 806 807 control_exist_sector($computer_db, $sector) or exit; 808 808 control_syntax_ip($ip) or exit; 809 809 if ( control_exist_ip($computer_db, $ip) == 1 ) { 810 810 die "Error: unkown IP address: $ip\n"; 811 811 } 812 control_exist_hostname($computer_db, $ domainset, $hostname) or die "Error: host already exist in domain set $domainset: $hostname\n";813 814 my @ domainsetdb = @{$computer_db->{$domainset}};812 control_exist_hostname($computer_db, $sector, $hostname) or die "Error: host already exist in sector $sector: $hostname\n"; 813 814 my @sectordb = @{$computer_db->{$sector}}; 815 815 816 816 LOOP_ON_COMPUTER: 817 for my $computer (@ domainsetdb) {817 for my $computer (@sectordb) { 818 818 my ($mac_address, $attribute) = %{$computer}; 819 819 … … 828 828 829 829 die "Error: failed to update hostname $hostname [FAILED]\n" . 830 " ... no IP $ip belongs to the domain set $domainset\n";830 " ... no IP $ip belongs to the sector $sector\n"; 831 831 } 832 832 … … 837 837 838 838 my $help = get_cmd_name(); 839 my ($hostname, $ domainset, $ip, $mac);839 my ($hostname, $sector, $ip, $mac); 840 840 841 841 GetOptions( 842 842 'hostname|h=s' => \$hostname, 843 ' domainset|d=s' => \$domainset,843 'sector|d=s' => \$sector, 844 844 'ip|i=s' => \$ip, 845 845 'mac|m=s' => \$mac, 846 846 ); 847 847 848 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;849 exit_on_error_option($help) 850 if $ domainseteq ''848 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 849 exit_on_error_option($help) 850 if $sector eq '' 851 851 or $mac eq ''; 852 852 exit_on_error_option($help) … … 854 854 and $ip ne ''; 855 855 856 change_mac($hostname, $ domainset, $ip, $mac);856 change_mac($hostname, $sector, $ip, $mac); 857 857 } 858 858 … … 863 863 864 864 my $help = get_cmd_name(); 865 my ($hostname, $ domainset, $ip);865 my ($hostname, $sector, $ip); 866 866 867 867 GetOptions( 868 868 'hostname|h=s' => \$hostname, 869 ' domainset|d=s' => \$domainset,869 'sector|d=s' => \$sector, 870 870 'ip|i=s' => \$ip, 871 871 ); 872 872 873 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;873 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 874 874 exit_on_error_option($help) 875 875 if $hostname eq '' 876 or $ domainseteq ''876 or $sector eq '' 877 877 or $ip eq ''; 878 878 879 change_ip($hostname, $ domainset, $ip);879 change_ip($hostname, $sector, $ip); 880 880 } 881 881 … … 886 886 887 887 my $help = get_cmd_name(); 888 my ($hostname, $ domainset, $ip);888 my ($hostname, $sector, $ip); 889 889 890 890 GetOptions( 891 891 'hostname|h=s' => \$hostname, 892 ' domainset|d=s' => \$domainset,892 'sector|d=s' => \$sector, 893 893 'ip|i=s' => \$ip, 894 894 ); 895 895 896 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;896 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 897 897 exit_on_error_option($help) 898 898 if $hostname eq '' 899 or $ domainseteq ''899 or $sector eq '' 900 900 or $ip eq ''; 901 901 902 change_host($hostname, $ domainset, $ip);902 change_host($hostname, $sector, $ip); 903 903 } 904 904 … … 909 909 910 910 my $help = get_cmd_name(); 911 my ($ domainset, $mac, $comment);911 my ($sector, $mac, $comment); 912 912 913 913 GetOptions( 914 ' domainset|d=s' => \$domainset,914 'sector|d=s' => \$sector, 915 915 'mac|m=s' => \$mac, 916 916 'comment|c=s' => \$comment, … … 918 918 919 919 exit_on_error_option($help) 920 if $ domainseteq ''920 if $sector eq '' 921 921 or $mac eq '' 922 922 or $comment eq ''; … … 927 927 my $computer_db = ipamdb_load($COMPUTER_YAML); 928 928 929 control_exist_ domainset($computer_db, $domainset) or exit;929 control_exist_sector($computer_db, $sector) or exit; 930 930 control_syntax_mac_address($mac) or exit; 931 931 control_syntax_comment($comment) or exit; 932 932 933 my @ domainsetdb = @{$computer_db->{$domainset}};933 my @sectordb = @{$computer_db->{$sector}}; 934 934 935 935 LOOP_ON_COMPUTER: 936 for my $computer (@ domainsetdb) {936 for my $computer (@sectordb) { 937 937 my ($mac_address, $attribute) = %{$computer}; 938 938 … … 945 945 } 946 946 die "Error : Host $mac comment [FAILED]\n" . 947 " ... No MAC: $mac belongs to the domaine set $ domainset.\n";947 " ... No MAC: $mac belongs to the domaine set $sector.\n"; 948 948 } 949 949 950 950 #-------------------------------------------------------------------------------- 951 951 952 sub cmd_change_ domainset{952 sub cmd_change_sector { 953 953 local @ARGV = @_; 954 954 955 955 my $help = get_cmd_name(); 956 my ($ domainset, $ip, $mac);956 my ($sector, $ip, $mac); 957 957 958 958 GetOptions( 959 ' domainset|d=s' => \$domainset,959 'sector|d=s' => \$sector, 960 960 'ip|i=s' => \$ip, 961 961 'mac|m=s' => \$mac, … … 963 963 964 964 exit_on_error_option($help) 965 if $ domainseteq ''965 if $sector eq '' 966 966 or $ip eq '' 967 967 or $mac eq ''; … … 971 971 my $computer_db = ipamdb_load($COMPUTER_YAML); 972 972 973 control_exist_ domainset($computer_db, $domainset) or exit;973 control_exist_sector($computer_db, $sector) or exit; 974 974 control_syntax_ip($ip) or exit; 975 975 control_syntax_mac_address($mac) or exit; 976 976 977 LOOP_ON_ DOMAINSET:978 for my $ domainset_current (keys %{$computer_db}) {979 next if $ domainset_current eq 'dset';980 next if $ domainset_current eq 'pool';981 next if $ domainset_current eq 'pxe';982 next if $ domainset_current eq 'tag';983 next if $ domainset_current eq 'version';984 985 my @ domainsetdb = @{$computer_db->{$domainset_current}};977 LOOP_ON_SECTOR: 978 for my $sector_current (keys %{$computer_db}) { 979 next if $sector_current eq 'dset'; 980 next if $sector_current eq 'pool'; 981 next if $sector_current eq 'pxe'; 982 next if $sector_current eq 'tag'; 983 next if $sector_current eq 'version'; 984 985 my @sectordb = @{$computer_db->{$sector_current}}; 986 986 my $computer_index = 0; 987 987 LOOP_ON_COMPUTER: 988 for my $computer (@ domainsetdb) {988 for my $computer (@sectordb) { 989 989 my ($mac_address, $attribute) = %{$computer}; 990 990 991 991 $computer_index++, next LOOP_ON_COMPUTER if $mac_address ne $mac; 992 next LOOP_ON_ DOMAINSETif $attribute->{'ip'} ne $ip;992 next LOOP_ON_SECTOR if $attribute->{'ip'} ne $ip; 993 993 994 994 $attribute->{'modify_time'} = time; 995 splice(@{$computer_db->{$ domainset_current}}, $computer_index => 1);996 push @{$computer_db->{$ domainset}}, { $mac => $attribute };995 splice(@{$computer_db->{$sector_current}}, $computer_index => 1); 996 push @{$computer_db->{$sector}}, { $mac => $attribute }; 997 997 998 998 ipamdb_save("$COMPUTER_YAML", $computer_db); … … 1000 1000 } 1001 1001 } 1002 die "Error: update of domain set $domainset[FAILED]\n" .1002 die "Error: update of sector $sector [FAILED]\n" . 1003 1003 " ... MAC $mac and IP $ip don't exists in the database\n"; 1004 1004 } … … 1010 1010 1011 1011 my $help = get_cmd_name(); 1012 my ($hostname, $ domainset, $ip, $mac, $tags);1012 my ($hostname, $sector, $ip, $mac, $tags); 1013 1013 1014 1014 GetOptions( 1015 1015 'hostname|h=s' => \$hostname, 1016 ' domainset|d=s' => \$domainset,1016 'sector|d=s' => \$sector, 1017 1017 'ip|i=s' => \$ip, 1018 1018 'mac|m=s' => \$mac, … … 1020 1020 ); 1021 1021 1022 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;1023 1024 exit_on_error_option($help) 1025 if $ domainseteq ''1022 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1023 1024 exit_on_error_option($help) 1025 if $sector eq '' 1026 1026 or $tags eq ''; 1027 1027 exit_on_error_option($help) … … 1043 1043 } 1044 1044 1045 control_exist_ domainset($computer_db, $domainset) or exit;1046 1047 $mac = get_mac_from_ip($computer_db, $ domainset, $ip, $mac) if $ip ne '';1048 $mac = get_mac_from_hostname($computer_db, $ domainset, $hostname, $mac) if $hostname ne '';1045 control_exist_sector($computer_db, $sector) or exit; 1046 1047 $mac = get_mac_from_ip($computer_db, $sector, $ip, $mac) if $ip ne ''; 1048 $mac = get_mac_from_hostname($computer_db, $sector, $hostname, $mac) if $hostname ne ''; 1049 1049 control_syntax_mac_address($mac) or exit; 1050 1050 1051 1051 LOOP_ON_COMPUTER: 1052 for my $computer (@{$computer_db->{$ domainset}}) {1052 for my $computer (@{$computer_db->{$sector}}) { 1053 1053 my ($mac_address, $attribute) = %{$computer}; 1054 1054 … … 1063 1063 } 1064 1064 print "Mise à jour du commentaire de la machine [FAILED]\n"; 1065 print "L'adresse MAC: $mac n'existe pas dans le domaine: $ domainset.\n";1065 print "L'adresse MAC: $mac n'existe pas dans le domaine: $sector.\n"; 1066 1066 } 1067 1067 … … 1075 1075 1076 1076 sub disable_pc { 1077 my ($hostname, $ domainset, $ip) = @_;1077 my ($hostname, $sector, $ip) = @_; 1078 1078 1079 1079 my $computer_db = ipamdb_load($COMPUTER_YAML); … … 1085 1085 } 1086 1086 1087 for my $ domainset_current (keys %{$computer_db}) {1088 next if $ domainset_current eq 'dset';1089 next if $ domainset_current eq 'pool';1090 next if $ domainset_current eq 'pxe';1091 next if $ domainset_current eq 'tag';1092 next if $ domainset_current eq 'version';1093 1094 my @ domainsetdb = @{$computer_db->{$domainset_current}};1087 for my $sector_current (keys %{$computer_db}) { 1088 next if $sector_current eq 'dset'; 1089 next if $sector_current eq 'pool'; 1090 next if $sector_current eq 'pxe'; 1091 next if $sector_current eq 'tag'; 1092 next if $sector_current eq 'version'; 1093 1094 my @sectordb = @{$computer_db->{$sector_current}}; 1095 1095 LOOP_ON_COMPUTER: 1096 for my $computer (@ domainsetdb) {1096 for my $computer (@sectordb) { 1097 1097 my ($mac_address, $attribute) = %{$computer}; 1098 1098 … … 1100 1100 1101 1101 if ($attribute->{'enabled'} eq 'no') { 1102 print "Info: IP $ip from domain set $domainset_current is already disable [OK]" .1102 print "Info: IP $ip from sector $sector_current is already disable [OK]" . 1103 1103 " ... Status: $attribute->{'enabled'}\n"; 1104 1104 exit; … … 1109 1109 $attribute->{'enabled'} = 'no'; 1110 1110 ipamdb_save("$COMPUTER_YAML", $computer_db); 1111 print "Info: disabling IP $ip from domain set $domainset_current [OK]" .1111 print "Info: disabling IP $ip from sector $sector_current [OK]" . 1112 1112 " ... Status: $attribute->{'enabled'}\n"; 1113 1113 exit; … … 1116 1116 } 1117 1117 else { # disable by Hostname 1118 control_exist_ domainset($computer_db, $domainset);1119 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {1120 die "Error: unkown host: $hostname, in domain set: $domainset[FAILED]\n";1118 control_exist_sector($computer_db, $sector); 1119 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 1120 die "Error: unkown host: $hostname, in sector: $sector [FAILED]\n"; 1121 1121 } 1122 1122 1123 1123 LOOP_ON_COMPUTER: 1124 for my $computer (@{$computer_db->{$ domainset}}) {1124 for my $computer (@{$computer_db->{$sector}}) { 1125 1125 my ($mac_address, $attribute) = %{$computer}; 1126 1126 … … 1128 1128 1129 1129 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1130 die "Error: host $hostname from domain set $domainsetbelongs to a a pool [FAILED]" .1130 die "Error: host $hostname from sector $sector belongs to a a pool [FAILED]" . 1131 1131 " ... use 'disable-float' command instead"; 1132 1132 } 1133 1133 1134 1134 if ($attribute->{'enabled'} eq 'no') { 1135 print "Info: host $hostname from domain set $domainsetis already disable [OK]" .1135 print "Info: host $hostname from sector $sector is already disable [OK]" . 1136 1136 " ... Status: $attribute->{'enabled'}\n"; 1137 1137 exit; … … 1142 1142 $attribute->{'enabled'} = 'no'; 1143 1143 ipamdb_save("$COMPUTER_YAML", $computer_db); 1144 print "Info: disabling host $hostname from domain set $domainset[OK]" .1144 print "Info: disabling host $hostname from sector $sector [OK]" . 1145 1145 " ... Status: $attribute->{'enabled'}\n"; 1146 1146 exit; … … 1160 1160 } 1161 1161 1162 for my $ domainset_current (keys %{$computer_db}) {1163 next if $ domainset_current eq 'dset';1164 next if $ domainset_current eq 'pool';1165 next if $ domainset_current eq 'pxe';1166 next if $ domainset_current eq 'tag';1167 next if $ domainset_current eq 'version';1168 1169 my @ domainsetdb = @{$computer_db->{$domainset_current}};1162 for my $sector_current (keys %{$computer_db}) { 1163 next if $sector_current eq 'dset'; 1164 next if $sector_current eq 'pool'; 1165 next if $sector_current eq 'pxe'; 1166 next if $sector_current eq 'tag'; 1167 next if $sector_current eq 'version'; 1168 1169 my @sectordb = @{$computer_db->{$sector_current}}; 1170 1170 1171 1171 LOOP_ON_COMPUTER: 1172 for my $computer (@ domainsetdb) {1172 for my $computer (@sectordb) { 1173 1173 my ($mac_address, $attribute) = %{$computer}; 1174 1174 next LOOP_ON_COMPUTER if $mac_address ne $mac; … … 1201 1201 1202 1202 sub enable_pc { 1203 my ($hostname, $ domainset, $ip) = @_;1204 1205 my $computer_db = ipamdb_load($COMPUTER_YAML); 1206 1207 control_exist_ domainset($computer_db, $domainset) or exit;1203 my ($hostname, $sector, $ip) = @_; 1204 1205 my $computer_db = ipamdb_load($COMPUTER_YAML); 1206 1207 control_exist_sector($computer_db, $sector) or exit; 1208 1208 1209 1209 if ($ip ne '') { # enable by IP … … 1214 1214 } 1215 1215 1216 for my $ domainset_current (keys %{$computer_db}) {1217 next if $ domainset_current eq 'dset';1218 next if $ domainset_current eq 'pool';1219 next if $ domainset_current eq 'pxe';1220 next if $ domainset_current eq 'tag';1221 next if $ domainset_current eq 'version';1222 1223 my @ domainsetdb = @{$computer_db->{$domainset_current}};1216 for my $sector_current (keys %{$computer_db}) { 1217 next if $sector_current eq 'dset'; 1218 next if $sector_current eq 'pool'; 1219 next if $sector_current eq 'pxe'; 1220 next if $sector_current eq 'tag'; 1221 next if $sector_current eq 'version'; 1222 1223 my @sectordb = @{$computer_db->{$sector_current}}; 1224 1224 1225 1225 LOOP_ON_COMPUTER: 1226 for my $computer (@ domainsetdb) {1226 for my $computer (@sectordb) { 1227 1227 my ($mac_address, $attribute) = %{$computer}; 1228 1228 if ($attribute->{'ip'} eq $ip) { 1229 1229 1230 1230 if ($attribute->{'enabled'} eq 'yes') { 1231 print "Info: IP $ip belongs to domain set $domainsetis already enable [OK]" .1231 print "Info: IP $ip belongs to sector $sector is already enable [OK]" . 1232 1232 " ... Status: $attribute->{'enabled'}\n"; 1233 1233 exit; … … 1246 1246 } 1247 1247 else { # enable by Hostname 1248 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {1249 die "Error: unkown host: $hostname, in domain set: $domainset\n";1248 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 1249 die "Error: unkown host: $hostname, in sector: $sector\n"; 1250 1250 } 1251 1251 1252 1252 LOOP_ON_COMPUTER: 1253 for my $computer (@{$computer_db->{$ domainset}}) {1253 for my $computer (@{$computer_db->{$sector}}) { 1254 1254 my ($mac_address, $attribute) = %{$computer}; 1255 1255 next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname; 1256 1256 1257 1257 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1258 die "Error: host $hostname from domain set $domainsetbelongs to a a pool [FAILED]" .1258 die "Error: host $hostname from sector $sector belongs to a a pool [FAILED]" . 1259 1259 " ... use 'enable-float' command instead"; 1260 1260 } 1261 1261 1262 1262 if ($attribute->{'enabled'} eq 'yes') { 1263 print "Info: host $hostname belongs to domain set $domainsetis already enable [OK]" .1263 print "Info: host $hostname belongs to sector $sector is already enable [OK]" . 1264 1264 " ... Status: $attribute->{'enabled'}\n"; 1265 1265 exit; … … 1288 1288 } 1289 1289 1290 for my $ domainset_current (keys %{$computer_db}) {1291 next if $ domainset_current eq 'dset';1292 next if $ domainset_current eq 'pool';1293 next if $ domainset_current eq 'pxe';1294 next if $ domainset_current eq 'tag';1295 next if $ domainset_current eq 'version';1296 1297 my @ domainsetdb = @{$computer_db->{$domainset_current}};1290 for my $sector_current (keys %{$computer_db}) { 1291 next if $sector_current eq 'dset'; 1292 next if $sector_current eq 'pool'; 1293 next if $sector_current eq 'pxe'; 1294 next if $sector_current eq 'tag'; 1295 next if $sector_current eq 'version'; 1296 1297 my @sectordb = @{$computer_db->{$sector_current}}; 1298 1298 1299 1299 LOOP_ON_COMPUTER: 1300 for my $computer (@ domainsetdb) {1300 for my $computer (@sectordb) { 1301 1301 my ($mac_address, $attribute) = %{$computer}; 1302 1302 next LOOP_ON_COMPUTER if $mac_address ne $mac; … … 1330 1330 1331 1331 my $help = get_cmd_name(); 1332 my ($hostname, $ domainset, $ip);1332 my ($hostname, $sector, $ip); 1333 1333 1334 1334 GetOptions( 1335 1335 'hostname|h=s' => \$hostname, 1336 ' domainset|d=s' => \$domainset,1336 'sector|d=s' => \$sector, 1337 1337 'ip|i=s' => \$ip, 1338 1338 ); 1339 1339 1340 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;1341 exit_on_error_option($help) 1342 if $ domainseteq '';1340 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1341 exit_on_error_option($help) 1342 if $sector eq ''; 1343 1343 exit_on_error_option($help) 1344 1344 if $hostname eq '' … … 1348 1348 and $ip ne ''; 1349 1349 1350 enable_pc($hostname, $ domainset, $ip);1350 enable_pc($hostname, $sector, $ip); 1351 1351 } 1352 1352 … … 1357 1357 1358 1358 my $help = get_cmd_name(); 1359 my ($hostname, $ domainset, $ip);1359 my ($hostname, $sector, $ip); 1360 1360 1361 1361 GetOptions( 1362 1362 'hostname|h=s' => \$hostname, 1363 ' domainset|d=s' => \$domainset,1363 'sector|d=s' => \$sector, 1364 1364 'ip|i=s' => \$ip, 1365 1365 ); 1366 1366 1367 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;1368 exit_on_error_option($help) 1369 if $ domainseteq '';1367 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1368 exit_on_error_option($help) 1369 if $sector eq ''; 1370 1370 exit_on_error_option($help) 1371 1371 if $hostname eq '' … … 1375 1375 and $ip ne ''; 1376 1376 1377 disable_pc($hostname, $ domainset, $ip);1377 disable_pc($hostname, $sector, $ip); 1378 1378 } 1379 1379 … … 1429 1429 1430 1430 sub del_pc { 1431 my ($hostname, $ domainset, $ip) = @_;1432 1433 my $computer_db = ipamdb_load($COMPUTER_YAML); 1434 1435 control_exist_ domainset($computer_db, $domainset) or exit;1431 my ($hostname, $sector, $ip) = @_; 1432 1433 my $computer_db = ipamdb_load($COMPUTER_YAML); 1434 1435 control_exist_sector($computer_db, $sector) or exit; 1436 1436 if ($ip ne '') { # delete by IP 1437 1437 if ( control_exist_ip($computer_db, $ip) == 1 ) { … … 1442 1442 1443 1443 LOOP_ON_COMPUTER: 1444 for my $computer (@{$computer_db->{$ domainset}}) {1444 for my $computer (@{$computer_db->{$sector}}) { 1445 1445 my ($mac_address, $attribute) = %{$computer}; 1446 1446 1447 1447 $computer_index++, next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip; 1448 1448 1449 splice(@{$computer_db->{$ domainset}}, $computer_index => 1);1449 splice(@{$computer_db->{$sector}}, $computer_index => 1); 1450 1450 ipamdb_save("$COMPUTER_YAML", $computer_db); 1451 print "Info: host $ip has been removed from the domain set $domainset[OK]\n";1451 print "Info: host $ip has been removed from the sector $sector [OK]\n"; 1452 1452 exit; 1453 1453 } 1454 1454 } 1455 1455 else { 1456 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {1457 die "Error: unkown host: $hostname, in domain set: $domainset\n";1456 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 1457 die "Error: unkown host: $hostname, in sector: $sector\n"; 1458 1458 } 1459 1459 … … 1461 1461 1462 1462 LOOP_ON_COMPUTER: 1463 for my $computer (@{$computer_db->{$ domainset}}) {1463 for my $computer (@{$computer_db->{$sector}}) { 1464 1464 my ($mac_address, $attribute) = %{$computer}; 1465 1465 … … 1467 1467 1468 1468 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1469 die "Error: host remove $hostname from the domain set $domainset[FAILED]" .1469 die "Error: host remove $hostname from the sector $sector [FAILED]" . 1470 1470 " ... The host $hostname belongs to a DHCP pool.\n"; 1471 1471 } 1472 1472 1473 splice(@{$computer_db->{$ domainset}}, $computer_index => 1);1473 splice(@{$computer_db->{$sector}}, $computer_index => 1); 1474 1474 ipamdb_save("$COMPUTER_YAML", $computer_db); 1475 print "Info: host $hostname has been removed from the domain set $domainset[OK]\n";1475 print "Info: host $hostname has been removed from the sector $sector [OK]\n"; 1476 1476 exit; 1477 1477 } … … 1493 1493 } 1494 1494 1495 for my $ domainset_current (keys %{$computer_db}) {1496 next if $ domainset_current eq 'dset';1497 next if $ domainset_current eq 'pool';1498 next if $ domainset_current eq 'pxe';1499 next if $ domainset_current eq 'tag';1500 next if $ domainset_current eq 'version';1501 1502 my @ domainsetdb = @{$computer_db->{$domainset_current}};1495 for my $sector_current (keys %{$computer_db}) { 1496 next if $sector_current eq 'dset'; 1497 next if $sector_current eq 'pool'; 1498 next if $sector_current eq 'pxe'; 1499 next if $sector_current eq 'tag'; 1500 next if $sector_current eq 'version'; 1501 1502 my @sectordb = @{$computer_db->{$sector_current}}; 1503 1503 1504 1504 my $computer_index = 0; 1505 1505 1506 1506 LOOP_ON_COMPUTER: 1507 for my $computer (@ domainsetdb) {1507 for my $computer (@sectordb) { 1508 1508 my ($mac_address, $attribute) = %{$computer}; 1509 1509 … … 1515 1515 } 1516 1516 1517 splice(@{$computer_db->{$ domainset_current}}, $computer_index => 1);1517 splice(@{$computer_db->{$sector_current}}, $computer_index => 1); 1518 1518 ipamdb_save("$COMPUTER_YAML", $computer_db); 1519 1519 print "Info: remove host $mac from the pool $pool [OK]\n"; … … 1529 1529 1530 1530 my $help = get_cmd_name(); 1531 my ($hostname, $ domainset, $ip);1531 my ($hostname, $sector, $ip); 1532 1532 1533 1533 GetOptions( 1534 1534 'hostname|h=s' => \$hostname, 1535 ' domainset|d=s' => \$domainset,1535 'sector|d=s' => \$sector, 1536 1536 'ip|i=s' => \$ip, 1537 1537 ); 1538 1538 1539 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;1540 exit_on_error_option($help) 1541 if $ domainseteq '';1539 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1540 exit_on_error_option($help) 1541 if $sector eq ''; 1542 1542 exit_on_error_option($help) 1543 1543 if $hostname eq '' … … 1547 1547 and $ip ne ''; 1548 1548 1549 del_pc($hostname, $ domainset, $ip);1549 del_pc($hostname, $sector, $ip); 1550 1550 } 1551 1551 … … 1572 1572 1573 1573 #------------------------------------------------------------------------------- 1574 # DOMAIN SETsection1575 #------------------------------------------------------------------------------- 1576 1577 sub cmd_create_ domainset{1574 # SECTOR section 1575 #------------------------------------------------------------------------------- 1576 1577 sub cmd_create_sector { 1578 1578 local @ARGV = @_; 1579 1579 1580 1580 my $help = get_cmd_name(); 1581 my ($ domainset, $dns_extension, $comment);1581 my ($sector, $dns_extension, $comment); 1582 1582 1583 1583 GetOptions( 1584 ' domainset|d=s' => \$domainset,1584 'sector|d=s' => \$sector, 1585 1585 'dns-extension|e=s' => \$dns_extension, 1586 1586 'comment|c=s' => \$comment, … … 1588 1588 1589 1589 exit_on_error_option($help) 1590 if $ domainseteq ''1590 if $sector eq '' 1591 1591 or $dns_extension eq '' 1592 1592 or $comment eq ''; … … 1597 1597 1598 1598 $computer_db->{'dset'} ||= {}; 1599 die "Error: domain set already exists: $domainset\n" if exists $computer_db->{'dset'}{$domainset};1599 die "Error: sector already exists: $sector\n" if exists $computer_db->{'dset'}{$sector}; 1600 1600 1601 1601 control_syntax_comment($comment) or exit; 1602 1602 1603 1603 my $timestamp = time; 1604 $computer_db->{'dset'}{$ domainset} = {1604 $computer_db->{'dset'}{$sector} = { 1605 1605 'dns_extension' => $dns_extension, 1606 1606 'comment' => $comment, … … 1608 1608 'modify_time' => $timestamp, 1609 1609 }; 1610 $computer_db->{$ domainset} ||= []; # Create empty domain setcomputer list by default1610 $computer_db->{$sector} ||= []; # Create empty sector computer list by default 1611 1611 ipamdb_save("$COMPUTER_YAML", $computer_db); 1612 1612 } … … 1627 1627 1628 1628 my $help = get_cmd_name(); 1629 my ($pool, $ domainset, $file_pool, $ipaddress_pool);1629 my ($pool, $sector, $file_pool, $ipaddress_pool); 1630 1630 1631 1631 GetOptions( 1632 1632 'pool|p=s' => \$pool, 1633 ' domainset|d=s' => \$domainset,1633 'sector|d=s' => \$sector, 1634 1634 'file-pool|f=s' => \$file_pool, 1635 1635 'ipaddress-pool|i=s' => \$ipaddress_pool, … … 1638 1638 exit_on_error_option($help) 1639 1639 if $pool eq '' 1640 or $ domainseteq ''1640 or $sector eq '' 1641 1641 or $file_pool eq '' 1642 1642 or $ipaddress_pool eq ''; … … 1649 1649 1650 1650 #--- control if the domain's pool exist ---# 1651 control_exist_ domainset($computer_db, $domainset) or exit;1651 control_exist_sector($computer_db, $sector) or exit; 1652 1652 1653 1653 my @ip_list = (); … … 1683 1683 'modify_time' => $timestamp, 1684 1684 'file' => $file_pool, 1685 'domain' => $ domainset,1685 'domain' => $sector, 1686 1686 }; 1687 1687 ipamdb_save("$COMPUTER_YAML", $computer_db); … … 1777 1777 1778 1778 # Test if some computer use this config 1779 LOOP_ON_ DOMAINSET:1780 for my $ domainset_current (keys %{$computer_db}) {1781 next if $ domainset_current eq 'dset';1782 next if $ domainset_current eq 'pool';1783 next if $ domainset_current eq 'pxe';1784 next if $ domainset_current eq 'tag';1785 next if $ domainset_current eq 'version';1779 LOOP_ON_SECTOR: 1780 for my $sector_current (keys %{$computer_db}) { 1781 next if $sector_current eq 'dset'; 1782 next if $sector_current eq 'pool'; 1783 next if $sector_current eq 'pxe'; 1784 next if $sector_current eq 'tag'; 1785 next if $sector_current eq 'version'; 1786 1786 1787 1787 LOOP_ON_COMPUTER: 1788 for my $computer (@{$computer_db->{$ domainset_current}}) {1788 for my $computer (@{$computer_db->{$sector_current}}) { 1789 1789 my ($mac_address, $attribute) = %{$computer}; 1790 1790 1791 1791 if (exists $attribute->{'pxe_config'}) { 1792 1792 my $hostname = $attribute->{'hostname'}; 1793 die "Error: computer still use this PXE config: $hostname.$ domainset_current $mac_address\n" if $pxe_config eq $attribute->{'pxe_config'};1793 die "Error: computer still use this PXE config: $hostname.$sector_current $mac_address\n" if $pxe_config eq $attribute->{'pxe_config'}; 1794 1794 } 1795 1795 } … … 1830 1830 1831 1831 my $help = get_cmd_name(); 1832 my ($hostname, $ domainset, $ip, $pxe_config);1832 my ($hostname, $sector, $ip, $pxe_config); 1833 1833 1834 1834 GetOptions( 1835 1835 'hostname|h=s' => \$hostname, 1836 ' domainset|d=s' => \$domainset,1836 'sector|d=s' => \$sector, 1837 1837 'ip|i=s' => \$ip, 1838 1838 'bootp|b=s' => \$pxe_config, 1839 1839 ); 1840 1840 1841 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;1842 exit_on_error_option($help) 1843 if $ domainseteq ''1841 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1842 exit_on_error_option($help) 1843 if $sector eq '' 1844 1844 or $pxe_config eq ''; 1845 1845 exit_on_error_option($help) … … 1854 1854 die "Error: PXE config not exists: $pxe_config\n" if not exists $computer_db->{'pxe'}{$pxe_config}; 1855 1855 1856 control_exist_ domainset($computer_db, $domainset) or exit;1856 control_exist_sector($computer_db, $sector) or exit; 1857 1857 if ($ip ne '') { 1858 1858 control_syntax_ip($ip); … … 1861 1861 } 1862 1862 1863 for my $ domainset_current (keys %{$computer_db}) {1864 next if $ domainset_current eq 'dset';1865 next if $ domainset_current eq 'pool';1866 next if $ domainset_current eq 'pxe';1867 next if $ domainset_current eq 'tag';1868 next if $ domainset_current eq 'version';1863 for my $sector_current (keys %{$computer_db}) { 1864 next if $sector_current eq 'dset'; 1865 next if $sector_current eq 'pool'; 1866 next if $sector_current eq 'pxe'; 1867 next if $sector_current eq 'tag'; 1868 next if $sector_current eq 'version'; 1869 1869 1870 1870 LOOP_ON_COMPUTER: 1871 for my $computer (@{$computer_db->{$ domainset_current}}) {1871 for my $computer (@{$computer_db->{$sector_current}}) { 1872 1872 my ($mac_address, $attribute) = %{$computer}; 1873 1873 next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip; … … 1876 1876 $attribute->{'pxe_config'} = $pxe_config; 1877 1877 ipamdb_save("$COMPUTER_YAML", $computer_db); 1878 print "Info: host $attribute->{'hostname'} ($ domainset_current), IP $ip, PXE enabled: $pxe_config\n";1878 print "Info: host $attribute->{'hostname'} ($sector_current), IP $ip, PXE enabled: $pxe_config\n"; 1879 1879 exit; 1880 1880 } … … 1882 1882 } 1883 1883 else { 1884 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {1885 die "Error: unkown host: $hostname, in domain set: $domainset\n";1884 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 1885 die "Error: unkown host: $hostname, in sector: $sector\n"; 1886 1886 } 1887 1887 1888 1888 LOOP_ON_COMPUTER: 1889 for my $computer (@{$computer_db->{$ domainset}}) {1889 for my $computer (@{$computer_db->{$sector}}) { 1890 1890 my ($mac_address, $attribute) = %{$computer}; 1891 1891 next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname; 1892 1892 1893 1893 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1894 die "Error. Host $hostname ($ domainset) in a pool. No PXE possible [FAILED]\n";1894 die "Error. Host $hostname ($sector) in a pool. No PXE possible [FAILED]\n"; 1895 1895 } 1896 1896 … … 1898 1898 $attribute->{'pxe_config'} = $pxe_config; 1899 1899 ipamdb_save("$COMPUTER_YAML", $computer_db); 1900 print "Info: host $hostname ($ domainset), IP $attribute->{'ip'}, PXE enabled: $pxe_config [OK]\n";1900 print "Info: host $hostname ($sector), IP $attribute->{'ip'}, PXE enabled: $pxe_config [OK]\n"; 1901 1901 exit; 1902 1902 } … … 1910 1910 1911 1911 my $help = get_cmd_name(); 1912 my ($hostname, $ domainset, $ip);1912 my ($hostname, $sector, $ip); 1913 1913 1914 1914 GetOptions( 1915 1915 'hostname|h=s' => \$hostname, 1916 ' domainset|d=s' => \$domainset,1916 'sector|d=s' => \$sector, 1917 1917 'ip|i=s' => \$ip, 1918 1918 ); 1919 1919 1920 ($hostname, $ domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;1921 exit_on_error_option($help) 1922 if $ domainseteq '';1920 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1921 exit_on_error_option($help) 1922 if $sector eq ''; 1923 1923 exit_on_error_option($help) 1924 1924 if $hostname eq '' … … 1930 1930 my $computer_db = ipamdb_load($COMPUTER_YAML); 1931 1931 1932 control_exist_ domainset($computer_db, $domainset) or exit;1932 control_exist_sector($computer_db, $sector) or exit; 1933 1933 if ($ip ne '') { 1934 1934 control_syntax_ip($ip); … … 1937 1937 } 1938 1938 1939 for my $ domainset_current (keys %{$computer_db}) {1940 next if $ domainset_current eq 'dset';1941 next if $ domainset_current eq 'pool';1942 next if $ domainset_current eq 'pxe';1943 next if $ domainset_current eq 'tag';1944 next if $ domainset_current eq 'version';1939 for my $sector_current (keys %{$computer_db}) { 1940 next if $sector_current eq 'dset'; 1941 next if $sector_current eq 'pool'; 1942 next if $sector_current eq 'pxe'; 1943 next if $sector_current eq 'tag'; 1944 next if $sector_current eq 'version'; 1945 1945 1946 1946 LOOP_ON_COMPUTER: 1947 for my $computer (@{$computer_db->{$ domainset_current}}) {1947 for my $computer (@{$computer_db->{$sector_current}}) { 1948 1948 my ($mac_address, $attribute) = %{$computer}; 1949 1949 … … 1961 1961 } 1962 1962 else { 1963 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 1 ) {1964 die "Error: unkown host: $hostname, in domain set: $domainset\n";1963 if ( control_exist_hostname($computer_db, $sector, $hostname) == 1 ) { 1964 die "Error: unkown host: $hostname, in sector: $sector\n"; 1965 1965 } 1966 1966 1967 1967 LOOP_ON_COMPUTER: 1968 for my $computer (@{$computer_db->{$ domainset}}) {1968 for my $computer (@{$computer_db->{$sector}}) { 1969 1969 my ($mac_address, $attribute) = %{$computer}; 1970 1970 … … 1972 1972 1973 1973 if ($attribute->{'address_type'} eq 'pool-dhcp') { 1974 die "Error: host $hostname ($ domainset) in a pool. No PXE possible [FAILED]\n";1974 die "Error: host $hostname ($sector) in a pool. No PXE possible [FAILED]\n"; 1975 1975 } 1976 1976 … … 1981 1981 delete $attribute->{'pxe_config'}; 1982 1982 ipamdb_save("$COMPUTER_YAML", $computer_db); 1983 print "Info: host $hostname ($ domainset), PXE disable from config: $pxe_config [OK]\n";1983 print "Info: host $hostname ($sector), PXE disable from config: $pxe_config [OK]\n"; 1984 1984 exit; 1985 1985 } … … 2051 2051 2052 2052 # Test if some computer use this config 2053 LOOP_ON_ DOMAINSET:2054 for my $ domainset_current (keys %{$computer_db}) {2055 next if $ domainset_current eq 'dset';2056 next if $ domainset_current eq 'pool';2057 next if $ domainset_current eq 'pxe';2058 next if $ domainset_current eq 'tag';2059 next if $ domainset_current eq 'version';2053 LOOP_ON_SECTOR: 2054 for my $sector_current (keys %{$computer_db}) { 2055 next if $sector_current eq 'dset'; 2056 next if $sector_current eq 'pool'; 2057 next if $sector_current eq 'pxe'; 2058 next if $sector_current eq 'tag'; 2059 next if $sector_current eq 'version'; 2060 2060 2061 2061 LOOP_ON_COMPUTER: 2062 for my $computer (@{$computer_db->{$ domainset_current}}) {2062 for my $computer (@{$computer_db->{$sector_current}}) { 2063 2063 my ($mac_address, $attribute) = %{$computer}; 2064 2064 2065 2065 if (exists $attribute->{'tag'}) { 2066 2066 my $hostname = $attribute->{'hostname'}; 2067 die "Error: computer still use this TAG: $hostname.$ domainset_current $mac_address\n" if $tag eq $attribute->{'tag'};2067 die "Error: computer still use this TAG: $hostname.$sector_current $mac_address\n" if $tag eq $attribute->{'tag'}; 2068 2068 } 2069 2069 } … … 2105 2105 my $computer_db = ipamdb_load($COMPUTER_YAML); 2106 2106 2107 LOOP_ON_ DOMAINSET:2108 for my $ domainset_current (keys %{$computer_db}) {2109 next if $ domainset_current eq 'dset';2110 next if $ domainset_current eq 'pool';2111 next if $ domainset_current eq 'pxe';2112 next if $ domainset_current eq 'tag';2113 next if $ domainset_current eq 'version';2114 2115 my @ domainsetdb = @{$computer_db->{$domainset_current}};2107 LOOP_ON_SECTOR: 2108 for my $sector_current (keys %{$computer_db}) { 2109 next if $sector_current eq 'dset'; 2110 next if $sector_current eq 'pool'; 2111 next if $sector_current eq 'pxe'; 2112 next if $sector_current eq 'tag'; 2113 next if $sector_current eq 'version'; 2114 2115 my @sectordb = @{$computer_db->{$sector_current}}; 2116 2116 2117 2117 LOOP_ON_COMPUTER: 2118 for my $computer (@ domainsetdb) {2118 for my $computer (@sectordb) { 2119 2119 my ($mac_address, $attribute) = %{$computer}; 2120 2120 my $new_mac = normalize_mac_address($mac_address); … … 2142 2142 #-------------------------------------------------------------------------------- 2143 2143 2144 sub cmd_show_ domainset{2144 sub cmd_show_sector { 2145 2145 local @ARGV = @_; 2146 2146 … … 2154 2154 2155 2155 my $tb_computer = Text::Table->new( 2156 {align => 'left', align_title => 'left', title => ' DomainSet'},2156 {align => 'left', align_title => 'left', title => 'Sector'}, 2157 2157 {is_sep => 1, body => ' '}, 2158 2158 {align => 'left', align_title => 'left', title => 'DNS-Extension:'}, … … 2163 2163 ); 2164 2164 2165 LOOP_ON_ DOMAINSET:2166 for my $ domainset_current (sort keys %{$computer_db}) {2167 next if $ domainset_current eq 'dset';2168 next if $ domainset_current eq 'pool';2169 next if $ domainset_current eq 'pxe';2170 next if $ domainset_current eq 'tag';2171 next if $ domainset_current eq 'version';2172 2173 $tb_computer->add($ domainset_current), next LOOP_ON_DOMAINSET if not exists $computer_db->{'dset'}{$domainset_current};2174 2175 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $computer_db->{'dset'}{$ domainset_current}{'modify_time'};2165 LOOP_ON_SECTOR: 2166 for my $sector_current (sort keys %{$computer_db}) { 2167 next if $sector_current eq 'dset'; 2168 next if $sector_current eq 'pool'; 2169 next if $sector_current eq 'pxe'; 2170 next if $sector_current eq 'tag'; 2171 next if $sector_current eq 'version'; 2172 2173 $tb_computer->add($sector_current), next LOOP_ON_SECTOR if not exists $computer_db->{'dset'}{$sector_current}; 2174 2175 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $computer_db->{'dset'}{$sector_current}{'modify_time'}; 2176 2176 $year += 1900; 2177 2177 $mon++; … … 2179 2179 2180 2180 my $category; 2181 my $comment = $computer_db->{'dset'}{$ domainset_current}{'comment'};2181 my $comment = $computer_db->{'dset'}{$sector_current}{'comment'}; 2182 2182 $comment =~ s/^\d\d\d\d-\d\d-\d\d\s//; 2183 2183 $comment =~ s/\s+(\(\w+\))$// and $category = $1; 2184 2184 2185 $tb_computer->add($ domainset_current,2186 $computer_db->{'dset'}{$ domainset_current}{'dns_extension'},2185 $tb_computer->add($sector_current, 2186 $computer_db->{'dset'}{$sector_current}{'dns_extension'}, 2187 2187 $date, 2188 2188 $comment, … … 2217 2217 control_syntax_mac_address($mac) or exit; 2218 2218 2219 LOOP_ON_ DOMAINSET:2220 for my $ domainset_current (keys %{$computer_db}) {2221 next if $ domainset_current eq 'dset';2222 next if $ domainset_current eq 'pool';2223 next if $ domainset_current eq 'pxe';2224 next if $ domainset_current eq 'tag';2225 next if $ domainset_current eq 'version';2226 2227 my @ domainsetdb = @{$computer_db->{$domainset_current}};2219 LOOP_ON_SECTOR: 2220 for my $sector_current (keys %{$computer_db}) { 2221 next if $sector_current eq 'dset'; 2222 next if $sector_current eq 'pool'; 2223 next if $sector_current eq 'pxe'; 2224 next if $sector_current eq 'tag'; 2225 next if $sector_current eq 'version'; 2226 2227 my @sectordb = @{$computer_db->{$sector_current}}; 2228 2228 2229 2229 LOOP_ON_COMPUTER: 2230 for my $computer (@ domainsetdb) {2230 for my $computer (@sectordb) { 2231 2231 my ($mac_address, $attribute) = %{$computer}; 2232 2232 … … 2250 2250 2251 2251 printf "%-30s %-20s %17s %9s %3s %10s %s\n", 2252 $attribute->{'hostname'} . '.' . $ domainset_current,2252 $attribute->{'hostname'} . '.' . $sector_current, 2253 2253 $attribute->{'ip'}, 2254 2254 $mac_address, … … 2271 2271 2272 2272 my $tb_computer = Text::Table->new( 2273 {align => 'left', align_title => 'left', title => 'Hostname. DomainSet'},2273 {align => 'left', align_title => 'left', title => 'Hostname.Sector'}, 2274 2274 {is_sep => 1, body => ' '}, 2275 2275 {align => 'left', align_title => 'left', title => 'IPv4-Address'}, … … 2284 2284 ); 2285 2285 2286 LOOP_ON_ DOMAINSET:2287 for my $ domainset_current (sort keys %{$computer_db}) {2288 next if $ domainset_current eq 'dset';2289 next if $ domainset_current eq 'pool';2290 next if $ domainset_current eq 'pxe';2291 next if $ domainset_current eq 'tag';2292 next if $ domainset_current eq 'version';2293 2294 my @ domainsetdb = @{$computer_db->{$domainset_current}};2286 LOOP_ON_SECTOR: 2287 for my $sector_current (sort keys %{$computer_db}) { 2288 next if $sector_current eq 'dset'; 2289 next if $sector_current eq 'pool'; 2290 next if $sector_current eq 'pxe'; 2291 next if $sector_current eq 'tag'; 2292 next if $sector_current eq 'version'; 2293 2294 my @sectordb = @{$computer_db->{$sector_current}}; 2295 2295 2296 2296 LOOP_ON_COMPUTER: 2297 for my $computer (@ domainsetdb) {2297 for my $computer (@sectordb) { 2298 2298 my ($mac_address, $attribute) = %{$computer}; 2299 2299 my $ip = $attribute->{'ip'}; … … 2304 2304 'mac_address' => $mac_address, 2305 2305 %{$attribute}, 2306 ' domainset' => $domainset_current,2306 'sector' => $sector_current, 2307 2307 }; 2308 2308 } … … 2331 2331 #printf "%-30s %-20s %17s %9s %3s %10s %s\n", 2332 2332 $tb_computer->add( 2333 $attribute->{'hostname'} . '.' . $ domainset_current,2333 $attribute->{'hostname'} . '.' . $sector_current, 2334 2334 $ip, 2335 2335 $mac_address, … … 2340 2340 ); 2341 2341 } 2342 #print "\n# *** List of pool computers in the domain set: $domainset_current ***\n";2343 } 2344 2345 #print "\n# *** List of computers ordered by IP and domain set***\n";2342 #print "\n# *** List of pool computers in the sector: $sector_current ***\n"; 2343 } 2344 2345 #print "\n# *** List of computers ordered by IP and sector ***\n"; 2346 2346 LOOP_ON_IP_ADDRESS: 2347 2347 foreach my $ip (Net::Netmask::sort_by_ip_address(keys %ipdb)) { … … 2364 2364 #printf "%-30s %-20s %17s %9s %3s %10s %s\n", 2365 2365 $tb_computer->add( 2366 $ipdb{$ip}->{'hostname'} . '.' . $ipdb{$ip}->{' domainset'},2366 $ipdb{$ip}->{'hostname'} . '.' . $ipdb{$ip}->{'sector'}, 2367 2367 $ip, 2368 2368 normalize_mac_address($ipdb{$ip}->{'mac_address'}), … … 2390 2390 my %file_pool; 2391 2391 2392 for my $ domainset_current (keys %{$computer_db}) {2393 next if $ domainset_current eq 'dset';2394 next if $ domainset_current eq 'pool';2395 next if $ domainset_current eq 'pxe';2396 next if $ domainset_current eq 'tag';2397 next if $ domainset_current eq 'version';2398 2399 open FILE_VLAN, '>', "$FOLDER_GEN_DHCP/$ domainset_current";2400 my @ domainsetdb = @{$computer_db->{$domainset_current}};2401 for my $value (@ domainsetdb) {2392 for my $sector_current (keys %{$computer_db}) { 2393 next if $sector_current eq 'dset'; 2394 next if $sector_current eq 'pool'; 2395 next if $sector_current eq 'pxe'; 2396 next if $sector_current eq 'tag'; 2397 next if $sector_current eq 'version'; 2398 2399 open FILE_VLAN, '>', "$FOLDER_GEN_DHCP/$sector_current"; 2400 my @sectordb = @{$computer_db->{$sector_current}}; 2401 for my $value (@sectordb) { 2402 2402 ALL_MAC_ADDRESS: 2403 2403 for my $mac_addres (keys %{$value}) { … … 2505 2505 my $computer_db = ipamdb_load($COMPUTER_YAML); 2506 2506 2507 for my $ domainset_current (keys %{$computer_db}) {2508 next if $ domainset_current eq 'dset';2509 next if $ domainset_current eq 'pool';2510 next if $ domainset_current eq 'pxe';2511 next if $ domainset_current eq 'tag';2512 next if $ domainset_current eq 'version';2513 2514 if ($ domainset_current eq 'pool') {2507 for my $sector_current (keys %{$computer_db}) { 2508 next if $sector_current eq 'dset'; 2509 next if $sector_current eq 'pool'; 2510 next if $sector_current eq 'pxe'; 2511 next if $sector_current eq 'tag'; 2512 next if $sector_current eq 'version'; 2513 2514 if ($sector_current eq 'pool') { 2515 2515 LOOP_ON_COMPUTER: 2516 for my $computer (@{$computer_db->{$ domainset_current}}) {2516 for my $computer (@{$computer_db->{$sector_current}}) { 2517 2517 for my $pool_name (keys %{$computer}) { 2518 2518 $pool_domain = $computer->{$pool_name}->{'domain'}."\n"; … … 2537 2537 else { 2538 2538 #--- Création du fichier non-reverse ---# 2539 open FILE_FORWARD_DNS, ">> $FOLDER_GEN_DNS/db.$ domainset_current.fwd";2540 open FILE_REVERSE_DNS, ">> $FOLDER_GEN_DNS/db.$ domainset_current.rev";2541 2542 my @ domainsetdb = @{$computer_db->{$domainset_current}};2539 open FILE_FORWARD_DNS, ">> $FOLDER_GEN_DNS/db.$sector_current.fwd"; 2540 open FILE_REVERSE_DNS, ">> $FOLDER_GEN_DNS/db.$sector_current.rev"; 2541 2542 my @sectordb = @{$computer_db->{$sector_current}}; 2543 2543 2544 2544 LOOP_ON_COMPUTER: 2545 for my $computer (@ domainsetdb) {2545 for my $computer (@sectordb) { 2546 2546 my ($mac_address, $attribute) = %{$computer}; 2547 2547 … … 2559 2559 next LOOP_ON_COMPUTER if not (($address_type eq 'dhcp') or ($address_type eq 'static')); 2560 2560 2561 my $dns_domain = $ domainset_current;2562 if (exists $computer_db->{'dset'}{$ domainset_current}) {2563 $dns_domain = $computer_db->{'dset'}{$ domainset_current}{'dns_extension'};2561 my $dns_domain = $sector_current; 2562 if (exists $computer_db->{'dset'}{$sector_current}) { 2563 $dns_domain = $computer_db->{'dset'}{$sector_current}{'dns_extension'}; 2564 2564 } 2565 2565 … … 2583 2583 close FILE_REVERSE_DNS; 2584 2584 close FILE_FORWARD_DNS; 2585 print "- DNS: db.$ domainset_current.fwd db.$domainset_current.rev [CREATE].\n" if $verbose;2586 print " Ex : sort -k 4n -t . $FOLDER_GEN_DNS/db.$ domainset_current.fwd\n" if $verbose;2585 print "- DNS: db.$sector_current.fwd db.$sector_current.rev [CREATE].\n" if $verbose; 2586 print " Ex : sort -k 4n -t . $FOLDER_GEN_DNS/db.$sector_current.fwd\n" if $verbose; 2587 2587 } 2588 2588 } … … 2620 2620 2621 2621 if ($opt_direct or not $opt_reverse) { # DDT to DNS check 2622 LOOP_ON_ DOMAINSET:2623 for my $ domainset_current (keys %{$computer_db}) {2624 next if $ domainset_current eq 'dset';2625 next if $ domainset_current eq 'pool';2626 next if $ domainset_current eq 'pxe';2627 next if $ domainset_current eq 'tag';2628 next if $ domainset_current eq 'version';2629 2630 my @ domainsetdb = @{$computer_db->{$domainset_current}};2622 LOOP_ON_SECTOR: 2623 for my $sector_current (keys %{$computer_db}) { 2624 next if $sector_current eq 'dset'; 2625 next if $sector_current eq 'pool'; 2626 next if $sector_current eq 'pxe'; 2627 next if $sector_current eq 'tag'; 2628 next if $sector_current eq 'version'; 2629 2630 my @sectordb = @{$computer_db->{$sector_current}}; 2631 2631 2632 2632 LOOP_ON_COMPUTER: 2633 for my $computer (@ domainsetdb) {2633 for my $computer (@sectordb) { 2634 2634 my ($mac_address, $attribute) = %{$computer}; 2635 2635 #my $new_mac = normalize_mac_address($mac_address); … … 2642 2642 2643 2643 if ($attribute->{'hostname'} ne $dns_hostname) { 2644 print "$mac_address ($ domainset_current) $ip - $dns_hostname / $attribute->{'hostname'} # $attribute->{'comment'}\n";2644 print "$mac_address ($sector_current) $ip - $dns_hostname / $attribute->{'hostname'} # $attribute->{'comment'}\n"; 2645 2645 next LOOP_ON_COMPUTER; 2646 2646 } … … 2689 2689 2690 2690 sub load_data_dhcp { 2691 my ($ domainset, $input_file) = @_;2691 my ($sector, $input_file) = @_; 2692 2692 2693 2693 my $computer_db = ipamdb_load($COMPUTER_YAML); … … 2739 2739 $cpt = 0; 2740 2740 2741 if ( control_exist_hostname($computer_db, $ domainset, $hostname) == 0 ) {2742 print "Error: host already exist in domain set $domainset: $hostname\n";2741 if ( control_exist_hostname($computer_db, $sector, $hostname) == 0 ) { 2742 print "Error: host already exist in sector $sector: $hostname\n"; 2743 2743 next; 2744 2744 } … … 2755 2755 } 2756 2756 my $timestamp = time; 2757 push @{$computer_db->{$ domainset}}, { $mac => {2757 push @{$computer_db->{$sector}}, { $mac => { 2758 2758 'hostname' => $hostname, 2759 2759 'ip' => $ip, … … 2773 2773 2774 2774 sub load_data_pool { 2775 my ($ domainset, $input_file) = @_;2775 my ($sector, $input_file) = @_; 2776 2776 2777 2777 my @T_mac; … … 2810 2810 } 2811 2811 2812 if ($computer_db->{'pool'}{'domain'} eq $ domainset) {2812 if ($computer_db->{'pool'}{'domain'} eq $sector) { 2813 2813 my $timestamp = time; 2814 push @{$computer_db->{$ domainset}}, { $mac => {2814 push @{$computer_db->{$sector}}, { $mac => { 2815 2815 'hostname' => $pool, 2816 2816 'ip' => $pool, … … 2823 2823 else { 2824 2824 print "Ajout de la machine $mac [FAILED]\n"; 2825 print "Error: the pool doesn't exists: $pool, for the domain: $ domainset\n";2825 print "Error: the pool doesn't exists: $pool, for the domain: $sector\n"; 2826 2826 } 2827 2827 } … … 2832 2832 2833 2833 sub load_data_file { 2834 my ($ domainset, $input_file, $type_file) = @_;2834 my ($sector, $input_file, $type_file) = @_; 2835 2835 2836 2836 my $computer_db = ipamdb_load($COMPUTER_YAML); … … 2838 2838 #$computer_db 2839 2839 if ($type_file eq 'dhcp') { 2840 load_data_dhcp($ domainset, $input_file);2840 load_data_dhcp($sector, $input_file); 2841 2841 } 2842 2842 2843 2843 elsif ($type_file eq 'pool-dhcp') { 2844 load_data_pool($ domainset, $input_file);2844 load_data_pool($sector, $input_file); 2845 2845 } 2846 2846 … … 2854 2854 2855 2855 my $help = get_cmd_name(); 2856 my ($ domainset, $input_file, $type_file);2856 my ($sector, $input_file, $type_file); 2857 2857 2858 2858 GetOptions( 2859 ' domainset|d=s' => \$domainset,2859 'sector|d=s' => \$sector, 2860 2860 'filename|f=s' => \$input_file, 2861 2861 'kind|k=s' => \$type_file, … … 2863 2863 2864 2864 exit_on_error_option($help) 2865 if $ domainseteq ''2865 if $sector eq '' 2866 2866 or $input_file eq '' 2867 2867 or $type_file eq ''; 2868 2868 2869 load_data_file($ domainset, $input_file, $type_file);2869 load_data_file($sector, $input_file, $type_file); 2870 2870 } 2871 2871 … … 2896 2896 if ($command eq 'add-dhcp') { 2897 2897 print "List of options for command: $command\n"; 2898 print " -d : domain setattachment (mandatory). Example: -d legi-sector03\n";2898 print " -d : sector attachment (mandatory). Example: -d legi-sector03\n"; 2899 2899 print " -h : computer hostname (mandatory if option -i != 'pool'). Example: -h info8pc154\n"; 2900 2900 print " -m : physical MAC address (mandatory). Example: -m 0F:58:AB:2A\n"; … … 2909 2909 elsif ($command eq 'add-float') { 2910 2910 print "List of options for command: $command\n"; 2911 print " -d : domain setattachment (mandatory)\n";2911 print " -d : sector attachment (mandatory)\n"; 2912 2912 print " -p : name of the DHCP pool to which the machine belongs (mandatory)\n"; 2913 2913 print " -m : physical MAC address (mandatory)\n"; … … 2919 2919 elsif ($command eq 'add-static') { 2920 2920 print "List of options for command: $command\n"; 2921 print " -d : domain setattachment (mandatory)\n";2921 print " -d : sector attachment (mandatory)\n"; 2922 2922 print " -i : internet IP address (mandatory)\n"; 2923 2923 print " -h : computer hostname (mandatory)\n"; … … 2930 2930 elsif ($command eq 'add-virtual') { 2931 2931 print "List of options for command: $command\n"; 2932 print " -d : domain setattachment (mandatory)\n";2932 print " -d : sector attachment (mandatory)\n"; 2933 2933 print " -i : internet IP address (mandatory)\n"; 2934 2934 print " -h : computer hostname (mandatory)\n"; … … 2940 2940 elsif ($command eq 'add-alias') { 2941 2941 print "List of options for command: $command\n"; 2942 print " -d : domain setattachment (mandatory)\n";2942 print " -d : sector attachment (mandatory)\n"; 2943 2943 print " -h : computer hostname (mandatory)\n"; 2944 2944 print " -a : computer alias name (mandatory)\n"; 2945 2945 } 2946 2946 2947 elsif ($command eq 'create- domainset') {2947 elsif ($command eq 'create-sector') { 2948 2948 print "List of options for command: $command\n"; 2949 print " -d : new domain set(mandatory)\n";2949 print " -d : new sector (mandatory)\n"; 2950 2950 print " -e : DNS domain name extension( mandatory). Example legi.grenoble-inp.fr\n"; 2951 2951 print " -c : comment (mandatory). Example: 2016-08-22 VLAN legi-261 (INFO)\n"; 2952 2952 print "Examples:\n"; 2953 print " ddt create_ domainset-d legi-264 -e legi.grenoble-inp.fr -c '2016-08-22 VLAN legi-261 (INFO)'\n";2953 print " ddt create_sector -d legi-264 -e legi.grenoble-inp.fr -c '2016-08-22 VLAN legi-261 (INFO)'\n"; 2954 2954 } 2955 2955 … … 2957 2957 print "List of options for command: $command\n"; 2958 2958 print " -p : name of the DHCP pool. Example: pool-legi-priv\n"; 2959 print " -d : domain set attachment for the pool. (domain setattachment must exist in file $COMPUTER_BASENAME.conf). Example: legi.grenoble-inp.fr\n";2959 print " -d : sector attachment for the pool. (sector attachment must exist in file $COMPUTER_BASENAME.conf). Example: legi.grenoble-inp.fr\n"; 2960 2960 print " -f : configuration filename on the DHCP server for the pool\n"; 2961 2961 print " -i : adresse(s) IP ou plage d'IP. Séparateur d'adresses IP: ','. Séparateur de plage '-'\n"; … … 2982 2982 print " -h : computer hostname (mandatory unless option -i)\n"; 2983 2983 print " -i : internet IP address (mandatory unless option -h)\n"; 2984 print " -d : domain setattachment (mandatory if option -h)\n";2984 print " -d : sector attachment (mandatory if option -h)\n"; 2985 2985 print " -b : name of the PXE/BOOTP configuration. Example: most\n"; 2986 2986 } … … 2990 2990 print " -h : computer hostname (mandatory unless option -i)\n"; 2991 2991 print " -i : internet IP address (mandatory unless option -h)\n"; 2992 print " -d : domain setattachment (mandatory if option -h)\n";2992 print " -d : sector attachment (mandatory if option -h)\n"; 2993 2993 } 2994 2994 … … 3007 3007 elsif ($command eq 'change-mac') { 3008 3008 print "List of options for command: $command\n"; 3009 print " -d : domain setattachment (mandatory). Example: -d legi-sector03\n";3009 print " -d : sector attachment (mandatory). Example: -d legi-sector03\n"; 3010 3010 print " -h : computer hostname (mandatory unless option -i)\n"; 3011 3011 print " -i : internet IP address (mandatory unless option -h). Possible value: classical IP address or the keyword 'pool'\n"; … … 3015 3015 elsif ($command eq 'change-ip') { 3016 3016 print "List of options for command: $command\n"; 3017 print " -d : domain setattachment (mandatory). Example: -d legi-sector03\n";3017 print " -d : sector attachment (mandatory). Example: -d legi-sector03\n"; 3018 3018 print " -h : computer hostname (mandatory)\n"; 3019 3019 print " -i : new internet IP address (mandatory). Possible value: classical IP address\n"; … … 3022 3022 elsif ($command eq 'change-host') { 3023 3023 print "List of options for command: $command\n"; 3024 print " -d : domain setattachment (mandatory). Example: -d legi-sector03\n";3024 print " -d : sector attachment (mandatory). Example: -d legi-sector03\n"; 3025 3025 print " -i : internet IP address (mandatory). Possible value: classical IP address\n"; 3026 3026 print " -h : new computer hostname (mandatory)\n"; … … 3030 3030 elsif ($command eq 'change-comment') { 3031 3031 print "List of options for command: $command\n"; 3032 print " -d : domain setattachment (mandatory). Example: -d legi-sector03\n";3032 print " -d : sector attachment (mandatory). Example: -d legi-sector03\n"; 3033 3033 print " -m : physical MAC address (mandatory). Example: -m 0F:58:AB:2A:22:11\n"; 3034 3034 print " -c : new comment (mandatory)\n"; 3035 3035 } 3036 3036 3037 elsif ($command eq 'change- domainset') {3037 elsif ($command eq 'change-sector') { 3038 3038 print "List of options for command: $command\n"; 3039 print " -d : new domain setattachment (mandatory). Example: -d legi-661\n";3039 print " -d : new sector attachment (mandatory). Example: -d legi-661\n"; 3040 3040 print " -m : physical MAC address (mandatory). Example: -m 0F:58:AB:2A:22:11\n"; 3041 3041 print " -i : internet IP address (mandatory)\n"; … … 3045 3045 print "List of options for command: $command\n"; 3046 3046 print " -h : computer hostname (mandatory unless option -i or -m)\n"; 3047 print " -d : domain setattachment (mandatory). Example: -d legi-sector03\n";3047 print " -d : sector attachment (mandatory). Example: -d legi-sector03\n"; 3048 3048 print " -i : internet IP address (mandatory unless option -h or -m)\n"; 3049 3049 print " -m : physical MAC address (mandatory unless option -h or -i, priority). Example: -m 0F:58:AB:2A:22:11\n"; … … 3053 3053 elsif ($command eq 'load-database') { 3054 3054 print "List of options for command: $command\n"; 3055 print " -d : domain setattachment\n";3055 print " -d : sector attachment\n"; 3056 3056 print " -f : input file in DHCP format\n"; 3057 3057 print " -k : possible cases (kind): dhcp, pool-dhcp, fix-address\n"; … … 3062 3062 print " -h : computer hostname (mandatory unless option -i)\n"; 3063 3063 print " -i : internet IP address (mandatory unless option -h)\n"; 3064 print " -d : domain setattachment (mandatory if option -h)\n";3064 print " -d : sector attachment (mandatory if option -h)\n"; 3065 3065 print "Examples:\n"; 3066 3066 print " ddt enable_pc -i 192.168.10.1\n"; … … 3084 3084 print " -h : computer hostname (mandatory unless option -i)\n"; 3085 3085 print " -i : internet IP address (mandatory unless option -h)\n"; 3086 print " -d : domain setattachment (mandatory if option -h)\n";3086 print " -d : sector attachment (mandatory if option -h)\n"; 3087 3087 print "Examples:\n"; 3088 3088 print " ddt disable_pc -i 192.168.10.1\n"; … … 3092 3092 elsif ($command eq 'del-pc') { 3093 3093 print "List of options for command: $command\n"; 3094 print " -d : domain setattachment (mandatory)\n";3094 print " -d : sector attachment (mandatory)\n"; 3095 3095 print " -h : computer hostname (mandatory unless option -i)\n"; 3096 3096 print " -i : internet IP address (mandatory unless option -h)\n"; … … 3139 3139 ddt - management of computer names and IP addresses 3140 3140 3141 ddt add-alias [--hostname|-h hostname] [-- domainset|-d domainset] [--alias|-a alias]3142 ddt add-dhcp [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment]3143 ddt add-float [--pool|-p pool] [-- domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]3144 ddt add-static [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment]3145 ddt add-virtual [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--comment|-c comment]3146 ddt change-comment [-- domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]3147 ddt change- domainset [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac]3148 ddt change-host [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3149 ddt change-ip [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3150 ddt change-mac [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac]3151 ddt change-tag [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag]3141 ddt add-alias [--hostname|-h hostname] [--sector|-s sector] [--alias|-a alias] 3142 ddt add-dhcp [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment] 3143 ddt add-float [--pool|-p pool] [--sector|-s sector] [--mac|-m mac] [--comment|-c comment] 3144 ddt add-static [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment] 3145 ddt add-virtual [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--comment|-c comment] 3146 ddt change-comment [--sector|-s sector] [--mac|-m mac] [--comment|-c comment] 3147 ddt change-sector [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] 3148 ddt change-host [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3149 ddt change-ip [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3150 ddt change-mac [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] 3151 ddt change-tag [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3152 3152 ddt check-dns [--direct] [--reverse] 3153 ddt create- domainset [--domainset|-d domainset] [--dns-extension|-e dns_extension] [--comment|-c comment]3154 ddt create-pool [--pool|-p pool] [-- domainset|-d domainset] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool]3153 ddt create-sector [--sector|-s sector] [--dns-extension|-e dns_extension] [--comment|-c comment] 3154 ddt create-pool [--pool|-p pool] [--sector|-s sector] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool] 3155 3155 ddt create-pxe [--bootp|-b pxe_config] [--next-server|-n next_server] [--filename|-f filename] [--comment|-c comment] 3156 3156 ddt create-tag [--tag|-t tag] [--comment|-c comment] 3157 3157 ddt del-float [--pool|-p pool] [--mac|-m mac] 3158 ddt del-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3159 ddt disable-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3158 ddt del-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3159 ddt disable-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3160 3160 ddt disable-float [--pool|-p pool] [--mac|-m mac] 3161 ddt disable-pxe [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3161 ddt disable-pxe [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3162 3162 ddt enable-float [--pool|-p pool] [--mac|-m mac] 3163 ddt enable-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3164 ddt enable-pxe [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--bootp|-b pxe_config]3163 ddt enable-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3164 ddt enable-pxe [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--bootp|-b pxe_config] 3165 3165 ddt gen-dhcp-file 3166 3166 ddt gen-dns-file [--verbose] 3167 3167 ddt help 3168 ddt load-database [-- domainset|-d domainset] [--filename|-f filename] [--kind|-k kind]3168 ddt load-database [--sector|-s sector] [--filename|-f filename] [--kind|-k kind] 3169 3169 ddt remove-pxe [--bootp|-b pxe_config] 3170 3170 ddt remove-tag [--tag|-t tag] 3171 3171 ddt search-mac [--mac|-m mac] 3172 ddt show- domainset[--no-header|-H]3172 ddt show-sector [--no-header|-H] 3173 3173 ddt show 3174 3174 ddt show-pool [--no-header|-H] … … 3185 3185 * add-virtual : add a virtual computer with a static IP but a virtual MAC (useful to declare float computer in DNS) 3186 3186 * change-comment : change the computer comment 3187 * change- domainset : change the domain setattachment for a computer3187 * change-sector : change the sector attachment for a computer 3188 3188 * change-host : change the computer hostname 3189 3189 * change-ip : change the computer IP address … … 3191 3191 * change-tag : change the list of TAGs associated to a computer 3192 3192 * check-dns : check the DNS table for base IPs 3193 * create- domainset : create a new domain set3193 * create-sector : create a new sector 3194 3194 * create-pool : create a new pool for DHCP records 3195 3195 * create-pxe : create a new PXE/BOOTP configuration … … 3210 3210 * remove-tag : remove a TAG 3211 3211 * search-mac : search physical MAC address computer 3212 * show- domainset : list all domain setgroup of computer3212 * show-sector : list all sector group of computer 3213 3213 * show : list all computers 3214 3214 * show-pool : list all pool … … 3233 3233 =head1 USAGE 3234 3234 3235 ddt add-alias [--hostname|-h hostname] [-- domainset|-d domainset] [--alias|-a alias]3236 ddt add-dhcp [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment]3237 ddt add-float [--pool|-p pool] [-- domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]3238 ddt add-static [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment]3239 ddt add-virtual [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--comment|-c comment]3240 ddt change-comment [-- domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]3241 ddt change- domainset [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac]3242 ddt change-host [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3243 ddt change-ip [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3244 ddt change-mac [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac]3245 ddt change-tag [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag]3235 ddt add-alias [--hostname|-h hostname] [--sector|-s sector] [--alias|-a alias] 3236 ddt add-dhcp [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment] 3237 ddt add-float [--pool|-p pool] [--sector|-s sector] [--mac|-m mac] [--comment|-c comment] 3238 ddt add-static [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment] 3239 ddt add-virtual [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--comment|-c comment] 3240 ddt change-comment [--sector|-s sector] [--mac|-m mac] [--comment|-c comment] 3241 ddt change-sector [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] 3242 ddt change-host [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3243 ddt change-ip [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3244 ddt change-mac [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] 3245 ddt change-tag [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3246 3246 ddt check-dns [--direct] [--reverse] 3247 ddt create- domainset [--domainset|-d domainset] [--dns-extension|-e dns_extension] [--comment|-c comment]3248 ddt create-pool [--pool|-p pool] [-- domainset|-d domainset] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool]3247 ddt create-sector [--sector|-s sector] [--dns-extension|-e dns_extension] [--comment|-c comment] 3248 ddt create-pool [--pool|-p pool] [--sector|-s sector] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool] 3249 3249 ddt create-pxe [--bootp|-b pxe_config] [--next-server|-n next_server] [--filename|-f filename] [--comment|-c comment] 3250 3250 ddt create-tag [--tag|-t tag] [--comment|-c comment] 3251 3251 ddt del-float [--pool|-p pool] [--mac|-m mac] 3252 ddt del-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3253 ddt disable-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3252 ddt del-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3253 ddt disable-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3254 3254 ddt disable-float [--pool|-p pool] [--mac|-m mac] 3255 ddt disable-pxe [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3255 ddt disable-pxe [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3256 3256 ddt enable-float [--pool|-p pool] [--mac|-m mac] 3257 ddt enable-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3258 ddt enable-pxe [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--bootp|-b pxe_config]3257 ddt enable-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3258 ddt enable-pxe [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--bootp|-b pxe_config] 3259 3259 ddt gen-dhcp-file 3260 3260 ddt gen-dns-file [--verbose] 3261 3261 ddt help 3262 ddt load-database [-- domainset|-d domainset] [--filename|-f filename] [--kind|-k kind]3262 ddt load-database [--sector|-s sector] [--filename|-f filename] [--kind|-k kind] 3263 3263 ddt remove-pxe [--bootp|-b pxe_config] 3264 3264 ddt remove-tag [--tag|-t tag] 3265 3265 ddt search-mac [--mac|-m mac] 3266 ddt show- domainset[--no-header|-H]3266 ddt show-sector [--no-header|-H] 3267 3267 ddt show 3268 3268 ddt show-pool [--no-header|-H] … … 3289 3289 =head2 add-alias 3290 3290 3291 ddt add-alias [--hostname|-h hostname] [-- domainset|-d domainset] [--alias|-a alias]3291 ddt add-alias [--hostname|-h hostname] [--sector|-s sector] [--alias|-a alias] 3292 3292 3293 3293 =head2 add-dhcp 3294 3294 3295 ddt add-dhcp [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment]3295 ddt add-dhcp [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment] 3296 3296 3297 3297 =head2 add-float 3298 3298 3299 ddt add-float [--pool|-p pool] [-- domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]3299 ddt add-float [--pool|-p pool] [--sector|-s sector] [--mac|-m mac] [--comment|-c comment] 3300 3300 3301 3301 =head2 add-static 3302 3302 3303 ddt add-static [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment]3303 ddt add-static [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--comment|-c comment] 3304 3304 3305 3305 =head2 add-virtual 3306 3306 3307 ddt add-virtual [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--comment|-c comment]3307 ddt add-virtual [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--comment|-c comment] 3308 3308 3309 3309 =head2 change-comment 3310 3310 3311 ddt change-comment [-- domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]3312 3313 =head2 change- domainset3314 3315 ddt change- domainset [--domainset|-d domainset] [--ip|-i ip] [--mac|-m mac]3311 ddt change-comment [--sector|-s sector] [--mac|-m mac] [--comment|-c comment] 3312 3313 =head2 change-sector 3314 3315 ddt change-sector [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] 3316 3316 3317 3317 =head2 change-host 3318 3318 3319 ddt change-host [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3319 ddt change-host [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3320 3320 3321 3321 =head2 change-ip 3322 3322 3323 ddt change-ip [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3323 ddt change-ip [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3324 3324 3325 3325 =head2 change-mac 3326 3326 3327 ddt change-mac [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac]3327 ddt change-mac [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] 3328 3328 3329 3329 =head2 change-tag 3330 3330 3331 ddt change-tag [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag]3331 ddt change-tag [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3332 3332 3333 3333 =head2 check-dns … … 3335 3335 ddt check-dns [--direct] [--reverse] 3336 3336 3337 =head2 create- domainset3338 3339 ddt create- domainset [--domainset|-d domainset] [--dns-extension|-e dns_extension] [--comment|-c comment]3337 =head2 create-sector 3338 3339 ddt create-sector [--sector|-s sector] [--dns-extension|-e dns_extension] [--comment|-c comment] 3340 3340 3341 3341 =head2 create-pool 3342 3342 3343 ddt create-pool [--pool|-p pool] [-- domainset|-d domainset] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool]3343 ddt create-pool [--pool|-p pool] [--sector|-s sector] [--file-pool|-f file_pool] [--ipaddress-pool|-i ipaddress_pool] 3344 3344 3345 3345 =head2 create-pxe … … 3357 3357 =head2 del-pc 3358 3358 3359 ddt del-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3359 ddt del-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3360 3360 3361 3361 =head2 disable-pc 3362 3362 3363 ddt disable-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3363 ddt disable-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3364 3364 3365 3365 =head2 disable-float … … 3369 3369 =head2 disable-pxe 3370 3370 3371 ddt disable-pxe [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3371 ddt disable-pxe [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3372 3372 3373 3373 =head2 enable-float … … 3377 3377 =head2 enable-pc 3378 3378 3379 ddt enable-pc [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip]3379 ddt enable-pc [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] 3380 3380 3381 3381 =head2 enable-pxe 3382 3382 3383 ddt enable-pxe [--hostname|-h hostname] [-- domainset|-d domainset] [--ip|-i ip] [--bootp|-b pxe_config]3383 ddt enable-pxe [--hostname|-h hostname] [--sector|-s sector] [--ip|-i ip] [--bootp|-b pxe_config] 3384 3384 3385 3385 =head2 gen-dhcp-file … … 3397 3397 =head2 load-database 3398 3398 3399 ddt load-database [-- domainset|-d domainset] [--filename|-f filename] [--kind|-k kind]3399 ddt load-database [--sector|-s sector] [--filename|-f filename] [--kind|-k kind] 3400 3400 3401 3401 =head2 remove-pxe … … 3411 3411 ddt search-mac [--mac|-m mac] 3412 3412 3413 =head2 show- domainset3414 3415 ddt show- domainset[--no-header|-H]3413 =head2 show-sector 3414 3415 ddt show-sector [--no-header|-H] 3416 3416 3417 3417 =head2 show -
trunk/ddt/ddt.bash_completion
r228 r345 16 16 return 0 17 17 ;; 18 - d|--domainset)19 local showlist=$(ddt show- domainset--no-header|awk '{print $1}')18 -s|--sector) 19 local showlist=$(ddt show-sector --no-header|awk '{print $1}') 20 20 COMPREPLY=($(compgen -W "${showlist}" -- "$cur")) 21 21 return 0
Note: See TracChangeset
for help on using the changeset viewer.