Example #1
0
class TriggerShutNoShutBgpNeighbors(TriggerShutNoShut):

    mapping = Mapping(\
            requirements={\
                'ops.bgp.bgp.Bgp': {
                    'requirements':[\
                        ['info', 'instance', '(?P<instance>.*)',
                        'vrf', '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)',
                        'session_state', 'established'],
                        ['info', 'instance', '(?P<instance>.*)', 'bgp_id', '(?P<bgp_id>.*)']],
                    'all_keys':True,
                    'kwargs':
                        {'attributes':['info']},
                    'exclude': bgp_exclude}},
            config_info={\
                'conf.bgp.Bgp': {
                    'requirements':[\
                        ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)',
                        'neighbor_attr', '(?P<neighbor>.*)', 'nbr_shutdown', True]],
                    'verify_conf':False,
                    'kwargs':{'mandatory':{'bgp_id': '(?P<bgp_id>.*)'}}}},
            verify_ops={\
                'ops.bgp.bgp.Bgp': {
                    'requirements':[\
                        ['info', 'instance', '(?P<instance>.*)', 'vrf',
                        '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)',
                        'session_state', 'idle'],
                        ['info', 'instance', '(?P<instance>.*)', 'vrf',
                        '(?P<vrf>.*)', 'neighbor', '(?P<neighbor>.*)',
                        'shutdown', True]],
                    'kwargs':
                        {'attributes':['info']},
                    'exclude': bgp_exclude}},
            num_values={'instance':1, 'vrf':1, 'neighbor': 'all'})
Example #2
0
class TriggerDisableEnableNveOverlay(TriggerDisableEnable):
    """Disable and enable feature nv overlay when it is enabled."""

    __description__ = """Disable and enable feature nv overlay when it is enabled.

    trigger_datafile:
        Mandatory:
            timeout:
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iteration when looping is needed,
                                in second. Default: 15
                method (`str`): Method to recover the device configuration,
                              Support methods:
                                'checkpoint': Rollback the configuration by
                                              checkpoint (nxos),
                                              archive file (iosxe),
                                              load the saved running-config file on disk (iosxr)
        Optional:
            tgn_timeout (`int`): Maximum wait time for all traffic threads to be
                                 restored to the reference rate,
                                 in second. Default: 60
            tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed,
                               in second. Default: 10
            timeout_recovery:
                Buffer recovery timeout make sure devices are recovered at the end
                of the trigger execution. Used when previous timeouts have been exhausted.

                max_time (`int`): Maximum wait time for the last step of the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iteration when looping is needed,
                                in second. Default: 15

    steps:
        1. Learn Vxlan Ops object and verify if nv overlay is enabled, if not, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Disable nv overlay feature with command "no feature nve overlay"
           via Vxlan Conf object
        4. Verify the state of feature nv overlay is "disabled"
        5. Recover the device configurations to the one in step 2
        6. Verify the state of feature nv overlay is "enabled" and
           learn Vxlan Ops again and verify it is the same as the Ops in step 1

    """

    mapping = Mapping(requirements={'ops.vxlan.vxlan.Vxlan': {
                                        'requirements': [['nve', 'enabled_nv_overlay', True]],
                                                        'kwargs': {'attributes': ['nve','l2route']},
                                                        'all_keys': True,
                                                        'exclude': vxlan_exclude + ['tx_id','peer_id']}},
                    config_info={'conf.vxlan.Vxlan': {
                                    'requirements': [['device_attr', '{uut}', 'enabled_nv_overlay', True]],
                                    'verify_conf': False}},
                    verify_ops={'ops.vxlan.vxlan.Vxlan': {
                                    'requirements': [['nve', 'enabled_nv_overlay', False]],
                                    'kwargs': {'attributes': ['nve','l2route']},
                                    'exclude': vxlan_exclude + ['l2route']}},
                    num_values={})

    feature_name = 'nve'
Example #3
0
class TriggerClearCounters(TriggerClear):

    mapping_extra_args = {
        'ops': 'ops_obj',
        'relation': 'sign',
        'threshold_time': 'compare_time'
    }

    # Learn interface ops for all interfaces on device
    mapping = Mapping(\
                    requirements={'ops.interface.interface.Interface':{
                                        'requirements':[\
                                            ['info', '(?P<name>[\w\-\/]+$)', 'enabled', '(?P<enabled>.*)']],
                                       'exclude': interface_exclude}},
                    num_values={'name': 'all'})

    # Verify callable definition
    verify = CompareUptime.compare_uptime
    ops_lib = 'ops.interface.interface.Interface'

    # Arguments for verify callable
    verify_func_args = {
        'r_obj':
        [R(['info', '(?P<name>.*)', 'counters', 'last_clear', '(.*)'])]
    }
