Exemplo n.º 1
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.

    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
            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
            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.

                 instance: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)

    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 protocol state in BGP instance(s) does not exist
        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>.*)',
                                  NotExists('protocol_state')
                              ]],
                              'kwargs': {
                                  'attributes': ['info']
                              },
                              'exclude':
                              bgp_exclude
                          }
                      },
                      num_values={'instance': 'all'})
Exemplo n.º 2
0
class TriggerUnconfigConfigAdvertiseEvpnMulticast(TriggerUnconfigConfig):
    """Unconfigure advertise evpn multisite and reapply the whole configurations of dynamically learned Conf Vxlan."""

    __description__ = """Unconfigure advertise evpn multisite and reapply the whole configurations of dynamically learned Vxlan.

        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 when the previous timeout has been exhausted,
                    to make sure the devices are recovered before ending the trigger

                    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 Conf object and check advertise_evpn_multisite is available
               if has any, otherwise, SKIP the trigger
            2. Save the current device configurations through "method" which user uses
            3. Unconfigure the advertise_evpn_multisite with Vxlan Conf object
            4. Verify the  advertise evpn multisite from step 3 are no longer existed
            5. Recover the device configurations to the one in step 2
            6. Learn Vxlan Conf obj again and verify it is the same as the Ops in step 1

        """

    mapping = Mapping( \
        requirements={ \
            'conf.vxlan.Vxlan': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'advertise_evpn_multicast', True]],
                'exclude': trm_exclude}},
        config_info={ \
            'conf.vxlan.Vxlan': {
                'requirements': [['device_attr', '{uut}', 'advertise_evpn_multicast', True]],
                'verify_conf': False,
                'kwargs': {}}},
        verify_ops={ \
            'conf.vxlan.Vxlan': {
                'requirements': [ \
                    [NotExists('device_attr')]],
                'exclude': trm_exclude}},
        num_values={})
Exemplo n.º 3
0
class TriggerAddRemoveAdvertiseEvpnMulticast(TriggerAddRemove):
    """Add advertise evpn multicast then restore the
        configuration by reapplying the whole running configuration"""

    __description__ = """Add advertise evpn multicast then restore the
                               configuration by re-applying the whole running configuration

       trigger_datafile:
           Mandatory Arguments:
               timeout:
                   max_time (`int`): Maximum wait time for the trigger in seconds.
                                     Default: 180
                   interval (`int`): Wait time between iteration when looping is
                                     needed in seconds. Default: 15
                   method (`str`): Method to recover the device configuration.
                                   Supported methods:
                                       'checkpoint': Rollback the configuration
                                                     using checkpoint (nxos),
                                                     archive file (iosxe),
                                                     load the saved running-config
                                                     file on disk (iosxr)
           Optional Arguments:
               tgn_timeout (`int`): Maximum wait time for all traffic streams to be
                                    restored to the reference rate in seconds.
                                    Default: 60
               tgn_delay (`int`): Wait time between each poll to verify if traffic
                                  is resumed in seconds. 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 seconds. Default: 180
                   interval (`int`): Wait time between iteration when looping is
                                     needed in seconds. Default: 15

       Steps:
           1. Learn Vxlan Conf object configured on device. SKIP the trigger if there
              is no vrf configured on the device.
           2. Save the current device configurations using "method" specified.
           3. Add advertise evpn multicast that using Genie Vxlan Conf.
           4. Verify the newly advertise evpn multicast is reflected in
              device configuration.
           5. Restore the device configuration to the original configuration saved
              in step 2.
           6. Learn Vxaln Conf object again and verify it is the same as step 1.
    """

    @aetest.test
    def verify_configuration(self, uut, abstract, steps):
        time.sleep(30)
        super().verify_configuration(uut, abstract, steps)

    mapping = Mapping( \
        requirements={ \
            'conf.vxlan.Vxlan': {
                'requirements': [ \
                    ['device_attr', '{uut}', NotExists('advertise_evpn_multicast')]],
                'exclude': trm_exclude}},
        config_info={ \
            'conf.vxlan.Vxlan': {
                'requirements': [['device_attr', '{uut}', 'advertise_evpn_multicast', True]],
                'verify_conf': False,
                'kwargs': {}}},
        verify_ops={ \
            'conf.vxlan.Vxlan': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'advertise_evpn_multicast', True]],
                'exclude': trm_exclude}},
        num_values={})
Exemplo n.º 4
0
class TriggerAddRemoveEthernetMacAcl(TriggerAddRemove):
    """Apply the mac acl to ethernet interface, and remove the
    added mac acl
    """

    __description__ = """Apply the mac acl to ethernet interface, and remove the
    added mac acl.

    trigger_datafile:
        Mandatory:
            timeout: 
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iterations 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 iterations when looping is needed,
                                in second. Default: 15
            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.

                interface: `str`

               (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                     OR
                     interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn acl Ops object and store the acls info if has any.
           Learn Interface ops object to select one trunk interface to add mac acl
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of acl with acl Conf object
        4. Verify the acl from step 3 has configured
        5. Remove the acl configurations.
        6. Recover the device configurations to the one in step 2
        7. Learn acl Ops again and verify it is the same as the Ops in step 1

    """
    ADD_ACL_NAME = 'etherent_mac_acl_add'

    mapping = Mapping(
        requirements={
            'ops.acl.acl.Acl': {
                'requirements': [['info', 'acls',
                                  NotExists(ADD_ACL_NAME)]],
                'exclude': acl_exclude
            },
            'ops.interface.interface.Interface': {
                'requirements':
                [[
                    'info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                    'switchport_mode', 'trunk'
                ],
                 [
                     'info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                     'oper_status', 'up'
                 ]],
                'exclude':
                interface_exclude,
                'kwargs': {
                    'attributes':
                    ['info[(.*)][switchport_mode]', 'info[(.*)][oper_status]']
                }
            }
        },
        config_info={
            'conf.acl.Acl': {
                'requirements':
                [[
                    'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                    'acl_type', 'eth-acl-type'
                ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'actions_forwarding', 'permit'
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'src', 'host 0011.2233.1111'
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'dst', 'host 0011.2233.2222'
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'interface_attr', '(?P<interface>\w+Ethernet[\d\/]+$)',
                     'if_in', True
                 ]],
                'verify_conf':
                False,
                'kwargs': {}
            }
        },
        verify_ops={
            'ops.acl.acl.Acl': {
                'requirements':
                [['info', 'acls', ADD_ACL_NAME, 'name', ADD_ACL_NAME],
                 ['info', 'acls', ADD_ACL_NAME, 'type', 'eth-acl-type'],
                 ['info', 'acls', ADD_ACL_NAME, 'aces', '10', 'name', '10'],
                 [
                     'info', 'acls', ADD_ACL_NAME, 'aces', '10', 'matches',
                     'l2', 'eth', 'destination_mac_address',
                     'host 0011.2233.2222'
                 ],
                 [
                     'info', 'acls', ADD_ACL_NAME, 'aces', '10', 'matches',
                     'l2', 'eth', 'source_mac_address', 'host 0011.2233.1111'
                 ],
                 [
                     'info', 'acls', ADD_ACL_NAME, 'aces', '10', 'actions',
                     'logging', 'log-none'
                 ],
                 [
                     'info', 'acls', ADD_ACL_NAME, 'aces', '10', 'actions',
                     'forwarding', 'permit'
                 ]],
                'kwargs': {
                    'attributes': ['info']
                },
                'exclude':
                acl_exclude
            },
            'ops.interface.interface.Interface': {
                'requirements': [[
                    'info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                    'switchport_mode', 'trunk'
                ],
                                 [
                                     'info',
                                     '(?P<interface>\w+Ethernet[\d\/]+$)',
                                     'oper_status', 'up'
                                 ]],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][switchport_mode]', 'info[(.*)][oper_status]']
                },
                'exclude':
                interface_exclude
            }
        },
        num_values={'interface': 1})
