- Timestamp:
- Sep 17, 2018, 9:13:47 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ddt/ddt
r363 r364 47 47 'change-mac' => \&cmd_change_mac, 48 48 'change-tag' => \&cmd_change_tag, 49 'change-type' => \&cmd_change_type, 49 50 'check-dns' => \&cmd_check_dns, 50 51 'create-sector' => \&cmd_create_sector, … … 1053 1054 1054 1055 exit_on_error_option($help) 1055 if $sector eq ''1056 if $sector eq '' 1056 1057 or $tags eq ''; 1057 1058 exit_on_error_option($help) … … 1094 1095 print "Mise à jour du commentaire de la machine [FAILED]\n"; 1095 1096 print "L'adresse MAC: $mac n'existe pas dans le domaine: $sector.\n"; 1097 } 1098 1099 #-------------------------------------------------------------------------------- 1100 1101 sub cmd_change_type { 1102 local @ARGV = @_; 1103 1104 my $help = get_cmd_name(); 1105 my ($hostname, $sector, $type); 1106 1107 GetOptions( 1108 'hostname|h=s' => \$hostname, 1109 'sector|s|d=s' => \$sector, 1110 'type|t=s' => \$type, 1111 ); 1112 1113 ($hostname, $sector) = split /\./, $hostname, 2 if $hostname =~ m/\./; 1114 1115 exit_on_error_option($help) 1116 if $sector eq '' 1117 and $hostname eq '' 1118 and $type eq ''; 1119 1120 my $computer_db = ipamdb_load($COMPUTER_YAML); 1121 1122 if ($type !~ m/^ (dhcp|float|static|virtual) $/xms) { 1123 die "Error: bad type: $type\n"; 1124 } 1125 1126 $type =~ s/^float$/pool-dhcp/; 1127 # No type virtual actually. See and write exactly type name and their property 1128 1129 control_exist_sector($computer_db, $sector) or exit; 1130 1131 $mac = get_mac_from_hostname($computer_db, $sector, $hostname, $mac); 1132 control_syntax_mac_address($mac) or exit; 1133 1134 LOOP_ON_COMPUTER: 1135 for my $computer (@{$computer_db->{$sector}}) { 1136 my ($mac_address, $attribute) = %{$computer}; 1137 1138 next LOOP_ON_COMPUTER if $mac_address ne $mac; 1139 1140 $attribute->{'address_type'} = $type; 1141 $attribute->{'modify_time'} = time; 1142 1143 ipamdb_save("$COMPUTER_YAML", $computer_db); 1144 exit; 1145 } 1146 print "Error: change host $hostname type [FAILED]\n"; 1096 1147 } 1097 1148 … … 3173 3224 } 3174 3225 3226 elsif ($command eq 'change-type') { 3227 print "List of options for command: $command\n"; 3228 print " -h : computer hostname (mandatory)\n"; 3229 print " -s : sector attachment (mandatory)\n"; 3230 print " -t : new type). Example: -t static\n"; 3231 } 3232 3175 3233 elsif ($command eq 'load-database') { 3176 3234 print "List of options for command: $command\n"; … … 3278 3336 ddt change-mac [--hostname|-h hostname] [--sector|-s|-d sector] [--ip|-i ip] [--mac|-m mac] 3279 3337 ddt change-tag [--hostname|-h hostname] [--sector|-s|-d sector] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3338 ddt change-type [--hostname|-h hostname] [--sector|-s|-d sector] [--type|-t type] 3280 3339 ddt check-dns [--direct] [--reverse] 3281 3340 ddt create-sector [--sector|-s|-d sector] [--dns-extension|-e dns_extension] [--comment|-c comment] … … 3319 3378 * change-mac : change the computer physical MAC address 3320 3379 * change-tag : change the list of TAGs associated to a computer 3380 * change-type : change the type associated to a computer 3321 3381 * check-dns : check the DNS table for base IPs 3322 3382 * create-sector : create a new sector … … 3374 3434 ddt change-mac [--hostname|-h hostname] [--sector|-s|-d sector] [--ip|-i ip] [--mac|-m mac] 3375 3435 ddt change-tag [--hostname|-h hostname] [--sector|-s|-d sector] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3436 ddt change-type [--hostname|-h hostname] [--sector|-s|-d sector] [--type|-t type] 3376 3437 ddt check-dns [--direct] [--reverse] 3377 3438 ddt create-sector [--sector|-s|-d sector] [--dns-extension|-e dns_extension] [--comment|-c comment] … … 3462 3523 ddt change-tag [--hostname|-h hostname] [--sector|-s|-d sector] [--ip|-i ip] [--mac|-m mac] [--tag|-t tag] 3463 3524 3525 =head2 change-type 3526 3527 ddt change-type [--hostname|-h hostname] [--sector|-s|-d sector] [--type|-t type] 3528 3464 3529 =head2 check-dns 3465 3530
Note: See TracChangeset
for help on using the changeset viewer.