示例#1
0
    def execution(self, device, **kwargs):

        # Init
        status = OK
        message = ''

        # Execute command to check for tracebacks - timeout set to 5 mins
        try:
            output = device.execute(self.show_cmd,
                                    timeout=self.args.alignmentcheck_timeout)
        except Exception as e:
            status += CRITICAL(str(e))
            return status

        if not output:
            return ERRORED('No output from {cmd}'.format(cmd=self.show_cmd))

        # Check for alignment errors. Hex values = problems.
        if '0x' in output:
            message = "Device {d} Alignment error detected: '{o}'"\
                .format(d=device.name, o=output)
            status += CRITICAL(message)
            logger.error(banner(message))

        # Log message to user
        if not message:
            message = "***** No alignment error found *****"
            status += OK(message)
            logger.info(banner(message))

        # Final status
        return status
示例#2
0
def send_install_cmd(ip_addr, username, password, rtr_hostname, install_cmd):
    """Used to send install command via pexpect. This is prefered as Csccon
       does not handle the cXR install add command well."""

    import pexpect
    attempts = 4
    rtr_hostname_result = False

    for i in range(attempts):
        log.info('attempting to connected to rtr attempt {} of {} via ip: {}'.
                 format(i, attempts, ip_addr))

        # ATTEMPTING TELNET CONNECTION
        child = pexpect.spawn('telnet {}'.format(ip_addr), timeout=90)

        if child.isatty() == True and child.isalive() == True:
            log.info(
                banner('Established connection to {} now sending '
                       'username {} and password {}'.format(
                           ip_addr, username, password)))
            log.info('sending pexpect username')
            child.expect('Username: '******'{}'.format(username))
            data = child.before
            str_data = str(data, 'utf-8')
            for line in str_data.split('\n'):
                log.info(line)

            child.expect('Password:'******'{}'.format(password))
            child.expect('#')
            data = child.before
            str_data = str(data, 'utf-8')
            for line in str_data.split('\n'):
                log.info(line)
                if rtr_hostname in line:
                    rtr_hostname_result = True
                    log.info(
                        banner('Pexpect successful found router prompt {} '
                               'telnet was successful'.format(rtr_hostname)))
            if rtr_hostname_result == True:
                break
            else:
                log.warning('could not find router hostname '
                            'prompt {}'.format(rtr_hostname))
        else:
            log.warning('connection was unsuccessful connection '
                        'status = {}'.format(child.isatty()))
            child.close()

    log.info('@@@ Pexpect logged into router \n'
             'sending command : {} @@@'.format(install_cmd))
    try:
        child.sendline('{}'.format(install_cmd))
        child.expect('#')
    except:
        log.info(banner('@@@ SENT INSTALL CMD VIA PEXPECT @@@'))
    child.close()
示例#3
0
    def verify_interface_count(self,
                               device,
                               ethernet_intf_count = 0,
                               serial_intf_count = 0):
        '''
        verify interface counts with `show ip interface brief`
        Sample of show ip interface brief command result:
        show ip interface brief
        Interface                  IP-Address      OK? Method Status                Protocol
        GigabitEthernet0/0         unassigned      YES unset  administratively down down
        GigabitEthernet0/1         10.10.10.2      YES manual up                    up
        '''

        try:
            # store execution result for later usage
            result = self.parameters[device].execute('show ip interface brief')

        except Exception as e:
            # abort/fail the testscript if show ip interface brief command
            # returns any exception such as connection timeout or command
            # failure
            self.failed('Device {} \'show ip interface brief\' failed: '
                            '{}'.format(device, str(e)),
                        goto = ['exit'])
        else:
            # extract ethernet interfaces
            match = re.search(r'(?P<ethernet>)GigabitEthernet\d', result)
            if match: 
                ethernet_interfaces = re.finditer(r'\r\nGigabitEthernet\d+/\d+\s+', result)
                #ethernet_interfaces:
                # total number of ethernet interface
                len_ethernet_interfaces = len(tuple(ethernet_interfaces))

                # log the ethernet interface counts
                logger.info(banner('\'show ip interface brief\' returns {} GigabitEthernet'
                               ' interfaces'.format(len_ethernet_interfaces)))

                # compare the ethernet interface count between
                # `show ip interface brief` and `show version`
                assert len_ethernet_interfaces == ethernet_intf_count
            else:
                ethernet_interfaces = re.finditer(r'\r\nFastEthernet\d+/\d+\s+', result)
                # total number of ethernet interface
                len_ethernet_interfaces = len(tuple(ethernet_interfaces))

                # log the ethernet interface counts
                logger.info(banner('\'show ip interface brief\' returns {} FastEthernet'
                                   ' interfaces'.format(len_ethernet_interfaces)))

                # compare the ethernet interface count between
                # `show ip interface brief` and `show version`
                assert len_ethernet_interfaces == ethernet_intf_count