Exemplo n.º 5
0
def learn_routing(device,
                  address_family,
                  paths,
                  ops_container=[],
                  ret_container={}):
    '''Dynamic learn routing information by using the paths that specified,
    and store the data into dictionary.

    Args:
      Mandatory:
        device (`obj`): Device object
        address_family (`str`) : Value of address_family, could be ipv4/ipv6
        paths (`list`) : Ops paths to look for the desired routing values
      Optional:
        ops_container (`list`): Container to store the learned ops,
                                in case multiple learning
        ret_container (`dict`) : Container to store the learned routes
                                 to let parent update on it

    Returns:
        None. Instead of returned values, it will store the learned
              information in the container to let parent update on it.

              The container values for ret_container looks like below
              10.9.1.0/24: {
                 10.9.1.2: {'R5': {route: 10.9.1.0/24, intf: Vlan99, vrf: default}},
                 10.9.1.1: {'R1': {route: 10.9.1.0/24, intf: Vlan99, vrf: default}},
              }
              10.9.1.0/24: {
                 10.9.1.2: {'R5': {route: 10.9.1.0/24, intf: GigabitEthernet1/0/4, vrf: test2}},
                 10.9.1.1: {'R5': {route: 10.9.1.0/24, intf: Vlan99, vrf: test1}},
              }


    Raises:
        Exception: Routing ops cannot sucessfully learned

    '''
    log.info(banner("learn routing info on device {}".format(device.name)))
    # get ip and vrf
    routing_ops = ops.routing.iosxe.routing.Routing(device)

    # learn the routing ops
    try:
        routing_ops.learn()
    except Exception as e:
        raise Exception('cannot learn routing ops: {}'.format(e))

    ops_container[device.name] = routing_ops

    log.info(banner("Get routing groups from device {}".format(device.name)))

    rs = [R(p) for p in paths]
    ret = find([routing_ops], *rs, filter_=False, all_keys=True)
    if ret:
        groups = GroupKeys.group_keys(reqs=paths,
                                      ret_num={},
                                      source=ret,
                                      all_keys=True)
        if groups:
            # learn interfaces ip
            if 'ipv4' in address_family:
                ip_out = ShowIpInterfaceBrief(device).parse()

            else:
                ip_out = ShowIpv6Interface(device).parse()

            for keys in groups:
                # find interface ip
                if 'ipv4' in address_family:
                    intf_r = [
                        R([
                            'interface', keys['intf'], 'ip_address',
                            '(?P<ip>.*)'
                        ])
                    ]
                else:
                    intf_r = [
                        R([
                            keys['intf'], 'ipv6', '(?P<ip_addr>.*)', 'ip',
                            '(?P<ip>.*)'
                        ]),
                        R([
                            keys['intf'], 'ipv6', '(?P<ip_addr>.*)',
                            NotExists('origin')
                        ])
                    ]
                ip = find([ip_out], *intf_r, filter_=False)
                if ip:
                    ip = ip[0][0]
                    ret_container.setdefault(keys['route'], {}).\
                        setdefault(ip, {}).update({device.name: keys})
Exemplo n.º 6
0
class TriggerUnconfigConfigVlanVnsegment(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically learned vlan(s)."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically learned vlan(s).

        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 when the previous timeout has been exhausted,
                    to make sure the devices are recovered before ending the trigger

                    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
                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.

                    vlan: `str`
                    vn_segment_id: `int`
                    (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                         OR
                         interface: 'Ethernet1/1/1' (Specific value)
        steps:
            1. Learn Vlan Ops object and store the "unshut" vlan(s) if has any, otherwise, SKIP the trigger
            2. Save the current device configurations through "method" which user uses
            3. Unconfigure the learned vn_segment_id with Vlan Conf object
            4. Verify the vlan(s) from step 3 are no longer existed
            5. Recover the device configurations to the one in step 2
            6. Learn Vlan 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.vlan.vlan.Vlan': {
            'requirements': [[
                'info', 'vlans', '(?P<vlan>.*)', 'vn_segment_id',
                '(?P<vn_segment_id>.*)'
            ]],
            'kwargs': {
                'attributes': ['info[vlans][(.*)][vn_segment_id]']
            },
            'all_keys':
            True,
            'exclude':
            vlan_exclude
        }
    },
                      config_info={
                          'conf.vlan.Vlan': {
                              'requirements': [[
                                  'device_attr', '{uut}', 'vlan_attr',
                                  '(?P<vlan>.*)', 'vn_segment_id',
                                  '(?P<vn_segment_id>.*)'
                              ]],
                              'verify_conf':
                              False,
                              'kwargs': {}
                          }
                      },
                      verify_ops={
                          'ops.vlan.vlan.Vlan': {
                              'requirements':
                              [['info', 'vlans',
                                NotExists('(?P<vlan>.*)')]],
                              'kwargs': {
                                  'attributes':
                                  ['info[vlans][(.*)][vn_segment_id]']
                              },
                              'exclude':
                              vlan_exclude
                          }
                      },
                      num_values={'vlan': 1})
