Exemple #1
0
    def test_uncfg(self):
        Genie.testbed = testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='nxos')

        with self.assertNoWarnings():
            Genie.testbed = None
            with self.assertRaises(TypeError):
                vlan = Vlan()
            Genie.testbed = testbed

            vlan = Vlan(vlan='102')
            vlan.device_attr[dev1].vlan_attr['102'].name = 'vlan2'
            vlan.device_attr[dev1].vlan_attr['102'].state = 'active'
            vlan.device_attr[dev1].vlan_attr['102'].mode = 'ce'

            self.assertIs(vlan.testbed, testbed)

            dev1.add_feature(vlan)

            cfgs = vlan.build_unconfig(apply=False)
            self.assertCountEqual(cfgs.keys(), [dev1.name])
            self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join([
                'no vlan 102',
            ]))
Exemple #2
0
    def test_basic_uncfg(self):
        testbed = Genie.testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='iosxe')
        dev2 = Device(testbed=testbed, name='PE2', os='iosxe')
        intf1 = Interface(name='GigabitEthernet0/0/1',device=dev1)
        intf1.switchport = True
        intf2 = Interface(name='GigabitEthernet0/0/2',device=dev2)
        intf3 = Interface(name='Vlan100',device=dev1)
        vlan = Vlan()
        vlan.device_attr[dev1].vlan_id = 100
        vlan.device_attr[dev2].vlan_id = 300
        access_map_id = 'ed'
        vlan_configuration_id = '3'
        vlan.device_attr[dev1]
        vlan.device_attr[dev2]
        vlan.device_attr[dev1].interface_attr[intf1].switchport_mode = \
            'trunk'
        vlan.device_attr[dev1].interface_attr[intf1].sw_trunk_allowed_vlan = \
            '200-201'

        vlan.device_attr[dev1].access_map_attr[access_map_id]
        vlan.device_attr[dev2].access_map_attr[access_map_id]
        vlan.device_attr[dev1].vlan_configuration_attr[vlan_configuration_id]
        vlan.device_attr[dev2].vlan_configuration_attr[vlan_configuration_id]

        # Defining attributes section
        with self.assertRaises(ValueError):
            vlan.media = 'invalid'
        vlan.media = 'enet'
        self.assertIs(type(vlan.media), Vlan.Media)
        vlan.accounting_type = 'input'
        vlan.device_attr[dev1].access_map_action = 'drop'

        # Unconfig testing
        # Set a mock
        dev1.configure = Mock()
        dev2.configure = Mock()
        dev1.add_feature(vlan)
        dev2.add_feature(vlan)
        # Mock config

        uncfg1 = vlan.build_unconfig(apply=False)
        self.assertCountEqual(uncfg1.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(uncfg1['PE1']),
            '\n'.join([
                'no vlan 100',
                'no vlan accounting input',
                'no vlan access-map ed',
                'no vlan configuration 3',
                'interface GigabitEthernet0/0/1',
                ' no switchport mode trunk',
                ' no switchport trunk allowed vlan 200-201',
                ' exit',
            ]))

        self.assertMultiLineEqual(
            str(uncfg1['PE2']),
            '\n'.join([
                'no vlan 300',
                'no vlan accounting input',
                'no vlan access-map ed',
                'no vlan configuration 3',
            ]))

        uncfg_intf = intf1.build_unconfig(apply=False, attributes="switchport")
        self.assertMultiLineEqual(
            str(uncfg_intf),
            '\n'.join([
                'interface GigabitEthernet0/0/1',
                ' no switchport',
                ' exit',
            ]))

        partial_uncfg1 = vlan.build_unconfig(apply=False,
                                             attributes={'device_attr':\
                                                        {'*':"media"}})
        self.assertCountEqual(partial_uncfg1.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_uncfg1['PE1']),
            '\n'.join([
                'vlan 100',
                ' no media enet',
                ' exit',
            ]))

        partial_unconfigure = vlan.build_unconfig(apply=False,
                                                  attributes={'device_attr':\
                                                             {'*':{'access_map_attr':\
                                                             {'*':"access_map_action"}}}})
        self.assertCountEqual(partial_unconfigure.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_unconfigure['PE1']),
            '\n'.join([
                'vlan access-map ed',
                ' no action drop',
                ' exit',
            ]))

        all_vlan_interface_uncfg = vlan.build_unconfig(apply=False,
                                                       attributes={'device_attr':\
                                                       {'*':{'interface_attr':'*'}}})
        self.assertCountEqual(all_vlan_interface_uncfg.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(all_vlan_interface_uncfg['PE1']),
            '\n'.join([
                'interface GigabitEthernet0/0/1',
                ' no switchport mode trunk',
                ' no switchport trunk allowed vlan 200-201',
                ' exit',
            ]))

        partial_vlan_interface_uncfg = vlan.build_unconfig(apply=False,
                                                           attributes={'device_attr':\
                                                           {'*':{'interface_attr':\
                                                           {'*':"sw_trunk_allowed_vlan"}}}})
        self.assertCountEqual(partial_vlan_interface_uncfg.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_vlan_interface_uncfg['PE1']),
            '\n'.join([
                'interface GigabitEthernet0/0/1',
                ' no switchport trunk allowed vlan 200-201',
                ' exit',
            ]))
