refactor layer and pseudo checks

This commit is contained in:
Oliver Gorwits
2017-09-13 19:22:40 +01:00
parent 753acc607f
commit 58cd488ccc
10 changed files with 40 additions and 33 deletions

View File

@@ -193,6 +193,29 @@ __PACKAGE__->might_have(
=head1 ADDITIONAL METHODS
=head2 is_pseudo
Returns true if the vendor of the device is "netdisco".
=cut
sub not_pseudo {
my $device = shift;
return (defined $device->vendor and $device->vendor eq 'netdisco');
}
=head2 has_layer( $number )
Returns true if the device provided sysServices and supports the given layer.
=cut
sub has_layer {
my ($device, $layer) = @_;
return unless $layer and $layer =~ m/^[1-8]$/;
return $device->layers and substr($device->layers, (9-$layer), 1) == 1;
}
=head2 renumber( $new_ip )
Will update this device and all related database records to use the new IP