Ignore:
Timestamp:
10/20/17 19:31:15 (7 years ago)
Author:
nanardon
Message:

Add attribute physicalDeliveryOfficeName and netLocked to nethost

Attribute netLocked make dhcp zone assigning localhost IP (127.0.0.1 or ::1)
addresses to deny to computer to connect to network.

File:
1 edited

Legend:

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

    r2112 r2117  
    702702                       ? '# ' . $desc . "\n" 
    703703                        : ''; 
    704                     my ($fixedparam, $label) = $retainip =~ /^\d+(\.\d+){3}$/ 
    705                         ? ('fixed-address', '') 
    706                         : ('fixed-address6', '-6'); 
     704                    my ($fixedparam, $label, $netLockIp) = $retainip =~ /^\d+(\.\d+){3}$/ 
     705                        ? ('fixed-address', '', '127.0.0.1') 
     706                        : ('fixed-address6', '-6', '::1'); 
    707707                    # If two ip are given for same protocol keep only first 
    708708                    $done{$fixedparam} and next; 
     
    712712                    $output .= sprintf("host %s-%s%s {\n", $nethost, lc($fmac), $label); 
    713713                    $output .= sprintf("    hardware ethernet %s;\n", $mac); 
    714                     $output .= sprintf("    $fixedparam %s;\n", $retainip) 
    715                     if ($retainip); 
     714                    if ($obj->get_attributes('netLocked')) { 
     715                        $output .= sprintf("    $fixedparam %s;\n", $netLockIp); 
     716                    } else { 
     717                        $output .= sprintf("    $fixedparam %s;\n", $retainip) 
     718                            if ($retainip); 
     719                    } 
    716720                    $output .= "}\n\n"; 
    717721                } 
     
    780784                my $fmac = $mac; 
    781785                $fmac =~ s/://g; 
    782                 $output .= sprintf("host %s-%s {\n", $nethost, lc($fmac)); 
    783                 $output .= sprintf("    hardware ethernet %s;\n", $mac); 
    784                 $output .= "}\n\n"; 
     786                if ($obj->get_attributes('netLocked')) { 
     787                    my ($ipv4, $ipv6); 
     788                    foreach ($ozone->get_attributes('net')) { 
     789                        if ($_ =~ /^\d+(\.\d+){3}\/(\d+)$/) { 
     790                            $ipv4 = 1; 
     791                        } else { 
     792                            $ipv6 = 1; 
     793                        } 
     794                    } 
     795 
     796                    if ($ipv4) { 
     797                        $output .= sprintf("host %s-%s {\n", $nethost, lc($fmac)); 
     798                        $output .= sprintf("    hardware ethernet %s;\n", $mac); 
     799                        $output .= sprintf("    fixed-address 127.0.0.1;\n"); 
     800                        $output .= "}\n\n"; 
     801                    } 
     802                    if ($ipv6) { 
     803                        $output .= sprintf("host %s-%s {\n", $nethost, lc($fmac)); 
     804                        $output .= sprintf("    hardware ethernet %s;\n", $mac); 
     805                        $output .= sprintf("    fixed-address6 ::1\n"); 
     806                        $output .= "}\n\n"; 
     807                    } 
     808                } else { 
     809                    $output .= sprintf("host %s-%s {\n", $nethost, lc($fmac)); 
     810                    $output .= sprintf("    hardware ethernet %s;\n", $mac); 
     811                    $output .= "}\n\n"; 
     812                } 
    785813            } 
    786814        } 
Note: See TracChangeset for help on using the changeset viewer.