store aggregate port into db

This commit is contained in:
Oliver Gorwits
2014-01-12 18:46:25 +00:00
parent fd7bb0cd62
commit 3a4beed2f1

View File

@@ -206,6 +206,7 @@ sub store_interfaces {
my $i_stp_state = $snmp->i_stp_state; my $i_stp_state = $snmp->i_stp_state;
my $i_vlan = $snmp->i_vlan; my $i_vlan = $snmp->i_vlan;
my $i_lastchange = $snmp->i_lastchange; my $i_lastchange = $snmp->i_lastchange;
my $agg_ports = $snmp->agg_ports;
# clear the cached uptime and get a new one # clear the cached uptime and get a new one
my $dev_uptime = $snmp->load_uptime; my $dev_uptime = $snmp->load_uptime;
@@ -278,10 +279,22 @@ sub store_interfaces {
type => $i_type->{$entry}, type => $i_type->{$entry},
vlan => $i_vlan->{$entry}, vlan => $i_vlan->{$entry},
pvid => $i_vlan->{$entry}, pvid => $i_vlan->{$entry},
is_master => 'false',
slave_of => undef,
lastchange => $lc, lastchange => $lc,
}; };
} }
# must do this after building %interfaces so that we can set is_master
foreach my $sidx (keys %$agg_ports) {
my $slave = $interfaces->{$sidx} or next;
my $master = $interfaces->{ $agg_ports->{$sidx} } or next;
next unless exists $interfaces{$slave} and exists $interfaces{$master};
$interfaces{$slave}->{slave_of} = $master;
$interfaces{$master}->{is_master} = 'true';
}
schema('netdisco')->resultset('DevicePort')->txn_do_locked(sub { schema('netdisco')->resultset('DevicePort')->txn_do_locked(sub {
my $gone = $device->ports->delete({keep_nodes => 1}); my $gone = $device->ports->delete({keep_nodes => 1});
debug sprintf ' [%s] interfaces - removed %d interfaces', debug sprintf ' [%s] interfaces - removed %d interfaces',