Hi Kurtis,
Kurtis Drefs wrote:
> Hi again.
>
> I was using v1.87 and had everything working well using a guest by
> default config in the custom.pm.
>
> I added
>
> sub custom_getCorrectVlan {
>
> my ( $this, $switch_ip, $ifIndex, $mac, $status, $vlan, $pid ) = @_;
>
>
>
> # $vlan represents the node's VLAN
>
> return ($vlan);
>
> }
>
> And this worked pretty well.
>
> I then upgraded to v1.90 and this script no longer works at all. Going
> through the release notes I noticed that there are some changes that
> could explain why this no longer works. What happens is now is no matter
> what kind of node, registered or unregistered, vlan defined or not, a
> switchport will flip to the registration VLAN and stay there no matter
> what gets plugged in next.
>
>
>
> “- lib/pf/vlan.pm interface changed
>
> If you built a customized version of vlan.pm in
> lib/pf/vlan/custom.pm be
>
> aware that the parameters expected by vlan_determine_for_node() and
>
> custom_getCorrectVlan() changed. Instead of the switch's IP, a switch
>
> object (pf::SNMP) is expected. Also, the whole node_info is passed to
>
> custom_getCorrectVlan() instead of scalars of node_info's content.”
>
>
As you guessed your pf::vlan::custom needs to be ported over the new
interface. Everything you had previously as separated parameters
regarding a node is now under a node_info hash reference. To give you an
example, your previous script would be replaced by:
return ($node_info->{'vlan'});
>
> What I would ultimately like to do is have the script do the following.
>
>
>
> If node is registered and Alternate dest. VLAN (‘vlan’ in the DB table)
> is not null, use value for ’vlan’ that is in the DB table for that node.
>
> else
>
> If node is registered and Alternate dest. VLAN is null use normalVLAN
>
> else
>
> If node is unregistered use registrationVLAN
>
> Any insight on how I can do this here or if it is even possible would be
> greatly appreciated. Admittedly, I am kind of lost with the coding for it.
>
First, the "is node registered?" test is done before. All nodes reaching
that code will be registered. Right now, they get into registration VLAN
probably because an undef value is returned (check the logs to be sure).
What you want would look like this:
WARNING: coded quickly without validating that it even compiles
if(ref($node_info) eq 'HASH' && defined($node_info->{'vlan'})) {
return $node_info->{'vlan'};
} else {
my $valid_switch_object = (defined($switch) && ref($switch) &&
$switch->isa('pf::SNMP'));
if ($valid_switch_object) {
return $switch->{_normalVlan};
} else {
# if switch object not correct, return default vlan
$logger->warn("Did not return correct VLAN: Invalid switch.
Will return default VLAN as a fallback");
# Grab switch config
my $switchFactory = new pf::SwitchFactory(-configFile =>
"$conf_dir/switches.conf");
my %Config = %{$switchFactory->{_config}};
return $Config{'default'}{'normalVlan'};
}
}
it's a mashup between 1.9's default pf::vlan behavior and your previous
script
sorry for the wrapping
Have a good one!
--
Olivier Bilodeau
[email protected] :: +1.514.447.4918 *115 :: www.inverse.ca
Inverse inc. :: Leaders behind SOGo (www.sogo.nu) and PacketFence
(www.packetfence.org)
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Packetfence-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users