diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Device.pm b/Netdisco/lib/App/Netdisco/DB/Result/Device.pm index 8caeef7d..3f22a717 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/Device.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/Device.pm @@ -144,6 +144,29 @@ __PACKAGE__->has_many( # helper which assumes we've just RIGHT JOINed to Vlans table sub vlan { return (shift)->vlans->first } +=head2 wireless_ports + +Returns the set of wireless IDs known to be configured on Ports on this +Device. + +=cut + +__PACKAGE__->has_many( + wireless_ports => 'App::Netdisco::DB::Result::DevicePortWireless', + 'ip', { join_type => 'RIGHT' } +); + +=head2 ssids + +Returns the set of SSIDs known to be configured on Ports on this Device. + +=cut + +__PACKAGE__->has_many( + ssids => 'App::Netdisco::DB::Result::DevicePortSsid', + 'ip', { join_type => 'RIGHT' } +); + =head1 ADDITIONAL COLUMNS =head2 uptime_age diff --git a/Netdisco/lib/App/Netdisco/DB/Result/DevicePortSsid.pm b/Netdisco/lib/App/Netdisco/DB/Result/DevicePortSsid.pm index b3c3d9b2..2155d3d1 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/DevicePortSsid.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/DevicePortSsid.pm @@ -26,6 +26,25 @@ __PACKAGE__->add_columns( # Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zvgylKzUQtizJZCe1rEdUg +=head1 RELATIONSHIPS + +=head2 device + +Returns the entry from the C table which hosts this SSID. + +=cut + +__PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' ); + +=head2 port + +Returns the entry from the C table which corresponds to this SSID. + +=cut + +__PACKAGE__->belongs_to( port => 'App::Netdisco::DB::Result::DevicePort', { + 'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port', +}); # You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Netdisco/lib/App/Netdisco/DB/Result/DevicePortWireless.pm b/Netdisco/lib/App/Netdisco/DB/Result/DevicePortWireless.pm index 6c7a6633..7cc6085b 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/DevicePortWireless.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/DevicePortWireless.pm @@ -24,6 +24,26 @@ __PACKAGE__->add_columns( # Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T5GmnCj/9BB7meiGZ3xN7g +=head1 RELATIONSHIPS + +=head2 device + +Returns the entry from the C table which hosts this wireless port. + +=cut + +__PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' ); + +=head2 port + +Returns the entry from the C table which corresponds to this wireless +interface. + +=cut + +__PACKAGE__->belongs_to( port => 'App::Netdisco::DB::Result::DevicePort', { + 'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port', +}); # You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm b/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm index 85cb6e0f..880999ee 100644 --- a/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm +++ b/Netdisco/lib/App/Netdisco/Util/DiscoverAndStore.pm @@ -240,6 +240,11 @@ sub store_wireless { }; } + schema('netdisco')->txn_do(sub { + $device->ssids->delete; + $device->ssids->populate(\@ssids); + }); + # build device channel list suitable for DBIC my @channels; foreach my $entry (keys %$channel) { @@ -258,13 +263,10 @@ sub store_wireless { }; } - # FIXME not sure what relations need adding for wireless ports - # - #schema('netdisco')->txn_do(sub { - # $device->ports->delete; - # $device->update_or_insert; - # $device->ports->populate(\@interfaces); - #}); + schema('netdisco')->txn_do(sub { + $device->wireless_ports->delete; + $device->wireless_ports->populate(\@channels); + }); } =head2 store_vlans( $device, $snmp )