Example #4
0
class TriggerUnconfigConfigEthernetInterface(UncfgCfgInterface):

    mapping = Mapping(requirements={'ops.interface.interface.Interface':{
                                        'requirements':[['info', '(?P<name>\w+Ethernet[0-9\/]+$)', 'enabled', True],
                                                        ['info', '(?P<name>.*)', 'port_channel', 'port_channel_member', False],
                                                        ['info', '(?P<name>.*)', 'oper_status', 'up']],
                                        'exclude': interface_exclude,
                                        'include_management_interface': False}},
                      config_info={'conf.interface.Interface':{
                                        'requirements':[],
                                        'verify_conf':False,
                                        'kwargs':{'mandatory':{'name': '(?P<name>.*)',
                                                               'attach': False}}}},
                      verify_ops={'ops.interface.interface.Interface':{
                                        'requirements':[['info', '(?P<name>.*)','access_vlan'],
                                                        ['info', '(?P<name>.*)','switchport_enable'],
                                                        ['info', '(?P<name>.*)','switchport_mode'],
                                                        ['info', '(?P<name>.*)','trunk_vlans'],
                                                        ['info', '(?P<name>.*)','vrf'],
                                                        ['info', '(?P<name>.*)','enabled'],
                                                        ['info', '(?P<name>.*)','duplex_mode'],
                                                        ['info', '(?P<name>.*)','mac_address'],
                                                        ['info', '(?P<name>.*)','oper_status']],
                                        'exclude': interface_exclude +\
                                                   [UncfgCfgInterface.remove_related_subinterface]}},
                      num_values={'name': 1})
Example #5
0
class TriggerSwitchover(CommonSwitchover):
    """Do switchover on device."""

    __description__ = """Do switchover on device.

    trigger_datafile:
        Mandatory:
            timeout: 
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iteration when looping is needed,
                                in second. Default: 15
        Optional:
            tgn_timeout (`int`): Maximum wait time for all traffic threads to be
                                 restored to the reference rate,
                                 in second. Default: 60
            tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed,
                               in second. Default: 10

    steps:
        1. Learn Platform Ops object and store the "active" RP and "standby" RP
           if has any, otherwise, SKIP the trigger
        2. Do switchover by command "redundancy force-switchover"
        3. Learn Platform Ops again and verify the roles of 
           "active" RP and "standby" RP are swapped,
           and verify left attributes from the ops are the same as the Ops in step 1
        4. Update platform PTS if feature pts is enabled,
           Update global/local veirifications if enabled

    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictates which key to verify
    mapping = Mapping(requirements={'ops.platform.platform.Platform':{
                                        'requirements': [\
                                            [['slot', 'rp', '(?P<active_rp>.*)',
                                              'redundancy_state', 'ACTIVE'],
                                            ['slot', 'rp', '(?P<active_rp>.*)',
                                              'state', 'ok, active']],
                                            [['slot', 'rp', '(?P<standby_rp>.*)',
                                              'redundancy_state', 'STANDBY HOT'],
                                            ['slot', 'rp', '(?P<standby_rp>.*)',
                                              'state', 'ok, standby']],
                                            [['redundancy_communication', True]],
                                          ],
                                        'all_keys': True,
                                        'exclude': platform_exclude}},
                      verify_ops={'ops.platform.platform.Platform':{
                                      'requirements': [\
                                          ['slot', 'rp', '(?P<active_rp>.*)',
                                           'redundancy_state', 'STANDBY HOT'],
                                          ['slot', 'rp', '(?P<active_rp>.*)',
                                           'state', 'ok, standby'],
                                          ['slot', 'rp', '(?P<standby_rp>.*)',
                                           'redundancy_state', 'ACTIVE'],
                                          ['slot', 'rp', '(?P<standby_rp>.*)',
                                           'state', 'ok, active']],
                                    'exclude': platform_exclude}},
                      num_values={'active_rp':1, 'standby_rp':1})
Example #6
0
class TriggerReload(CommonReload):
    """Reload the whole device."""

    __description__ = """Reload the whole device.

    trigger_datafile:
        Mandatory:
            timeout: 
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iteration when looping is needed,
                                in second. Default: 15
        Optional:
            tgn_timeout (`int`): Maximum wait time for all traffic threads to be
                                 restored to the reference rate,
                                 in second. Default: 60
            tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed,
                               in second. Default: 10

    steps:
        1. Learn Platform Ops object and store the "ok, active|ok, standby|Ready" slot(s)
           if has any, otherwise, SKIP the trigger
        2. Do reload by command "reload"
        3. Learn Platform Ops again and verify the state of RP(s) is 
           "ok, active|ok, standby", verify every LC status is "Ready",
           and verify left attributes from the ops are the same as the Ops in step 1
        4. Update platform PTS if feature pts is enabled,
           Update global/local veirifications if enabled

    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictates which key to verify
    mapping = Mapping(requirements={'ops.platform.platform.Platform':{
                                        'requirements': [\
                                            ['slot', 'rp', '(?P<rp>.*)',
                                              'state', '(?P<state>ok, active|ok, standby|Ready)'],
                                            ['slot', 'lc', '(?P<lc>.*)',
                                              'state', 'ok'],
                                            ['slot', 'oc', '(?P<oc>.*)',
                                              'state', '(?P<oc_state>ok, active|ok, standby|ok|ps, fail)'],
                                          ],
                                        'all_keys': True,
                                        'exclude': platform_exclude}},
                      verify_ops={'ops.platform.platform.Platform':{
                                      'requirements': [\
                                          ['slot', 'rp', '(?P<rp>.*)',
                                           'state', '(ok, active|ok, standby|Ready)'],
                                          ['slot', 'rp', '(?P<rp>.*)',
                                           'redundancy_state', '(ACTIVE|STANDBY HOT)'],
                                          ['slot', 'lc', '(?P<lc>.*)',
                                           'state', 'ok'],
                                          ['slot', 'oc', '(?P<oc>.*)',
                                           'state', '(ok, active|ok, standby|ok|ps, fail)']],
                                    'exclude': platform_exclude}},
                      num_values={'rp': 'all', 'lc': 'all', 'oc': 'all'})
