Changeset 299


Ignore:
Timestamp:
Jul 18, 2018, 1:08:50 PM (6 years ago)
Author:
g7moreau
Message:
  • Use table for command show
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ddt/ddt

    r298 r299  
    22612261   my $computer_db = ipamdb_load($COMPUTER_YAML);
    22622262
    2263    LOOP_ON_DOMAIN:
     2263   my $tb_computer = Text::Table->new(
     2264     {align  => 'left',   align_title => 'left',   title => 'Hostname.DomainSet'},
     2265     {is_sep => 1,        body        => '  '},
     2266     {align  => 'left',   align_title => 'left',   title => 'IPv4-Address'},
     2267     {is_sep => 1,        body        => '  '},
     2268     {align  => 'center', align_title => 'center', title => 'MAC-Address'},
     2269     {is_sep => 1,        body        => '  '},
     2270     {align  => 'right',  align_title => 'right',  title => 'Type'},
     2271     {align  => 'right',  align_title => 'right',  title => 'Status'},
     2272     {is_sep => 1,        body        => '  '},
     2273     {align  => 'left',   align_title => 'left',   title => 'Date'},
     2274     {align  => 'left',   align_title => 'left',   title => 'Comment'},
     2275     );
     2276
     2277  LOOP_ON_DOMAIN:
    22642278   for my $domainset_current (sort keys %{$computer_db}) {
    22652279      next if $domainset_current eq 'dset';
     
    22692283      next if $domainset_current eq 'version';
    22702284
    2271       my $tb_computer = Text::Table->new(
    2272          {align  => 'left',   align_title => 'left',   title => 'Hostname.DomainSet'},
    2273          {is_sep => 1,        body        => '  '},
    2274          {align  => 'left',   align_title => 'left',   title => 'IPv4-Address'},
    2275          {is_sep => 1,        body        => '  '},
    2276          {align  => 'center', align_title => 'center', title => 'MAC-Address'},
    2277          {is_sep => 1,        body        => '  '},
    2278          {align  => 'right',  align_title => 'right',  title => 'Type'},
    2279          {align  => 'right',  align_title => 'right',  title => 'Status'},
    2280          {is_sep => 1,        body        => '  '},
    2281          {align  => 'left',   align_title => 'left',   title => 'Date'},
    2282          {align  => 'left',   align_title => 'left',   title => 'Comment'},
    2283          );
    2284 
    2285       #printf "%-30s  %-20s %17s %5s %7s %-10s %s\n",
    2286       #   'Hostname',
    2287       #   'IPv4-Address',
    2288       #   'MAC-Address',
    2289       #   'Type',
    2290       #   'Status',
    2291       #   'Date',
    2292       #   'Comment';
    22932285      my @domainsetdb = @{$computer_db->{$domainset_current}};
    22942286
     
    23052297                  'domainset'    => $domainset_current,
    23062298                  };
    2307                next LOOP_ON_COMPUTER;
    23082299               }
    23092300            else {
    2310                print {*STDERR} "# Warning: $ip already exists in the database !\n";
     2301               print {*STDERR} "# Warning: $ip already exists in the database with MAC $mac_address!\n";
    23112302               }
     2303            next LOOP_ON_COMPUTER;
    23122304            }
    23132305
     
    23392331            );
    23402332         }
    2341 
    2342       if ($tb_computer->body_height) {
    2343          print "\n# *** List of pool computers in the domain set: $domainset_current ***\n";
    2344          print $tb_computer->title();
    2345          print $tb_computer->rule('-');
    2346          print $tb_computer->body();
    2347          }
    2348       }
    2349 
    2350    print "\n# *** List of computers ordered by IP and domain set ***\n";
     2333      #print "\n# *** List of pool computers in the domain set: $domainset_current ***\n";
     2334      }
     2335
     2336   #print "\n# *** List of computers ordered by IP and domain set ***\n";
    23512337   LOOP_ON_IP_ADDRESS:
    23522338   foreach my $ip (Net::Netmask::sort_by_ip_address(keys %ipdb)) {
     
    23672353         }
    23682354
    2369       printf "%-30s %-20s %17s %9s %3s %10s %s\n",
     2355      #printf "%-30s %-20s %17s %9s %3s %10s %s\n",
     2356      $tb_computer->add(
    23702357         $ipdb{$ip}->{'hostname'} . '.' . $ipdb{$ip}->{'domainset'},
    23712358         $ip,
     
    23742361         $enable,
    23752362         $date,
    2376          $comment;
    2377       }
     2363         $comment
     2364         );
     2365      }
     2366
     2367   print $tb_computer->title();
     2368   print $tb_computer->rule('-');
     2369   print $tb_computer->body();
    23782370   }
    23792371
Note: See TracChangeset for help on using the changeset viewer.