Exemplo n.º 7
0
class TriggerAddRemoveNveVniMultisiteIngressReplication(TriggerAddRemove):
    """Add multisite ingress replication under vxlan and then restore the
            configuration by reapplying the whole running configuration"""

    __description__ = """Add multisite ingress replication under Vxlan then restore the
                           configuration by reapplying the whole running configuration

           trigger_datafile:
               Mandatory Arguments:
                   timeout:
                       max_time (`int`): Maximum wait time for the trigger in seconds.
                                         Default: 180
                       interval (`int`): Wait time between iteration when looping is
                                         needed in seconds. Default: 15
                       method (`str`): Method to recover the device configuration.
                                       Supported methods:
                                           'checkpoint': Rollback the configuration
                                                         using checkpoint (nxos),
                                                         archive file (iosxe),
                                                         load the saved running-config
                                                         file on disk (iosxr)
               Optional Arguments:
                   tgn_timeout (`int`): Maximum wait time for all traffic streams to be
                                        restored to the reference rate in seconds.
                                        Default: 60
                   tgn_delay (`int`): Wait time between each poll to verify if traffic
                                      is resumed in seconds. 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 seconds. Default: 180
                       interval (`int`): Wait time between iteration when looping is
                                         needed in seconds. Default: 15
                   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.

                       nve_name: `str`
                       nve_vni: `int`

                       (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                             OR
                             interface: 'Ethernet1/1/1' (Specific value)

           Steps:
               1. Learn Vxlan Ops configured on device. SKIP the trigger if there
                  is no vxlan configured on the device.
               2. Save the current device configurations using "method" specified.
               3. Add multisite ingress replication that using Genie Interface Conf.
               4. Verify the newly multisite ingress replication under Vxlan is reflected in
                  device configuration.
               5. Restore the device configuration to the original configuration saved
                  in step 2.
               6. 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', '(?P<nve_name>.*)', 'vni', '(?P<nve_vni>.*)',\
                                                          NotExists('multisite_ingress_replication')],
                                                         ['nve', '(?P<nve_name>.*)', 'vni', '(?P<nve_vni>.*)', 'associated_vrf', False]],
                                        'kwargs': {'attributes': ['nve[(.*)][vni][(.*)]']},
                                        'all_keys': True,
                                        'exclude': vxlan_exclude}},
                        config_info={'conf.interface.Interface': {
                                        'requirements': [['nve_vni', '(?P<nve_vni>.*)'],
                                                         ['nve_vni_multisite_ingress_replication', True],
                                                         ['nve_vni_associate_vrf', False]],
                                        'verify_conf': False,
                                        'kwargs': {'mandatory': {'name': '(?P<nve_name>.*)', 'attach': False}}}},
                        verify_ops={'ops.vxlan.vxlan.Vxlan': {
                                        'requirements': [['nve', '(?P<nve_name>.*)', 'vni', '(?P<nve_vni>.*)',\
                                                          'multisite_ingress_replication', True]],
                                        'kwargs': {'attributes': ['nve[(.*)][vni][(.*)]']},
                                        'exclude': vxlan_exclude}},
                        num_values={'nve_name': 1, 'nve_vni':1 })
Exemplo n.º 8
0
class TriggerShutNoShutLoopbackInterface(TriggerShutNoShut):
    """Shut and unshut the dynamically learned loopback interface(s)."""

    __description__ = """Shut and unshut the dynamically learned loopback interface(s).

           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
                   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
                   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.

                       interface: `str`

                      (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                            OR
                            interface: 'Ethernet1/1/1' (Specific value)
           steps:
               1. Learn Interface Ops object and store the "up" loopback interface(s)
                  if has any, otherwise, SKIP the trigger.
               2. Shut the learned loopback interface(s) from step 1 with Interface Conf object
               3. Verify the state of learned loopback interface(s) from step 2 is "down"
               4. Unshut the loopback interface(s) with Interface Conf object
               5. Learn Interface Ops again and verify it is the same as the Ops in step 1

           """

    # 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<interface>(Loopback|Lo|loopback)[0-9]+)',
                    'oper_status', 'up'
                ],
                 [
                     'info', '(?P<interface>(Loopback|Lo|loopback)[0-9]+)',
                     '(?P<af>ipv4|6)',
                     NotExists('unnumbered')
                 ]],
                'exclude':
                interface_exclude
            }
        },
        config_info={
            'conf.interface.Interface': {
                'requirements': [['enabled', False]],
                'verify_conf': False,
                'kwargs': {
                    'mandatory': {
                        'name': '(?P<interface>.*)',
                        'attach': False
                    }
                }
            }
        },
        verify_ops={
            'ops.interface.interface.Interface': {
                'requirements':
                [['info', '(?P<interface>.*)', 'enabled', False],
                 ['info', '(?P<interface>.*)', 'oper_status', 'down']],
                'exclude':
                interface_exclude
            }
        },
        num_values={'interface': 1})
Exemplo n.º 9
0
class TriggerShutNoShutDot1xInterface(TriggerShutNoShut):
    """Shut and unshut the dynamically learned Dot1x Ethernet interface(s)."""

    __description__ = """Shut and unshut the dynamically learned Dot1x Ethernet interface(s).

    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
            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
            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.

                interface: `str`
                vlan: `str`
                client: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Interface Ops object and store the "up" Ethernet interface(s)
           if has any, otherwise, SKIP the trigger, then check if the status of dot1x is 'auth',
           and the peer mac-address in UUT's table is 'static', if not, SKIP the trigger
           And Learn Dot1x Ops object and store the dot1x interface whcih are from the
           interface ops.
        2. Shut the learned Dot1x Ethernet interface(s) from step 1 with Interface Conf object
        3. Verify the state of learned Dot1x Ethernet interface(s) from step 2 is "down"
        4. Unshut the Dot1x Ethernet interface(s) with Interface Conf object
        5. Learn Interface Ops again and verify it is the same as the Ops in step 1

    """

    # 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<interface>\w+Ethernet[\d\/]+$)', 'enabled',
                    True
                ], ['info', '(?P<interface>.*)', 'switchport_enable', True],
                 [
                     'info', '(?P<interface>.*)', 'switchport_mode',
                     'static access'
                 ], ['info', '(?P<interface>.*)', 'oper_status', 'up']],
                'all_keys':
                True,
                'kwargs': {
                    'attributes': [
                        'info[(.*)][switchport_mode]',
                        'info[(.*)][oper_status]', 'info[(.*)][enabled]',
                        'info[(.*)][switchport_enable]',
                        'info[(.*)][operational_mode]'
                    ]
                },
                'exclude':
                interface_exclude
            },
            'ops.fdb.fdb.Fdb': {
                'requirements': [
                    [
                        'info', 'mac_table', 'vlans', '(?P<vlan>.*)',
                        'mac_addresses', '(?P<client>.*)', 'interfaces',
                        '(?P<interface>.*)', 'entry_type', 'static'
                    ]
                ],
                'all_keys':
                True,
                'kwargs': {
                    'attributes': ['info[mac_table][vlans][(.*)]']
                },
                'exclude':
                fdb_exclude + ['mac_addresses']
            },
            'ops.dot1x.dot1x.Dot1x': {
                'requirements': [
                    [
                        'info', 'interfaces', '(?P<interface>.*)', 'clients',
                        '(?P<client>.*)', 'status', 'authorized'
                    ]
                ],
                'kwargs': {
                    'attributes':
                    ['info[interfaces][(.*)][clients][(.*)][status]']
                },
                'all_keys':
                True,
                'exclude':
                dot1x_exclude
            }
        },
        config_info={
            'conf.interface.Interface': {
                'requirements': [['enabled', False]],
                'verify_conf': False,
                'kwargs': {
                    'mandatory': {
                        'name': '(?P<interface>.*)',
                        'attach': False
                    }
                }
            }
        },
        verify_ops={
            'ops.interface.interface.Interface': {
                'requirements':
                [['info', '(?P<interface>.*)', 'enabled', False],
                 ['info', '(?P<interface>.*)', 'oper_status', 'down'],
                 ['info', '(?P<interface>.*)', 'switchport_enable', False]],
                'kwargs': {
                    'attributes':
                    [
                        'info[(.*)][switchport_mode]',
                        'info[(.*)][oper_status]', 'info[(.*)][enabled]',
                        'info[(.*)][switchport_enable]',
                        'info[(.*)][operational_mode]'
                    ]
                },
                'exclude':
                interface_exclude
            },
            'ops.fdb.fdb.Fdb': {
                'requirements': [[
                    'info', 'mac_table', 'vlans', '(?P<vlan>.*)',
                    'mac_addresses',
                    NotExists('(?P<client>.*)')
                ]],
                'kwargs': {
                    'attributes':
                    ['info[mac_table][vlans][(.*)]']
                },
                'exclude':
                fdb_exclude +
                ['mac_addresses']
            },
            'ops.dot1x.dot1x.Dot1x': {
                'requirements':
                [['info', 'interfaces',
                  NotExists('(?P<interface>.*)')]],
                'kwargs': {
                    'attributes':
                    ['info[interfaces][(.*)][clients][(.*)][status]']
                },
                'all_keys':
                True,
                'exclude':
                dot1x_exclude + ['attributes']
            }
        },
        num_values={'interface': 'all'})
Exemplo n.º 10
0
class TriggerUnconfigConfigPimNbrVrfInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the dynamically learned pim neighbor interface(s) under non-default vrf."""

    __description__ = """Unconfigure and reapply the dynamically learned
    pim neighbor interface(s) under non-default vrf.

    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
            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 Pim Ops object and verify if has any "up" pim neighbor
           interface(s) under non-default vrf, otherwise, SKIP the trigger
        2. Unconfigure the learned pim neighbor interface(s) from step 1 with Interface Conf object
        3. Verify the state of learned pim neighbor interface(s) from step 2 is removed
        4. Reapply the configuration of pim neighbor interface(s) with checkpoint
        5. Learn Pim Ops again and verify it is the same as the Ops in step 1
        
    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(
        requirements={
            'ops.pim.pim.Pim': {
                'requirements':
                [[
                    'info', 'vrf', '(?P<vrf>^(?!default)\w+$)', 'interfaces',
                    '(?P<pim_intf>(Ethernet\d+\/\d+\.\d+)|(Loopback\d+))',
                    'address_family', '(?P<af>.*)', 'oper_status', 'up'
                ],
                 [
                     'info', 'vrf', '(?P<vrf>^(?!default)\w+$)', 'interfaces',
                     '(?P<pim_intf>(Ethernet\d+\/\d+\.\d+)|(Loopback\d+))',
                     'address_family', '(?P<af>.*)', 'neighbors',
                     '(?P<address>.*)'
                 ]],
                'kwargs': {
                    'attributes': [
                        'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][oper_status]',
                        'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][neighbors]'
                    ]
                },
                'exclude':
                pim_exclude
            },
            'ops.interface.interface.Interface': {
                'requirements': [
                    [
                        'info', '(?P<pim_intf>(Ethernet\d+\/\d+\.\d+)|(Loopback\d+))',
                        'vrf', '(?P<vrf>.*)'
                    ],
                    [
                        'info',
                        '(?P<pim_intf>(Ethernet\d+\/\d+\.\d+)|(Loopback\d+))',
                        'oper_status', 'up'
                    ]
                ],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][vrf]', 'info[(.*)][oper_status]']
                },
                'exclude':
                interface_exclude
            }
        },
        config_info={
            'conf.interface.Interface': {
                'requirements': [],
                'verify_conf': False,
                'kwargs': {
                    'mandatory': {
                        'name': '(?P<pim_intf>.*)',
                        'attach': False
                    }
                }
            }
        },
        verify_ops={
            'ops.interface.interface.Interface': {
                'requirements':
                [['info',
                  NotExists('(?P<pim_intf>.*)')]],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][vrf]', 'info[(.*)][oper_status]']
                },
                'exclude': interface_exclude
            },
            'ops.pim.pim.Pim': {
                'requirements': [[
                    'info', 'vrf', '(?P<vrf>^(?!default)\w+$)', 'interfaces',
                    NotExists('(?P<pim_intf>.*)')
                ]],
                'kwargs': {
                    'attributes':
                    [
                        'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][oper_status]',
                        'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][neighbors]'
                    ]
                },
                'exclude':
                pim_exclude
            }
        },
        num_values={
            'pim_intf': 1,
            'vrf': 'all'
        })
Exemplo n.º 11
0
class TriggerUnconfigConfigMsdpOriginatorId(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically
    learned MSDP originator-id."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically
    learned MSDP originator-id.

    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
            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.

                vrf: `str`
                peer: `str`
                originator_id: `str`
                originating_rp: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Msdp Ops object and store the MSDP originator-id
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned MSDP originator-id from step 1 
           with Msdp Conf object
        4. Verify the MSDP originator-id from step 3 are no longer existed
        5. Recover the device configurations to the one in step 2
        6. Learn Msdp Ops again and verify it is the same as the Ops in step 1

    """
    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(requirements={'ops.msdp.msdp.Msdp':{
                                          'requirements':[\
                                              ['info', 'vrf', '(?P<vrf>.*)', 'global',
                                               'originator_id', '(?P<originator_id>.*)']],
                                          'kwargs':{'attributes': [
                                              'info[vrf][(.*)][global][originator_id]',
                                              'info[vrf][(.*)][peer][(.*)][session_state]']},
                                          'exclude': msdp_exclude},
                                    'conf.msdp.Msdp':{
                                          'requirements':[\
                                              ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)',
                                               'originating_rp', '(?P<originating_rp>.*)']],
                                          'kwargs':{'attributes': [
                                              'msdp[vrf_attr][(.*)][originating_rp]']},
                                          'exclude': msdp_exclude}},
                      config_info={'conf.msdp.Msdp':{
                                       'requirements':[
                                         ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)',
                                          'originating_rp', '(?P<originating_rp>.*)']],
                                       'verify_conf':False,
                                       'kwargs':{}}},
                      verify_ops={'conf.msdp.Msdp':{
                                    'requirements':[\
                                        ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)',
                                         NotExists('originating_rp')]], # , '(?P<originating_rp>.*)'
                                    'kwargs':{'attributes': [
                                                  'info[vrf][(.*)][originating_rp]',
                                                  'info[vrf][(.*)][peer][(.*)][session_state]']},
                                    'exclude': msdp_exclude}},
                      num_values={'vrf': 1, 'peer':1})