Example #7
0
class TriggerReloadStandbyRP(TriggerReloadLc):
    """Reload standby supervisor slot on device."""

    __description__ = """Reload standby supervisor slot on device.

    trigger_datafile:
        Mandatory:
            timeout: 
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iteration when looping is needed,
                                in second. Default: 15
            lcRole (`str`): The role of LC which is 'active'
        Optional:
            tgn_timeout (`int`): Maximum wait time for all traffic threads to be
                                 restored to the reference rate,
                                 in second. Default: 60
            tgn_delay (`int`): Wait time between each poll to verify if traffic is resumed,
                               in second. Default: 10
            static:
                The keys below are dynamically learnt by default.
                However, they can also be set to a custom value when provided in the trigger datafile.

                standby_rp: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                   OR
                   interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Platform Ops object and store the "ok, standby" RP
           if has any, otherwise, SKIP the trigger
        2. Do reload by command "hw-module slot <lc> reload"
        3. Learn Platform Ops again and the ops are the same as the Ops in step 1
        4. Update platform PTS if feature pts is enabled,
           Update global/local veirifications if enabled

    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictates which key to verify
    mapping = Mapping(requirements={'ops.platform.platform.Platform':{
                                        'requirements': [\
                                             [['slot', 'rp', '(?P<standby_rp>.*)',
                                              'redundancy_state', 'STANDBY HOT'],
                                             ['slot', 'rp', '(?P<standby_rp>.*)',
                                              'state', 'ok, standby']],
                                             [['redundancy_communication', True]],
                                          ],
                                        'all_keys': True,
                                        'exclude': platform_exclude}},
                      verify_ops={'ops.platform.platform.Platform':{
                                      'requirements': [\
                                          ['slot', 'rp', '(?P<standby_rp>.*)',
                                           'redundancy_state', 'STANDBY HOT']],
                                    'exclude': platform_exclude}},
                      num_values={'standby_rp':1})
Example #8
0
class TriggerUnconfigConfigPhysicalTrunkInterface(
        TriggerUnconfigConfigPhysicalInterface):

    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(
        requirements={
            'ops.interface.interface.Interface': {
                'requirements':
                [[
                    'info', '(?P<name>\w+Ethernet[\d\/\.]+)',
                    'switchport_mode', 'trunk'
                ],
                 [
                     'info', '(?P<name>\w+Ethernet[\d\/\.]+)', 'port_channel',
                     'port_channel_int', '(?P<port_int>.*)'
                 ]],
                'exclude':
                interface_exclude
            }
        },
        config_info={
            'conf.interface.Interface': {
                'requirements': [],
                'verify_conf': False,
                'kwargs': {
                    'mandatory': {
                        'name': '(?P<name>.*)',
                        'attach': False
                    }
                }
            }
        },
        verify_ops={
            'ops.interface.interface.Interface': {
                'requirements':
                [['info', '(?P<name>.*)', 'oper_status', 'down'],
                 ['info', '(?P<name>.*)', 'enabled', False],
                 [
                     'info', '(?P<name>.*)', 'port_channel',
                     'port_channel_member', False
                 ], ['info', '(?P<name>.*)', 'mac_address', '([\w\.]+)'],
                 ['info', '(?P<name>.*)', '(.*)'],
                 [
                     'info', '(?P<port_int>.*)', 'port_channel',
                     'port_channel_member_intfs', '(.*)'
                 ], ['info', '(Port-channel.*)', 'mac_address', '(.*)'],
                 ['info', '(Port-channel.*)', 'phys_address', '(.*)']],
                'exclude':
                interface_exclude
            }
        },
        num_values={'name': 1})
Example #9
0
class TriggerShutNoShutBgp(TriggerShutNoShut):
    """Shut BGP protocol by shutdown the dynamically learned BGP process,
    then unshut it by restart bpm. """

    __description__ = """Shut BGP protocol by shutdown the dynamically learned BGP process,
    then unshut it by restart bpm. 

    steps:
        1. Learn BGP Ops object and store the BGP instance(s)
           if has any, otherwise, SKIP the trigger
        2. Do "process shutdown bgp"
        3. Verify the state of BGP instance(s) is "KILLED"
        4. Do "process restart bpm"
        5. Learn BGP Ops again and verify it is the same as the Ops in step 1

    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictates which key to verify
    mapping = Mapping(requirements={
        'ops.bgp.bgp.Bgp': {
            'requirements':
            [['info', 'instance', '(?P<instance>.*)',
              '(?P<instance_info>.*)']],
            'kwargs': {
                'attributes': ['info']
            },
            'exclude':
            bgp_exclude
        }
    },
                      verify_ops={
                          'ops.bgp.bgp.Bgp': {
                              'requirements': [[
                                  'info', 'instance', '(?P<instance>.*)',
                                  'protocol_state', 'KILLED'
                              ],
                                               [
                                                   'info', 'instance',
                                                   '(?P<instance>.*)', '(.*)'
                                               ]],
                              'kwargs': {
                                  'attributes': ['info']
                              },
                              'exclude':
                              bgp_exclude
                          }
                      },
                      num_values={'instance': 'all'})