Exemple #3
0
    def test_basic_uncfg(self):
        testbed = Genie.testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='nxos', context='yang')
        dev2 = Device(testbed=testbed, name='PE2', os='nxos', context='yang')
        intf1 = Interface(name='Ethernet0/0/1', device=dev1)
        intf2 = Interface(name='Ethernet0/0/2', device=dev2)
        vlan = Vlan()

        for dev in testbed.devices:
            dev.connections = Mock()
            dev.connections = {'netconf': NetconfConnectionInfo()}

        vlan.device_attr[dev1].vlan_id = 100
        vlan.device_attr[dev2].vlan_id = 300

        # Unconfig testing
        # Set a mock
        dev1.configure = Mock()
        dev2.configure = Mock()
        dev1.add_feature(vlan)
        dev2.add_feature(vlan)
        # Mock config

        uncfg1 = vlan.build_unconfig(apply=False)
        self.assertCountEqual(uncfg1.keys(), ['PE1', 'PE2'])

        compare = ""
        for i in uncfg1['PE1']:
            compare += str(i)

        self.assertMultiLineEqual(
            compare, '\n'.join([
                '<edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\n'
                '  <target>\n'
                '    <running></running>\n'
                '  </target>\n'
                '  <config>\n'
                '    <vlan xmlns="http://cisco.com/ns/yang/ned/ios">\n'
                '      <vlan-list>\n'
                '        <id>100</id>\n'
                '      </vlan-list>\n'
                '    </vlan>\n'
                '  </config>\n'
                '</edit-config>\n'
            ]))

        compare = ""
        for i in uncfg1['PE2']:
            compare += str(i)

        self.assertMultiLineEqual(
            compare, '\n'.join([
                '<edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\n'
                '  <target>\n'
                '    <running></running>\n'
                '  </target>\n'
                '  <config>\n'
                '    <vlan xmlns="http://cisco.com/ns/yang/ned/ios">\n'
                '      <vlan-list>\n'
                '        <id>300</id>\n'
                '      </vlan-list>\n'
                '    </vlan>\n'
                '  </config>\n'
                '</edit-config>\n'
            ]))
Exemple #4
0
    def test_enable_disable(self):

        # For failures
        self.maxDiff = None

        # Set testbed
        Genie.testbed = testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='nxos')

        # Create Vlan object
        vlan1 = Vlan()
        dev1.add_feature(vlan1)
        vlan1.device_attr[dev1].enabled = True

        # Check config strings built correctly
        cfgs = vlan1.build_config(apply=False)
        self.assertMultiLineEqual(
            str(cfgs[dev1.name]),
            '\n'.join([
                'feature interface-vlan',
                'feature vn-segment-vlan-based',
            ]))

        # Unconfigure
        uncfgs = vlan1.build_unconfig(apply=False)
        self.assertMultiLineEqual(
            str(uncfgs[dev1.name]),
            '\n'.join([
                'no feature interface-vlan',
                'no feature vn-segment-vlan-based',
            ]))

        dev1.remove_feature(vlan1)

        # Create Vlan object
        vlan2 = Vlan()
        dev1.add_feature(vlan2)
        vlan2.device_attr[dev1].enabled_interface_vlan = True

        # Check config strings built correctly
        cfgs = vlan2.build_config(apply=False)
        self.assertMultiLineEqual(
            str(cfgs[dev1.name]),
            '\n'.join([
                'feature interface-vlan',
            ]))

        # Unconfigure
        uncfgs = vlan2.build_unconfig(apply=False)
        self.assertMultiLineEqual(
            str(uncfgs[dev1.name]),
            '\n'.join([
                'no feature interface-vlan',
            ]))

        # Remove feature
        dev1.remove_feature(vlan2)

        # Create Vlan object
        vlan3 = Vlan()
        dev1.add_feature(vlan3)
        vlan3.device_attr[dev1].enabled_vn_segment_vlan_based = True

        # Build config
        cfgs = vlan3.build_config(apply=False)
        self.assertMultiLineEqual(
            str(cfgs[dev1.name]),
            '\n'.join([
                'feature vn-segment-vlan-based',
            ]))

        # Unconfigure
        uncfgs = vlan3.build_unconfig(apply=False)
        self.assertMultiLineEqual(
            str(uncfgs[dev1.name]),
            '\n'.join([
                'no feature vn-segment-vlan-based',
            ]))