Exemplo n.º 12
0
class TriggerUnconfigConfigVxlanNveOverlayInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the dynamically learned Nve onverlay interface(s)."""

    __description__ = """Unconfigure and reapply the dynamically learned Nve onverlay interface(s).

    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
            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 has any "up" Nve interface(s),
           otherwise, SKIP the trigger
        2. Unconfigure the learned Nve interface(s) from step 1 with Interface Conf object
        3. Verify the state of learned Nve interface(s) from step 2 is removed
        4. Reapply the configuration of Nve interface(s) with checkpoint
        5. Learn VxLan Ops again and verify it is the same as the Ops in step 1
        
    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(
        requirements={
            'ops.vxlan.vxlan.Vxlan': {
                'requirements': [['nve', '(?P<name>.*)', 'if_state', 'up']],
                'kwargs': {
                    'attributes': [
                        'nve[(.*)][if_state]', 'nve[(.*)][vni][(.*)][vni]',
                        'l2route', 'bgp_l2vpn_evpn'
                    ]
                },
                'exclude':
                nve_exclude + multisite_exclude + [
                    'tx_id', 'flags', 'peer_id', 'pathnr', 'bestpathnr',
                    'advertisedto', 'prefixversion', 'prefixreceived', 'mac',
                    'prefix', 'bytesattrs', 'memoryused', 'totalpaths',
                    'numberattrs', 'mac_ip', 'memory', 'objects', 'total_mem',
                    'total_obj', 'total_memory', 'totalnetworks'
                ]
            }
        },
        config_info={
            'conf.interface.Interface': {
                'requirements': [],
                'verify_conf': False,
                'kwargs': {
                    'mandatory': {
                        'name': '(?P<name>.*)',
                        'attach': False
                    }
                }
            }
        },
        verify_ops={
            'ops.vxlan.vxlan.Vxlan': {
                'requirements': [
                    [NotExists('nve')]
                ],  # enh to support or() could be [['nve', NotExists('(?P<name>.*)')]]
                'kwargs': {
                    'attributes': [
                        'nve[(.*)][if_state]', 'nve[(.*)][vni][(.*)][vni]',
                        'l2route', 'bgp_l2vpn_evpn'
                    ]
                },
                'exclude': nve_exclude + ['l2route', 'bgp_l2vpn_evpn']
            }
        },
        num_values={'name': 1})
Exemplo n.º 13
0
class TriggerUnconfigConfigAutoRpInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the dynamically learned pim auto-rp interface(s) under default vrf."""

    __description__ = """Unconfigure and reapply the dynamically learned pim auto-rp interface(s) under default vrf.

    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
            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 Pim Ops object and verify if has any "up"  pim auto-rp
           interface(s) under default vrf, otherwise, SKIP the trigger
        2. Unconfigure the learned pim auto-rp interface(s) from step 1 with Interface Conf object
        3. Verify the state of learned pim auto-rp interface(s) from step 2 is removed
        4. Reapply the configuration of pim auto-rp interface(s) with checkpoint
        5. Learn Pim Ops again and verify it is the same as the Ops in step 1
        
    """

    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(requirements={
        'conf.pim.Pim': {
            'requirements': [[
                'device_attr', '{uut}', '_vrf_attr', '(?P<vrf>^default$)',
                '_address_family_attr', '(?P<af>ipv4)',
                'send_rp_announce_intf', '(?P<rp_intf>(l|L)oopback\d+)'
            ]],
            'kwargs': {
                'attributes': [
                    'pim[vrf_attr][(.*)][address_family_attr][ipv4][send_rp_announce_intf]'
                ]
            },
            'exclude':
            pim_conf_exclude
        }
    },
                      config_info={
                          'conf.interface.Interface': {
                              'requirements': [],
                              'verify_conf': False,
                              'kwargs': {
                                  'mandatory': {
                                      'name': '(?P<rp_intf>.*)',
                                      'attach': False
                                  }
                              }
                          }
                      },
                      verify_ops={
                          'ops.interface.interface.Interface': {
                              'requirements':
                              [['info', NotExists('(?P<rp_intf>.*)')]],
                              'kwargs': {
                                  'attributes': ['info[(.*)][enabled]']
                              },
                              'exclude':
                              interface_exclude
                          }
                      },
                      num_values={'rp_intf': 1})
Exemplo n.º 14
0
class TriggerUnconfigConfigMldStaticGroup(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically
    learned enabled Mld interface(s)'s static-groups."""

    __description__ = """Unconfigure and reapply the whole configurations
    of dynamically learned enabled Mld interface(s)'s static-groups.

    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
            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.

                interface: `str`
                vrf: `str`
                group: `str`
                static_group: `str`
                source: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)

    steps:
        1. Learn Mld Ops object and store the enabled Mld interface(s)'s static-groups
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned Mld interface(s)'s static-groups from step 1 
           with Mld Conf object
        4. Verify the Mld interface(s)'s static-groups from step 3
           are no longer existed
        5. Recover the device configurations to the one in step 2
        6. Learn Mld Ops again and verify it is the same as the Ops in step 1

    """
    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(requirements={
                          'ops.mld.mld.Mld':{
                                'requirements':[\
                                    ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<interface>.*)', 'static_group', '(?P<static_group>.*)',
                                     'group', '(?P<group>.*)'],
                                    ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<interface>.*)', 'static_group', '(?P<static_group>.*)',
                                     'source', '(?P<source>\*)']],
                                'all_keys': True,
                                'kwargs':{'attributes': [
                                    'info[vrfs][(.*)][interfaces][(.*)][join_group]',
                                    'info[vrfs][(.*)][interfaces][(.*)][static_group]',
                                    'info[vrfs][(.*)][interfaces][(.*)][group]']},
                                'exclude': mld_exclude + ['last_reporter']}},
                      config_info={'conf.mld.Mld':{
                                       'requirements':[
                                         [partial(configure_add_attributes,  # callable configuration
                                            add_obj=MldGroup,
                                            base=[['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)',
                                                  'interface_attr', '(?P<interface>.*)']],
                                            add_attribute=[['static_group', '(?P<group>.*)'],
                                                           ['static_group_source_addr', '(?P<source>.*)'],],
                                            add_method='add_groups',
                                        )]],
                                       'verify_conf':False,
                                       'kwargs':{}}},
                      verify_ops={
                          'ops.mld.mld.Mld':{
                                'requirements': [[partial(verify_ops_or_logic,
                                                      requires=[['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', 'static_group',
                                                                 NotExists('(?P<static_group>.*)')],
                                                                ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', NotExists('static_group')],
                                                                ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', 'static_group',
                                                                 '(?P<static_group>.*)', '(.*)']
                                                               ])
                                                  ],
                                                  [partial(verify_ops_or_logic,
                                                      requires=[['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', 'group', NotExists('(?P<group>.*)')],
                                                                ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', NotExists('group')],
                                                                ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', 'group', '(?P<group>.*)',
                                                                 'source', NotExists('(?P<source>\*)')],
                                                                ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', 'group', '(?P<group>.*)',
                                                                 NotExists('source')]
                                                               ])
                                                  ],
                                                ],
                                'kwargs':{'attributes': [
                                    'info[vrfs][(.*)][interfaces][(.*)][join_group]',
                                    'info[vrfs][(.*)][interfaces][(.*)][static_group]',
                                    'info[vrfs][(.*)][interfaces][(.*)][group]']},
                                'exclude': mld_exclude + ['last_reporter']}},
                      num_values={'vrf': 1, 'interface': 1, 'static_group': 1, 'group': 1})
