Changeset 345 for trunk/ddt


Ignore:
Timestamp:
Aug 30, 2018, 4:25:34 PM (6 years ago)
Author:
g7moreau
Message:
Location:
trunk/ddt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ddt/ddt

    r344 r345  
    2121use strict;
    2222#use warnings;
    23 use version; our $VERSION = version->declare('0.10.5');
     23use version; our $VERSION = version->declare('0.11.0');
    2424
    2525use Getopt::Long qw(GetOptions);
     
    4141   'add-virtual'        => \&cmd_add_virtual,
    4242   'change-comment'     => \&cmd_change_comment,
    43    'change-domainset'   => \&cmd_change_domainset,
     43   'change-sector'      => \&cmd_change_sector,
    4444   'change-host'        => \&cmd_change_host,
    4545   'change-ip'          => \&cmd_change_ip,
     
    4747   'change-tag'         => \&cmd_change_tag,
    4848   'check-dns'          => \&cmd_check_dns,
    49    'create-domainset'   => \&cmd_create_domainset,
     49   'create-sector'      => \&cmd_create_sector,
    5050   'create-pool'        => \&cmd_create_pool,
    5151   'create-pxe'         => \&cmd_create_pxe,
     
    6767   'search-mac'         => \&cmd_search_mac,
    6868   'show'               => \&cmd_show_host,
    69    'show-domainset'     => \&cmd_show_domainset,
     69   'show-sector'        => \&cmd_show_sector,
    7070   'show-pool'          => \&cmd_show_pool,
    7171   'show-pxe'           => \&cmd_show_pxe,
     
    165165
    166166#-------------------------------------------------------------------------------
    167 #Nom: control_exist_domainset
    168 #Description: controle l'existence d'un domain set dans le fichier YAML
     167#Nom: control_exist_sector
     168#Description: controle l'existence d'un sector dans le fichier YAML
    169169#             return 0 (faux) ou 1 (vrai)
    170170
    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 $domainset not found\n";
     171sub 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";
    177177   return 0;
    178178   }
     
    184184
    185185sub 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 '') {
    189189      return 1;
    190190      }
    191191
    192    my @domainsetdb = @{$computer_db->{$domainset}};
    193 
    194    for my $computer (@domainsetdb) {
     192   my @sectordb = @{$computer_db->{$sector}};
     193
     194   for my $computer (@sectordb) {
    195195      my ($mac_address, $attribute) = %{$computer};
    196196      return 0 if $attribute->{'hostname'} eq $hostname;
     
    207207   my ($computer_db, $mac) = @_;
    208208
    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}};
    217217
    218218      LOOP_ON_COMPUTER:
    219       for my $computer (@domainsetdb) {
     219      for my $computer (@sectordb) {
    220220         my ($mac_address, $attribute) = %{$computer};
    221221         return 0 if $mac_address eq $mac;
     
    233233   my ($computer_db, $ip) = @_;
    234234
    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';
    241241
    242242      LOOP_ON_COMPUTER:
    243       for my $computer (@{$computer_db->{$domainset_current}}) {
     243      for my $computer (@{$computer_db->{$sector_current}}) {
    244244         my ($mac_address, $attribute) = %{$computer};
    245245         #print "Erreur: cette adresse IP $ip existe déjà\n";
     
    357357
    358358sub get_mac_from_hostname {
    359    my ($computer_db, $domainset, $hostname, $mac) = @_;
     359   my ($computer_db, $sector, $hostname, $mac) = @_;
    360360
    361361   return $mac if $mac ne '';
     
    363363
    364364   LOOP_ON_COMPUTER:
    365    for my $computer (@{$computer_db->{$domainset}}) {
     365   for my $computer (@{$computer_db->{$sector}}) {
    366366      my ($mac_address, $attribute) = %{$computer};
    367367
     
    375375
    376376sub get_mac_from_ip {
    377    my ($computer_db, $domainset, $ip, $mac) = @_;
     377   my ($computer_db, $sector, $ip, $mac) = @_;
    378378
    379379   return $mac if $mac ne '';
     
    381381
    382382   LOOP_ON_COMPUTER:
    383    for my $computer (@{$computer_db->{$domainset}}) {
     383   for my $computer (@{$computer_db->{$sector}}) {
    384384      my ($mac_address, $attribute) = %{$computer};
    385385
     
    394394
    395395sub get_computer_from_mac {
    396    my ($computer_db, $domainset, $mac) = @_;
     396   my ($computer_db, $sector, $mac) = @_;
    397397
    398398   LOOP_ON_COMPUTER:
    399    for my $computer (@{$computer_db->{$domainset}}) {
     399   for my $computer (@{$computer_db->{$sector}}) {
    400400      my ($mac_address, $attribute) = %{$computer};
    401401
     
    416416
    417417sub 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}};
    424424
    425425   LOOP_ON_COMPUTER:
    426    for my $computer (@domainsetdb) {
     426   for my $computer (@sectordb) {
    427427      my ($mac_address, $attribute) = %{$computer};
    428428
     
    443443
    444444sub add_static {
    445    my ($computer_db, $hostname, $domainset, $ip, $mac, $comment) = @_;
     445   my ($computer_db, $hostname, $sector, $ip, $mac, $comment) = @_;
    446446
    447447   $mac = normalize_mac_address($mac);
    448448   $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";
    450450   control_syntax_mac_address($mac)                   or exit;
    451451   control_exist_mac($computer_db, $mac)              or die "Error: physical MAC address already exists: $mac\n";
    452452   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";
    454454   control_syntax_comment($comment)                   or exit;
    455455   my $timestamp = time;
    456    push @{$computer_db->{$domainset}}, { $mac => {
     456   push @{$computer_db->{$sector}}, { $mac => {
    457457      'hostname'     => $hostname,
    458458      'ip'           => $ip,
     
    464464      'alias'        =>  '',
    465465      }};
    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";
    467467
    468468   ipamdb_save("$COMPUTER_YAML", $computer_db);
     
    476476
    477477sub add_dhcp {
    478    my ($computer_db, $hostname, $domainset, $ip, $mac, $comment) = @_;
     478   my ($computer_db, $hostname, $sector, $ip, $mac, $comment) = @_;
    479479
    480480   my $timestamp = time;
    481481   $mac = normalize_mac_address($mac);
    482482   $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";
    485485   control_syntax_mac_address($mac)                   or exit;
    486486   control_exist_mac($computer_db, $mac)              or die "Error: physical MAC address already exists: $mac\n";
    487487   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";
    489489   control_syntax_comment($comment)                   or exit;
    490490
    491    push @{$computer_db->{$domainset}}, { $mac => {
     491   push @{$computer_db->{$sector}}, { $mac => {
    492492      'hostname'     => $hostname,
    493493      'ip'           => $ip,
     
    499499      'alias'        => '',
    500500      }};
    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";
    502502
    503503   ipamdb_save("$COMPUTER_YAML", $computer_db);
     
    508508
    509509sub add_float {
    510    my ($computer_db, $pool, $domainset, $mac, $comment) = @_;
     510   my ($computer_db, $pool, $sector, $mac, $comment) = @_;
    511511
    512512   my $timestamp = time;
    513513   $mac = normalize_mac_address($mac);
    514514   $comment = normalize_comment($comment);
    515    control_exist_domainset($computer_db, $domainset)  or exit;
     515   control_exist_sector($computer_db, $sector)  or exit;
    516516   control_syntax_mac_address($mac)                   or exit;
    517517   control_exist_mac($computer_db, $mac)              or die "Error: physical MAC address already exists: $mac\n";
    518518   control_exist_pool($computer_db, $pool)            or die "Error: the pool doesn't exists: $pool\n";
    519519   control_syntax_comment($comment)                   or exit;
    520    push @{$computer_db->{$domainset}}, { $mac => {
     520   push @{$computer_db->{$sector}}, { $mac => {
    521521      'hostname'     => $pool,
    522522      'ip'           => $pool,
     
    527527      'comment'      => $comment,
    528528      }};
    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";
    530530
    531531   ipamdb_save("$COMPUTER_YAML", $computer_db);
     
    540540
    541541   my $help = get_cmd_name();
    542    my ($hostname, $domainset, $alias);
     542   my ($hostname, $sector, $alias);
    543543
    544544   GetOptions(
    545545      'hostname|h=s'    => \$hostname,
    546       'domainset|d=s'   => \$domainset,
     546      'sector|d=s'   => \$sector,
    547547      'alias|a=s'       => \$alias,
    548548      );
    549549
    550    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     550   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    551551   exit_on_error_option($help)
    552552      if $hostname   eq ''
    553       or $domainset  eq ''
     553      or $sector  eq ''
    554554      or $alias      eq '';
    555555
    556556   my $computer_db = ipamdb_load($COMPUTER_YAML);
    557    add_alias($computer_db, $hostname, $domainset, $alias);
     557   add_alias($computer_db, $hostname, $sector, $alias);
    558558   }
    559559
     
    564564
    565565   my $help = get_cmd_name();
    566    my ($hostname, $domainset, $ip, $mac, $comment);
     566   my ($hostname, $sector, $ip, $mac, $comment);
    567567
    568568   GetOptions(
    569569      'hostname|h=s'    => \$hostname,
    570       'domainset|d=s'   => \$domainset,
     570      'sector|d=s'   => \$sector,
    571571      'ip|i=s'          => \$ip,
    572572      'mac|m=s'         => \$mac,
     
    574574      );
    575575
    576    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     576   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    577577   exit_on_error_option($help)
    578578      if $hostname   eq ''
    579       or $domainset  eq ''
     579      or $sector  eq ''
    580580      or $ip         eq ''
    581581      or $mac        eq ''
     
    583583
    584584   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);
    586586   }
    587587
     
    592592
    593593   my $help = get_cmd_name();
    594    my ($pool, $domainset, $mac, $comment);
     594   my ($pool, $sector, $mac, $comment);
    595595
    596596   GetOptions(
    597597      'pool|p=s'        => \$pool,
    598       'domainset|d=s'   => \$domainset,
     598      'sector|d=s'   => \$sector,
    599599      'mac|m=s'         => \$mac,
    600600      'comment|c=s'     => \$comment,
    601601      );
    602602
    603    ($pool, $domainset) = split /\./, $pool, 2 if $pool =~ m/\./;
     603   ($pool, $sector) = split /\./, $pool, 2 if $pool =~ m/\./;
    604604   exit_on_error_option($help)
    605605      if $pool       eq ''
    606       or $domainset  eq ''
     606      or $sector  eq ''
    607607      or $mac        eq ''
    608608      or $comment    eq '';
    609609
    610610   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);
    612612   }
    613613
     
    618618
    619619   my $help = get_cmd_name();
    620    my ($hostname, $domainset, $ip, $mac, $comment);
     620   my ($hostname, $sector, $ip, $mac, $comment);
    621621
    622622   GetOptions(
    623623      'hostname|h=s'    => \$hostname,
    624       'domainset|d=s'   => \$domainset,
     624      'sector|d=s'   => \$sector,
    625625      'ip|i=s'          => \$ip,
    626626      'mac|m=s'         => \$mac,
     
    628628      );
    629629
    630    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     630   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    631631   exit_on_error_option($help)
    632632      if $hostname   eq ''
    633       or $domainset  eq ''
     633      or $sector  eq ''
    634634      or $ip         eq ''
    635635      or $mac        eq ''
     
    637637
    638638   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);
    640640   }
    641641
     
    647647
    648648   my $help = get_cmd_name();
    649    my ($hostname, $domainset, $ip, $comment);
     649   my ($hostname, $sector, $ip, $comment);
    650650
    651651   GetOptions(
    652652      'hostname|h=s'    => \$hostname,
    653       'domainset|d=s'   => \$domainset,
     653      'sector|d=s'   => \$sector,
    654654      'ip|i=s'          => \$ip,
    655655      'comment|c=s'     => \$comment,
    656656      );
    657657
    658    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     658   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    659659   exit_on_error_option($help)
    660660      if $hostname   eq ''
    661       or $domainset  eq ''
     661      or $sector  eq ''
    662662      or $ip         eq ''
    663663      or $comment    eq '';
     
    668668   my $timestamp = time;
    669669
    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";
    672672   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";
    674674   control_syntax_comment($comment)                            or exit;
    675675
     
    678678   control_exist_mac($computer_db, $mac)         or die "Error: virtual physical MAC address already exists: $mac\n";
    679679
    680    push @{$computer_db->{$domainset}}, { $mac => {
     680   push @{$computer_db->{$sector}}, { $mac => {
    681681      'hostname'     => $hostname,
    682682      'ip'           => $ip,
     
    687687      'comment'      => $comment,
    688688      }};
    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";
    690690
    691691   ipamdb_save("$COMPUTER_YAML", $computer_db);
     
    704704
    705705sub change_mac {
    706    my ($hostname, $domainset, $ip, $mac) = @_;
     706   my ($hostname, $sector, $ip, $mac) = @_;
    707707
    708708   my $computer_db = ipamdb_load($COMPUTER_YAML);
    709709
    710710   $mac = normalize_mac_address($mac);
    711    control_exist_domainset($computer_db, $domainset)  or exit;
     711   control_exist_sector($computer_db, $sector)  or exit;
    712712   control_syntax_mac_address($mac)                   or exit;
    713713   control_exist_mac($computer_db, $mac)              or die "Error: physical MAC address already exists: $mac\n";
     
    718718         exit;
    719719         }
    720       my @domainsetdb = @{$computer_db->{$domainset}};
     720      my @sectordb = @{$computer_db->{$sector}};
    721721      LOOP_ON_COMPUTER:
    722       for my $computer (@domainsetdb) {
     722      for my $computer (@sectordb) {
    723723         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;
    725725
    726726         next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip;
     
    731731
    732732         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";
    734734         exit;
    735735         }
    736736      }
    737737   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}};
    742742      LOOP_ON_COMPUTER:
    743       for my $computer (@domainsetdb) {
     743      for my $computer (@sectordb) {
    744744         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;
    746746
    747747         next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname;
     
    752752
    753753         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";
    755755         exit;
    756756         }
     
    764764
    765765sub 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";
    773773      }
    774774   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}};
    778778
    779779   LOOP_ON_COMPUTER:
    780    for my $computer (@domainsetdb) {
     780   for my $computer (@sectordb) {
    781781      my ($mac_address, $attribute) = %{$computer};
    782782     
     
    784784 
    785785      if ($attribute->{'address_type'} eq 'pool-dhcp') {
    786          die "Error: host $hostname from domain set $domainset belongs to a a pool [FAILED]" .
     786         die "Error: host $hostname from sector $sector belongs to a a pool [FAILED]" .
    787787            " ... use 'del-float' command before";
    788788         }
     
    801801
    802802sub 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;
    808808   control_syntax_ip($ip)   or exit;
    809809   if ( control_exist_ip($computer_db, $ip) == 1 ) {
    810810      die "Error: unkown IP address: $ip\n";
    811811      }
    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}};
    815815
    816816   LOOP_ON_COMPUTER:
    817    for my $computer (@domainsetdb) {
     817   for my $computer (@sectordb) {
    818818      my ($mac_address, $attribute) = %{$computer};
    819819
     
    828828
    829829   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";
    831831   }
    832832
     
    837837
    838838   my $help = get_cmd_name();
    839    my ($hostname, $domainset, $ip, $mac);
     839   my ($hostname, $sector, $ip, $mac);
    840840
    841841   GetOptions(
    842842      'hostname|h=s'    => \$hostname,
    843       'domainset|d=s'   => \$domainset,
     843      'sector|d=s'   => \$sector,
    844844      'ip|i=s'          => \$ip,
    845845      'mac|m=s'         => \$mac,
    846846      );
    847847
    848    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    849    exit_on_error_option($help)
    850       if $domainset  eq ''
     848   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     849   exit_on_error_option($help)
     850      if $sector  eq ''
    851851      or $mac        eq '';
    852852   exit_on_error_option($help)
     
    854854      and $ip        ne '';
    855855
    856    change_mac($hostname, $domainset, $ip, $mac);
     856   change_mac($hostname, $sector, $ip, $mac);
    857857   }
    858858
     
    863863
    864864   my $help = get_cmd_name();
    865    my ($hostname, $domainset, $ip);
     865   my ($hostname, $sector, $ip);
    866866
    867867   GetOptions(
    868868      'hostname|h=s'    => \$hostname,
    869       'domainset|d=s'   => \$domainset,
     869      'sector|d=s'   => \$sector,
    870870      'ip|i=s'          => \$ip,
    871871      );
    872872
    873    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     873   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    874874   exit_on_error_option($help)
    875875      if $hostname   eq ''
    876       or $domainset  eq ''
     876      or $sector  eq ''
    877877      or $ip         eq '';
    878878
    879    change_ip($hostname, $domainset, $ip);
     879   change_ip($hostname, $sector, $ip);
    880880   }
    881881
     
    886886
    887887   my $help = get_cmd_name();
    888    my ($hostname, $domainset, $ip);
     888   my ($hostname, $sector, $ip);
    889889
    890890   GetOptions(
    891891      'hostname|h=s'    => \$hostname,
    892       'domainset|d=s'   => \$domainset,
     892      'sector|d=s'   => \$sector,
    893893      'ip|i=s'          => \$ip,
    894894      );
    895895
    896    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     896   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    897897   exit_on_error_option($help)
    898898      if $hostname   eq ''
    899       or $domainset  eq ''
     899      or $sector  eq ''
    900900      or $ip         eq '';
    901901
    902    change_host($hostname, $domainset, $ip);
     902   change_host($hostname, $sector, $ip);
    903903   }
    904904
     
    909909
    910910   my $help = get_cmd_name();
    911    my ($domainset, $mac, $comment);
     911   my ($sector, $mac, $comment);
    912912
    913913   GetOptions(
    914       'domainset|d=s'   => \$domainset,
     914      'sector|d=s'   => \$sector,
    915915      'mac|m=s'         => \$mac,
    916916      'comment|c=s'     => \$comment,
     
    918918
    919919   exit_on_error_option($help)
    920       if $domainset  eq ''
     920      if $sector  eq ''
    921921      or $mac        eq ''
    922922      or $comment    eq '';
     
    927927   my $computer_db = ipamdb_load($COMPUTER_YAML);
    928928
    929    control_exist_domainset($computer_db, $domainset)  or exit;
     929   control_exist_sector($computer_db, $sector)  or exit;
    930930   control_syntax_mac_address($mac)                   or exit;
    931931   control_syntax_comment($comment)                   or exit;
    932932
    933    my @domainsetdb = @{$computer_db->{$domainset}};
     933   my @sectordb = @{$computer_db->{$sector}};
    934934
    935935   LOOP_ON_COMPUTER:
    936    for my $computer (@domainsetdb) {
     936   for my $computer (@sectordb) {
    937937      my ($mac_address, $attribute) = %{$computer};
    938938
     
    945945      }
    946946   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";
    948948   }
    949949
    950950#--------------------------------------------------------------------------------
    951951
    952 sub cmd_change_domainset {
     952sub cmd_change_sector {
    953953   local @ARGV = @_;
    954954
    955955   my $help = get_cmd_name();
    956    my ($domainset, $ip, $mac);
     956   my ($sector, $ip, $mac);
    957957
    958958   GetOptions(
    959       'domainset|d=s'   => \$domainset,
     959      'sector|d=s'   => \$sector,
    960960      'ip|i=s'          => \$ip,
    961961      'mac|m=s'         => \$mac,
     
    963963
    964964   exit_on_error_option($help)
    965       if $domainset  eq ''
     965      if $sector  eq ''
    966966      or $ip         eq ''
    967967      or $mac        eq '';
     
    971971   my $computer_db = ipamdb_load($COMPUTER_YAML);
    972972
    973    control_exist_domainset($computer_db, $domainset)   or exit;
     973   control_exist_sector($computer_db, $sector)   or exit;
    974974   control_syntax_ip($ip)                             or exit;
    975975   control_syntax_mac_address($mac)                   or exit;
    976976
    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}};
    986986      my $computer_index = 0;
    987987      LOOP_ON_COMPUTER:
    988       for my $computer (@domainsetdb) {
     988      for my $computer (@sectordb) {
    989989         my ($mac_address, $attribute) = %{$computer};
    990990
    991991         $computer_index++, next LOOP_ON_COMPUTER if $mac_address ne $mac;
    992          next LOOP_ON_DOMAINSET if $attribute->{'ip'} ne $ip;
     992         next LOOP_ON_SECTOR if $attribute->{'ip'} ne $ip;
    993993
    994994         $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 };
    997997
    998998         ipamdb_save("$COMPUTER_YAML", $computer_db);
     
    10001000         }
    10011001      }
    1002    die "Error: update of domain set $domainset [FAILED]\n" .
     1002   die "Error: update of sector $sector [FAILED]\n" .
    10031003      " ... MAC $mac and IP $ip don't exists in the database\n";
    10041004   }
     
    10101010
    10111011   my $help = get_cmd_name();
    1012    my ($hostname, $domainset, $ip, $mac, $tags);
     1012   my ($hostname, $sector, $ip, $mac, $tags);
    10131013
    10141014   GetOptions(
    10151015      'hostname|h=s'    => \$hostname,
    1016       'domainset|d=s'   => \$domainset,
     1016      'sector|d=s'   => \$sector,
    10171017      'ip|i=s'          => \$ip,
    10181018      'mac|m=s'         => \$mac,
     
    10201020      );
    10211021
    1022    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    1023 
    1024    exit_on_error_option($help)
    1025       if $domainset  eq ''
     1022   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     1023
     1024   exit_on_error_option($help)
     1025      if $sector  eq ''
    10261026      or $tags       eq '';
    10271027   exit_on_error_option($help)
     
    10431043      }
    10441044
    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 '';
    10491049   control_syntax_mac_address($mac) or exit;
    10501050
    10511051   LOOP_ON_COMPUTER:
    1052    for my $computer (@{$computer_db->{$domainset}}) {
     1052   for my $computer (@{$computer_db->{$sector}}) {
    10531053      my ($mac_address, $attribute) = %{$computer};
    10541054
     
    10631063      }
    10641064   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";
    10661066   }
    10671067
     
    10751075
    10761076sub disable_pc {
    1077    my ($hostname, $domainset, $ip) = @_;
     1077   my ($hostname, $sector, $ip) = @_;
    10781078
    10791079   my $computer_db = ipamdb_load($COMPUTER_YAML);
     
    10851085         }
    10861086
    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}};
    10951095         LOOP_ON_COMPUTER:
    1096          for my $computer (@domainsetdb) {
     1096         for my $computer (@sectordb) {
    10971097            my ($mac_address, $attribute) = %{$computer};
    10981098
     
    11001100
    11011101            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]" .
    11031103                  " ... Status: $attribute->{'enabled'}\n";
    11041104               exit;
     
    11091109            $attribute->{'enabled'}     = 'no';
    11101110            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]" .
    11121112               " ... Status: $attribute->{'enabled'}\n";
    11131113            exit;
     
    11161116      }
    11171117   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";
    11211121         }
    11221122
    11231123      LOOP_ON_COMPUTER:
    1124       for my  $computer (@{$computer_db->{$domainset}}) {
     1124      for my  $computer (@{$computer_db->{$sector}}) {
    11251125         my ($mac_address, $attribute) = %{$computer};
    11261126
     
    11281128
    11291129         if ($attribute->{'address_type'} eq 'pool-dhcp') {
    1130             die "Error: host $hostname from domain set $domainset belongs to a a pool [FAILED]" .
     1130            die "Error: host $hostname from sector $sector belongs to a a pool [FAILED]" .
    11311131               " ... use 'disable-float' command instead";
    11321132            }
    11331133
    11341134         if ($attribute->{'enabled'} eq 'no') {
    1135             print "Info: host $hostname from domain set $domainset is already disable [OK]" .
     1135            print "Info: host $hostname from sector $sector is already disable [OK]" .
    11361136               " ... Status: $attribute->{'enabled'}\n";
    11371137            exit;
     
    11421142         $attribute->{'enabled'}     = 'no';
    11431143         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]" .
    11451145            " ... Status: $attribute->{'enabled'}\n";
    11461146         exit;
     
    11601160      }
    11611161
    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}};
    11701170
    11711171      LOOP_ON_COMPUTER:
    1172       for my $computer (@domainsetdb) {
     1172      for my $computer (@sectordb) {
    11731173         my ($mac_address, $attribute) = %{$computer};
    11741174         next LOOP_ON_COMPUTER if $mac_address ne $mac;
     
    12011201
    12021202sub 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;
    12081208
    12091209   if ($ip ne '') { # enable by IP
     
    12141214         }
    12151215
    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}};
    12241224
    12251225         LOOP_ON_COMPUTER:
    1226          for my $computer (@domainsetdb) {
     1226         for my $computer (@sectordb) {
    12271227            my ($mac_address, $attribute) = %{$computer};
    12281228            if ($attribute->{'ip'} eq $ip) {
    12291229
    12301230               if ($attribute->{'enabled'} eq 'yes') {
    1231                   print "Info: IP $ip belongs to domain set $domainset is already enable [OK]" .
     1231                  print "Info: IP $ip belongs to sector $sector is already enable [OK]" .
    12321232                     " ... Status: $attribute->{'enabled'}\n";
    12331233                  exit;
     
    12461246      }
    12471247   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";
    12501250         }
    12511251
    12521252      LOOP_ON_COMPUTER:
    1253       for my $computer (@{$computer_db->{$domainset}}) {
     1253      for my $computer (@{$computer_db->{$sector}}) {
    12541254         my ($mac_address, $attribute) = %{$computer};
    12551255         next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname;
    12561256
    12571257         if ($attribute->{'address_type'} eq 'pool-dhcp') {
    1258             die "Error: host $hostname from domain set $domainset belongs to a a pool [FAILED]" .
     1258            die "Error: host $hostname from sector $sector belongs to a a pool [FAILED]" .
    12591259               " ... use 'enable-float' command instead";
    12601260            }
    12611261
    12621262         if ($attribute->{'enabled'} eq 'yes') {
    1263             print "Info: host $hostname belongs to domain set $domainset is already enable [OK]" .
     1263            print "Info: host $hostname belongs to sector $sector is already enable [OK]" .
    12641264               " ... Status: $attribute->{'enabled'}\n";
    12651265            exit;
     
    12881288      }
    12891289
    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}};
    12981298
    12991299      LOOP_ON_COMPUTER:
    1300       for my $computer (@domainsetdb) {
     1300      for my $computer (@sectordb) {
    13011301         my ($mac_address, $attribute) = %{$computer};
    13021302         next LOOP_ON_COMPUTER if $mac_address ne $mac;
     
    13301330
    13311331   my $help = get_cmd_name();
    1332    my ($hostname, $domainset, $ip);
     1332   my ($hostname, $sector, $ip);
    13331333
    13341334   GetOptions(
    13351335      'hostname|h=s'    => \$hostname,
    1336       'domainset|d=s'   => \$domainset,
     1336      'sector|d=s'   => \$sector,
    13371337      'ip|i=s'          => \$ip,
    13381338      );
    13391339
    1340    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    1341    exit_on_error_option($help)
    1342       if $domainset  eq '';
     1340   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     1341   exit_on_error_option($help)
     1342      if $sector  eq '';
    13431343   exit_on_error_option($help)
    13441344      if $hostname   eq ''
     
    13481348      and $ip        ne '';
    13491349
    1350    enable_pc($hostname, $domainset, $ip);
     1350   enable_pc($hostname, $sector, $ip);
    13511351   }
    13521352
     
    13571357
    13581358   my $help = get_cmd_name();
    1359    my ($hostname, $domainset, $ip);
     1359   my ($hostname, $sector, $ip);
    13601360
    13611361   GetOptions(
    13621362      'hostname|h=s'    => \$hostname,
    1363       'domainset|d=s'   => \$domainset,
     1363      'sector|d=s'   => \$sector,
    13641364      'ip|i=s'          => \$ip,
    13651365      );
    13661366
    1367    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    1368    exit_on_error_option($help)
    1369       if $domainset  eq '';
     1367   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     1368   exit_on_error_option($help)
     1369      if $sector  eq '';
    13701370   exit_on_error_option($help)
    13711371      if $hostname   eq ''
     
    13751375      and $ip        ne '';
    13761376
    1377    disable_pc($hostname, $domainset, $ip);
     1377   disable_pc($hostname, $sector, $ip);
    13781378   }
    13791379
     
    14291429
    14301430sub 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;
    14361436   if ($ip ne '') { # delete by IP
    14371437      if ( control_exist_ip($computer_db, $ip) == 1 ) {
     
    14421442
    14431443      LOOP_ON_COMPUTER:
    1444       for my $computer (@{$computer_db->{$domainset}}) {
     1444      for my $computer (@{$computer_db->{$sector}}) {
    14451445         my ($mac_address, $attribute) = %{$computer};
    14461446
    14471447         $computer_index++, next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip;
    14481448         
    1449          splice(@{$computer_db->{$domainset}}, $computer_index => 1);
     1449         splice(@{$computer_db->{$sector}}, $computer_index => 1);
    14501450         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";
    14521452         exit;
    14531453         }
    14541454      }
    14551455   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";
    14581458         }
    14591459
     
    14611461
    14621462      LOOP_ON_COMPUTER:
    1463       for my $computer (@{$computer_db->{$domainset}}) {
     1463      for my $computer (@{$computer_db->{$sector}}) {
    14641464         my ($mac_address, $attribute) = %{$computer};
    14651465
     
    14671467
    14681468         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]" .
    14701470               " ... The host $hostname belongs to a DHCP pool.\n";
    14711471            }
    14721472
    1473          splice(@{$computer_db->{$domainset}}, $computer_index => 1);
     1473         splice(@{$computer_db->{$sector}}, $computer_index => 1);
    14741474         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";
    14761476         exit;
    14771477         }
     
    14931493      }
    14941494
    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}};
    15031503
    15041504      my $computer_index = 0;
    15051505
    15061506      LOOP_ON_COMPUTER:
    1507       for my $computer (@domainsetdb) {
     1507      for my $computer (@sectordb) {
    15081508         my ($mac_address, $attribute) = %{$computer};
    15091509
     
    15151515            }
    15161516
    1517          splice(@{$computer_db->{$domainset_current}}, $computer_index => 1);
     1517         splice(@{$computer_db->{$sector_current}}, $computer_index => 1);
    15181518         ipamdb_save("$COMPUTER_YAML", $computer_db);
    15191519         print "Info: remove host $mac from the pool $pool [OK]\n";
     
    15291529
    15301530   my $help = get_cmd_name();
    1531    my ($hostname, $domainset, $ip);
     1531   my ($hostname, $sector, $ip);
    15321532
    15331533   GetOptions(
    15341534      'hostname|h=s'    => \$hostname,
    1535       'domainset|d=s'   => \$domainset,
     1535      'sector|d=s'   => \$sector,
    15361536      'ip|i=s'          => \$ip,
    15371537      );
    15381538
    1539    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    1540    exit_on_error_option($help)
    1541       if $domainset  eq '';
     1539   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     1540   exit_on_error_option($help)
     1541      if $sector  eq '';
    15421542   exit_on_error_option($help)
    15431543      if $hostname   eq ''
     
    15471547      and $ip        ne '';
    15481548
    1549    del_pc($hostname, $domainset, $ip);
     1549   del_pc($hostname, $sector, $ip);
    15501550   }
    15511551
     
    15721572
    15731573#-------------------------------------------------------------------------------
    1574 # DOMAIN SET section
    1575 #-------------------------------------------------------------------------------
    1576 
    1577 sub cmd_create_domainset {
     1574# SECTOR section
     1575#-------------------------------------------------------------------------------
     1576
     1577sub cmd_create_sector {
    15781578   local @ARGV = @_;
    15791579
    15801580   my $help = get_cmd_name();
    1581    my ($domainset, $dns_extension, $comment);
     1581   my ($sector, $dns_extension, $comment);
    15821582
    15831583   GetOptions(
    1584       'domainset|d=s'      => \$domainset,
     1584      'sector|d=s'      => \$sector,
    15851585      'dns-extension|e=s'  => \$dns_extension,
    15861586      'comment|c=s'        => \$comment,
     
    15881588
    15891589   exit_on_error_option($help)
    1590       if $domainset     eq ''
     1590      if $sector     eq ''
    15911591      or $dns_extension eq ''
    15921592      or $comment       eq '';
     
    15971597
    15981598   $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};
    16001600
    16011601   control_syntax_comment($comment)    or exit;
    16021602
    16031603   my $timestamp = time;
    1604    $computer_db->{'dset'}{$domainset} = {
     1604   $computer_db->{'dset'}{$sector} = {
    16051605      'dns_extension'   => $dns_extension,
    16061606      'comment'         => $comment,
     
    16081608      'modify_time'     => $timestamp,
    16091609      };
    1610    $computer_db->{$domainset} ||= []; # Create empty domain set computer list by default
     1610   $computer_db->{$sector} ||= []; # Create empty sector computer list by default
    16111611   ipamdb_save("$COMPUTER_YAML", $computer_db);
    16121612   }
     
    16271627
    16281628   my $help = get_cmd_name();
    1629    my ($pool, $domainset, $file_pool, $ipaddress_pool);
     1629   my ($pool, $sector, $file_pool, $ipaddress_pool);
    16301630
    16311631   GetOptions(
    16321632      'pool|p=s'           => \$pool,
    1633       'domainset|d=s'      => \$domainset,
     1633      'sector|d=s'      => \$sector,
    16341634      'file-pool|f=s'      => \$file_pool,
    16351635      'ipaddress-pool|i=s' => \$ipaddress_pool,
     
    16381638   exit_on_error_option($help)
    16391639      if $pool             eq ''
    1640       or $domainset        eq ''
     1640      or $sector        eq ''
    16411641      or $file_pool        eq ''
    16421642      or $ipaddress_pool   eq '';
     
    16491649
    16501650   #--- 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;
    16521652
    16531653   my @ip_list = ();
     
    16831683      'modify_time' => $timestamp,
    16841684      'file'        => $file_pool,
    1685       'domain'      => $domainset,
     1685      'domain'      => $sector,
    16861686      };
    16871687   ipamdb_save("$COMPUTER_YAML", $computer_db);
     
    17771777
    17781778   # 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';
    17861786
    17871787      LOOP_ON_COMPUTER:
    1788       for my $computer (@{$computer_db->{$domainset_current}}) {
     1788      for my $computer (@{$computer_db->{$sector_current}}) {
    17891789         my ($mac_address, $attribute) = %{$computer};
    17901790
    17911791         if (exists $attribute->{'pxe_config'}) {
    17921792            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'};
    17941794            }
    17951795         }
     
    18301830
    18311831   my $help = get_cmd_name();
    1832    my ($hostname, $domainset, $ip, $pxe_config);
     1832   my ($hostname, $sector, $ip, $pxe_config);
    18331833
    18341834   GetOptions(
    18351835      'hostname|h=s'    => \$hostname,
    1836       'domainset|d=s'   => \$domainset,
     1836      'sector|d=s'   => \$sector,
    18371837      'ip|i=s'          => \$ip,
    18381838      'bootp|b=s'       => \$pxe_config,
    18391839      );
    18401840
    1841    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    1842    exit_on_error_option($help)
    1843       if $domainset  eq ''
     1841   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     1842   exit_on_error_option($help)
     1843      if $sector  eq ''
    18441844      or $pxe_config eq '';
    18451845   exit_on_error_option($help)
     
    18541854   die "Error: PXE config not exists: $pxe_config\n" if not exists $computer_db->{'pxe'}{$pxe_config};
    18551855
    1856    control_exist_domainset($computer_db, $domainset) or exit;
     1856   control_exist_sector($computer_db, $sector) or exit;
    18571857   if ($ip ne '') {
    18581858      control_syntax_ip($ip);
     
    18611861         }
    18621862
    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';
    18691869
    18701870         LOOP_ON_COMPUTER:
    1871          for my $computer (@{$computer_db->{$domainset_current}}) {
     1871         for my $computer (@{$computer_db->{$sector_current}}) {
    18721872            my ($mac_address, $attribute) = %{$computer};
    18731873            next LOOP_ON_COMPUTER if $attribute->{'ip'} ne $ip;
     
    18761876            $attribute->{'pxe_config'}  = $pxe_config;
    18771877            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";
    18791879            exit;
    18801880            }
     
    18821882      }
    18831883   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";
    18861886         }
    18871887
    18881888      LOOP_ON_COMPUTER:
    1889       for my $computer (@{$computer_db->{$domainset}}) {
     1889      for my $computer (@{$computer_db->{$sector}}) {
    18901890         my ($mac_address, $attribute) = %{$computer};
    18911891         next LOOP_ON_COMPUTER if $attribute->{'hostname'} ne $hostname;
    18921892         
    18931893         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";
    18951895            }
    18961896
     
    18981898         $attribute->{'pxe_config'}  = $pxe_config;
    18991899         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";
    19011901         exit;
    19021902         }
     
    19101910
    19111911   my $help = get_cmd_name();
    1912    my ($hostname, $domainset, $ip);
     1912   my ($hostname, $sector, $ip);
    19131913
    19141914   GetOptions(
    19151915      'hostname|h=s'    => \$hostname,
    1916       'domainset|d=s'   => \$domainset,
     1916      'sector|d=s'   => \$sector,
    19171917      'ip|i=s'          => \$ip,
    19181918      );
    19191919
    1920    ($hostname, $domainset) = split /\./, $hostname, 2 if $hostname =~ m/\./;
    1921    exit_on_error_option($help)
    1922       if $domainset  eq '';
     1920   ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./;
     1921   exit_on_error_option($help)
     1922      if $sector  eq '';
    19231923   exit_on_error_option($help)
    19241924      if $hostname   eq ''
     
    19301930   my $computer_db = ipamdb_load($COMPUTER_YAML);
    19311931
    1932    control_exist_domainset($computer_db, $domainset) or exit;
     1932   control_exist_sector($computer_db, $sector) or exit;
    19331933   if ($ip ne '') {
    19341934      control_syntax_ip($ip);
     
    19371937         }
    19381938
    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';
    19451945
    19461946         LOOP_ON_COMPUTER:
    1947          for my $computer (@{$computer_db->{$domainset_current}}) {
     1947         for my $computer (@{$computer_db->{$sector_current}}) {
    19481948            my ($mac_address, $attribute) = %{$computer};
    19491949           
     
    19611961      }
    19621962   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";
    19651965         }
    19661966
    19671967      LOOP_ON_COMPUTER:
    1968       for my $computer (@{$computer_db->{$domainset}}) {
     1968      for my $computer (@{$computer_db->{$sector}}) {
    19691969         my ($mac_address, $attribute) = %{$computer};
    19701970
     
    19721972
    19731973         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";
    19751975            }
    19761976
     
    19811981         delete $attribute->{'pxe_config'};
    19821982         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";
    19841984         exit;
    19851985         }
     
    20512051
    20522052   # 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';
    20602060
    20612061      LOOP_ON_COMPUTER:
    2062       for my $computer (@{$computer_db->{$domainset_current}}) {
     2062      for my $computer (@{$computer_db->{$sector_current}}) {
    20632063         my ($mac_address, $attribute) = %{$computer};
    20642064
    20652065         if (exists $attribute->{'tag'}) {
    20662066            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'};
    20682068            }
    20692069         }
     
    21052105   my $computer_db = ipamdb_load($COMPUTER_YAML);
    21062106
    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}};
    21162116
    21172117      LOOP_ON_COMPUTER:
    2118       for my $computer (@domainsetdb) {
     2118      for my $computer (@sectordb) {
    21192119         my ($mac_address, $attribute) = %{$computer};
    21202120         my $new_mac = normalize_mac_address($mac_address);
     
    21422142#--------------------------------------------------------------------------------
    21432143
    2144 sub cmd_show_domainset {
     2144sub cmd_show_sector {
    21452145   local @ARGV = @_;
    21462146
     
    21542154
    21552155   my $tb_computer = Text::Table->new(
    2156      {align  => 'left',   align_title => 'left',   title => 'DomainSet'},
     2156     {align  => 'left',   align_title => 'left',   title => 'Sector'},
    21572157     {is_sep => 1,        body        => '  '},
    21582158     {align  => 'left',   align_title => 'left',   title => 'DNS-Extension:'},
     
    21632163     );
    21642164
    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'};
    21762176      $year += 1900;
    21772177      $mon++;
     
    21792179
    21802180      my $category;
    2181       my $comment = $computer_db->{'dset'}{$domainset_current}{'comment'};
     2181      my $comment = $computer_db->{'dset'}{$sector_current}{'comment'};
    21822182      $comment =~ s/^\d\d\d\d-\d\d-\d\d\s//;
    21832183      $comment =~ s/\s+(\(\w+\))$// and $category = $1;
    21842184
    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'},
    21872187         $date,
    21882188         $comment,
     
    22172217   control_syntax_mac_address($mac) or exit;
    22182218
    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}};
    22282228
    22292229      LOOP_ON_COMPUTER:
    2230       for my $computer (@domainsetdb) {
     2230      for my $computer (@sectordb) {
    22312231         my ($mac_address, $attribute) = %{$computer};
    22322232
     
    22502250
    22512251         printf "%-30s  %-20s %17s %9s %3s %10s %s\n",
    2252             $attribute->{'hostname'} . '.' . $domainset_current,
     2252            $attribute->{'hostname'} . '.' . $sector_current,
    22532253            $attribute->{'ip'},
    22542254            $mac_address,
     
    22712271
    22722272   my $tb_computer = Text::Table->new(
    2273      {align  => 'left',   align_title => 'left',   title => 'Hostname.DomainSet'},
     2273     {align  => 'left',   align_title => 'left',   title => 'Hostname.Sector'},
    22742274     {is_sep => 1,        body        => '  '},
    22752275     {align  => 'left',   align_title => 'left',   title => 'IPv4-Address'},
     
    22842284     );
    22852285
    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}};
    22952295
    22962296      LOOP_ON_COMPUTER:
    2297       for my $computer (@domainsetdb) {
     2297      for my $computer (@sectordb) {
    22982298         my ($mac_address, $attribute) = %{$computer};
    22992299         my $ip = $attribute->{'ip'};
     
    23042304                  'mac_address'  => $mac_address,
    23052305                  %{$attribute},
    2306                   'domainset'    => $domainset_current,
     2306                  'sector'    => $sector_current,
    23072307                  };
    23082308               }
     
    23312331         #printf "%-30s  %-20s %17s %9s %3s %10s %s\n",
    23322332         $tb_computer->add(
    2333             $attribute->{'hostname'} . '.' . $domainset_current,
     2333            $attribute->{'hostname'} . '.' . $sector_current,
    23342334            $ip,
    23352335            $mac_address,
     
    23402340            );
    23412341         }
    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";
    23462346   LOOP_ON_IP_ADDRESS:
    23472347   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %ipdb)) {
     
    23642364      #printf "%-30s %-20s %17s %9s %3s %10s %s\n",
    23652365      $tb_computer->add(
    2366          $ipdb{$ip}->{'hostname'} . '.' . $ipdb{$ip}->{'domainset'},
     2366         $ipdb{$ip}->{'hostname'} . '.' . $ipdb{$ip}->{'sector'},
    23672367         $ip,
    23682368         normalize_mac_address($ipdb{$ip}->{'mac_address'}),
     
    23902390   my %file_pool;
    23912391
    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) {
    24022402         ALL_MAC_ADDRESS:
    24032403         for my $mac_addres (keys %{$value}) {
     
    25052505   my $computer_db = ipamdb_load($COMPUTER_YAML);
    25062506
    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') {
    25152515         LOOP_ON_COMPUTER:
    2516          for my $computer (@{$computer_db->{$domainset_current}}) {
     2516         for my $computer (@{$computer_db->{$sector_current}}) {
    25172517            for my $pool_name (keys %{$computer}) {
    25182518               $pool_domain = $computer->{$pool_name}->{'domain'}."\n";
     
    25372537      else {
    25382538         #--- 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}};
    25432543
    25442544         LOOP_ON_COMPUTER:
    2545          for my $computer (@domainsetdb) {
     2545         for my $computer (@sectordb) {
    25462546            my ($mac_address, $attribute) = %{$computer};
    25472547
     
    25592559            next LOOP_ON_COMPUTER if not (($address_type eq 'dhcp') or ($address_type eq 'static'));
    25602560
    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'};
    25642564               }
    25652565
     
    25832583         close FILE_REVERSE_DNS;
    25842584         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;
    25872587         }
    25882588      }
     
    26202620
    26212621   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}};
    26312631
    26322632         LOOP_ON_COMPUTER:
    2633          for my $computer (@domainsetdb) {
     2633         for my $computer (@sectordb) {
    26342634            my ($mac_address, $attribute) = %{$computer};
    26352635            #my $new_mac = normalize_mac_address($mac_address);
     
    26422642
    26432643            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";
    26452645               next LOOP_ON_COMPUTER;
    26462646               }
     
    26892689
    26902690sub load_data_dhcp {
    2691    my ($domainset, $input_file) = @_;
     2691   my ($sector, $input_file) = @_;
    26922692
    26932693   my $computer_db = ipamdb_load($COMPUTER_YAML);
     
    27392739         $cpt = 0;
    27402740
    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";
    27432743            next;
    27442744            }
     
    27552755            }
    27562756         my $timestamp = time;
    2757          push @{$computer_db->{$domainset}}, { $mac => {
     2757         push @{$computer_db->{$sector}}, { $mac => {
    27582758            'hostname'     => $hostname,
    27592759            'ip'           => $ip,
     
    27732773
    27742774sub load_data_pool {
    2775    my ($domainset, $input_file) = @_;
     2775   my ($sector, $input_file) = @_;
    27762776
    27772777   my @T_mac;
     
    28102810            }
    28112811
    2812          if ($computer_db->{'pool'}{'domain'} eq $domainset) {
     2812         if ($computer_db->{'pool'}{'domain'} eq $sector) {
    28132813            my $timestamp = time;
    2814             push @{$computer_db->{$domainset}}, { $mac => {
     2814            push @{$computer_db->{$sector}}, { $mac => {
    28152815               'hostname'     => $pool,
    28162816               'ip'           => $pool,
     
    28232823         else {
    28242824            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";
    28262826            }
    28272827         }
     
    28322832
    28332833sub load_data_file {
    2834    my ($domainset, $input_file, $type_file) = @_;
     2834   my ($sector, $input_file, $type_file) = @_;
    28352835
    28362836   my $computer_db = ipamdb_load($COMPUTER_YAML);
     
    28382838   #$computer_db
    28392839   if ($type_file eq 'dhcp') {
    2840       load_data_dhcp($domainset, $input_file);
     2840      load_data_dhcp($sector, $input_file);
    28412841      }
    28422842
    28432843   elsif ($type_file eq 'pool-dhcp') {
    2844       load_data_pool($domainset, $input_file);
     2844      load_data_pool($sector, $input_file);
    28452845      }
    28462846
     
    28542854
    28552855   my $help = get_cmd_name();
    2856    my ($domainset, $input_file, $type_file);
     2856   my ($sector, $input_file, $type_file);
    28572857
    28582858   GetOptions(
    2859       'domainset|d=s'   => \$domainset,
     2859      'sector|d=s'   => \$sector,
    28602860      'filename|f=s'    => \$input_file,
    28612861      'kind|k=s'        => \$type_file,
     
    28632863
    28642864   exit_on_error_option($help)
    2865       if $domainset  eq ''
     2865      if $sector  eq ''
    28662866      or $input_file eq ''
    28672867      or $type_file  eq '';
    28682868
    2869    load_data_file($domainset, $input_file, $type_file);
     2869   load_data_file($sector, $input_file, $type_file);
    28702870   }
    28712871
     
    28962896   if ($command eq 'add-dhcp') {
    28972897      print "List of options for command: $command\n";
    2898       print " -d : domain set attachment (mandatory). Example: -d legi-sector03\n";
     2898      print " -d : sector attachment (mandatory). Example: -d legi-sector03\n";
    28992899      print " -h : computer hostname (mandatory if option -i != 'pool'). Example: -h info8pc154\n";
    29002900      print " -m : physical MAC address (mandatory). Example: -m 0F:58:AB:2A\n";
     
    29092909   elsif ($command eq 'add-float') {
    29102910      print "List of options for command: $command\n";
    2911       print " -d : domain set attachment (mandatory)\n";
     2911      print " -d : sector attachment (mandatory)\n";
    29122912      print " -p : name of the DHCP pool to which the machine belongs (mandatory)\n";
    29132913      print " -m : physical MAC address (mandatory)\n";
     
    29192919   elsif ($command eq 'add-static') {
    29202920      print "List of options for command: $command\n";
    2921       print " -d : domain set attachment (mandatory)\n";
     2921      print " -d : sector attachment (mandatory)\n";
    29222922      print " -i : internet IP address (mandatory)\n";
    29232923      print " -h : computer hostname (mandatory)\n";
     
    29302930   elsif ($command eq 'add-virtual') {
    29312931      print "List of options for command: $command\n";
    2932       print " -d : domain set attachment (mandatory)\n";
     2932      print " -d : sector attachment (mandatory)\n";
    29332933      print " -i : internet IP address (mandatory)\n";
    29342934      print " -h : computer hostname (mandatory)\n";
     
    29402940   elsif ($command eq 'add-alias') {
    29412941      print "List of options for command: $command\n";
    2942       print " -d : domain set attachment (mandatory)\n";
     2942      print " -d : sector attachment (mandatory)\n";
    29432943      print " -h : computer hostname (mandatory)\n";
    29442944      print " -a : computer alias name (mandatory)\n";
    29452945      }
    29462946
    2947    elsif ($command eq 'create-domainset') {
     2947   elsif ($command eq 'create-sector') {
    29482948      print "List of options for command: $command\n";
    2949       print " -d : new domain set (mandatory)\n";
     2949      print " -d : new sector (mandatory)\n";
    29502950      print " -e : DNS domain name extension( mandatory). Example legi.grenoble-inp.fr\n";
    29512951      print " -c : comment (mandatory). Example: 2016-08-22 VLAN legi-261 (INFO)\n";
    29522952      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";
    29542954      }
    29552955
     
    29572957      print "List of options for command: $command\n";
    29582958      print " -p : name of the DHCP pool. Example: pool-legi-priv\n";
    2959       print " -d : domain set attachment for the pool. (domain set attachment 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";
    29602960      print " -f : configuration filename on the DHCP server for the pool\n";
    29612961      print " -i : adresse(s) IP ou plage d'IP. Séparateur d'adresses IP: ','. Séparateur de plage '-'\n";
     
    29822982      print " -h : computer hostname (mandatory unless option -i)\n";
    29832983      print " -i : internet IP address (mandatory unless option -h)\n";
    2984       print " -d : domain set attachment (mandatory if option -h)\n";
     2984      print " -d : sector attachment (mandatory if option -h)\n";
    29852985      print " -b : name of the PXE/BOOTP configuration. Example: most\n";
    29862986      }
     
    29902990      print " -h : computer hostname (mandatory unless option -i)\n";
    29912991      print " -i : internet IP address (mandatory unless option -h)\n";
    2992       print " -d : domain set attachment (mandatory if option -h)\n";
     2992      print " -d : sector attachment (mandatory if option -h)\n";
    29932993      }
    29942994
     
    30073007   elsif ($command eq 'change-mac') {
    30083008      print "List of options for command: $command\n";
    3009       print " -d : domain set attachment (mandatory). Example: -d legi-sector03\n";
     3009      print " -d : sector attachment (mandatory). Example: -d legi-sector03\n";
    30103010      print " -h : computer hostname (mandatory unless option -i)\n";
    30113011      print " -i : internet IP address (mandatory unless option -h). Possible value: classical IP address or the keyword 'pool'\n";
     
    30153015   elsif ($command eq 'change-ip') {
    30163016      print "List of options for command: $command\n";
    3017       print " -d : domain set attachment (mandatory). Example: -d legi-sector03\n";
     3017      print " -d : sector attachment (mandatory). Example: -d legi-sector03\n";
    30183018      print " -h : computer hostname (mandatory)\n";
    30193019      print " -i : new internet IP address (mandatory). Possible value: classical IP address\n";
     
    30223022   elsif ($command eq 'change-host') {
    30233023      print "List of options for command: $command\n";
    3024       print " -d : domain set attachment (mandatory). Example: -d legi-sector03\n";
     3024      print " -d : sector attachment (mandatory). Example: -d legi-sector03\n";
    30253025      print " -i : internet IP address (mandatory). Possible value: classical IP address\n";
    30263026      print " -h : new computer hostname (mandatory)\n";
     
    30303030   elsif ($command eq 'change-comment') {
    30313031      print "List of options for command: $command\n";
    3032       print " -d : domain set attachment (mandatory). Example: -d legi-sector03\n";
     3032      print " -d : sector attachment (mandatory). Example: -d legi-sector03\n";
    30333033      print " -m : physical MAC address (mandatory). Example: -m 0F:58:AB:2A:22:11\n";
    30343034      print " -c : new comment (mandatory)\n";
    30353035      }
    30363036
    3037    elsif ($command eq 'change-domainset') {
     3037   elsif ($command eq 'change-sector') {
    30383038      print "List of options for command: $command\n";
    3039       print " -d : new domain set attachment (mandatory). Example: -d legi-661\n";
     3039      print " -d : new sector attachment (mandatory). Example: -d legi-661\n";
    30403040      print " -m : physical MAC address (mandatory). Example: -m 0F:58:AB:2A:22:11\n";
    30413041      print " -i : internet IP address (mandatory)\n";
     
    30453045      print "List of options for command: $command\n";
    30463046      print " -h : computer hostname (mandatory unless option -i or -m)\n";
    3047       print " -d : domain set attachment (mandatory). Example: -d legi-sector03\n";
     3047      print " -d : sector attachment (mandatory). Example: -d legi-sector03\n";
    30483048      print " -i : internet IP address (mandatory unless option -h or -m)\n";
    30493049      print " -m : physical MAC address (mandatory unless option -h or -i, priority). Example: -m 0F:58:AB:2A:22:11\n";
     
    30533053   elsif ($command eq 'load-database') {
    30543054      print "List of options for command: $command\n";
    3055       print " -d : domain set attachment\n";
     3055      print " -d : sector attachment\n";
    30563056      print " -f : input file in DHCP format\n";
    30573057      print " -k : possible cases (kind): dhcp, pool-dhcp, fix-address\n";
     
    30623062      print " -h : computer hostname (mandatory unless option -i)\n";
    30633063      print " -i : internet IP address (mandatory unless option -h)\n";
    3064       print " -d : domain set attachment (mandatory if option -h)\n";
     3064      print " -d : sector attachment (mandatory if option -h)\n";
    30653065      print "Examples:\n";
    30663066      print " ddt enable_pc -i 192.168.10.1\n";
     
    30843084      print " -h : computer hostname (mandatory unless option -i)\n";
    30853085      print " -i : internet IP address (mandatory unless option -h)\n";
    3086       print " -d : domain set attachment (mandatory if option -h)\n";
     3086      print " -d : sector attachment (mandatory if option -h)\n";
    30873087      print "Examples:\n";
    30883088      print " ddt disable_pc -i 192.168.10.1\n";
     
    30923092   elsif ($command eq 'del-pc') {
    30933093      print "List of options for command: $command\n";
    3094       print " -d : domain set attachment (mandatory)\n";
     3094      print " -d : sector attachment (mandatory)\n";
    30953095      print " -h : computer hostname (mandatory unless option -i)\n";
    30963096      print " -i : internet IP address (mandatory unless option -h)\n";
     
    31393139ddt - management of computer names and IP addresses
    31403140
    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]
    31523152 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]
    31553155 ddt create-pxe [--bootp|-b pxe_config] [--next-server|-n next_server] [--filename|-f filename] [--comment|-c comment]
    31563156 ddt create-tag [--tag|-t tag] [--comment|-c comment]
    31573157 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]
    31603160 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]
    31623162 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]
    31653165 ddt gen-dhcp-file
    31663166 ddt gen-dns-file [--verbose]
    31673167 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]
    31693169 ddt remove-pxe [--bootp|-b pxe_config]
    31703170 ddt remove-tag [--tag|-t tag]
    31713171 ddt search-mac [--mac|-m mac]
    3172  ddt show-domainset [--no-header|-H]
     3172 ddt show-sector [--no-header|-H]
    31733173 ddt show
    31743174 ddt show-pool [--no-header|-H]
     
    31853185 * add-virtual      : add a virtual computer with a static IP but a virtual MAC (useful to declare float computer in DNS)
    31863186 * change-comment   : change the computer comment
    3187  * change-domainset : change the domain set attachment for a computer
     3187 * change-sector : change the sector attachment for a computer
    31883188 * change-host      : change the computer hostname
    31893189 * change-ip        : change the computer IP address
     
    31913191 * change-tag       : change the list of TAGs associated to a computer
    31923192 * check-dns        : check the DNS table for base IPs
    3193  * create-domainset : create a new domain set
     3193 * create-sector : create a new sector
    31943194 * create-pool      : create a new pool for DHCP records
    31953195 * create-pxe       : create a new PXE/BOOTP configuration
     
    32103210 * remove-tag       : remove a TAG
    32113211 * search-mac       : search physical MAC address computer
    3212  * show-domainset   : list all domain set group of computer
     3212 * show-sector   : list all sector group of computer
    32133213 * show             : list all computers
    32143214 * show-pool        : list all pool
     
    32333233=head1 USAGE
    32343234
    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]
    32463246 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]
    32493249 ddt create-pxe [--bootp|-b pxe_config] [--next-server|-n next_server] [--filename|-f filename] [--comment|-c comment]
    32503250 ddt create-tag [--tag|-t tag] [--comment|-c comment]
    32513251 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]
    32543254 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]
    32563256 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]
    32593259 ddt gen-dhcp-file
    32603260 ddt gen-dns-file [--verbose]
    32613261 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]
    32633263 ddt remove-pxe [--bootp|-b pxe_config]
    32643264 ddt remove-tag [--tag|-t tag]
    32653265 ddt search-mac [--mac|-m mac]
    3266  ddt show-domainset [--no-header|-H]
     3266 ddt show-sector [--no-header|-H]
    32673267 ddt show
    32683268 ddt show-pool [--no-header|-H]
     
    32893289=head2 add-alias
    32903290
    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]
    32923292
    32933293=head2 add-dhcp
    32943294
    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]
    32963296
    32973297=head2 add-float
    32983298
    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]
    33003300
    33013301=head2 add-static
    33023302
    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]
    33043304
    33053305=head2 add-virtual
    33063306
    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]
    33083308
    33093309=head2 change-comment
    33103310
    3311  ddt change-comment [--domainset|-d domainset] [--mac|-m mac] [--comment|-c comment]
    3312 
    3313 =head2 change-domainset
    3314 
    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]
    33163316
    33173317=head2 change-host
    33183318
    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]
    33203320
    33213321=head2 change-ip
    33223322
    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]
    33243324
    33253325=head2 change-mac
    33263326
    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]
    33283328
    33293329=head2 change-tag
    33303330
    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]
    33323332
    33333333=head2 check-dns
     
    33353335 ddt check-dns [--direct] [--reverse]
    33363336
    3337 =head2 create-domainset
    3338 
    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]
    33403340
    33413341=head2 create-pool
    33423342
    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]
    33443344
    33453345=head2 create-pxe
     
    33573357=head2 del-pc
    33583358
    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]
    33603360
    33613361=head2 disable-pc
    33623362
    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]
    33643364
    33653365=head2 disable-float
     
    33693369=head2 disable-pxe
    33703370
    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]
    33723372
    33733373=head2 enable-float
     
    33773377=head2 enable-pc
    33783378
    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]
    33803380
    33813381=head2 enable-pxe
    33823382
    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]
    33843384
    33853385=head2 gen-dhcp-file
     
    33973397=head2 load-database
    33983398
    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]
    34003400
    34013401=head2 remove-pxe
     
    34113411 ddt search-mac [--mac|-m mac]
    34123412
    3413 =head2 show-domainset
    3414 
    3415  ddt show-domainset [--no-header|-H]
     3413=head2 show-sector
     3414
     3415 ddt show-sector [--no-header|-H]
    34163416
    34173417=head2 show
  • trunk/ddt/ddt.bash_completion

    r228 r345  
    1616         return 0
    1717         ;;
    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}')
    2020         COMPREPLY=($(compgen -W "${showlist}" -- "$cur"))
    2121         return 0
Note: See TracChangeset for help on using the changeset viewer.