Device-Cisco-NXAPI
view release on metacpan or search on metacpan
lib/Device/Cisco/NXAPI/Test.pm view on Meta::CPAN
package Device::Cisco::NXAPI::Test;
use 5.020;
use strict;
use warnings;
use Moose;
use Modern::Perl;
use Data::Dumper;
use Carp;
use List::Util qw( any );
use List::MoreUtils qw( uniq );
use Array::Utils qw{ array_minus };
use Params::Validate qw( :all );
=head1 NAME
Device::Cisco::NXAPI::Test - Run a suite of tests on switches that support NXAPI.
=head1 VERSION
Version 0.02
=cut
our $VERSION = '0.02';
=head1 SYNOPSIS
This module contains a set of methods that run tests against an NXAPI compatible switch.
The functions take arguments and return 1 or 0 depending on the current runtime state of the switch.
These methods should be used in conjunction with the B<ok()> function provided by B<Test::More>.
use Device::Cisco::NXAPI;
use Test::More;
# The Device::Cisco::NXAPI module provides a method that returns a Device::Cisco::NXAPI::Test object.
my $tests = Device::Cisco::NXAPI->new(uri => 'http://hostname', username => 'admin', password => 'admin')->tester();
# Test whether interfaces are up
ok( $tests->interfaces_up(interfaces => ['Ethernet1/1', 'Ethernet1/2']), "Interfaces are up" );
# Test for the presence of routes
ok( $tests->routes(routes => ['192.168.1.0/24', '10.0.0.0/8']), 'Routes in routing table' );
=cut
has 'switch' => ( is => 'ro', isa => 'Device::Cisco::NXAPI', default => sub { });
=head1 SUBROUTINES
=cut
=head2 routes(%options)
ok(
$tests->routes(
vrf => '',
af => 'ipv4' | 'ipv6',
routes => [],
)
);
Returns 1 is all of the routes specified in the ARRAYREF are present in the routing table.
Returns 0 if any of the routes are not int the routing table.
( run in 0.728 second using v1.01-cache-2.11-cpan-f56aa216473 )