Exemplo n.º 15
0
class TriggerUnconfigConfigPimNeighborFilter(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically
    learned PIM interface(s)'s neighbor-filter."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically
    learned PIM interface(s)'s neighbor-filter.

    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
            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.

                vrf: `str`
                interface: `str`
                address_family: `str`
                neighbor_filter: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Pim Ops object and store the "up" PIM interface(s)'s neighbor-filter
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned PIM interface(s)'s neighbor-filter from step 1 
           with Pim Conf object
        4. Verify the PIM interface(s)'s neighbor-filter from step 3
           are no longer existed
        5. Recover the device configurations to the one in step 2
        6. Learn Pim Ops again and verify it is the same as the Ops in step 1

    """
    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(requirements={
                          'ops.pim.pim.Pim':{
                                'requirements':[\
                                    ['info', 'vrf', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<interface>.*)', 'address_family', '(?P<address_family>.*)',
                                     'neighbor_filter', '(?P<neighbor_filter>.*)'],
                                    ['info', 'vrf', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<interface>.*)', 'address_family', '(?P<address_family>.*)',
                                     'oper_status', 'up']],
                                'kwargs':{'attributes': [
                                    'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][oper_status]',
                                    'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][neighbor_filter]']},
                                'exclude': pim_exclude}},
                      config_info={'conf.pim.Pim':{
                                       'requirements':[
                                         ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)',
                                          'address_family_attr', '(?P<address_family>.*)', 'interface_attr',
                                          '(?P<interface>.*)', 'neighbor_filter', '(?P<neighbor_filter>.*)']],
                                       'verify_conf':False,
                                       'kwargs':{}}},
                      verify_ops={
                          'ops.pim.pim.Pim':{
                                'requirements':[\
                                    ['info', 'vrf', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<interface>.*)', 'address_family', '(?P<address_family>.*)',
                                     NotExists('neighbor_filter')]],
                                'kwargs':{'attributes': [
                                    'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][oper_status]',
                                    'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][neighbor_filter]']},
                                'exclude': pim_exclude}},
                      num_values={'vrf': 1, 'address_family': 1, 'interface': 1})
Exemplo n.º 16
0
class TriggerUnconfigConfigBgpVpnRd(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically
    learned BGP vrf(s) route-distinguisher."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically
    learned BGP vrf(s) route-distinguisher.
    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 when the previous timeout has been exhausted,
                to make sure the devices are recovered before ending the trigger
                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
           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.
                instance: `str`
                vrf: `str`
                neighbor: `str`
                address_family: `str`
                rd: `str`
                default_vrf: `str`
                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn BGP Ops object and store the BGP vrf(s) with route_distinguisher
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned BGP vrf(s) route-distinguisher from step 1 
           with BGP Conf object
        4. Verify the BGP vrf(s) route_distinguisher from step 3 are no longer existed
        5. Recover the device configurations to the one in step 2
        6. Learn BGP Ops again and verify it is the same as the Ops in step 1
    """

    @aetest.test
    def verify_unconfigure(self, uut, abstract, steps):
        time.sleep(120)
        super().verify_unconfigure(uut, abstract, steps)

    mapping = Mapping(requirements={
        'ops.bgp.bgp.Bgp': {
            'requirements': [[
                'table', 'instance', '(?P<instance>.*)', 'vrf', '(?P<vrf>.*)',
                'address_family', '(?P<address_family>.*)',
                'route_distinguisher', '(?P<rd>.*)'
            ]],
            'kwargs': {
                'attributes': ['table', 'info']
            },
            'exclude':
            bgp_exclude + ['table_version']
        },
        'ops.vrf.vrf.Vrf': {
            'requirements': [[
                'info', 'vrfs', '(?P<vrf>.*)', 'route_distinguisher',
                '(?P<rd>.*)'
            ]],
            'kwargs': {
                'attributes': ['info']
            },
            'exclude': ['maker']
        }
    },
                      config_info={
                          'conf.vrf.Vrf': {
                              'requirements':
                              [['device_attr', '{uut}', 'rd', '(?P<rd>.*)']],
                              'verify_conf':
                              False,
                              'kwargs': {
                                  'mandatory': {
                                      'name': '(?P<vrf>.*)'
                                  }
                              }
                          }
                      },
                      verify_ops={
                          'ops.bgp.bgp.Bgp': {
                              'requirements': [[
                                  'table', 'instance', '(?P<instance>.*)',
                                  'vrf',
                                  NotExists('(?P<vrf>.*)')
                              ]],
                              'kwargs': {
                                  'attributes': ['table', 'info']
                              },
                              'exclude':
                              bgp_exclude + [
                                  'label_allocation_mode', 'vpnv4 unicast',
                                  'vpnv6 unicast', 'table_version'
                              ]
                          },
                          'ops.vrf.vrf.Vrf': {
                              'requirements': [[
                                  'info', 'vrfs', '(?P<vrf>.*)',
                                  NotExists('route_distinguisher')
                              ]],
                              'kwargs': {
                                  'attributes': ['info']
                              },
                              'exclude': ['maker']
                          }
                      },
                      num_values={
                          'vrf': 'all',
                          'instance': 1,
                          'address_family': 'all',
                          'rd': 1,
                      })
Exemplo n.º 17
0
class TriggerUnconfigConfigNveVni(TriggerUnconfigConfig):
    """Unconfigure NVE L2 or L3 VNI and reapply the whole configurations of dynamically learned Nve(s)."""

    __description__ = """Unconfigure nve L2 or L3 VNI and reapply the whole configurations of dynamically learned Nve(s).

       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 when the previous timeout has been exhausted,
                 to make sure the devices are recovered before ending the trigger

                 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
             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.

                  nve_name: `str`
                  nve_vni: `str`

                  (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                        OR
                        interface: 'Ethernet1/1/1' (Specific value)
       steps:
         1. Learn Vxlan Ops object and store the nve information under nve if has any,
            otherwise, SKIP the trigger
         2. Save the current device configurations through "method" which user uses
         3. Unconfigure the nve_vni with Interface Conf object
         4. Verify the nve_vni from step 3 no longer exists
         5. Recover the device configurations to the one in step 2
         6. 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', '(?P<nve_name>nve.*)', 'vni', '(?P<nve_vni>.*)', 'vni_state', 'Up'],
                                                         ['nve', '(?P<nve_name>nve.*)', 'admin_state','Up'],
                                                         ['nve', '(?P<nve_name>nve.*)', 'oper_state','Up']],
                                        'kwargs': {'attributes': ['nve[(.*)]']},
                                        'all_keys': True,
                                        'exclude': vxlan_vni_exclude}},
                      config_info={'conf.interface.Interface': {
                                        'requirements': [['nve_vni','(?P<nve_vni>.*)']],
                                        'verify_conf': False,
                                        'kwargs': {'mandatory': {'name': '(?P<nve_name>nve.*)', 'attach': False}}}},
                      verify_ops={'ops.vxlan.vxlan.Vxlan': {
                                        'requirements': [['nve', '(?P<nve_name>nve.*)', 'vni', NotExists('(?P<nve_vni>.*)')]],
                                        'kwargs': {'attributes': ['nve[(.*)]']},
                                        'all_keys': True,
                                        'exclude': vxlan_vni_exclude}},
                      num_values={'nve_name':1 , 'nve_vni':1 })
Exemplo n.º 18
0
class TriggerUnconfigConfigBgp(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically learned BGP instance(s)."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically learned BGP instance(s).

    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
            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.

                bgp_id: `int`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn BGP Ops object and store the BGP instance(s)
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned BGP instance(s) from step 1
           with BGP Conf object
        4. Verify the BGP instance(s) from step 3 are no longer existed
        5. Recover the device configurations to the one in step 2
        6. Learn BGP Ops again and verify it is the same as the Ops in step 1

    """

    mapping = Mapping(requirements={
        'ops.bgp.bgp.Bgp': {
            'requirements': [[
                'info', 'instance', '(?P<instance>.*)', 'bgp_id',
                '(?P<bgp_id>.*)'
            ]],
            'kwargs': {
                'attributes': ['info']
            },
            'exclude':
            bgp_exclude
        }
    },
                      config_info={
                          'conf.bgp.Bgp': {
                              'requirements': [['device_attr', '{uut}']],
                              'verify_conf': False,
                              'kwargs': {
                                  'mandatory': {
                                      'bgp_id': '(?P<bgp_id>.*)'
                                  }
                              }
                          }
                      },
                      verify_ops={
                          'ops.bgp.bgp.Bgp': {
                              'requirements': [[NotExists('info')]],
                              'kwargs': {
                                  'attributes': ['info']
                              },
                              'exclude': bgp_exclude
                          }
                      },
                      num_values={
                          'bgp_id': 'all',
                          'instance': 'all'
                      })
Exemplo n.º 19
0
class TriggerAddRemoveEvpnMsiteBgwDelayRestoreTime(TriggerAddRemove):
    """Add msite bgw delay restore time under vxlan and then restore the
        configuration by reapplying the whole running configuration"""

    __description__ = """Add msite bgw delay restore time under Vxlan then restore the
                       configuration by reapplying the whole running configuration

           trigger_datafile:
               Mandatory Arguments:
                   timeout:
                       max_time (`int`): Maximum wait time for the trigger in seconds.
                                         Default: 180
                       interval (`int`): Wait time between iteration when looping is
                                         needed in seconds. Default: 15
                       method (`str`): Method to recover the device configuration.
                                       Supported methods:
                                           'checkpoint': Rollback the configuration
                                                         using checkpoint (nxos),
                                                         archive file (iosxe),
                                                         load the saved running-config
                                                         file on disk (iosxr)
               Optional Arguments:
                   tgn_timeout (`int`): Maximum wait time for all traffic streams to be
                                        restored to the reference rate in seconds.
                                        Default: 60
                   tgn_delay (`int`): Wait time between each poll to verify if traffic
                                      is resumed in seconds. 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 seconds. Default: 180
                       interval (`int`): Wait time between iteration when looping is
                                         needed in seconds. Default: 15
                   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.

                       evpn_multisite_border_gateway: `int`

                       (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                             OR
                             interface: 'Ethernet1/1/1' (Specific value)
           Steps:
               1. Learn Vxlan Ops configured on device. SKIP the trigger if there
                  is no Vxlan configured on the device.
               2. Save the current device configurations using "method" specified.
               3. Add msite bgw delay restore time that using Genie Vxlan Conf.
               4. Verify the newly msite bgw delay restore time under Vxlan is reflected in
                  device configuration.
               5. Restore the device configuration to the original configuration saved
                  in step 2.
               6. 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', 'evpn_multisite_border_gateway', '(?P<evpn_multisite_border_gateway>.*)'],
                                                         ['nve', NotExists('multisite_convergence_time'), NotExists('(.*)')]],
                                        'kwargs': {'attributes': ['nve[(.*)][vni][(.*)]',
                                                                  'nve[evpn_multisite_border_gateway]',
                                                                  'nve[multisite_convergence_time]','bgp_l2vpn_evpn','l2route']},
                                        'all_keys': True,
                                        'exclude': vxlan_exclude + multisite_exclude + ['flags'] }},
                    config_info={'conf.vxlan.Vxlan': {
                                        'requirements': [['device_attr', '{uut}', 'evpn_msite_attr', '(?P<evpn_multisite_border_gateway>.*)',\
                                                          'evpn_msite_bgw_delay_restore_time', 30]],
                                        'verify_conf': False,
                                        'kwargs': {}}},
                    verify_ops={'ops.vxlan.vxlan.Vxlan': {
                                        'requirements': [['nve', 'multisite_convergence_time', 30]],
                                        'kwargs': {'attributes': ['nve[(.*)][vni][(.*)]',
                                                                  'nve[evpn_multisite_border_gateway]',
                                                                  'nve[multisite_convergence_time]','bgp_l2vpn_evpn','l2route']},
                                        'exclude': vxlan_exclude+ ['bgp_l2vpn_evpn','l2route'] }},
                    num_values={'nve_name': 1, 'nve_vni':1 ,'evpn_multisite_border_gateway':1 })
Exemplo n.º 20
0
class TriggerUnconfigConfigEthernetInterface(UncfgCfgInterface):
    """Unconfigure and reapply the whole configurations of dynamically learned ethernet interface(s)."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically learned ethernet interface(s).

    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
            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.

                interface: `str`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Interface Ops object and store the "up" ethernet interface(s)
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned ethernet interface(s) from step 1
           with Interface Conf object
        4. Verify the learned ethernet interface(s) are "down"
        5. Recover the device configurations to the one in step 2
        6. Learn Interface Ops again and verify it is the same as the Ops in step 1

    """

    mapping = Mapping(requirements={'ops.interface.interface.Interface':{
                                        'requirements':[['info', '(?P<interface>\w+Ethernet[0-9\/]+$)', 'enabled', True],
                                                        ['info', '(?P<interface>.*)', 'port_channel', 'port_channel_member', False],
                                                        ['info', '(?P<interface>.*)', 'oper_status', 'up']],
                                        'exclude': interface_exclude,
                                        'include_management_interface': False}},
                      config_info={'conf.interface.Interface':{
                                        'requirements':[],
                                        'verify_conf':False,
                                        'kwargs':{'mandatory':{'name': '(?P<interface>.*)',
                                                               'attach': False}}}},
                      verify_ops={'ops.interface.interface.Interface':{
                                        'requirements':[['info', '(?P<interface>.*)', NotExists('access_vlan')],
                                                        ['info', '(?P<interface>.*)', 'switchport_enable', False],
                                                        ['info', '(?P<interface>.*)', NotExists('switchport_mode')],
                                                        ['info', '(?P<interface>.*)', NotExists('trunk_vlans')],
                                                        ['info', '(?P<interface>.*)', NotExists('vrf')],
                                                        ['info', '(?P<interface>.*)', 'enabled', False],
                                                        ['info', '(?P<interface>.*)', NotExists('duplex_mode')],
                                                        ['info', '(?P<interface>.*)', NotExists('mac_address')],
                                                        ['info', '(?P<interface>.*)', 'oper_status', '(.*down.*)']],
                                        'exclude': interface_exclude +\
                                                   [UncfgCfgInterface.remove_related_subinterface]}},
                      num_values={'interface': 1})
Exemplo n.º 21
0
class TriggerAddRemoveNveMultisiteBgwInterface(TriggerAddRemove):
    """Add multisite bgw interface under vxlan and then restore the
       configuration by reapplying the whole running configuration"""

    __description__ = """Add Add multisite bgw interface under Vxlan then restore the
                          configuration by reapplying the whole running configuration

              trigger_datafile:
                  Mandatory Arguments:
                      timeout:
                          max_time (`int`): Maximum wait time for the trigger in seconds.
                                            Default: 180
                          interval (`int`): Wait time between iteration when looping is
                                            needed in seconds. Default: 15
                          method (`str`): Method to recover the device configuration.
                                          Supported methods:
                                              'checkpoint': Rollback the configuration
                                                            using checkpoint (nxos),
                                                            archive file (iosxe),
                                                            load the saved running-config
                                                            file on disk (iosxr)
                  Optional Arguments:
                      tgn_timeout (`int`): Maximum wait time for all traffic streams to be
                                           restored to the reference rate in seconds.
                                           Default: 60
                      tgn_delay (`int`): Wait time between each poll to verify if traffic
                                         is resumed in seconds. 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 seconds. Default: 180
                          interval (`int`): Wait time between iteration when looping is
                                            needed in seconds. Default: 15
                      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.

                          nve_name: `str`
                          source_if: `str`

                          (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                                OR
                                interface: 'Ethernet1/1/1' (Specific value)

              Steps:
                  1. Learn Vxlan Ops configured on device. SKIP the trigger if there
                     is no Vxlan configured on the device.
                  2. Save the current device configurations using "method" specified.
                  3. Add multisite bgw interface that using Genie Interface Conf.
                  4. Verify the newly multisite bgw interface under Vxlan is reflected in
                     device configuration.
                  5. Restore the device configuration to the original configuration saved
                     in step 2.
                  6. Learn Vxlan Ops again and verify it is the same as the Ops in step 1.
              """

    # configuration steps callable
    # adding new value for multisite bgw interface
    def configure_multisite_bgw_interface(self, conf_obj, unconfig, **kwargs):
        ret = ""
        for key in self.keys:
            if key['source_if'] != key['intf_name']:
                ret = key['intf_name']

        self.keys[0]['multisite_bgw_intf'] = ret
        conf_obj.nve_multisite_bgw_intf = ret
        if not unconfig:
            conf_obj.build_config()
        else:
            conf_obj.build_unconfig(apply=True,
                                    attributes={'nve_multisite_bgw_intf': ret})

        @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<nve_name>.*)', '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)


    mapping = Mapping(requirements={'ops.vxlan.vxlan.Vxlan':{
                                            'requirements': [[['nve', '(?P<nve_name>.*)', 'source_if', '(?P<source_if>.*)']],
                                                             [['nve', '(?P<nve_name>.*)', NotExists('multisite_bgw_if')]]],
                                            'all_keys': True,
                                            'kwargs': {'attributes': ['nve']},
                                            'exclude': vxlan_exclude},
                                    'ops.interface.interface.Interface':{
                                            'requirements': [['info', '(?P<intf_name>loopback.*)', 'oper_status', 'up']],
                                            'kwargs': {'attributes': ['info']},
                                            'exclude': interface_exclude}},
                        config_info={'conf.interface.Interface': {
                                            'requirements': [[partial(configure_multisite_bgw_interface,\
                                                                      nve_multisite_bgw_intf='(?P<source_if>.*)')]],
                                            'verify_conf': False,
                                            'kwargs': {'mandatory': {'name': '(?P<nve_name>.*)', 'attach': False}}}},
                        verify_ops={'ops.vxlan.vxlan.Vxlan': {
                                            'requirements': [],
                                            'kwargs': {'attributes': ['nve']},
                                            'exclude': vxlan_exclude}},
                        num_values={'nve_name':'all', 'source_if': 'all', 'intf_name':'all'})
Exemplo n.º 22
0
class TriggerUnconfigConfigVirtualTrunkInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically learned virtual trunk interface(s)."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically learned virtual trunk interface(s).

        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
                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.

                    interface: `str`

                    (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                          OR
                          interface: 'Ethernet1/1/1' (Specific value)
        steps:
            1. Learn Interface Ops object and store the "up" port-channel interface(s)
               if has any, otherwise, SKIP the trigger
            2. Save the current device configurations through "method" which user uses
            3. Unconfigure the learned port-channel interface(s) from step 1
               with Interface Conf object
            4. Verify the learned port-channel interface(s) no longer exists
            5. Recover the device configurations to the one in step 2
            6. Learn Interface Ops again and verify it is the same as the Ops in step 1

        """

    # 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<interface>[p|P]ort-channel[\d\.]+)',
                                                        'switchport_mode', 'trunk'],
                                                       ['info', '(?P<interface>[p|P]ort-channel[\d\.]+)',
                                                        'port_channel', 'port_channel_member', False]],
                                       'exclude': interface_exclude}},
                      config_info={'conf.interface.Interface':{
                                       'requirements':[],
                                       'verify_conf':False,
                                       'kwargs':{'mandatory':{'name': '(?P<interface>.*)',
                                                              'attach': False}}}},
                      verify_ops={'ops.interface.interface.Interface':{
                                       'requirements':[['info', NotExists('(?P<interface>.*)')]],
                                       'exclude': interface_exclude}},
                      num_values={'interface':1})