示例#4
0
    def execution(self, device, **kwargs):

        # Init
        status = OK
        
        # create timeout object
        timeout = Timeout(max_time=int(self.args.cpucheck_timeout),
                          interval=int(self.args.cpucheck_interval))

        # loop status
        loop_stat_ok = True

        if not hasattr(self, 'PARSER_MODULE'):
            return WARNING('Does not have CPU related parsers to check')

        while timeout.iterate():
            # Execute command to get five minutes usage percentage
            try:
                cpu_dict = self.PARSER_MODULE(device).parse(
                    sort_time='5min', key_word='CPU')
            except Exception as e:
                return ERRORED('No output from show processes cpu\n{}'.format(e))

            # Check 5 minutes percentage smaller than cpucheck_fivemin_pcnt
            if int(cpu_dict['five_min_cpu']) >= int(self.args.cpucheck_fivemin_pcnt):
                message = "****** Device {d} *****\n".format(d=device.name)
                message += "Excessive CPU utilization detected for 5 min interval\n"
                message += "Allowed: {e}%\n".format(e=self.args.cpucheck_fivemin_pcnt)
                message += "Measured: FiveMin: {r}%".format(r=cpu_dict['five_min_cpu'])
                loop_stat_ok = False
                timeout.sleep()
            else:
                message = "***** CPU usage is Expected ***** \n"
                message += "Allowed threashold: {e} \n"\
                                .format(e=self.args.cpucheck_fivemin_pcnt)
                message += "Measured from device: {r}"\
                                .format(r=cpu_dict['five_min_cpu'])
                loop_stat_ok = True
                status += OK(message)
                logger.info(banner(message))
                break

        if not loop_stat_ok:
            status += CRITICAL(message)
            logger.error(banner(message))

        # Final status
        return status
示例#5
0
def _verify_finds_root_interface(ops, requirements, **kwargs):
    '''Triggers in this file specified verify method. This is to check only 1 interface
    change to root after change the priority to highest
    '''
    log.info(banner("check only One interface change to root for each vlan"))
    ret = find([ops], R(requirements), filter_=False)
    if not ret:
        raise Exception(
            'There is no Root interfaces after changing the priority')
    group_keys = GroupKeys.group_keys(reqs=[requirements],
                                      ret_num={},
                                      source=ret)

    vlan_dict = {}
    for item in group_keys:
        vlan_dict.setdefault(item['vlan'],
                             {}).setdefault(item['interface'], {})

    for vlan in vlan_dict:
        if len(vlan_dict[vlan].keys()) != 1:
            raise Exception(
                'Expect ONE Root interface for vlan {v} but got {i}'.format(
                    v=vlan, i=list(vlan_dict[vlan].keys())))
        else:
            log.info('Find ONE ROOT interface {i} for vlan {v}'.format(i=list(
                vlan_dict[vlan].keys())[0],
                                                                       v=vlan))
