Changeset 2117


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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r2114 r2117  
    164164            inventoryNumber 
    165165            expire 
     166            netLocked 
    166167            related 
    167168            encryptKey 
    168169            site 
     170            physicalDeliveryOfficeName 
    169171            owner 
    170172            user 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r2113 r2117  
    126126                delayed => 1, 
    127127                label => l('User'), 
     128                monitored => 1, 
    128129            }, 
    129130            netZone => { 
     
    252253                label => l('Site'), 
    253254            }, 
     255            physicalDeliveryOfficeName => { 
     256                label => l('Office'), 
     257            }, 
     258            netLocked => { 
     259                formtype => 'CHECKBOX', 
     260                monitored => 1, 
     261                label => l('Locked'), 
     262            }, 
     263 
    254264        } 
    255265    ) 
  • 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.