Exemplo n.º 23
0
class TriggerAddRemoveVlanIpAclPermit(TriggerAddRemove):
    """Apply the IP acls with L2 ports which is Vlan interfaces to device, and remove the
    added IP acls.
    """

    __description__ = """Apply the IP acls with L2 ports which is Vlan
    interfaces to device, and remove the added IP acls..

    trigger_datafile:
        Mandatory:
            timeout: 
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iterations 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 iterations when looping is needed,
                                in second. Default: 15

    steps:
        1. Learn acl Ops object and store the acls info if has any.
           Learn Interface ops object to select one Vlan interface to add ipv4 icmp acl
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of acl with acl Conf object
        4. Verify the acl from step 3 has configured
        5. Remove the acl configurations.
        6. Recover the device configurations to the one in step 2
        7. Learn acl Ops again and verify it is the same as the Ops in step 1

    """
    ADD_ACL_NAME = 'vlan_ip_acl_permit_add'
    ACTION = 'permit'

    mapping = Mapping(
        requirements={
            'ops.acl.acl.Acl': {
                'requirements': [['info', 'acls',
                                  NotExists(ADD_ACL_NAME)]],
                'exclude': acl_exclude
            },
            'ops.interface.interface.Interface': {
                'requirements': [[
                    'info', '(?P<intf>Vlan[\d]+$)', 'ipv4', '(?P<ip>.*)', 'ip',
                    '(?P<ip_addr>.*)'
                ], ['info', '(?P<intf>Vlan[\d]+$)', 'oper_status', 'up']],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][oper_status]', 'info[(.*)][ipv4]']
                },
                'all_keys':
                True,
                'exclude':
                interface_exclude
            }
        },
        config_info={
            'conf.acl.Acl': {
                'requirements':
                [[
                    'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                    'acl_type', 'ipv4-acl-type'
                ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'actions_forwarding', ACTION
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'protocol', 'icmp'
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'src', 'any'
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'ace_attr', '10', 'dst', 'any'
                 ],
                 [
                     'device_attr', '{uut}', 'acl_attr', ADD_ACL_NAME,
                     'interface_attr', '(?P<intf>.*)', 'if_in', True
                 ]],
                'verify_conf':
                False,
                'kwargs': {}
            }
        },
        verify_ops={
            'ops.acl.acl.Acl': {
                'requirements':
                [['info', 'acls', ADD_ACL_NAME, 'name', ADD_ACL_NAME],
                 ['info', 'acls', ADD_ACL_NAME, 'type', 'ipv4-acl-type'],
                 ['info', 'acls', ADD_ACL_NAME, 'aces', '10', 'name', '10'],
                 [
                     'info', 'acls', ADD_ACL_NAME, 'aces', '10', 'actions',
                     'logging', 'log-none'
                 ],
                 [
                     'info', 'acls', ADD_ACL_NAME, 'aces', '10', 'actions',
                     'forwarding', ACTION
                 ]],
                'kwargs': {
                    'attributes': ['info']
                },
                'exclude':
                acl_exclude
            },
            'ops.interface.interface.Interface': {
                'requirements': [['info', '(?P<intf>.*)', 'oper_status',
                                  'up']],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][oper_status]', 'info[(.*)][ipv4]']
                },
                'exclude': interface_exclude
            }
        },
        num_values={'intf': 1})