Example #10
0
class TriggerUnconfigConfigEthernetInterface(TriggerUnconfigConfig):

    mapping = Mapping(requirements={
        'ops.interface.interface.Interface': {
            'requirements':
            [[
                'info',
                '(?P<name>(GigabitEthernet|gigabitEthernet|TenGigE|HundredGigE)[0-9\/]+)',
                'enabled', True
            ],
             [
                 'info',
                 '(?P<name>(GigabitEthernet|gigabitEthernet|TenGigE|HundredGigE)[0-9\/]+)',
                 'oper_status', 'up'
             ]],
            'exclude':
            interface_exclude
        }
    },
                      config_info={
                          'conf.interface.Interface': {
                              'requirements': [],
                              'verify_conf': False,
                              'kwargs': {
                                  'mandatory': {
                                      'name': '(?P<name>.*)',
                                      'attach': False
                                  }
                              }
                          }
                      },
                      verify_ops={
                          'ops.interface.interface.Interface': {
                              'requirements':
                              [['info', '(?P<name>.*)', 'access_vlan'],
                               ['info', '(?P<name>.*)', 'switchport_enable'],
                               ['info', '(?P<name>.*)', 'switchport_mode'],
                               ['info', '(?P<name>.*)', 'trunk_vlans'],
                               ['info', '(?P<name>.*)', 'vrf'],
                               ['info', '(?P<name>.*)', 'duplex_mode'],
                               ['info', '(?P<name>.*)', 'mac_address'],
                               ['info', '(?P<name>.*)', 'oper_status']],
                              'exclude':
                              interface_exclude
                          }
                      },
                      num_values={'name': 1})