Exemple #5
0
    def test_cfg_with_igmp(self):
        Genie.testbed = testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='nxos')

        with self.assertNoWarnings():
            Genie.testbed = None
            with self.assertRaises(TypeError):
                vlan = Vlan()
            Genie.testbed = testbed

            vlan = Vlan(vlan='102')
            vlan.device_attr[dev1].vlan_attr['102'].name = 'vlan2'
            vlan.device_attr[dev1].vlan_attr['102'].state = 'active'
            vlan.device_attr[dev1].vlan_attr['102'].mode = 'ce'

            vlan.device_attr[dev1].config_vlan_attr['102'].config_vlan_id = '102'
            vlan.device_attr[dev1].config_vlan_attr['102'].ip_igmp_snooping = True

            self.assertIs(vlan.testbed, testbed)

            dev1.add_feature(vlan)

            cfgs = vlan.build_config(apply=False)
            self.assertCountEqual(cfgs.keys(), [dev1.name])
            self.assertMultiLineEqual(str(cfgs[dev1.name]), '\n'.join([
                'vlan 102',
                ' name vlan2',
                ' state active',
                ' mode ce',
                ' exit',
                'vlan configuration 102',
                ' ip igmp snooping',
                ' exit'
            ]))

            un_cfgs = vlan.build_unconfig(apply=False)
            self.assertMultiLineEqual(str(un_cfgs[dev1.name]), '\n'.join([
                'no vlan 102',
                'no vlan configuration 102',
            ]))

            un_cfgs = vlan.build_unconfig(apply=False,
                                          attributes={'device_attr': {
                                                        dev1: {
                                                            'vlan_attr': {
                                                                '102': {"mode": None}
                                                            },
                                                            'config_vlan_attr': {
                                                                '102': {"ip_igmp_snooping": None}
                                                            }
                                                        }
                                                    }
                                                })
            self.assertCountEqual(un_cfgs.keys(), [dev1.name])
            self.assertMultiLineEqual(str(un_cfgs[dev1.name]), '\n'.join([
                'vlan 102',
                ' no mode ce',
                ' exit',
                'vlan configuration 102',
                ' no ip igmp snooping',
                ' exit',
            ]))