Exemplo n.º 24
0
class TriggerAddRemoveRouteTargetMvpn(TriggerAddRemove):
    """Add route-target mvpn then restore the
        configuration by reapplying the whole running configuration"""

    __description__ = """Add route-target mvpn then restore the
                               configuration by re-applying the whole running configuration

       trigger_datafile:
           Mandatory Arguments:
               timeout:
                   max_time (`int`): Maximum wait time for the trigger in seconds.
                                     Default: 180
                   interval (`int`): Wait time between iteration when looping is
                                     needed in seconds. Default: 15
                   method (`str`): Method to recover the device configuration.
                                   Supported methods:
                                       'checkpoint': Rollback the configuration
                                                     using checkpoint (nxos),
                                                     archive file (iosxe),
                                                     load the saved running-config
                                                     file on disk (iosxr)
           Optional Arguments:
               tgn_timeout (`int`): Maximum wait time for all traffic streams to be
                                    restored to the reference rate in seconds.
                                    Default: 60
               tgn_delay (`int`): Wait time between each poll to verify if traffic
                                  is resumed in seconds. 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 seconds. Default: 180
                   interval (`int`): Wait time between iteration when looping is
                                     needed in seconds. Default: 15
               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.

                    vrf: `str`
                    address_family: `str`
                    rt: `str`

                    (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                          OR
                          interface: 'Ethernet1/1/1' (Specific value)
       Steps:
           1. Learn Vrf Conf object configured on device. SKIP the trigger if there
              is no vrf configured on the device.
           2. Save the current device configurations using "method" specified.
           3. Add route-target mvpn that using Genie Vrf Conf.
           4. Verify the newly route-target mvpn under Vrf is reflected in
              device configuration.
           5. Restore the device configuration to the original configuration saved
              in step 2.
           6. Learn Vrf Conf object again and verify it is the same as step 1.
    """

    @aetest.test
    def verify_configuration(self, uut, abstract, steps):
        time.sleep(60)
        super().verify_configuration(uut, abstract, steps)

    PROTOCOL = 'mvpn'
    requirements = OrderedDict()
    requirements['conf.vrf.Vrf'] = {
        'requirements': [[
            'device_attr', '{uut}', 'address_family_attr',
            '(?P<address_family>.*)', '_route_target_attr', '(?P<rt>.*)',
            '_protocol_attr',
            NotExists(PROTOCOL)
        ], ['device_attr', '{uut}', 'vrf_name', '(?P<vrf>.*)']],
        'all_keys':
        True,
        'exclude':
        trm_exclude
    }

    requirements['ops.vrf.vrf.Vrf'] = {
        'requirements': [['info', 'vrfs', '(?P<vrf>.*)', '(.*)']],
        'kwargs': {
            'attributes': ['info']
        },
        'exclude': trm_exclude
    }

    mapping = Mapping( \
        requirements= requirements,
        config_info={ \
            'conf.vrf.Vrf': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', 'route_target_attr', '(?P<rt>.*)', \
                     'rt_type', 'both'],
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', 'route_target_attr', '(?P<rt>.*)', \
                     'protocol_attr', 'mvpn', 'rt_mvpn', True]
                ],
                'verify_conf': False,
                'kwargs': {'mandatory': {'name': '(?P<vrf>.*)'}}}},
        verify_ops={ \
            'conf.vrf.Vrf': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', '_route_target_attr', '(?P<rt>.*)',
                     '_protocol_attr', 'mvpn', 'rt_mvpn', True]],
                'exclude': trm_exclude},
            'ops.vrf.vrf.Vrf': {
                'requirements': [ \
                    ['info', 'vrfs', '(?P<vrf>.*)', '(.*)']],
                'kwargs': {'attributes': ['info']},
                'exclude': trm_exclude}},
        num_values={'vrf': 1, 'rt': 1, 'address_family': 1})