示例#6
0
class ST_IPV6_PING(aetest.Testcase):

    uid = "ST_IPV6_PING"

    logger.info(banner("Overall ICMP IPv6 ping from/to/thru UUT"))
    logger.info("Verify that IPv6 punt/inject/thru path on UUT")

    @aetest.test
    def ST_IPV6_PING_1(self, uut1, rtr1, rtr2):
        logger.info("ICMP IPv6 ping to verify punt/inject path")

        #ping ipv6
        if not ping_test(uut1, rtr1IPv6, ipv6=True):
            self.failed("ICMP IPv6 ping test for punt/inject path failed")
        else:
            logger.info("Ping successfull")

        try:
            uut1.execute("show ipv6 neighbors")
            rtr1.execute("show ipv6 neighbors")
            rtr2.execute("show ipv6 neighbors")

        except Exception as e:
            self.failed("Command failed")

    @aetest.test
    def ST_IPV6_PING_2(self, uut1, rtr1, rtr2):
        logger.info("ICMP IPv6 ping to verify thru path")

        #ping ipv6
        if not ping_test(rtr1, rtr2IPv6, ipv6=True):
            self.failed('ICMP IPv6 ping test for thru path failed')
        else:
            logger.info('Ping successfull')

        try:
            uut1.execute("show ipv6 neighbors")
            rtr1.execute("show ipv6 neighbors")
            rtr2.execute("show ipv6 neighbors")

        except Exception as e:
            self.failed("Command failed")

    @aetest.test
    def ST_IPV6_PING_3(self, uut1, rtr1, rtr2):
        logger.info("ICMP IPv6 ping to UUT")

        #ping ipv6
        if not ping_test(rtr1, uutInt1IPv6, ipv6=True):
            self.failed('ICMP IPv6 ping to UUT failed')
        else:
            logger.info('Ping successfull')

        try:
            uut1.execute("show ipv6 neighbors")
            rtr1.execute("show ipv6 neighbors")
            rtr2.execute("show ipv6 neighbors")

        except Exception as e:
            self.failed("Command failed")
示例#7
0
    def test(self, uut1):
        logger.info(banner("Verify the bootflash can be accessed"))
        logger.info("Verify the bootflash can be accessed")
        logger.info(title('Setup'))

        #Get dir output
        dir_output = uut1.execute("dir bootflash:mcp_crashinfo*")

        check_status = re.findall("(Error|Invalid|Incomplete|bytes free)",
                                  dir_output)

        if "Error" or "Invalid" or "Incomplete" in check_status:
            logger.info(
                "Failed to access the bootflash {}".format(check_status))
        elif "bytes free" in check_status:
            logger.info(banner("The bootflash can be accessed"))
示例#8
0
    def test(self, uut1):
        logger.info(banner("Check GigE SPA status"))
        logger.info("Check if GigE SPA is online")
        logger.info(title('Setup'))

        #Get status
        output_sh_pl = uut1.execute("show platform")
        check_status = re.search("SPA-\dX1GE...\s+(ok)\s+", output_sh_pl)

        #check fp status
        if check_status.group(1) == "ok":
            logger.info(
                banner("GigE SPA is up status {}".format(
                    check_status.group(1))))
        else:
            self.failed("GigE SPA is NOT up")
示例#9
0
    def test(self, uut1):
        logger.info(banner("Check CC1 status"))
        logger.info("Check if CC1 is online")
        logger.info(title('Setup'))

        #Get status
        output_sh_pl = uut1.execute("show platform")
        check_status = re.search("0\s+(MCP-CC|ASR\d+-SIP\d+)\s+(ok)\s+",
                                 output_sh_pl)

        #check fp status
        if check_status.group(2) == "ok":
            logger.info(
                banner("CC1 is up status {}".format(check_status.group(2))))
        else:
            self.failed("CC1 is NOT up")
    def check_ip_protocols(self):
        mega_dict = {}
        mega_tabular = []
        for dev in self.parent.parameters['dev']:
            if dev.name == "terminal_server":
                pass
            else:
                mega_dict[dev.name] = []
                log.info(banner("Gathering IP Protocol Information from {}".format(
                    dev.name)))
                output = dev.parse('sh ip protocols')
                smaller_tabular = []
                smaller_tabular.append(dev.name)
                gateways = output["protocols"]["isis"]["vrf"]["default"]["address_family"]["ipv4"]["instance"]["CUSTOMER_NAME"]["routing_information_sources"]["gateway"].keys()
                mega_dict[dev.name] = gateways
                smaller_tabular.append(", ".join(gateways))
                if set(gateways).issubset(set(test_params.params["routers_addr"])):
                    smaller_tabular.append('Passed')
                else:
                    smaller_tabular.append('Failed')
                mega_tabular.append(smaller_tabular)
        log.info(tabulate(mega_tabular,
                          headers = ['ISIS Gateways',
                                   'Passed/Failed'],
                          tablefmt='orgtbl'))

        for dev_name in mega_dict:
            if not set(mega_dict[dev_name]).issubset(set(test_params.params["routers_addr"])):
                self.failed("{d}: Does not contain all the routers, it contains: {e}".format(
                        d=dev_name, e=", ".join(mega_dict[dev_name])))
        self.passed("All devices' slots are in a ok state")