Exemple #6
0
    def test_cfg_with_args(self):
        testbed = Genie.testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='nxos')
        dev2 = Device(testbed=testbed, name='PE2', os='nxos')
        intf1 = Interface(name='Ethernet0/0/1', device=dev1, layer=Layer.L3)
        intf2 = Interface(name='Ethernet0/0/2', device=dev2, layer=Layer.L2)
        link = Link(name='1_2_1', testbed=testbed)
        link.connect_interface(interface=intf1)
        link.connect_interface(interface=intf2)
        vlan = Vlan(vlan_id=100)
        link.add_feature(vlan)

        access_map_id = 'ed'
        vlan_configuration_id = '3'

        vlan.device_attr[dev1]
        vlan.device_attr[dev2]
        vlan.device_attr[dev1].interface_attr[intf1]
        vlan.device_attr[dev2].interface_attr[intf2]
        vlan.device_attr[dev2].interface_attr[intf2].switchport_mode = \
            L2_type.TRUNK
        vlan.device_attr[dev2].interface_attr[intf2].sw_trunk_allowed_vlan = \
            '200-201'
        vlan.device_attr[dev1].access_map_attr[access_map_id]
        vlan.device_attr[dev2].access_map_attr[access_map_id]
        vlan.device_attr[dev1].vlan_configuration_attr[vlan_configuration_id]
        vlan.device_attr[dev2].vlan_configuration_attr[vlan_configuration_id]

        # Defining attributes section
        vlan.shutdown = False
        with self.assertRaises(ValueError):
            vlan.media = 'invalid'
        vlan.media = 'enet'
        self.assertIs(type(vlan.media), Vlan.Media)
        vlan.egress_load_balance = True
        vlan.device_attr[dev1].access_map_action = 'drop'
        vlan.datalink_flow_monitor = True

        intf1.ipv4 = '201.0.12.1'
        intf1.ipv4.netmask = '255.255.255.0'
        intf1.speed = 1000
        intf1.mtu = 500
        intf1.ipv6 = '2001::12:1'

        cfg1 = vlan.build_config(apply=False)
        cfg2 = intf1.build_config(apply=False)
        self.assertCountEqual(cfg1.keys(), ['PE1', 'PE2'])

        self.assertMultiLineEqual(
            str(cfg1['PE1']),
            '\n'.join([
                'vlan 100',
                ' media enet',
                ' no shutdown',
                ' exit',
                'vlan access-map ed',
                ' action drop',
                ' exit',
                'vlan configuration 3',
                ' egress port-channel load-balance random',
                ' exit',
                'interface Ethernet0/0/1',
                ' mtu 500',
                ' ip address 201.0.12.1 255.255.255.0',
                ' ipv6 address 2001::12:1/128',
                ' speed 1000',
                ' exit',
            ]))

        self.assertMultiLineEqual(
            str(cfg1['PE2']),
            '\n'.join([
                'vlan 100',
                ' media enet',
                ' no shutdown',
                ' exit',
                'vlan access-map ed',
                ' exit',
                'vlan configuration 3',
                ' egress port-channel load-balance random',
                ' exit',
                'interface Ethernet0/0/2',
                ' switchport mode trunk',
                ' switchport trunk allowed vlan 200-201',
                ' exit',
            ]))

        self.assertMultiLineEqual(
            str(cfg2),
            '\n'.join([
                'interface Ethernet0/0/1',
                ' mtu 500',
                ' ip address 201.0.12.1 255.255.255.0',
                ' ipv6 address 2001::12:1/128',
                ' speed 1000',
                ' exit',
            ]))

        uncfg = vlan.build_unconfig(apply=False, attributes={'device_attr': {
                                                        dev1: {
                                                            'shutdown': None}
                                                            }})
        self.assertMultiLineEqual(
            str(uncfg['PE1']),
            '\n'.join([
                'vlan 100',
                ' shutdown',
                ' exit',
            ]))
