Changeset 2569


Ignore:
Timestamp:
04/27/23 12:01:22 (12 months ago)
Author:
nanardon
Message:

Manage par host radius parameters

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r2565 r2569  
    272272                label => l('Support'), 
    273273            }, 
     274            radiusParams => { multiple => 1 }, 
    274275            vlan => { }, 
    275276        } 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm

    r2565 r2569  
    204204            description => { }, 
    205205            hostParams => { multiple => 1 },  
     206            radiusParams => { iname => 'hostParams', ro => 1 }, 
    206207            vlan => { }, 
    207208        } 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Buildnet.pm

    r2568 r2569  
    931931    my $output = ''; 
    932932 
    933     my $zoneVLan = $outzone->get_attributes( 'vlan' ); 
    934  
    935933    my @net; 
    936934    if ($outzone->get_attributes('net')) { 
     
    10281026    } 
    10291027 
    1030     my @parameters = grep { $_ } $outzone->get_attributes('hostParams'); 
     1028    my %zRadius = (); 
     1029    foreach ( $outzone->get_attributes('hostParams') ) { 
     1030        /^\s*(\S+)(?:\s*(.*))$/; 
     1031        $zRadius{ $1 } = $2; 
     1032    } 
     1033    if ( my $zoneVLan = $outzone->get_attributes( 'vlan' ) ) { 
     1034        $zRadius{'Tunnel-Type'} ||= '= VLAN'; 
     1035        $zRadius{'Tunnel-Medium-Type'} ||= '= 6'; 
     1036        $zRadius{'Tunnel-Private-Group-ID'} ||= "= $zoneVLan"; 
     1037    } 
     1038 
    10311039    foreach my $nethost (sort keys %hosts) { 
    10321040        my $obj = $self->_base->get_object('nethost', $nethost); 
     
    10351043        $obj->get_attributes('noDynamic') and next; 
    10361044 
    1037         my $vlan = $obj->get_attributes( 'vlan' ) || $zoneVLan; 
     1045        my %hRadius = %zRadius; 
     1046        foreach ( $obj->get_attributes('radiusParams') ) { 
     1047            /^\s*(\S+)(?:\s*(.*))$/; 
     1048            $hRadius{ $1 } = $2; 
     1049        } 
     1050        if ( my $vlan = $obj->get_attributes( 'vlan' ) ) { 
     1051            $hRadius{'Tunnel-Type'} ||= '= VLAN'; 
     1052            $hRadius{'Tunnel-Medium-Type'} ||= '= 6'; 
     1053            $hRadius{'Tunnel-Private-Group-ID'} = "= $vlan"; 
     1054        } 
     1055 
     1056        my @parameters = map { "$_ " . $hRadius{ $_ } } grep { $hRadius{ $_ } } keys ( %hRadius ); 
    10381057 
    10391058        $output .= "# Host: $nethost\n"; 
     
    10461065            $fmac =~ s/://g; 
    10471066            $output .= sprintf("%s ClearText-Password := \"%s\"\n", lc($fmac), lc($fmac)); 
    1048             $output .= join (",\n", map { "    $_" } @parameters) . "\n" if(@parameters); 
    1049             if ( $vlan ) { 
    1050                 $output .= "    Tunnel-Type = VLAN\n"; 
    1051                 $output .= "    Tunnel-Medium-Type = 6\n"; 
    1052                 $output .= "    Tunnel-Private-Group-ID = $vlan\n"; 
    1053             } 
     1067            $output .= join (",\n", map { "    $_" } @parameters) if( @parameters ); 
     1068            $output .= "\n"; 
    10541069        } 
    10551070        $output .= "\n"; 
Note: See TracChangeset for help on using the changeset viewer.