complete the migration of connected device ID to connected inventory
This commit is contained in:
@@ -314,7 +314,44 @@ state, or else `undef` if the port is not in an error state.
|
||||
|
||||
=cut
|
||||
|
||||
sub error_disable_cause { return (shift)->get_column('properties_error_disable_cause') }
|
||||
sub error_disable_cause { return (shift)->get_column('error_disable_cause') }
|
||||
|
||||
=head2 remote_is_wap
|
||||
|
||||
Returns true if the remote LLDP neighbor has reported Wireless Access Point
|
||||
capability.
|
||||
|
||||
=cut
|
||||
|
||||
sub remote_is_wap { return (shift)->get_column('remote_is_wap') }
|
||||
|
||||
=head2 remote_is_phone
|
||||
|
||||
Returns true if the remote LLDP neighbor has reported Telephone capability.
|
||||
|
||||
=cut
|
||||
|
||||
sub remote_is_phone { return (shift)->get_column('remote_is_phone') }
|
||||
|
||||
=head2 remote_inventory
|
||||
|
||||
Returns a synthesized description of the remote LLDP device if inventory
|
||||
information was given, including vendor, model, OS version, and serial number.
|
||||
|
||||
=cut
|
||||
|
||||
sub remote_inventory {
|
||||
my $port = shift;
|
||||
my $os_ver = ($port->get_column('remote_os_ver')
|
||||
? ('running '. $port->get_column('remote_os_ver')) : '');
|
||||
my $serial = ($port->get_column('remote_serial')
|
||||
? ('('. $port->get_column('remote_serial') .')') : '');
|
||||
|
||||
my $retval = join ' ', ($port->get_column('remote_vendor') || ''),
|
||||
($port->get_column('remote_model') || ''), $serial, $os_ver;
|
||||
|
||||
return (($retval =~ m/[[:alnum:]]/) ? $retval : '');
|
||||
}
|
||||
|
||||
=head2 vlan_count
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ __PACKAGE__->add_columns(
|
||||
{ data_type => "boolean", is_nullable => 1 },
|
||||
"remote_vendor",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"remote_os_ver",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"remote_model",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"remote_os_ver",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"remote_serial",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
);
|
||||
|
||||
@@ -113,6 +113,10 @@ will add the following additional synthesized columns to the result set:
|
||||
|
||||
=item error_disable_cause
|
||||
|
||||
=item remote_is_wap (boolean)
|
||||
|
||||
=item remote_is_phone (boolean)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -124,8 +128,54 @@ sub with_properties {
|
||||
->search_rs($cond, $attrs)
|
||||
->search({},
|
||||
{
|
||||
'+select' => ['properties.error_disable_cause'],
|
||||
'+as' => ['properties_error_disable_cause'],
|
||||
'+select' => [qw/
|
||||
properties.error_disable_cause
|
||||
properties.remote_is_wap
|
||||
properties.remote_is_phone
|
||||
/],
|
||||
'+as' => [qw/
|
||||
error_disable_cause
|
||||
remote_is_wap remote_is_phone
|
||||
/],
|
||||
join => 'properties',
|
||||
});
|
||||
}
|
||||
|
||||
=head2 with_remote_inventory
|
||||
|
||||
This is a modifier for any C<search()> which
|
||||
will add the following additional synthesized columns to the result set:
|
||||
|
||||
=over 4
|
||||
|
||||
=item remote_vendor
|
||||
|
||||
=item remote_model
|
||||
|
||||
=item remote_os_ver
|
||||
|
||||
=item remote_serial
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub with_remote_inventory {
|
||||
my ($rs, $cond, $attrs) = @_;
|
||||
|
||||
return $rs
|
||||
->search_rs($cond, $attrs)
|
||||
->search({},
|
||||
{
|
||||
'+select' => [qw/
|
||||
properties.remote_vendor
|
||||
properties.remote_model
|
||||
properties.remote_os_ver
|
||||
properties.remote_serial
|
||||
/],
|
||||
'+as' => [qw/
|
||||
remote_vendor remote_model remote_os_ver remote_serial
|
||||
/],
|
||||
join => 'properties',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user