diff --git a/Netdisco/Changes b/Netdisco/Changes index 7f2505d7..63790588 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,5 +1,9 @@ 2.021001 + [NEW FEATURES] + + * [#81] Identify wireless nodes and provide information when available + [ENHANCEMENTS] * [#32] Show device layers in Details tab diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Node.pm b/Netdisco/lib/App/Netdisco/DB/Result/Node.pm index 8aa6a320..9cd9aeca 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/Node.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/Node.pm @@ -112,6 +112,17 @@ the current Node's. __PACKAGE__->has_many( ips => 'App::Netdisco::DB::Result::NodeIp', { 'foreign.mac' => 'self.mac', 'foreign.active' => 'self.active' } ); +=head2 wireless + +Returns the set of C entries associated with this Node. That +is, the SSIDs and wireless statistics associated with this MAC address +at the time of discovery. + +=cut + +__PACKAGE__->has_many( wireless => 'App::Netdisco::DB::Result::NodeWireless', + { 'foreign.mac' => 'self.mac' } ); + =head2 oui Returns the C table entry matching this Node. You can then join on this diff --git a/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm b/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm index ad1f5fd6..ef22c0fa 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/NodeWireless.pm @@ -47,5 +47,17 @@ __PACKAGE__->set_primary_key("mac", "ssid"); # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3xsSiWzL85ih3vhdews8Hg -# You can replace this text with custom code or comments, and it will be preserved on regeneration +=head2 node + +Returns the C table entry matching this wireless entry. + +The JOIN is of type LEFT, in case the C is no longer present in the +database but the relation is being used in C. + +=cut + +__PACKAGE__->belongs_to( node => 'App::Netdisco::DB::Result::Node', + { 'foreign.mac' => 'self.mac' }, + { join_type => 'LEFT' } ); + 1; diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 8f08c336..52f872b7 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -48,6 +48,7 @@ hook 'before' => sub { var('connected_properties' => [ { name => 'n_age', label => 'Age Stamp', default => '' }, { name => 'n_ip', label => 'IP Address', default => 'on' }, + { name => 'n_ssid', label => 'SSID', default => 'on' }, { name => 'n_archived', label => 'Archived Data', default => '' }, ]); diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index d41cd194..735aa273 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -129,6 +129,10 @@ get '/ajax/content/device/ports' => require_login sub { $set = $set->search_rs({}, { prefetch => [{$nodes_name => 'ips'}] }) if param('c_nodes'); + # retrieve wireless SSIDs, if asked for + $set = $set->search_rs({}, { prefetch => [{$nodes_name => 'wireless'}] }) + if param('c_nodes'); + # retrieve neighbor devices, if asked for $set = $set->search_rs({}, { prefetch => [{neighbor_alias => 'device'}] }) if param('c_neighbors'); diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index 6aab58a4..0cc58174 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -243,8 +243,19 @@ [% FOREACH node IN row.$nodes %] [% '
' IF (row.remote_ip OR row.is_uplink) OR NOT loop.first %] [% '  ' IF NOT node.active %] + [% '  ' IF node.wireless.defined %] [% node.net_mac.$mac_format_call | html_entity %] + [% IF (node.vlan > 0) && (node.vlan != row.vlan) %] + (on vlan [% node.vlan | html_entity %]) + [% END %] + [% IF params.n_ssid AND node.wireless.defined %] + (SSID: + [% FOREACH wlan IN node.wireless %] + [%+ wlan.ssid | html_entity %] + [% END %] + ) + [% END %] [% ' (' _ node.time_last_age _ ')' IF params.n_age %] [% IF params.n_ip %] [% FOREACH ip IN node.ips %]