示例#11
0
    def test_netconf(self):
        """ Verify device reachable through NETCONF """

        for dev in self.parent.parameters["dev"]:
            if "netconf" in dev.connections:
                log.info(
                    banner("Testing NETCONF Access to {}".format(dev.name))
                )
                # Retry loop
                for _ in range(MAX_RETRIES):
                    try:
                        with manager.connect(
                                host = str(dev.connections.netconf.ip),
                                port = str(dev.connections.netconf.port),
                                username = dev.tacacs.username,
                                password = dev.passwords.tacacs,
                                hostkey_verify = False,
                                look_for_keys=False
                        ) as m:
                            log.info("NETCONF Connected is {}".format(m.connected))

                    # If unable to connect, fail test
                    except Exception as e:
                        log.error("Attempt number {} to connect with NETCONF failed.".format(_ + 1))
                        log.error(e)
                    else:
                        break
                # If unable to connect, fail test
                else:
                    self.failed(
                        "Failed to establish NETCONF connection to '{}'".format(
                            dev.name
                        )
                    )
 def check_isis_neighbors(self):
     mega_dict = {}
     mega_tabular = []
     for dev in self.parent.parameters['dev']:
         if dev.name == "terminal_server":
             pass
         else:
             mega_dict[dev.name] = 0
             log.info(banner("Gathering Isis Neighbors Information from {}".format(
                 dev.name)))
             output = dev.parse('sh isis neighbors') 
             nNeighbors = len(output["isis"]["CUSTOMER_NAME"]["neighbors"])
             mega_dict[dev.name] = nNeighbors
             smaller_tabular = []
             smaller_tabular.append(dev.name)
             smaller_tabular.append(", ".join(output["isis"]["CUSTOMER_NAME"]["neighbors"]))
             smaller_tabular.append(nNeighbors)
             if nNeighbors == test_params.params["nIsisNeighbors"]:
                 smaller_tabular.append('Passed')
             else:
                 smaller_tabular.append('Failed')
             mega_tabular.append(smaller_tabular)
     log.info(tabulate(mega_tabular,
                       headers = ['Neighbors', 'Number of Neighbors',
                                'Passed/Failed'],
                       tablefmt='orgtbl'))
     for dev_name in mega_dict:
         if mega_dict[dev_name] != test_params.params["nIsisNeighbors"]:
             self.failed("{d}: has {e} isis neighbors, instead of 2".format(
                 d=dev_name, e=mega_dict[dev_name]))
     self.passed("All devices have 2 isis neighbors")
示例#13
0
def save_bootvar(self, testbed):
    """Check boot information and save bootvar to startup-config

       Args:
           testbed (`obj`): Testbed object

       Returns:
           None

       Raises:
           pyATS Results
    """
    log.info(banner('Check boot information to see if they are consistent\n'
      'and save bootvar to startup-config'))
    # get uut
    devices = testbed.find_devices(alias='uut')

    for uut in devices:
        lookup = Lookup.from_device(uut)
        # get platform pts
        platform_pts = self.parameters.get('pts', {}).get('platform', {}).get('uut', None)
        
        try:
            lookup.sdk.libs.abstracted_libs.subsection.save_device_information(
                device=uut, platform_pts=platform_pts)
        except Exception as e:
            self.passx('Failed to save boot var or copy running-config to startup-config',
                        from_exception=e)
示例#14
0
    def new_subsection_in_variant(self):
        '''New Subsection

        demonstrating that after inheriting the previous CommonSetup, we can add
        more sections to it.
        '''
        logger.info(banner('new subsection is now called'))
示例#15
0
    def section_test(self, uut1, rtr1, rtr2):

        tries = 0
        max_tries = 18

        while tries < max_tries:
            ospf_output = uut1.execute("show ip ospf neighbor")
            start_time_stamp = time.time()
            for line in ospf_output.splitlines():
                neighbor_output = re.search(
                    '(FULL)\S*\s+[0-9\:]*\s+(\d+\.\d+\.\d+\.\d+)', ospf_output)
                end_time_stamp = time.time()
                total_time = start_time_stamp - end_time_stamp
                if neighbor_output.group(
                        1) == "FULL" and neighbor_output.group(2) == rtr1IP:
                    logger.info(
                        banner("OSPF reached FULL state in {} seconds".format(
                            round(total_time))))
                    break
                else:
                    tries += 1
                    time.sleep(10)
                    self.failed("OSPF - adjacency-based inject test failed")
            break
        logging.info("OSPF - adjacency-based inject test Successfull")
