Changeset 2058 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 08/17/17 14:04:40 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Buildnet.pm
r2057 r2058 368 368 $ozone->get_attributes('netExclude'))) 369 369 if ($ozone->get_attributes('netExclude')); 370 if ($ozone->get_attributes('type') eq 'dhcp') { 371 push(@output, 'This dhcp zone include dynamic IP address') 370 if ($ozone->get_attributes('type') =~ /^(dhcp|radius)$/) { 371 my @dynFrom = grep { $_ } $ozone->get_attributes('dynFrom'); 372 push(@output, sprintf('This zone include host from zone: %s', join(', ', sort @dynFrom))) 373 if (@dynFrom); 374 push(@output, 'This zone include dynamic IP address') 372 375 if ($ozone->get_attributes('allow_dyn')); 373 376 } … … 796 799 } 797 800 798 my @parameters = $outzone->get_attributes('hostParams');801 my %hosts; 799 802 800 803 { … … 828 831 }; 829 832 while (my $res = $find->fetchrow_hashref) { 830 my $nethost = $res->{name}; 831 832 my $obj = $self->_base->get_object('nethost', $nethost) or do { 833 la_log LA_ERR, "Cannot fetch host %s", $res->{name}; 834 return; 835 }; 836 837 my $retainip; 838 if (@net) { 839 foreach my $inet (@net) { 840 ($retainip) = grep { $_ && $inet->overlaps(Net::IP->new($_)) } $obj->get_attributes('ip') 841 and last; 842 } 843 } 844 845 $obj->get_attributes('noDynamic') && !$retainip and next; 846 847 my $desc = $self->_comment_nethost($obj); 848 foreach my $mac (sort grep { $_ } $obj->get_attributes('macaddr')) { 849 $output .= $desc 850 ? '# ' . $desc . "\n" 851 : ''; 852 my $fmac = $mac; 853 $fmac =~ s/://g; 854 $output .= sprintf("%s Auth-Type := EAP, User-Password == \"%s\"\n", $nethost, lc($fmac)); 855 $output .= join (",\n", map { " $_" } @parameters); 856 $output .= "\n\n"; 857 } 833 $hosts{ $res->{name} } = 1; 858 834 } 859 835 } 860 836 if ($ozone->get_attributes('allow_dyn')) { 861 $output .= "\n# Host without IP:\n";862 837 my @dynfrom = grep { $_ } $ozone->get_attributes('dynFrom'); 863 838 my $find = $self->_base->db->prepare(q{ … … 906 881 }; 907 882 while (my $res = $find->fetchrow_hashref) { 908 my $nethost = $res->{name}; 909 910 my $obj = $self->_base->get_object('nethost', $nethost); 911 912 $obj->get_attributes('noDynamic') and next; 913 914 my $desc = $self->_comment_nethost($obj); 915 foreach my $mac (sort grep { $_ } $obj->get_attributes('macaddr')) { 916 $output .= $desc 917 ? '# ' . $desc . "\n" 918 : ''; 919 my $fmac = $mac; 920 $fmac =~ s/://g; 921 $output .= sprintf("%s Auth-Type := EAP, User-Password == \"%s\"\n", $nethost, lc($fmac)); 922 $output .= join (",\n", map { " $_" } @parameters); 923 $output .= "\n\n"; 924 } 925 } 883 $hosts{ $res->{name} } = 1; 884 } 885 } 886 887 my @parameters = grep { $_ } $outzone->get_attributes('hostParams'); 888 foreach my $nethost (sort keys %hosts) { 889 my $obj = $self->_base->get_object('nethost', $nethost); 890 891 $obj->get_attributes('noDynamic') and next; 892 893 $output .= "# Host: $nethost\n"; 894 my $desc = $self->_comment_nethost($obj); 895 $output .= $desc 896 ? '# ' . $desc . "\n" 897 : ''; 898 foreach my $mac (sort grep { $_ } $obj->get_attributes('macaddr')) { 899 my $fmac = $mac; 900 $fmac =~ s/://g; 901 $output .= sprintf("%s Auth-Type := EAP, User-Password == \"%s\"\n", lc($fmac), lc($fmac)); 902 $output .= join (",\n", map { " $_" } @parameters) . "\n" if(@parameters); 903 $output .= "\n"; 904 } 905 $output .= "\n"; 926 906 } 927 907
Note: See TracChangeset
for help on using the changeset viewer.