Exemple #7
0
    def test_basic_uncfg(self):
        testbed = Genie.testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='nxos')
        dev2 = Device(testbed=testbed, name='PE2', os='nxos')
        intf1 = Interface(name='Ethernet0/0/1', device=dev1, layer=Layer.L3)
        intf2 = Interface(name='Ethernet0/0/2', device=dev2, layer=Layer.L2)
        link = Link(name='1_2_1', testbed=testbed)
        link.connect_interface(interface=intf1)
        link.connect_interface(interface=intf2)
        vlan = Vlan()
        link.add_feature(vlan)
        vlan.vlan_id = 100
        access_map_id = 'ed'
        vlan_configuration_id = '3'

        vlan.device_attr[dev1]
        vlan.device_attr[dev2]
        vlan.device_attr[dev1].access_map_attr[access_map_id]
        vlan.device_attr[dev2].access_map_attr[access_map_id]
        vlan.device_attr[dev1].interface_attr[intf1]
        vlan.device_attr[dev2].interface_attr[intf2]
        vlan.device_attr[dev2].interface_attr[intf2].switchport_mode = \
            L2_type.TRUNK
        vlan.device_attr[dev2].interface_attr[intf2].sw_trunk_allowed_vlan = \
            '200-201'
        vlan.device_attr[dev1].vlan_configuration_attr[vlan_configuration_id]
        vlan.device_attr[dev2].vlan_configuration_attr[vlan_configuration_id]

        # Defining attributes section
        vlan.shutdown = False
        with self.assertRaises(ValueError):
            vlan.media = 'invalid'
        vlan.media = 'enet'
        self.assertIs(type(vlan.media), Vlan.Media)
        vlan.egress_port_channel_load_balance_random = True
        vlan.device_attr[dev1].access_map_action = 'drop'
        vlan.datalink_flow_monitor = True

        # Unconfig testing
        # Set a mock
        dev1.cli = Mock()
        dev1.configure = Mock()
        dev2.cli = Mock()
        dev2.configure = Mock()
        dev1.add_feature(vlan)
        dev2.add_feature(vlan)
        # Mock config

        output = vlan.build_config(apply=True)

        uncfg1 = vlan.build_unconfig(apply=False)
        self.assertCountEqual(uncfg1.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(uncfg1['PE1']),
            '\n'.join([
                'no vlan 100',
                'no vlan access-map ed',
                'no vlan configuration 3',
            ]))

        self.assertMultiLineEqual(
            str(uncfg1['PE2']),
            '\n'.join([
                'no vlan 100',
                'no vlan access-map ed',
                'no vlan configuration 3',
                'interface Ethernet0/0/2',
                ' no switchport mode trunk',
                ' no switchport trunk allowed vlan 200-201',
                ' exit',
            ]))

        partial_uncfg1 = vlan.build_unconfig(apply=False,
                                             attributes={'device_attr': \
                                                             {'*': "media"}})
        self.assertCountEqual(partial_uncfg1.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_uncfg1['PE1']),
            '\n'.join([
                'vlan 100',
                ' no media enet',
                ' exit',
            ]))

        partial_unconfigure = vlan.build_unconfig(apply=False,
                                                  attributes={'device_attr': \
                                                                  {'*': {'access_map_attr': \
                                                                             {'*': "access_map_action"}}}})
        self.assertCountEqual(partial_unconfigure.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_unconfigure['PE1']),
            '\n'.join([
                'vlan access-map ed',
                ' no action drop',
                ' exit',
            ]))

        all_vlan_interface_uncfg = vlan.build_unconfig(apply=False,
                                                       attributes={ \
                                                           'device_attr': {'*': { \
                                                               'interface_attr': '*'}}})
        self.assertCountEqual(all_vlan_interface_uncfg.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(all_vlan_interface_uncfg['PE2']),
            '\n'.join([
                'interface Ethernet0/0/2',
                ' no switchport mode trunk',
                ' no switchport trunk allowed vlan 200-201',
                ' exit',
            ]))

        partial_vlan_interface_uncfg = vlan.build_unconfig(apply=False,
                                                           attributes={ \
                                                               'device_attr': {'*': \
                                                                                   {'interface_attr': \
                                                                                        {
                                                                                            '*': "sw_trunk_allowed_vlan"}}}})
        self.assertCountEqual(partial_vlan_interface_uncfg.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_vlan_interface_uncfg['PE2']),
            '\n'.join([
                'interface Ethernet0/0/2',
                ' no switchport trunk allowed vlan 200-201',
                ' exit',
            ]))
Exemple #8
0
    def test_basic_uncfg(self):
        testbed = Genie.testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='iosxr')
        dev2 = Device(testbed=testbed, name='PE2', os='iosxr')
        intf1 = Interface(name='GigabitEthernet0/0/1', device=dev1)
        intf2 = Interface(name='GigabitEthernet0/0/2', device=dev2)
        intf3 = Interface(name='GigabitEthernet0/0/3', device=dev1)
        link = Link(name='1_2_1', testbed=testbed)
        link.connect_interface(interface=intf1)
        link.connect_interface(interface=intf2)
        vlan = Vlan()
        link.add_feature(vlan)

        # Defining attributes section
        vlan.device_attr[dev1]
        vlan.device_attr[dev2]
        vlan.device_attr[dev1].interface_attr[intf1]
        vlan.device_attr[dev1].interface_attr[intf1].eth_encap_type1 = 'dot1q'
        vlan.device_attr[dev1].interface_attr[intf1].eth_encap_val1 = 2
        vlan.device_attr[dev1].interface_attr[
            intf1].eth_encap_type2 = 'second-dot1q'
        vlan.device_attr[dev1].interface_attr[intf1].eth_encap_val2 = 5

        # Unconfig testing
        # Set a mock
        dev1.cli = Mock()
        dev1.configure = Mock()
        dev2.cli = Mock()
        dev2.configure = Mock()
        dev1.add_feature(vlan)
        dev2.add_feature(vlan)
        # Mock config

        output = vlan.build_config(apply=True)

        uncfg = vlan.build_unconfig(apply=False)
        self.assertMultiLineEqual(
            str(uncfg['PE1']), '\n'.join([
                'interface GigabitEthernet0/0/1',
                ' no encapsulation dot1q 2 second-dot1q 5',
                ' exit',
            ]))

        all_vlan_interface_uncfg = vlan.build_unconfig(apply=False,
                                                       attributes={'device_attr':\
                                                       {'*':{'interface_attr':'*'}}})
        self.assertCountEqual(all_vlan_interface_uncfg.keys(), ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(all_vlan_interface_uncfg['PE1']), '\n'.join([
                'interface GigabitEthernet0/0/1',
                ' no encapsulation dot1q 2 second-dot1q 5',
                ' exit',
            ]))

        partial_vlan_interface_uncfg = vlan.build_unconfig(apply=False,
                                                           attributes={'device_attr':\
                                                           {'*':{'interface_attr':\
                                                           {'*':"eth_encap_type1"}}}})
        self.assertCountEqual(partial_vlan_interface_uncfg.keys(),
                              ['PE1', 'PE2'])
        self.assertMultiLineEqual(
            str(partial_vlan_interface_uncfg['PE1']), '\n'.join([
                'interface GigabitEthernet0/0/1',
                ' no encapsulation dot1q 2 second-dot1q 5',
                ' exit',
            ]))