示例#16
0
class ScriptCommonSetup(aetest.CommonSetup):

    logger.info(banner('Executing common_setup section'))
    
    @aetest.subsection
    def validate_params(self, testbed, **parameters):
        for parameter in parameters:
            assert parameter in mandatory_parameters, \
            self.failed("Missing parameter {} from mandatory_parameters".format(parameter))

    @aetest.subsection
    def get_testbed_info(self, uut1, rtr1, rtr2, uutInt1, uutInt2, rtr1Int, rtr2Int,  testbed, **parameters):
    
        logger.info(banner('Connecting to Router'))
        
        uut1 = testbed.devices[uut1]
        rtr1 = testbed.devices[rtr1]
        rtr2 = testbed.devices[rtr2]
        
        self.parent.parameters['uut1'] = uut1
        self.parent.parameters['rtr1'] = rtr1
        self.parent.parameters['rtr2'] = rtr2
            
        uut1.connect()
        assert uut1.connected, "Could not connect to device: {}".format(uut1.name)
        rtr1.connect()
        assert rtr1.connected, "Could not connect to device: {}".format(rtr1.name)
        rtr2.connect()
        assert rtr2.connected, "Could not connect to device: {}".format(rtr2.name)

        logger.info("Configuring uut1 Interfaces IP address")
 def check_interfaces_crc_errors(self):
     mega_dict = {}
     mega_tabular = []
     for dev in self.parent.parameters['dev']:
         if dev.name == "terminal_server":
             pass
         else:
             mega_dict[dev.name] = {}
             log.info(banner("Gathering MPLS Forwarding Table Information from {}".format(
                 dev.name)))
             output = dev.parse('show interfaces')
             mega_dict[dev.name]={}
             for interface in output:
                 smaller_tabular = []
                 smaller_tabular.append(dev.name)
                 smaller_tabular.append(interface)
                 in_crc_errors = output[interface]["counters"]["in_crc_errors"]
                 smaller_tabular.append(in_crc_errors)
                 mega_dict[dev.name][interface] = in_crc_errors
                 if in_crc_errors == 0:
                     smaller_tabular.append('Passed')
                 else:
                     smaller_tabular.append('Failed')
                 mega_tabular.append(smaller_tabular)
     log.info(tabulate(mega_tabular,
                       headers = ['Interface', 'CRC_Errors',
                                'Passed/Failed'],
                       tablefmt='orgtbl'))
     for dev_name in mega_dict:
         for interface in mega_dict[dev_name]:
             if mega_dict[dev_name][interface] > 0:
                 self.failed("{d}: {int} has experienced {e} CRC Errors ".format(
                     d=dev_name, int=interface, e=mega_dict[dev_name][interface]))
     self.passed("No interface has experienced CRC Errors ")
示例#18
0
    def show_log(self):

        self.logging_server = {}
        for dev in self.parent.parameters['dev']:
            log.info(banner("Gather log data from {}".format(dev.name)))
            logout = dev.execute("show log | exclude Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec")
            logout = logout.split("Log Buffer")[0]
            self.logging_server[dev.name] = logout
示例#19
0
    def test(self, uut1):
        logger.info(banner("Check active FP status"))
        logger.info("Check if active FP is online")
        logger.info(title('Setup'))

        #Get status
        output_sh_pl = uut1.execute("show platform")
        check_status = re.search("F\d\s+[^\s]+\s+(ok)\,\s+active",
                                 output_sh_pl)

        #check fp status
        if check_status.group(1) == "ok":
            logger.info(
                banner("Active FP is up status {}".format(
                    check_status.group(1))))
        else:
            self.failed("Active FP is NOT up")