Exemplo n.º 25
0
class TriggerAddRemoveL3EtherchannelPagp(TriggerAddRemove):
    """Apply the configuration for L3 Etherchannel in PAGP mode, and remove the
    added Etherchannel in PAGP mode
    """

    __description__ = """Apply the configuration for L3 Etherchannel in PAGP mode, and remove the
    added Etherchannel in PAGP mode.

    trigger_datafile:
        Mandatory:
            timeout: 
                max_time (`int`): Maximum wait time for the trigger,
                                in second. Default: 180
                interval (`int`): Wait time between iterations 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 iterations when looping is needed,
                                in second. Default: 15
            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.

                interface: `str`
                bundle_intf: `str`
                bundle_id: `int`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Interface Ops object to select up interfaces.
           Learn LAG ops object to find port-channle interfaces which does not exists.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of Etherchannel in PAGP mode with interface Conf object,
           Add ip address configuration to the learned port-channel interfaces
        4. Verify the interfaces are in the por-channle interfaces from step 3 has configured
        5. Remove the Etherchannel and port-channel configurations.
        6. Recover the device configurations to the one in step 2
        7. Learn LAG Ops again and verify it is the same as the Ops in step 1

    """
    counters_port = []
    counters_keys = [['interface', '(?P<bundle_intf>.*)', 'out', 'ucast_pkts', '(.*)']]

    @aetest.processors(post=[partial(check_interface_counters, ports=counters_port,
                                        keys =counters_keys, threshold='islargerthan(100)')])
    @aetest.test
    def verify_configuration(self, uut, abstract, steps):
        super().verify_configuration(uut, abstract, steps)


    mapping = Mapping(requirements={'ops.lag.lag.Lag':{
                                            'requirements':[\
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)', NotExists('members')],
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)', 'bundle_id', '(?P<bundle_id>.*)']],
                                            'all_keys': True,
                                            'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                            'exclude': lag_exclude},
                                    'ops.interface.interface.Interface':{
                                            'requirements':[['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                             'switchport_enable', False],
                                                            ['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                             'oper_status', 'up']],
                                            'kwargs': {'attributes': ['info[(.*)][switchport_enable]',
                                                                      'info[(.*)][operational_mode]',
                                                                      'info[(.*)][oper_status]',
                                                                      'info[(.*)][enabled]',
                                                                      'info[(.*)][port_channel]']},
                                            'exclude': interface_exclude}},
                       config_info={'conf.interface.Interface':{
                                        'requirements':[['lag_bundle_id', '(?P<bundle_id>.*)'],
                                                        ['lag_activity', 'desirable']],
                                        'verify_conf':False,
                                        'kwargs':{'mandatory':{'name': '(?P<interface>.*)',
                                                               'attach': False}}}},
                      verify_ops={'ops.lag.lag.Lag':{
                                      'requirements': [\
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)',
                                                 'bundle_id', '(?P<bundle_id>.*)'],
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)',
                                                 'protocol', 'pagp'],
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)',
                                                 'oper_status', 'up'],
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)',
                                                 'name', '(?P<bundle_intf>.*)'],
                                                ['info', 'interfaces', '(?P<bundle_intf>.*)',
                                                 'members', '(?P<interface>.*)', 'bundled', True]],
                                      'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                      'exclude': lag_exclude + ['attribute']},
                                  'ops.interface.interface.Interface':{
                                          'requirements':[['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                           'switchport_enable', False],
                                                          ['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                           'oper_status', 'up'],
                                                          ['info', '(?P<bundle_intf>.*)',
                                                           'oper_status', 'up'],
                                                          ['info', '(?P<bundle_intf>.*)',
                                                           'enabled', True],
                                                          ['info', '(?P<bundle_intf>.*)',
                                                           'oper_status', 'up'],
                                                          ['info', '(?P<bundle_intf>.*)',
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', '(?P<bundle_intf>.*)',
                                                           'port_channel', 'port_channel_member_intfs', '(.*)']],
                                            'kwargs': {'attributes': ['info[(.*)][switchport_enable]',
                                                                      'info[(.*)][operational_mode]',
                                                                      'info[(.*)][oper_status]',
                                                                      'info[(.*)][enabled]',
                                                                      'info[(.*)][port_channel]']},
                                          'exclude': interface_exclude}},
                      num_values={'interface':'all', 'bundle_id': 1})
Exemplo n.º 26
0
class TriggerUnconfigConfigRouteTargetMvpn(TriggerUnconfigConfig):
    """Unconfigure route-target mvpn and reapply the whole configurations of dynamically learned Vrf."""

    __description__ = """Unconfigure route-target mvpn and reapply the whole configurations of dynamically learned Vrf.

        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 when the previous timeout has been exhausted,
                    to make sure the devices are recovered before ending the trigger

                    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
                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.

                    vrf: `str`
                    address_family: `str`
                    rt: `str`
                    rt_type: `str`

                    (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                          OR
                          interface: 'Ethernet1/1/1' (Specific value)
        steps:
            1. Learn Vrf Conf object and check rt_mvpn is available
               if has any, otherwise, SKIP the trigger
            2. Save the current device configurations through "method" which user uses
            3. Unconfigure the rt_mvpn with Vrf Conf object
            4. Verify the mvpn from step 3 are no longer existed
            5. Recover the device configurations to the one in step 2
            6. Learn Vrf Conf obj again and verify it is the same as the Ops in step 1

        """
    mapping = Mapping( \
        requirements={ \
            'conf.vrf.Vrf': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', '_route_target_attr', '(?P<rt>.*)', \
                      'rt_type', '(?P<rt_type>.*)'],
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', '_route_target_attr', '(?P<rt>.*)',
                      '_protocol_attr', '(?P<protocol_name>^(mvpn).*)', 'rt_mvpn', True],
                    ['device_attr', '{uut}', 'vrf_name', '(?P<vrf>.*)']],
                'exclude': trm_exclude,
                'all_keys': True,
                'kwargs': {'attributes': ['vrf[vrf][(.*)]']}},
            'ops.vrf.vrf.Vrf':{
                 'requirements': [ \
                     ['info', 'vrfs', '(?P<vrf>.*)', '(.*)']],
                 'all_keys': False,
                 'kwargs': {'attributes': ['info']},
                 'exclude': trm_exclude}},
        config_info={ \
            'conf.vrf.Vrf': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', 'route_target_attr', '(?P<rt>.*)', \
                     'rt_type', '(?P<rt_type>.*)'],
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', 'route_target_attr', '(?P<rt>.*)',\
                     'protocol_attr', '(?P<protocol_name>.*)', 'rt_mvpn', False]],
                'verify_conf': False,
                'kwargs': {'mandatory': {'name': '(?P<vrf>.*)'}}}},
        verify_ops={ \
            'conf.vrf.Vrf': {
                'requirements': [ \
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<address_family>.*)', '_route_target_attr','(?P<rt>.*)',
                     '_protocol_attr', NotExists('(?P<protocol_name>(?!mvpn).*)')]], # , '(.*)'
                'exclude': trm_exclude,
                'kwargs': {'attributes': ['vrf[vrf][(.*)]']}},
            'ops.vrf.vrf.Vrf':{
                'requirements': [ \
                    ['info', 'vrfs', '(?P<vrf>.*)', '(.*)']],
                'kwargs': {'attributes': ['info']},
                'exclude': trm_exclude}},
        num_values={'protocol_name': 1, 'vrf': 1, 'rt': 1, 'rt_type': 1, 'address_family': 1})