Exemple #9
0
    def test_basic_uncfg(self):
        testbed = Genie.testbed = Testbed()
        dev1 = Device(testbed=testbed, name='PE1', os='iosxe', context='yang')
        dev2 = Device(testbed=testbed, name='PE2', os='iosxe', context='yang')
        intf1 = Interface(name='GigabitEthernet0/0/1', device=dev1)
        intf2 = Interface(name='GigabitEthernet0/0/2', device=dev2)
        intf3 = Interface(name='Vlan100', device=dev1)
        vlan = Vlan()

        for dev in testbed.devices:
            dev.connections = Mock()
            dev.connections = {'netconf': NetconfConnectionInfo()}

        vlan.device_attr[dev1].vlan_id = 100
        vlan.device_attr[dev2].vlan_id = 300

        # Unconfig testing
        # Set a mock
        dev1.configure = Mock()
        dev2.configure = Mock()
        dev1.add_feature(vlan)
        dev2.add_feature(vlan)
        # Mock config

        uncfg1 = vlan.build_unconfig(apply=False)
        self.assertCountEqual(uncfg1.keys(), ['PE1', 'PE2'])

        compare = ""
        for i in uncfg1['PE1']:
            compare += str(i)

        # A case has been already raised by JB so the unconfig for yang works as expected.
        # Currently, retruned xml for yang unconfig is exactly the same for the unconfig one.
        self.assertMultiLineEqual(
            compare, '\n'.join([
                '<edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\n'
                '  <target>\n'
                '    <running></running>\n'
                '  </target>\n'
                '  <config>\n'
                '    <vlan xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">\n'
                '      <vlan-list xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-vlan">\n'
                '        <id>100</id>\n'
                '      </vlan-list>\n'
                '    </vlan>\n'
                '  </config>\n'
                '</edit-config>\n'
            ]))

        compare = ""
        for i in uncfg1['PE2']:
            compare += str(i)

        self.assertMultiLineEqual(
            compare, '\n'.join([
                '<edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\n'
                '  <target>\n'
                '    <running></running>\n'
                '  </target>\n'
                '  <config>\n'
                '    <vlan xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">\n'
                '      <vlan-list xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-vlan">\n'
                '        <id>300</id>\n'
                '      </vlan-list>\n'
                '    </vlan>\n'
                '  </config>\n'
                '</edit-config>\n'
            ]))
new_vlan = Vlan(vlan_id="3001", name="GenieConfigured")

# Add new vlan to device as a feature
device.add_feature(new_vlan)
new_vlan.devices

# Build the configuration for the vlan, but don't send to device
output = new_vlan.build_config(apply=False)
output
print(output["sbx-n9kv-ao"])

# Build and send the configuration to devices
output = new_vlan.build_config(apply=True)

# Build and print out the configuraiton to REMOVE the Vlan from the devices
output = new_vlan.build_unconfig(apply=False)
print(output["sbx-n9kv-ao"])

# Build and send the configuration to remove the Vlan from the device
output = new_vlan.build_unconfig()

# Create a new Interface object for the device
new_interface = Interface(name="Ethernet1/10", device=device)

# Configure interface properties
new_interface.description = "Genie set me!"
new_interface.enabled = False
new_interface.switchport_enable = True
new_interface.switchport_mode = "trunk"
new_interface.native_vlan = "101"
new_interface.trunk_vlans = "101-105"