示例#20
0
    def test(self, uut1):
        logger.info(banner("Check standby FP status"))
        logger.info("Check if standby FP reaches ok state")
        logger.info(title('Setup'))

        #Get status
        output_sh_pl = uut1.execute("show platform")
        check_status = re.search("F\d\s+[^\s]+\s+(ok)\,\s+standby",
                                 output_sh_pl)

        #check fp status
        if check_status.group(1) == "ok":
            logger.info(
                banner("Standby FP is status {}".format(
                    check_status.group(1))))
        else:
            self.failed("Standby FP failed to reach ok state")
示例#21
0
    def section_test(self, uut1, rtr1, rtr2):
        logger.info(banner("IP Connectivity"))
        logger.info("Verifying ping before ACL configuration")

        target_ip_1 = "101.101.101.101"
        target_ip_2 = "3.3.3.3"

        uut1.execute("set platform software trace all debug")

        logger.info("Verify IP connectivity between routers")

        time.sleep(10)

        #Verify IP connectivity between routers
        #ipv4 ping test
        if not ping_test(rtr1, target_ip_1, ipv6=False):
            self.failed('Ping failed between rtr1 and rtr2')
        else:
            logger.info('Connectivity between rtr1 and rtr2 successfull')

        if not ping_test(rtr1, target_ip_2, ipv6=False):
            self.failed('Ping failed between rtr1 and rtr2')
        else:
            logger.info('Connectivity between rtr1 and rtr2 successfull')

        #ipv6 ping test
        if not ping_test(rtr1, rtr2IPv6, ipv6=True):
            self.failed('ICMP IPv6 ping test failed between rtr1 and rtr2')
        else:
            logger.info('ipv6 connectivity between rtr1 and rtr2 successfull')

        if not ping_test(rtr1, rtr2lo101IPv6, ipv6=True):
            self.failed('ICMP IPv6 ping test failed between rtr1 and rtr2')
        else:
            logger.info('ipv6 connectivity between rtr1 and rtr2 successfull')

        #neighbors check
        try:
            uut1.execute("show ipv6 neighbors")
            rtr1.execute("show ipv6 neighbors")
            rtr2.execute("show ipv6 neighbors")

        except Exception as e:
            logger.info("IPv6 Connectivity Failure")

        logger.info(banner("acl configuration successfull"))
示例#22
0
    def cleanup(self):
        """Testcase cleanup."""
        cs = Common_setup()
        log.info('Matthew your in cleanup')

        log.info(banner('@@@  disconnecting telnet session  @@@'))
        cs.rtr.mgmt1.disconnect()
        cs.rtr.mgmt2.disconnect()
示例#23
0
def learn_the_system(self, testbed, steps, features=None):
    """Learn and store the system properties

       Args:
           testbed (`obj`): Testbed object
           steps (`obj`): aetest steps object
           features (`dict`): dict of components and the feature that contains the component.
                              ex. {'pim': ['autorp',],
                                   'bgp': ['confederationpeers', 'gracefulrestart']}


       Returns:
           None

       Raises:
           pyATS Results
    """
    log.info(
        banner('Learn and store platform information, lldp neighbors'
               ', from PTS if PTS is existed, otherwise from show commands'))
    # get uut, having a uut is mandatory in Genie
    uut = testbed.devices['uut']

    lookup = Lookup.from_device(uut)

    # get platform PTS
    platform_pts = self.parameters.get('pts', {}).get('platform',
                                                      {}).get('uut', None)

    with steps.start(
            "Store and learn platform information from 'show lldp neighbors detail' on {}"
            .format(self.name)) as step:
        try:
            lookup.sdk.libs.abstracted_libs\
                .subsection.learn_system(device=uut, steps=steps, platform_pts=platform_pts)
        except Exception as e:
            step.passx('Cannot Learn and Store system info', from_exception=e)

    # learn platform lldp neighbors
    with steps.start("learn platform lldp neighbors on device {}".format(
            uut.name)) as step:

        # inital lldp ops object
        lldp_ops = lookup.ops.lldp.lldp.Lldp(
            uut,
            attributes=['info[interfaces][(.*)][neighbors][(.*)][port_id]'])

        # learn the lldp ops
        try:
            lldp_ops.learn()
        except Exception as e:
            step.passx('Cannot learn lldp information', from_exception=e)

        if not hasattr(lldp_ops, 'info'):
            step.passx('No LLDP neighbors')

        # store the lldp information
        uut.lldp_mapping = lldp_ops.info['interfaces']
    def learn_bgp(self):
        """ Sample test section. Only print """

        self.all_bgp_sessions = {}
        for dev in self.parent.parameters['dev']:
            log.info(
                banner("Gathering BGP Information from {}".format(dev.name)))
            bgp = dev.learn('bgp')
            self.all_bgp_sessions[dev.name] = bgp.info
