How to use pyats - 10 common examples

To help you get started, we’ve selected a few pyats examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / modify / bgp / nxos / modify.py View on Github external
    @aetest.test
    def verify_modification(self, uut, abstract, steps):
        # modify self.keys to modify the address_family value
        for item in self.mapping.keys:
            try:
                ret = item['address_family'].split()
                ret[-1] = self.MODIFY_RD
                item['address_family'] = ' '.join(ret)
            except Exception:
                log.warning('Cannot modify address family RD information.'
                             'Mismatch is expected')

        super().verify_modification(uut, abstract, steps)
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / apis / junos / ospf / verify.py View on Github external
reqs=reqs.args, ret_num={}, source=found, all_keys=True)
                local_address = keys[0].get('local')

                try:
                    out = device.parse('show ted database extensive')
                except SchemaEmptyParserError:
                    log.info('Parser is empty')
                    timeout.sleep()
                    continue

                reqs = R([
                    'node', '(.*)', 'protocol', '(.*)', 'to', '(.*)', 'local',
                    local_address.split('/')[0], 'remote', '(.*)', 'metric',
                    '(?P.*)'
                ])
                found = find([out], reqs, filter_=False, all_keys=True)
                if found:
                    keys = GroupKeys.group_keys(
                        reqs=reqs.args,
                        ret_num={},
                        source=found,
                        all_keys=True)
                    if 'metric' in keys[0] and int(expected_cost) == int(
                            keys[0]['metric']):
                        return True

            timeout.sleep()
        return False

    log.info('This api does not support cost type {}'.format(cost_type))
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / contrib / modify / acl / iosxe / modify.py View on Github external
    @aetest.test
    def remove_acl_modify(self,uut,aclname):
        uut.configure('''\
ip access-list extended {acl_n}
1022 deny tcp any eq 18000 any eq ftp-data'''.format(acl_n=aclname))
#        uut.configure('''\
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / addremove / msdp / nxos / addremove.py View on Github external
    @aetest.test
    def restore_configuration(self, uut, method, abstract):
      # restore object point uut restore
      self.lib = self.uut_restore
      super().restore_configuration(uut, method, abstract)
      # restore object point peer restore
      self.lib = self.peer_restore
      super().restore_configuration(self.uut_peer, method, abstract)
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / addremove / vxlan / nxos / addremove.py View on Github external
        @aetest.test
        def verify_configuration(self, uut, abstract, steps):
            # modify self.keys to modify the multisite bgw interface value
            for item in self.mapping.keys:
                try:
                    ret = item['multisite_bgw_intf']
                    req = ['nve', '(?P.*)', 'multisite_bgw_if']
                    req.insert(len(req), ret)
                    self.mapping._verify_ops_dict['ops.vxlan.vxlan.Vxlan']['requirements'].append(req)
                    log.info("\n\nVerifying the following requirements: {req}".format(req=req))
                except Exception as e:
                    self.failed('Failed to verify the '
                                'added feature', from_exception=e)

            super().verify_configuration(uut, abstract, steps)
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / contrib / unconfigconfig / cdp / iosxe / unconfigconfig.py View on Github external
    @aetest.test
    def restore_configuration(self, uut, method, abstract, steps):
        '''Rollback the configuration

           Can be either done via TFTP or checkpoint feature (If exists for OS)

           Args:
               uut (`obj`): Device object.
               method (`str`): Save method from trigger datafile.
                                Only accpet "local" and "checkpoint"

           Returns:
               None

           Raises:
               pyATS Results
        '''
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / addremove / addremove.py View on Github external
    @aetest.test
    def save_configuration(self, uut, method, abstract):
        '''Save current configuration

           Can be either done via TFTP or checkpoint feature (If exists for OS)

           Args:
               uut (`obj`): Device object.
               method (`str`): Save method from trigger datafile.
                               Only accpet "local" and "checkpoint"

            Returns:
                None

            Raises:
                pyATS Results
        '''
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / template / ha.py View on Github external
    @aetest.test
    def perform_issu(self, uut, abstract, steps):
        raise NotImplementedError
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / addremove / routing / iosxe / addremove.py View on Github external
    @aetest.test
    def verify_configuration(self, uut, abstract, steps): 

        # replace the traceroute_info if has any
        if hasattr(self, 'traceroute_info'):
            for item_args in self.traceroute_info:
                for keys in self.mapping.keys:
                    item_args['dest_route'] = keys['next_hop']         
        super().verify_configuration(uut, abstract, steps)
github CiscoTestAutomation / genielibs / pkgs / sdk-pkg / src / genie / libs / sdk / triggers / xe_sanity / checkcommands / iosxe / checkcommands.py View on Github external
    @aetest.test
    def verify_show_version (self, uut, steps, timeout):
        '''Platform Manager: Log Check for show version
           Args:
               uut (`obj`): Device object.
               steps (`step obj`): aetest step object
               timeout (`timeout obj`): Timeout Object

           Returns:
               None

           Raises:
               pyATS Results
        '''
        
        try:
            if hasattr(uut, 'workers'):