Changeset 2102 for trunk


Ignore:
Timestamp:
09/21/17 10:22:41 (7 years ago)
Author:
nanardon
Message:

Ensure host are uniq in dhcp zone

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Buildnet.pm

    r2101 r2102  
    692692            my $desc = $self->_comment_nethost($obj); 
    693693            foreach my $mac (sort grep { $_ } $obj->get_attributes('macaddr')) { 
    694                 foreach my $retainip (@retainip) { 
     694                my %done; 
     695                foreach my $retainip (sort @retainip) { 
    695696                    $output .= $desc 
    696697                       ? '# ' . $desc . "\n" 
    697698                        : ''; 
    698                     my $fixedparam = $retainip =~ /^\d+(\.\d+){3}$/ 
    699                         ? '' 
    700                         : '6'; 
     699                    my ($fixedparam, $label) = $retainip =~ /^\d+(\.\d+){3}$/ 
     700                        ? ('fixed-address', '') 
     701                        : ('fixed-address6', '-6'); 
     702                    # If two ip are given for same protocol keep only first 
     703                    $done{$fixedparam} and next; 
     704                    $done{$fixedparam} = 1; 
    701705                    my $fmac = $mac; 
    702706                    $fmac =~ s/://g; 
    703                     $output .= sprintf("host %s$fixedparam-%s {\n", $nethost, lc($fmac)); 
     707                    $output .= sprintf("host %s-%s$label {\n", $nethost, lc($fmac)); 
    704708                    $output .= sprintf("    hardware ethernet %s;\n", $mac); 
    705709                    $output .= sprintf("    fixed-address$fixedparam %s;\n", $retainip) 
Note: See TracChangeset for help on using the changeset viewer.