示例#25
0
    def parse_macaddresses(self):
        """ Sample test section. Only print """

        for device in self.parent.parameters['dev']:
            log.info(banner("Gathering mac address tabel from {}".format(
                device.name)))
            macaddresses = device.parse("show mac address-table")
            self.all_mac = macaddresses
            self.name = device.name
    def show_interfaces_switchspor(self):
        """ Collect struted data from show interfaces switchport """

        self.all_interfaces = {}
        for dev in self.parent.parameters['dev']:
            log.info(banner("Gathering Interface Information from {}".format(
                dev.name)))
            switchport = dev.parse("show interfaces switchport")
            self.all_interfaces[dev.name] = switchport
示例#27
0
    def learn_version(self):

        self.version_info = {}
        for ios_device in self.parent.parameters['dev']:
            log.info(banner("Gathering Version Information from {}".format(
                ios_device.name
            )))
            version_info = ios_device.parse("show version")
            self.version_info[ios_device.name] = version_info['version']
示例#28
0
 def check_interfaces_crc_errors(self):
     # Big dictionary for collecting testcase relevant info
     mega_dict = {}
     # Object for storing the summarized info table
     mega_tabular = []
     # Loop through all devices
     for dev in self.parent.parameters['dev']:
         # If using CML avoid interacting with terminal server as it is other type of device
         if dev.name == "terminal_server":
             pass
         else:
             # Dictionary for saving variables for checking testcase conditions
             mega_dict[dev.name] = {}
             # Big log banner for debugging
             log.info(
                 banner(
                     "Gathering MPLS Forwarding Table Information from {}".
                     format(dev.name)))
             # CLI command to execute and parse into a dictionary
             output = dev.parse('show interfaces')
             # Loop through the dictionary with the parsed output
             for interface in output:
                 # Identify the interested variables for condition checking and storing it
                 in_crc_errors = output[interface]["counters"][
                     "in_crc_errors"]
                 mega_dict[dev.name][interface] = in_crc_errors
                 # Variable for storing table row info
                 smaller_tabular = []
                 smaller_tabular.append(dev.name)
                 smaller_tabular.append(interface)
                 smaller_tabular.append(in_crc_errors)
                 # Checking for marking Passed or failed in each row
                 if in_crc_errors == 0:
                     smaller_tabular.append('Passed')
                 else:
                     smaller_tabular.append('Failed')
                 # Row aggregation for the global table
                 mega_tabular.append(smaller_tabular)
     # Complete summarized info table representation
     log.info(
         tabulate(mega_tabular,
                  headers=['Interface', 'CRC_Errors', 'Passed/Failed'],
                  tablefmt='orgtbl'))
     # Loop for checking the test case success or failure
     for dev_name in mega_dict:
         for interface in mega_dict[dev_name]:
             # Failing condition
             if mega_dict[dev_name][interface] > 0:
                 # After identifying one case will stop execution of the test case and be marked as failure and this message will be displayed
                 self.failed(
                     "{d}: {int} has experienced {e} CRC Errors ".format(
                         d=dev_name,
                         int=interface,
                         e=mega_dict[dev_name][interface]))
     # If no failure condition has been found the reult will be a passed and this message will be displayed
     self.passed("No interface has experienced CRC Errors ")
    def learn_interfaces(self):
        """ Sample test section. Only print """

        self.all_interfaces = {}
        for dev in self.parent.parameters['dev']:
            log.info(
                banner("Gathering interface Information from {}".format(
                    dev.name)))
            interfaces = dev.learn("interface")
            self.all_interfaces[dev.name] = interfaces.info
示例#30
0
 def section_test(self, uut1, rtr1, rtr2):
     logger.info(banner("Verify iP Connectivity before QoS test"))
     logger.info("Verifying ping before QoS configuration")
     logger.info(title('Setup'))
     
     # Verify IP connectivity between routers
     if not ping_test(rtr1, rtr2IP, ipv6 = False):
         self.failed('Connectivity failure between rtr1 and rtr2')
     else:
         logger.info('Ping successfull')