Пример #1
0
def testValues_sync_diff_07():
    """Test diffs with remove_lines=False"""
    ## config_01 is the starting point
    config_01 = [
        '!',
        'vlan 51',
        ' state active',
        'vlan 53',
        '!',
        'vtp mode transparent',
    ]

    required_config = [
        '!',
        'vlan 51',
        ' name SOME-VLAN',
        ' state active',
        'vlan 52',
        ' name BLAH',
        ' state active',
        '!',
    ]

    result_correct = [
        'vlan 51', ' name SOME-VLAN', 'vlan 52', ' name BLAH', ' state active'
    ]

    linespec = r'vlan\s+\S+|name\s+\S+|state.+'
    parse = CiscoConfParse(config_01)
    test_result = parse.sync_diff(required_config,
                                  linespec,
                                  linespec,
                                  remove_lines=False)
    assert result_correct == test_result
Пример #2
0
def testValues_sync_diff_06():
    """Test diffs against double-spacing for children (such as NXOS)"""
    ## config_01 is the starting point
    config_01 = [
        '!',
        'vlan 51',
        '  state active',
        'vlan 53',
        '!',
    ]

    required_config = [
        '!',
        'vlan 51',
        '  name SOME-VLAN',
        '  state active',
        'vlan 52',
        '  name BLAH',
        '  state active',
        '!',
    ]

    result_correct = [
        'no vlan 53', 'vlan 51', '  name SOME-VLAN', 'vlan 52', '  name BLAH',
        '  state active'
    ]

    linespec = r'vlan\s+\S+|name\s+\S+|state.+'
    parse = CiscoConfParse(config_01)
    test_result = parse.sync_diff(required_config, linespec, linespec)
    assert result_correct == test_result
Пример #3
0
def testValues_sync_diff_04():
    """Test diffs against double-spacing for children (such as NXOS)"""
    ## config_01 is the starting point
    config_01 = [
        '!', 'interface GigabitEthernet 1/5',
        '  ip address 1.1.1.2 255.255.255.0', '  standby 5 ip 1.1.1.1',
        '  standby 5 preempt', '!'
    ]

    required_config = [
        '!',
        'interface GigabitEthernet 1/5',
        '  switchport',
        '  switchport mode access',
        '  switchport access vlan 5',
        '  switchport nonegotiate',
        '!',
        'interface Vlan5',
        '  no shutdown',
        '  ip address 1.1.1.2 255.255.255.0',
        '  standby 5 ip 1.1.1.1',
        '  standby 5 preempt',
        '!',
    ]

    result_correct = [
        'interface GigabitEthernet 1/5',
        '  no ip address 1.1.1.2 255.255.255.0',
        '  no standby 5 ip 1.1.1.1',
        '  no standby 5 preempt',
        'interface GigabitEthernet 1/5',
        '  switchport',
        '  switchport mode access',
        '  switchport access vlan 5',
        '  switchport nonegotiate',
        'interface Vlan5',
        '  no shutdown',
        '  ip address 1.1.1.2 255.255.255.0',
        '  standby 5 ip 1.1.1.1',
        '  standby 5 preempt',
    ]

    linespec = r''
    parse = CiscoConfParse(config_01)
    test_result = parse.sync_diff(required_config, linespec, linespec)
    assert result_correct == test_result
Пример #4
0
def testValues_sync_diff_09():
    """Test diffs with explicit ignore_order=True"""
    ## config_01 is the starting point
    config_01 = [
        '!',
        'vlan 51',
        ' state active',
        'vlan 53',
        '!',
        'vtp mode transparent',
    ]

    required_config = [
        '!',
        'vtp mode transparent',
        'vlan 51',
        ' name SOME-VLAN',
        ' state active',
        'vlan 52',
        ' name BLAH',
        ' state active',
        '!',
    ]

    result_correct = [
        'no vlan 53',
        'vlan 51',
        ' name SOME-VLAN',
        'vlan 52',
        ' name BLAH',
        ' state active',
    ]

    linespec = r'vlan\s+\S+|name\s+\S+|state.+|vtp'
    parse = CiscoConfParse(config_01)
    test_result = parse.sync_diff(required_config,
                                  linespec,
                                  linespec,
                                  ignore_order=True)
    assert result_correct == test_result
Пример #5
0
def testValues_sync_diff_05():
    ## config_01 is the starting point
    config_01 = ['!', 'vlan 51', ' state active', 'vlan 53', '!']

    required_config = [
        '!',
        'vlan 51',
        ' name SOME-VLAN',
        ' state active',
        'vlan 52',
        ' name BLAH',
        ' state active',
        '!',
    ]

    result_correct = [
        'no vlan 53', 'vlan 51', ' name SOME-VLAN', 'vlan 52', ' name BLAH',
        ' state active'
    ]

    linespec = r'vlan\s+\S+|name\s+\S+|state.+'
    parse = CiscoConfParse(config_01)
    test_result = parse.sync_diff(required_config, linespec, linespec)
    assert result_correct == test_result