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

        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>.*)']],
                                          '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>.*)']],
                                     '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.º 2
0
class TriggerUnconfigConfigAutoRpVrfInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the dynamically learned pim auto-rp interface(s) under non-default vrf."""

    __description__ = """Unconfigure and reapply the dynamically learned pim
    auto-rp 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 auto-rp
           interface(s) under non-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)\w+$)', '_address_family_attr',
                                                          '(?P<af>ipv4)', 'send_rp_announce_intf', '(?P<rp_intf>.*)']],
                                        '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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
0
class TriggerAddRemoveEthernetIpAclDeny(TriggerAddRemove):
    """Apply the IP acls with L2 ports which is Ethernet interfaces to device, and remove the
    added IP acls.
    """

    __description__ = """Apply the IP acls with L2 ports which is Ethernet
    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 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 = 'ethernet_ip_acl_deny_add'
    ACTION = 'deny'
    EXPECT_RES = 'failed'

    ping_info = [{
        'src': 'helper',
        'dest': 'uut',
        'ping': {
            'proto': 'ip',
            'count': 5,
            'size': 64,
            'extd_ping': 'n',
            'ping_packet_timeout': 2
        },
        'timeout_interval': 5,
        'timeout_max_time': 60,
        'exp_succ_perc': 100,
        'peer_num': 2
    }]

    @aetest.processors.post(
        partial(ping_devices,
                ping_parameters=ping_info,
                expect_result=EXPECT_RES))
    @aetest.test
    def verify_configuration(self, uut, abstract, steps):
        super().verify_configuration(uut, abstract, steps)

    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>\w+Ethernet[\d\/]+$)', 'switchport_mode',
                    'trunk'
                ],
                                 [
                                     'info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                     'oper_status', 'up'
                                 ]],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][switchport_mode]', 'info[(.*)][oper_status]']
                },
                '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>\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', '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>\w+Ethernet[\d\/]+$)', 'switchport_mode',
                    'trunk'
                ],
                                 [
                                     'info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                     'oper_status', 'up'
                                 ]],
                'kwargs': {
                    'attributes':
                    ['info[(.*)][switchport_mode]', 'info[(.*)][oper_status]']
                },
                'exclude':
                interface_exclude
            }
        },
        num_values={'intf': 1})
Exemplo n.º 8
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

              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.º 9
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.º 10
0
class TriggerUnconfigConfigStaticRpInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the dynamically learned pim static rp interface(s) under default vrf."""

    __description__ = """Unconfigure and reapply the dynamically learned pim
    static 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 static rp
           interface(s) under default vrf, otherwise, SKIP the trigger
        2. Unconfigure the learned pim static rp interface(s) from step 1 with Interface Conf object
        3. Verify the state of learned pim static rp interface(s) from step 2 is removed
        4. Reapply the configuration of pim static 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={'ops.pim.pim.Pim': {
                                        'requirements': [['info', 'vrf', '(?P<vrf>^default$)',
                                                          'address_family','(?P<af>.*)', 'rp', 'static_rp',
                                                          '(?P<rp_addr>.*)', '(?P<rp_rest>.*)']],
                                        'kwargs': {'attributes': [
                                                      'info[vrf][default][address_family][(.*)][rp][static_rp][(.*)]']},
                                        'exclude': pim_exclude },
                                  'ops.interface.interface.Interface': {
                                        'requirements': [['info', '(?P<rp_intf>.*)', 'ipv4',
                                                          '(?P<rp_addr>.*)','ip', '(?P<rp_addr>.*)'],
                                                         ['info', '(?P<rp_intf>.*)', 'vrf', '(?P<vrf>^default$)'],
                                                         ['info', '(?P<rp_intf>.*)', 'oper_status', 'up']],
                                        'kwargs': {'attributes': [
                                                      'info[(.*)][(ipv4|ipv6)][(.*)][ip]',
                                                      'info[(.*)][vrf]',
                                                      'info[(.*)][oper_status]']},
                                        'exclude': interface_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[(.*)][(ipv4|ipv6)][(.*)][ip]',
                                                      'info[(.*)][vrf]',
                                                      'info[(.*)][oper_status]']},
                                       'exclude': interface_exclude},
                                  'ops.pim.pim.Pim':{
                                       'requirements': [[partial(verify_ops_or_logic,
                                                            requires=[['info', 'vrf', '(?P<vrf>^default$)',
                                                                       'address_family','(?P<af>.*)', 'rp', 'static_rp',
                                                                       NotExists('(?P<rp_addr>.*)')],
                                                                      ['info', 'vrf', '(?P<vrf>^default$)',
                                                                       'address_family','(?P<af>.*)', 'rp', NotExists('static_rp')],
                                                                      ['info', 'vrf', '(?P<vrf>^default$)',
                                                                       'address_family','(?P<af>.*)', 'rp', 'static_rp',
                                                                       '(?P<rp_addr>.*)', '(?P<rp_rest>.*)'],
                                                               ])
                                                  ],
                                                ],
                                        'kwargs': {'attributes': [
                                                      'info[vrf][default][address_family][(.*)][rp][static_rp][(.*)]']},
                                        'exclude': pim_exclude }},
                      num_values={'rp_intf': 1, 'vrf': 'all', 'rp_addr': 'all', 'af': 'all'})
Exemplo n.º 11
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.º 12
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.º 13
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

       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(30)
        super().verify_configuration(uut, abstract, steps)

    PROTOCOL = 'mvpn'
    requirements = OrderedDict()
    requirements['conf.vrf.Vrf'] = {
        'requirements': [[
            'device_attr', '{uut}', 'address_family_attr', '(?P<af>.*)',
            '_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<af>.*)', 'route_target_attr', '(?P<rt>.*)', \
                     'rt_type', 'both'],
                    ['device_attr', '{uut}', 'address_family_attr', '(?P<af>.*)', '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<af>.*)', '_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, 'af': 1})
Exemplo n.º 14
0
class TriggerAddRemoveTrunkEtherchannelLacp(TriggerAddRemove):
    """Apply the Etherchannel in LACP mode, and remove the
    added Etherchannel in LACP mode
    """

    __description__ = """Apply the Etherchannel in LACP mode, and remove the
    added Etherchannel in LACP 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`

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Interface Ops object to select trunk interfaces.
           Learn LAG ops object to find port-channle interfaces which does not have
           the learned interfaces as memebers.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of Etherchannel in LACP mode with interface Conf object
        4. Verify the interfaces are in the por-channle interfaces from step 3 has configured
        5. Remove the Etherchannel 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

    """
    # The added new values
    BUNDLE_ID = 10
    BUNDLE_ID_INTF = 'Port-channel' + str(BUNDLE_ID)

    @aetest.processors(post=[
        partial(
            check_interface_counters,
            ports=[BUNDLE_ID_INTF],
            keys=[['interface', BUNDLE_ID_INTF, 'out', 'ucast_pkts', '(.*)']],
            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', NotExists({BUNDLE_ID_INTF})],
                                                             [NotExists('info')]],
                                            'all_keys': True,
                                            'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                            'exclude': lag_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[(.*)][enabled]',
                                                                      'info[(.*)][oper_status]',
                                                                      'info[(.*)][port_channel]']},
                                            'exclude': interface_exclude}},
                       config_info={'conf.interface.Interface':{
                                        'requirements':[['lag_bundle_id', BUNDLE_ID],
                                                        ['lag_activity', 'active']],
                                        'verify_conf':False,
                                        'kwargs':{'mandatory':{'name': '(?P<interface>.*)',
                                                               'attach': False}}}},
                      verify_ops={'ops.lag.lag.Lag':{
                                      'requirements': [\
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'bundle_id', BUNDLE_ID],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'protocol', 'lacp'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'oper_status', 'up'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'name', 'Port-channel10'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'members', '(?P<interface>.*)', 'bundled', True]],
                                      'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                      'exclude': lag_exclude},
                                  'ops.interface.interface.Interface':{
                                          'requirements':[['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                           'switchport_mode', 'trunk'],
                                                          ['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                           'oper_status', 'up'],
                                                          ['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', '(?P<interface>\w+Ethernet[\d\/]+$)',
                                                           'port_channel', 'port_channel_int', BUNDLE_ID_INTF],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'oper_status', 'up'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'enabled', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'oper_status', 'up'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'port_channel', 'port_channel_member_intfs', '(.*)'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'switchport_enable', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'switchport_mode', 'trunk'],],
                                          'kwargs': {'attributes': ['info']},
                                          'exclude': interface_exclude}},
                      num_values={'interface':'all', 'bundle_id': 1})
Exemplo n.º 15
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

           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<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<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 ,'border_gateway':1 })
Exemplo n.º 16
0
class TriggerAddRemoveAccessEtherchannelPagp(TriggerAddRemove):
    """Apply the Etherchannel in PAGP mode, and remove the
    added Etherchannel in PAGP mode
    """

    __description__ = """Apply the 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

    steps:
        1. Learn Interface Ops object to select trunk interfaces.
           Learn LAG ops object to find port-channle interfaces which does not have
           the learned interfaces as memebers.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of Etherchannel in PAGP mode with interface Conf object
        4. Verify the interfaces are in the por-channle interfaces from step 3 has configured
        5. Remove the Etherchannel 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

    """
    BUNDLE_ID = 10
    BUNDLE_ID_INTF = 'Port-channel' + str(BUNDLE_ID)

    mapping = Mapping(requirements={'ops.lag.lag.Lag':{
                                            'requirements':[\
                                                ['info', 'interfaces', NotExists(BUNDLE_ID_INTF)],
                                                [NotExists('info')]],
                                            'all_keys': True,
                                            'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                            'exclude': lag_exclude},
                                    'ops.interface.interface.Interface':{
                                            'requirements':[['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                             'switchport_mode', 'static access'],
                                                            ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                             'oper_status', 'up']],
                                          'kwargs': {'attributes': ['info[(.*)][switchport_mode]',
                                                                    'info[(.*)][enabled]',
                                                                    'info[(.*)][oper_status]',
                                                                    'info[(.*)][port_channel]']},
                                            'exclude': interface_exclude}},
                       config_info={'conf.interface.Interface':{
                                        'requirements':[['lag_bundle_id', BUNDLE_ID],
                                                        ['lag_activity', 'desirable']],
                                        'verify_conf':False,
                                        'kwargs':{'mandatory':{'name': '(?P<intf>.*)',
                                                               'attach': False}}}},
                      verify_ops={'ops.lag.lag.Lag':{
                                      'requirements': [\
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'bundle_id', BUNDLE_ID],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'protocol', 'pagp'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'oper_status', 'up'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'name', 'Port-channel10'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'members', '(?P<intf>.*)', 'bundled', True]],
                                      'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                      'exclude': lag_exclude},
                                  'ops.interface.interface.Interface':{
                                          'requirements':[['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'switchport_mode', 'static access'],
                                                          ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'oper_status', 'up'],
                                                          ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'port_channel', 'port_channel_int', BUNDLE_ID_INTF],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'oper_status', 'up'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'enabled', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'port_channel', 'port_channel_member_intfs', '(.*)'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'switchport_mode', 'static access']],
                                          'kwargs': {'attributes': ['info']},
                                          'exclude': interface_exclude}},
                      num_values={'intf':'all', 'bundle_id': 1})
Exemplo n.º 17
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

           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.º 18
0
class TriggerAddRemoveTrunkEtherchannelLacp(TriggerAddRemove):
    """Apply the Etherchannel in LACP mode, and remove the
    added Etherchannel in LACP mode
    """

    __description__ = """Apply the Etherchannel in LACP mode, and remove the
    added Etherchannel in LACP 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

    steps:
        1. Learn Interface Ops object to select trunk interfaces.
           Learn LAG ops object to find port-channle interfaces which does not have
           the learned interfaces as memebers.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of Etherchannel in LACP mode with interface Conf object
        4. Verify the interfaces are in the por-channle interfaces from step 3 has configured
        5. Remove the Etherchannel 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

    """
    # The added new values
    BUNDLE_ID = 10
    BUNDLE_ID_INTF = 'Port-channel' + str(BUNDLE_ID)

    # debug_dumper commands
    # Will be moved to trigger yaml file when feature is ready
    pre_commands = {
        'uut': {
            'pass': [
                "show int trunk", "show ip int br | inc up",
                "sh plat soft fed sw 1 etherchannel {} group-mask".format(
                    BUNDLE_ID), "sh plat soft fed sw 1 port summary",
                "sh plat soft fed sw 2 etherchannel {} group-mask".format(
                    BUNDLE_ID), "sh plat soft fed sw 2 port summary",
                "sh plat soft fed sw 3 etherchannel {} group-mask".format(
                    BUNDLE_ID), "sh plat soft fed sw 3 port summary"
            ]
        }
    }

    post_commands = {
        'uut': {
            'fail': [
                "sh arp", "show run", "show cdp nei",
                "show ip inter brief | inc up", "sh int trunk",
                "sh interface counter error",
                "sh interface counter etherchannel",
                "show plat software fed switch 1 port summary",
                "Show plat software vp switch 1 r0 summary",
                "show plat software vp switch 2 r0 summary",
                "show plat software matm f0 table 1 content",
                "show plat software fed sw active punt cpuq 2",
                "show plat software fed sw active punt cpuq 0",
                "show log | red flash:/tracelogs/lacp_stack_ping_check.log",
                "show switch", "sh int {}".format(BUNDLE_ID_INTF),
                "show etherchannel detail",
                "sh plat soft fed sw 1 etherchannel {} group-mask".format(
                    BUNDLE_ID),
                "sh plat soft fed sw 2 etherchannel {} group-mask".format(
                    BUNDLE_ID),
                "sh plat soft fed sw 3 etherchannel {} group-mask".format(
                    BUNDLE_ID)
            ]
        },
        'helper': {
            'fail': [
                "show run", "show arp", "show cdp nei", "sh int trunk",
                "show log | red flash:lacp_stack_ping_check.log",
                "sh int {}".format(BUNDLE_ID_INTF), "sh ip int br | inc up",
                "show int trunk", "show etherchannel detail"
            ]
        }
    }

    # ping info
    # Will be moved to trigger yaml file when feature is ready
    pre_ping_info = [{
        'src': 'uut',
        'dest': 'helper',
        'ping': {
            'proto': 'ip',
            'count': 20,
            'size': 64,
            'extd_ping': 'n',
            'ping_packet_timeout': 2
        },
        'timeout_interval': 5,
        'timeout_max_time': 60,
        'exp_succ_perc': 100,
        'peer_num': 1
    }, {
        'src': 'helper',
        'dest': 'uut',
        'ping': {
            'proto': 'ip',
            'count': 100,
            'size': 64,
            'extd_ping': 'n',
            'ping_packet_timeout': 2
        },
        'timeout_interval': 5,
        'timeout_max_time': 60,
        'exp_succ_perc': 100,
        'peer_num': 1
    }]

    @aetest.processors(pre=[
        partial(debug_dumper, commands=pre_commands),
        partial(ping_devices, ping_parameters=pre_ping_info),
        partial(debug_dumper, commands=post_commands)
    ],
                       post=[
                           partial(check_interface_counters,
                                   ports=[BUNDLE_ID_INTF],
                                   keys=[[
                                       'interface', BUNDLE_ID_INTF, 'out',
                                       'ucast_pkts', '(.*)'
                                   ]],
                                   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', NotExists({BUNDLE_ID_INTF})],
                                                             [NotExists('info')]],
                                            'all_keys': True,
                                            'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                            'exclude': lag_exclude},
                                    'ops.interface.interface.Interface':{
                                            'requirements':[['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                             'switchport_mode', 'trunk'],
                                                            ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                             'oper_status', 'up']],
                                            'kwargs': {'attributes': ['info[(.*)][switchport_mode]',
                                                                      'info[(.*)][enabled]',
                                                                      'info[(.*)][oper_status]',
                                                                      'info[(.*)][port_channel]']},
                                            'exclude': interface_exclude}},
                       config_info={'conf.interface.Interface':{
                                        'requirements':[['lag_bundle_id', BUNDLE_ID],
                                                        ['lag_activity', 'active']],
                                        'verify_conf':False,
                                        'kwargs':{'mandatory':{'name': '(?P<intf>.*)',
                                                               'attach': False}}}},
                      verify_ops={'ops.lag.lag.Lag':{
                                      'requirements': [\
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'bundle_id', BUNDLE_ID],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'protocol', 'lacp'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'oper_status', 'up'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'name', 'Port-channel10'],
                                                ['info', 'interfaces', BUNDLE_ID_INTF,
                                                 'members', '(?P<intf>.*)', 'bundled', True]],
                                      'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                      'exclude': lag_exclude},
                                  'ops.interface.interface.Interface':{
                                          'requirements':[['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'switchport_mode', 'trunk'],
                                                          ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'oper_status', 'up'],
                                                          ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'port_channel', 'port_channel_int', BUNDLE_ID_INTF],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'oper_status', 'up'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'enabled', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'oper_status', 'up'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'port_channel', 'port_channel_member', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'port_channel', 'port_channel_member_intfs', '(.*)'],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'switchport_enable', True],
                                                          ['info', BUNDLE_ID_INTF,
                                                           'switchport_mode', 'trunk'],],
                                          'kwargs': {'attributes': ['info']},
                                          'exclude': interface_exclude}},
                      num_values={'intf':'all', 'bundle_id': 1})
Exemplo n.º 19
0
class TriggerAddRemoveIpv6StaticRoutes(TriggerAddRemoveIpv4StaticRoutes):
    """Apply the ipv6 static routing to device, and remove the
    added ipv6 static routing.
    """

    __description__ = """Apply the ipv6 static routing to device, and remove the
    added ipv6 static routing.

    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.

                vrf: `str`
                route: `str`
                out_intf: `str`

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

    """
    ADD_ROUTE = '::/0'
    AF = 'ipv6'

    traceroute_info = [{
        'src': 'uut',
        'dest': 'helper',
        'protocol': AF,
        'dest_route': '(?P<next_hop>.*)',
        'timeout_interval': 5,
        'timeout_max_time': 60,
        'peer_num': 1
    }]

    @aetest.processors.post(
        partial(traceroute_loopback, traceroute_args=traceroute_info))
    @aetest.test
    def verify_configuration(self, uut, abstract, steps):
        super().verify_configuration(uut, abstract, steps)

    mapping = Mapping(
        requirements={
            'ops.static_routing.static_routing.StaticRoute': {
                'requirements': [[
                    'info', 'vrf', '(?P<vrf>.*)', 'address_family', AF,
                    'routes',
                    NotExists(ADD_ROUTE)
                ], [NotExists('info')]],
                'kwargs': {
                    'attributes': ['info[vrf][(.*)][address_family][(.*)]']
                },
                'exclude':
                routing_exclude
            },
            'ops.routing.routing.Routing': {
                'requirements':
                [[
                    'info', 'vrf', '(?P<vrf>.*)', 'address_family', AF,
                    'routes', '(?P<route>.*)', 'source_protocol', 'connected'
                ],
                 [
                     'info', 'vrf', '(?P<vrf>.*)', 'address_family',
                     AF, 'routes', '(?P<route>.*)', 'next_hop',
                     'outgoing_interface', '(?P<out_intf>.*)',
                     'outgoing_interface', '(?P<out_intf>.*)'
                 ]],
                'kwargs': {
                    'attributes':
                    ['info[vrf][(.*)][address_family][ipv6][routes][(.*)]']
                },
                'exclude':
                routing_exclude
            }
        },
        config_info={
            'conf.static_routing.StaticRouting': {
                'requirements': [[
                    'device_attr', '{uut}', 'vrf_attr', 'default',
                    'address_family_attr', AF, 'route_attr', ADD_ROUTE,
                    'next_hop_attr', '(?P<next_hop>.*)'
                ]],
                'verify_conf':
                False,
                'kwargs': {}
            }
        },
        verify_ops={
            'ops.static_routing.static_routing.StaticRoute': {
                'requirements': [[
                    'info', 'vrf', 'default', 'address_family', AF, 'routes',
                    ADD_ROUTE, 'next_hop', 'next_hop_list', 1, 'active', True
                ],
                                 [
                                     'info', 'vrf', 'default',
                                     'address_family', AF, 'routes', ADD_ROUTE,
                                     'next_hop', 'next_hop_list', 1, 'index', 1
                                 ],
                                 [
                                     'info', 'vrf', 'default',
                                     'address_family', AF, 'routes', ADD_ROUTE,
                                     'next_hop', 'next_hop_list', 1,
                                     'next_hop', '(?P<next_hop>.*)'
                                 ],
                                 [
                                     'info', 'vrf', 'default',
                                     'address_family', AF, 'routes', ADD_ROUTE,
                                     'next_hop', 'next_hop_list', 1,
                                     'preference', 1
                                 ],
                                 [
                                     'info', 'vrf', 'default',
                                     'address_family', AF, 'routes', ADD_ROUTE,
                                     'route', ADD_ROUTE
                                 ]],
                'kwargs': {
                    'attributes': ['info[vrf][(.*)][address_family][(.*)]']
                },
                'exclude':
                routing_exclude
            }
        },
        num_values={
            'vrf': 1,
            'route': 'all'
        })
Exemplo n.º 20
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

    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', '(.*)'
    ]]

    # ping info
    pre_ping_info = [{
        'src': 'uut',
        'dest': 'helper',
        'ping': {
            'proto': 'ip',
            'count': 20,
            'size': 64,
            'extd_ping': 'n',
            'ping_packet_timeout': 2
        },
        'timeout_interval': 5,
        'timeout_max_time': 60,
        'exp_succ_perc': 100,
        'peer_num': 1
    }, {
        'src': 'helper',
        'dest': 'uut',
        'ping': {
            'proto': 'ip',
            'count': 100,
            'size': 64,
            'extd_ping': 'n',
            'ping_packet_timeout': 2
        },
        'timeout_interval': 5,
        'timeout_max_time': 60,
        'exp_succ_perc': 100,
        'peer_num': 1
    }]

    @aetest.processors(
        pre=[partial(ping_devices, ping_parameters=pre_ping_info)],
        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<intf>\w+Ethernet[\d\/]+$)',
                                                             'switchport_enable', False],
                                                            ['info', '(?P<intf>\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<intf>.*)',
                                                               '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<intf>.*)', 'bundled', True]],
                                      'kwargs':{'attributes':['info[interfaces][(.*)]']},
                                      'exclude': lag_exclude + ['attribute']},
                                  'ops.interface.interface.Interface':{
                                          'requirements':[['info', '(?P<intf>\w+Ethernet[\d\/]+$)',
                                                           'switchport_enable', False],
                                                          ['info', '(?P<intf>\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={'intf':'all', 'bundle_id': 1})
Exemplo n.º 21
0
class TriggerUnconfigConfigVlanInterface(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically learned Vlan interface(s)."""
    
    __description__ = """Unconfigure and reapply the whole configurations of dynamically learned Vlan 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" Vlan interface(s)
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned Vlan interface(s) from step 1 
           with Interface Conf object
        4. Verify the learned Vlan interface(s) are no longer existed
        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

    """

    vlan_exclude = interface_exclude + ['oper_status']

    # 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>(Vlan|vlan)[0-9]+)', 'oper_status', 'up']],
                                       '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': vlan_exclude}},
                      num_values={'interface':1})
Exemplo n.º 22
0
class TriggerUnconfigConfigMsdpSaFilterIn(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically
    learned MSDP peer(s) sa-filter in."""

    __description__ = """Unconfigure and reapply the whole configurations of dynamically
    learned MSDP peer(s) sa-filter in.

    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`
                sa_filter_in: `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 "established" MSDP peer(s) sa-filter in
           if has any, otherwise, SKIP the trigger
        2. Save the current device configurations through "method" which user uses
        3. Unconfigure the learned MSDP peer(s) sa-filter in from step 1 
           with Msdp Conf object
        4. Verify the MSDP peer(s) sa-filter in 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>.*)', 'peer',
                                               '(?P<peer>.*)', 'session_state', 'established'],
                                              ['info', 'vrf', '(?P<vrf>.*)', 'peer', '(?P<peer>.*)',
                                               'sa_filter', 'in', '(?P<sa_filter_in>.*)']],
                                          'kwargs':{'attributes': [
                                              'info[vrf][(.*)][peer][(.*)][session_state]',
                                              'info[vrf][(.*)][peer][(.*)][sa_filter]']},
                                          'exclude': msdp_exclude}},
                      config_info={'conf.msdp.Msdp':{
                                       'requirements':[
                                         ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)',
                                          'peer_attr', '(?P<peer>.*)', 'sa_filter_in','(?P<sa_filter_in>.*)']],
                                       'verify_conf':False,
                                       'kwargs':{}}},
                      verify_ops={'ops.msdp.msdp.Msdp':{
                                    'requirements':[\
                                      ['info', 'vrf', '(?P<vrf>.*)', 'peer', '(?P<peer>.*)',
                                       'sa_filter', NotExists('in')]], # , '(?P<sa_filter_in>.*)'
                                    'kwargs':{'attributes': ['info[vrf][(.*)][peer][(.*)][session_state]',
                                                             'info[vrf][(.*)][peer][(.*)][sa_filter]']},
                                    'exclude': msdp_exclude}},
                      num_values={'vrf': 1, 'peer':1})
Exemplo n.º 23
0
class TriggerAddRemoveIpv4StaticRoutes(TriggerAddRemove):
    """Apply the ipv4 static routing to device, and remove the
    added ipv4 static routing.
    """

    __description__ = """Apply the ipv4 static routing to device, and remove the
    added ipv4 static routing.

    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 static_routing Ops object and store the routes info if has any.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of static routing with static_routing Conf object
        4. Verify the static_routing from step 3 has configured
        5. Remove the static_routing configurations.
        6. Recover the device configurations to the one in step 2
        7. Learn static_routing Ops again and verify it is the same as the Ops in step 1

    """
    ADD_ROUTE = '0.0.0.0/0'
    AF = 'ipv4'

    # will move below to datafile when subsection 
    # prepost processors passing from datafile suppported

    traceroute_info = [{'src': 'uut',
                        'dest': 'helper',
                        'protocol': AF,
                        'dest_route': '{next_hop}',
                        'timeout_interval': 5,
                        'timeout_max_time': 60,
                        'peer_num': 1}]

    @aetest.processors.post(partial(traceroute_loopback, traceroute_args=traceroute_info))
    @aetest.test
    def verify_configuration(self, uut, abstract, steps): 

        # replace the traceroute_info if has any
        if hasattr(self, 'traceroute_info'):
            for item_args in self.traceroute_info:
                for keys in self.mapping.keys:
                    item_args['dest_route'] = keys['next_hop']         
        super().verify_configuration(uut, abstract, steps)


    mapping = Mapping(requirements={'ops.static_routing.static_routing.StaticRoute':{
                                            'requirements':[['info', 'vrf', '(?P<vrf>.*)',
                                                             'address_family', AF,
                                                             'routes', NotExists(ADD_ROUTE)],
                                                            [NotExists('info')]],
                                            'kwargs':{'attributes':['info[vrf][(.*)][address_family][(.*)]']},
                                            'exclude': routing_exclude}},
                      config_info={'conf.static_routing.StaticRouting':{
                                      'requirements':[['device_attr', '{uut}',
                                                       'vrf_attr', 'default',
                                                       'address_family_attr',AF,
                                                       'route_attr', ADD_ROUTE,
                                                       'next_hop_attr', '(?P<next_hop>.*)']],
                                      'verify_conf':False,
                                      'kwargs':{}}},
                      verify_ops={'ops.static_routing.static_routing.StaticRoute':{
                                      'requirements': [['info', 'vrf', 'default', 'address_family', AF,
                                                        'routes', ADD_ROUTE, 'next_hop',
                                                        'next_hop_list', 1, 'active', True],

                                                       ['info', 'vrf', 'default', 'address_family', AF,
                                                        'routes', ADD_ROUTE, 'next_hop',
                                                        'next_hop_list', 1, 'index', 1],

                                                       ['info', 'vrf', 'default', 'address_family', AF,
                                                        'routes', ADD_ROUTE, 'next_hop',
                                                        'next_hop_list', 1, 'next_hop', '(?P<next_hop>.*)'],

                                                       ['info', 'vrf', 'default', 'address_family', AF,
                                                        'routes', ADD_ROUTE, 'next_hop',
                                                        'next_hop_list',  1, 'preference', 1],

                                                       ['info', 'vrf', 'default',
                                                        'address_family', AF,
                                                        'routes', ADD_ROUTE, 'route', ADD_ROUTE]],
                                            'kwargs':{'attributes':['info[vrf][(.*)][address_family][(.*)]']},
                                      'exclude': routing_exclude}},
                      num_values={'vrf':1, 'route': 'all'})
Exemplo n.º 24
0
class TriggerAddRemovePimNeighborFilter(TriggerAddRemove):
    """Apply the Pim interface(s)'s neighbor-filter, add remove added Pim interface(s)'s neighbor-filter"""

    __description__ = """Apply the Pim interface(s)'s neighbor-filter,
    add remove added 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

    steps:
        1. Learn Pim Ops/Conf object and store the Pim interface(s)'s neighbor-filter.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of Pim interface(s)'s neighbor-filter with Pim Conf object
        4. Verify the Pim interface(s)'s neighbor-filter from step 3 has configured
        5. Remove the Pim interface(s)'s neighbor-filter configurations.
        6. Recover the device configurations to the one in step 2
        7. Learn Pim Ops again and verify it is the same as the Ops in step 1

    """
    ADD_NAME = 'added_pim_neighbor_policy'

    # 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<pim_intf>.*)', 'address_family', '(?P<af>.*)',
                                     NotExists('neighbor_filter')],
                                    ['info', 'vrf', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<pim_intf>.*)', 'address_family', '(?P<af>.*)',
                                     '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<af>.*)', 'interface_attr',
                                          '(?P<pim_intf>.*)', 'neighbor_filter', ADD_NAME]],
                                       'verify_conf':False,
                                       'kwargs':{}}},
                      verify_ops={
                          'ops.pim.pim.Pim':{
                                'requirements':[\
                                    ['info', 'vrf', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<pim_intf>.*)', 'address_family', '(?P<af>.*)',
                                     'neighbor_filter', ADD_NAME],
                                    ['info', 'vrf', '(?P<vrf>.*)', 'interfaces',
                                     '(?P<pim_intf>.*)', 'address_family', '(?P<af>.*)',
                                     'oper_status', 'up']],
                                'kwargs':{'attributes': [
                                    'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][oper_status]',
                                    'info[vrf][(.*)][interfaces][(.*)][address_family][(.*)][neighbor_filter]']},
                                'exclude': pim_exclude}},
                      num_values={'vrf': 1, 'af': 1, 'pim_intf': 1})
Exemplo n.º 25
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.º 26
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.º 27
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})
Exemplo n.º 28
0
class TriggerUnconfigConfigIgmpStaticGroup(TriggerUnconfigConfig):
    """Unconfigure and reapply the whole configurations of dynamically
    learned enabled Igmp interface(s)'s static-groups."""

    __description__ = """Unconfigure and reapply the whole configurations
    of dynamically learned enabled Igmp 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.

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

                (e.g) interface: '(?P<interface>Ethernet1*)' (Regex supported)
                      OR
                      interface: 'Ethernet1/1/1' (Specific value)
    steps:
        1. Learn Igmp Ops object and store the enabled PIM 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 Igmp interface(s)'s static-groups from step 1 
           with Igmp Conf object
        4. Verify the Igmp 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 Igmp 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.igmp.igmp.Igmp':{
                                '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': igmp_exclude}},
                      config_info={'conf.igmp.Igmp':{
                                       'requirements':[
                                         [partial(configure_add_attributes,  # callable configuration
                                            add_obj=IgmpGroup,
                                            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.igmp.igmp.Igmp':{
                                '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>.*)',
                                                                 NotExists('source')],
                                                                ['info', 'vrfs', '(?P<vrf>.*)', 'interfaces',
                                                                 '(?P<interface>.*)', 'group', '(?P<group>.*)',
                                                                 'source', NotExists('(?P<source>\*)')]
                                                               ])
                                                  ],
                                                ],
                                'kwargs':{'attributes': [
                                    'info[vrfs][(.*)][interfaces][(.*)][join_group]',
                                    'info[vrfs][(.*)][interfaces][(.*)][static_group]',
                                    'info[vrfs][(.*)][interfaces][(.*)][group]']},
                                'exclude': igmp_exclude}},
                      num_values={'vrf': 1, 'interface': 1, 'static_group': 1, 'group': 1})
Exemplo n.º 29
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.º 30
0
class TriggerAddRemoveMsdpDescription(TriggerAddRemove):
    """Apply the MSDP peer(s) description,
    and remove added MSDP peer(s) description"""

    __description__ = """Apply the MSDP vrf(s) description, and
    remove added MSDP vrf(s) description.

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

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

    steps:
        1. Learn Msdp Ops object and store the MSDP peer(s) which does not have
           description configured.
        2. Save the current device configurations through "method" which user uses
        3. Add the configuration of msdp description with Msdp Conf object
        4. Verify the msdp description from step 3 has configured
        5. Remove the msdp description configurations.
        6. Recover the device configurations to the one in step 2
        7. Learn Msdp Ops again and verify it is the same as the Ops in step 1

    """
    ADD_NAME = 'Added description'
    # Mapping of Information between Ops and Conf
    # Also permit to dictate which key to verify
    mapping = Mapping(requirements={'conf.msdp.Msdp':{
                                          'requirements':[\
                                              ['device_attr', '{uut}', '_vrf_attr', '(?P<vrf>.*)',
                                               '_peer_attr', '(?P<peer>.*)', NotExists('description')]],
                                          'all_keys': True,
                                          'kwargs':{'attributes': [
                                              'msdp[vrf_attr][(.*)][peer_attr][(.*)]']},
                                          'exclude': msdp_exclude}},
                      config_info={'conf.msdp.Msdp':{
                                       'requirements':[
                                         ['device_attr', '{uut}', 'vrf_attr', '(?P<vrf>.*)',
                                          'peer_attr', '(?P<peer>.*)', 'description', ADD_NAME]],
                                       'verify_conf':False,
                                       'kwargs':{}}},
                      verify_ops={'ops.msdp.msdp.Msdp':{
                                    'requirements':[\
                                      ['info', 'vrf', '(?P<vrf>.*)', 'peer',
                                       '(?P<peer>.*)', 'description', ADD_NAME]],
                                    'kwargs':{'attributes': ['info[vrf][(.*)][peer][(.*)][description]']},
                                    'exclude': msdp_exclude}},
                      num_values={'vrf': 1, 'peer': 1})