Changeset 317


Ignore:
Timestamp:
Jul 19, 2018, 9:08:30 PM (6 years ago)
Author:
g7moreau
Message:
  • Better command show-domainset
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ddt/ddt

    r316 r317  
    21432143
    21442144sub cmd_show_domainset {
    2145 
    2146    my $computer_db = ipamdb_load($COMPUTER_YAML);
     2145   local @ARGV = @_;
     2146
     2147   my ($no_header);
     2148
     2149   GetOptions(
     2150      'no-header|H' => \$no_header,
     2151      );
     2152
     2153   my $computer_db = ipamdb_load($COMPUTER_YAML);
     2154
     2155   my $tb_computer = Text::Table->new(
     2156     {align  => 'left',   align_title => 'left',   title => 'DomainSet'},
     2157     {is_sep => 1,        body        => '  '},
     2158     {align  => 'left',   align_title => 'left',   title => 'DNS-Extension:'},
     2159     {is_sep => 1,        body        => '  '},
     2160     {align  => 'left',   align_title => 'left',   title => 'Date'},
     2161     {align  => 'left',   align_title => 'left',   title => 'Comment'},
     2162     );
    21472163
    21482164   LOOP_ON_DOMAIN:
     
    21542170      next if $domainset_current eq 'version';
    21552171
    2156       print "$domainset_current\n";
    2157       }
     2172      $tb_computer->add($domainset_current) and next LOOP_ON_DOMAIN if not exists $computer_db->{'dset'}{$domainset_current};
     2173
     2174      my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime $computer_db->{'dset'}{$domainset_current}{'modify_time'};
     2175      $year += 1900;
     2176      $mon++;
     2177      my $date = sprintf '%04i-%02i-%02i', $year, $mon, $mday;
     2178
     2179      my $comment = $computer_db->{'dset'}{$domainset_current}{'comment'};
     2180      $comment =~ s/^\d\d\d\d-\d\d-\d\d\s//;
     2181         
     2182      $tb_computer->add($domainset_current,
     2183         $computer_db->{'dset'}{$domainset_current}{'dns_extension'},
     2184         $date,
     2185         $comment,
     2186         );
     2187      }
     2188
     2189   print $tb_computer->title(),
     2190         $tb_computer->rule('-') if not $no_header;
     2191   print $tb_computer->body();
    21582192   }
    21592193
     
    30983132 ddt remove-tag [--tag|-t tag]
    30993133 ddt search-mac [--mac|-m mac]
    3100  ddt show-domainset
     3134 ddt show-domainset [--no-header|-H]
    31013135 ddt show
    31023136 ddt show-pool [--no-header|-H]
     
    31923226 ddt remove-tag [--tag|-t tag]
    31933227 ddt search-mac [--mac|-m mac]
    3194  ddt show-domainset
     3228 ddt show-domainset [--no-header|-H]
    31953229 ddt show
    31963230 ddt show-pool [--no-header|-H]
     
    33413375=head2 show-domainset
    33423376
    3343  ddt show-domainset
     3377 ddt show-domainset [--no-header|-H]
    33443378
    33453379=head2 show
Note: See TracChangeset for help on using the changeset viewer.