示例#1
0
def replaceSourceBridge(domxml, macbindopts, devType=None):
    for vnicmac, vnicdev in macbindopts.iteritems():
        if devType is None:
            if isDevice(vnicdev):
                deviceType = Link._detectType(vnicdev)
            else:
                raise Exception("Invalid device [%s]" % vnicdev)
        else:
            deviceType = devType
        if deviceType in _DEV_TYPE:
            for iface in domxml.getElementsByTagName('interface'):
                mac = iface.getElementsByTagName('mac')[0]
                macaddr = mac.getAttribute('address')
                if macaddr == vnicmac:
                    oldsource = iface.getElementsByTagName('source')[0]
                    iface.removeChild(oldsource)
                    iface.appendChild(createElement(domxml,
                                                    'source',
                                                    'bridge',
                                                    vnicdev))
                    if deviceType == 'openvswitch':
                        iface.appendChild(createElement(domxml,
                                                        'virtualport',
                                                        'type',
                                                        'openvswitch'))
        else:
            raise Exception("Invalid device type [%s]" % deviceType)
示例#2
0
def replaceSourceBridge(domxml, macbindopts, devType=None):
    for vnicmac, vnicdev in macbindopts.iteritems():
        if devType is None:
            if isDevice(vnicdev):
                deviceType = Link._detectType(vnicdev)
            else:
                raise Exception("Invalid device [%s]" % vnicdev)
        else:
            deviceType = devType
        if deviceType in _DEV_TYPE:
            for iface in domxml.getElementsByTagName('interface'):
                mac = iface.getElementsByTagName('mac')[0]
                macaddr = mac.getAttribute('address')
                if macaddr == vnicmac:
                    oldsource = iface.getElementsByTagName('source')[0]
                    iface.removeChild(oldsource)
                    iface.appendChild(createElement(domxml,
                                                    'source',
                                                    'bridge',
                                                    vnicdev))
                    if deviceType == 'openvswitch':
                        iface.appendChild(createElement(domxml,
                                                        'virtualport',
                                                        'type',
                                                        'openvswitch'))
        else:
            raise Exception("Invalid device type [%s]" % deviceType)
示例#3
0
 def testLinkFromRHEL64Text(self):
     lines = (
         "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state "
         "UNKNOWN \\    link/loopback 00:00:00:00:00:00 brd "
         "00:00:00:00:00:00",
         "2: p1p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN "
         "qlen 1000\\    link/ether 00:10:18:e1:6c:f0 brd "
         "ff:ff:ff:ff:ff:ff",
         "3: p1p2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN "
         "qlen 1000\\    link/ether 00:10:18:e1:6c:f2 brd "
         "ff:ff:ff:ff:ff:ff",
         "4: p1p3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq "
         "state DOWN qlen 1000\\    link/ether 00:10:18:e1:6c:f4 brd "
         "ff:ff:ff:ff:ff:ff",
         "5: p1p4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen "
         "1000\\    link/ether 00:10:18:e1:6c:f6 brd ff:ff:ff:ff:ff:ff",
         "6: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq "
         "state UP qlen 1000\\    link/ether d0:67:e5:f0:76:59 brd "
         "ff:ff:ff:ff:ff:ff",
         "7: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen "
         "1000\\    link/ether d0:67:e5:f0:76:5a brd ff:ff:ff:ff:ff:ff",
         "9: ;vdsmdummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state "
         "DOWN \\    link/ether 52:ca:1c:18:36:98 brd ff:ff:ff:ff:ff:ff",
         "10: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue "
         "state DOWN \\    link/ether 00:00:00:00:00:00 brd "
         "ff:ff:ff:ff:ff:ff",
         "11: bond4: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue "
         "state DOWN \\    link/ether 00:00:00:00:00:00 brd "
         "ff:ff:ff:ff:ff:ff",
         "12: bond1: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop "
         "state DOWN \\    link/ether 00:00:00:00:00:00 brd "
         "ff:ff:ff:ff:ff:ff",
         "13: bond2: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop "
         "state DOWN \\    link/ether 00:00:00:00:00:00 brd "
         "ff:ff:ff:ff:ff:ff",
         "14: bond3: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop "
         "state DOWN \\    link/ether 00:00:00:00:00:00 brd "
         "ff:ff:ff:ff:ff:ff",
         "15: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN "
         "\\    link/ether 1e:dd:89:60:6f:1a brd ff:ff:ff:ff:ff:ff\\    "
         "dummy ",
         "417: p1p3.13@p1p3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 "
         "qdisc noqueue state LOWERLAYERDOWN \\    link/ether "
         "00:10:18:e1:6c:f4 brd ff:ff:ff:ff:ff:ff\\    vlan id 13 "
         "<REORDER_HDR> ",
         "418: bar: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc "
         "noqueue state UNKNOWN \\    link/ether 00:10:18:e1:6c:f4 brd "
         "ff:ff:ff:ff:ff:ff",
     )
     devices = [Link.fromText(line) for line in lines]
     self.assertEqual(len(devices), len(lines))
     self.assertEqual(devices[-2].vlanid, 13)
     self.assertEqual(devices[1].address, "00:10:18:e1:6c:f0")
     self.assertEqual(devices[-3].type, LinkType.DUMMY)
     self.assertEqual(devices[-2].name, "p1p3.13")
示例#4
0
 def testLinkFromRHEL64Text(self):
     lines = (
         '1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state '
         'UNKNOWN \\    link/loopback 00:00:00:00:00:00 brd '
         '00:00:00:00:00:00',
         '2: p1p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN '
         'qlen 1000\\    link/ether 00:10:18:e1:6c:f0 brd '
         'ff:ff:ff:ff:ff:ff',
         '3: p1p2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN '
         'qlen 1000\\    link/ether 00:10:18:e1:6c:f2 brd '
         'ff:ff:ff:ff:ff:ff',
         '4: p1p3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq '
         'state DOWN qlen 1000\\    link/ether 00:10:18:e1:6c:f4 brd '
         'ff:ff:ff:ff:ff:ff',
         '5: p1p4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen '
         '1000\\    link/ether 00:10:18:e1:6c:f6 brd ff:ff:ff:ff:ff:ff',
         '6: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq '
         'state UP qlen 1000\\    link/ether d0:67:e5:f0:76:59 brd '
         'ff:ff:ff:ff:ff:ff',
         '7: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen '
         '1000\\    link/ether d0:67:e5:f0:76:5a brd ff:ff:ff:ff:ff:ff',
         '9: ;vdsmdummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state '
         'DOWN \\    link/ether 52:ca:1c:18:36:98 brd ff:ff:ff:ff:ff:ff',
         '10: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '11: bond4: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '12: bond1: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '13: bond2: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '14: bond3: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '15: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN '
         '\\    link/ether 1e:dd:89:60:6f:1a brd ff:ff:ff:ff:ff:ff\\    '
         'dummy ',
         '417: p1p3.13@p1p3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 '
         'qdisc noqueue state LOWERLAYERDOWN \\    link/ether '
         '00:10:18:e1:6c:f4 brd ff:ff:ff:ff:ff:ff\\    vlan id 13 '
         '<REORDER_HDR> ',
         '418: bar: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
         'noqueue state UNKNOWN \\    link/ether 00:10:18:e1:6c:f4 brd '
         'ff:ff:ff:ff:ff:ff')
     devices = [Link.fromText(line) for line in lines]
     self.assertEqual(len(devices), len(lines))
     self.assertEqual(devices[-2].vlanid, '13')
     self.assertEqual(devices[1].address, '00:10:18:e1:6c:f0')
     self.assertEqual(devices[-3].type, LinkType.DUMMY)
     self.assertEqual(devices[-2].name, 'p1p3.13')
示例#5
0
 def testLinkFromRHEL64Text(self):
     lines = (
         '1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state '
         'UNKNOWN \\    link/loopback 00:00:00:00:00:00 brd '
         '00:00:00:00:00:00',
         '2: p1p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN '
         'qlen 1000\\    link/ether 00:10:18:e1:6c:f0 brd '
         'ff:ff:ff:ff:ff:ff',
         '3: p1p2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN '
         'qlen 1000\\    link/ether 00:10:18:e1:6c:f2 brd '
         'ff:ff:ff:ff:ff:ff',
         '4: p1p3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq '
         'state DOWN qlen 1000\\    link/ether 00:10:18:e1:6c:f4 brd '
         'ff:ff:ff:ff:ff:ff',
         '5: p1p4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen '
         '1000\\    link/ether 00:10:18:e1:6c:f6 brd ff:ff:ff:ff:ff:ff',
         '6: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq '
         'state UP qlen 1000\\    link/ether d0:67:e5:f0:76:59 brd '
         'ff:ff:ff:ff:ff:ff',
         '7: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen '
         '1000\\    link/ether d0:67:e5:f0:76:5a brd ff:ff:ff:ff:ff:ff',
         '9: ;vdsmdummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state '
         'DOWN \\    link/ether 52:ca:1c:18:36:98 brd ff:ff:ff:ff:ff:ff',
         '10: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '11: bond4: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '12: bond1: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '13: bond2: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '14: bond3: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop '
         'state DOWN \\    link/ether 00:00:00:00:00:00 brd '
         'ff:ff:ff:ff:ff:ff',
         '15: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN '
         '\\    link/ether 1e:dd:89:60:6f:1a brd ff:ff:ff:ff:ff:ff\\    '
         'dummy ',
         '417: p1p3.13@p1p3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 '
         'qdisc noqueue state LOWERLAYERDOWN \\    link/ether '
         '00:10:18:e1:6c:f4 brd ff:ff:ff:ff:ff:ff\\    vlan id 13 '
         '<REORDER_HDR> ',
         '418: bar: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
         'noqueue state UNKNOWN \\    link/ether 00:10:18:e1:6c:f4 brd '
         'ff:ff:ff:ff:ff:ff')
     devices = [Link.fromText(line) for line in lines]
     self.assertEqual(len(devices), len(lines))
     self.assertEqual(devices[-2].vlanid, 13)
     self.assertEqual(devices[1].address, '00:10:18:e1:6c:f0')
     self.assertEqual(devices[-3].type, LinkType.DUMMY)
     self.assertEqual(devices[-2].name, 'p1p3.13')
示例#6
0
 def testLinkFromF20Text(self):
     lines = (
         "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state "
         "UNKNOWN mode DEFAULT group default \\    link/loopback "
         "00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 ",
         "2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc "
         "pfifo_fast state UP mode DEFAULT group default qlen 1000\\  "
         "  link/ether f0:de:f1:da:aa:e7 brd ff:ff:ff:ff:ff:ff "
         "promiscuity 0 ",
         "3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc "
         "mq state UP mode DORMANT group default qlen 1000\\    "
         "link/ether 24:77:03:5b:a7:70 brd ff:ff:ff:ff:ff:ff "
         "promiscuity 0 ",
         "9: ;vdsmdummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop "
         "state DOWN mode DEFAULT group default \\    link/ether "
         "92:91:9b:9a:41:b9 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\    "
         "bridge ",
         "128: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu "
         "1500 qdisc noqueue state DOWN mode DEFAULT group default \\ "
         "   link/ether 56:62:c2:71:75:c0 brd ff:ff:ff:ff:ff:ff "
         "promiscuity 0 \\    bond ",
         "148: dummy_999: <BROADCAST,NOARP,SLAVE,UP,LOWER_UP> mtu 1500"
         " qdisc noqueue master bond777 state UNKNOWN mode DEFAULT "
         "group default \\    link/ether 1a:38:3e:28:c0:32 brd "
         "ff:ff:ff:ff:ff:ff promiscuity 1 \\    dummy ",
         "149: dummy_888: <BROADCAST,NOARP,SLAVE,UP,LOWER_UP> mtu 1500"
         " qdisc noqueue master bond777 state UNKNOWN mode DEFAULT "
         "group default \\    link/ether 1a:38:3e:28:c0:32 brd "
         "ff:ff:ff:ff:ff:ff promiscuity 1 \\    dummy ",
         "150: bond777: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu "
         "1500 qdisc noqueue state UP mode DEFAULT group default \\   "
         " link/ether 1a:38:3e:28:c0:32 brd ff:ff:ff:ff:ff:ff "
         "promiscuity 1 \\    bond ",
         "151: bond777.555@bond777: <BROADCAST,MULTICAST,UP,LOWER_UP> "
         "mtu 1500 qdisc noqueue master foo state UP mode DEFAULT "
         "group default \\    link/ether 1a:38:3e:28:c0:32 brd "
         "ff:ff:ff:ff:ff:ff promiscuity 1 \\    vlan protocol 802.1Q "
         "id 555 <REORDER_HDR> ",
         "152: foo: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc "
         "noqueue state UP mode DEFAULT group default \\    link/ether"
         " 1a:38:3e:28:c0:32 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\   "
         " bridge ",
         "153: assaf@em1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop "
         "state DOWN mode DEFAULT group default \\    link/ether "
         "00:43:af:3e:e0:a1 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\    "
         "macvlan  mode vepa ",
     )
     devices = [Link.fromText(line) for line in lines]
     self.assertEqual(len(devices), len(lines))
     self.assertEqual(devices[-3].vlanid, 555)
     self.assertEqual(devices[1].address, "f0:de:f1:da:aa:e7")
     self.assertEqual(devices[-5].type, LinkType.DUMMY)
     self.assertEqual(devices[-3].master, devices[-2].name)
示例#7
0
 def testLinkFromF20Text(self):
     lines = ('1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state '
              'UNKNOWN mode DEFAULT group default \\    link/loopback '
              '00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 ',
              '2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
              'pfifo_fast state UP mode DEFAULT group default qlen 1000\\  '
              '  link/ether f0:de:f1:da:aa:e7 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 0 ',
              '3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
              'mq state UP mode DORMANT group default qlen 1000\\    '
              'link/ether 24:77:03:5b:a7:70 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 0 ',
              '9: ;vdsmdummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop '
              'state DOWN mode DEFAULT group default \\    link/ether '
              '92:91:9b:9a:41:b9 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\    '
              'bridge ',
              '128: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu '
              '1500 qdisc noqueue state DOWN mode DEFAULT group default \\ '
              '   link/ether 56:62:c2:71:75:c0 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 0 \\    bond ',
              '148: dummy_999: <BROADCAST,NOARP,SLAVE,UP,LOWER_UP> mtu 1500'
              ' qdisc noqueue master bond777 state UNKNOWN mode DEFAULT '
              'group default \\    link/ether 1a:38:3e:28:c0:32 brd '
              'ff:ff:ff:ff:ff:ff promiscuity 1 \\    dummy ',
              '149: dummy_888: <BROADCAST,NOARP,SLAVE,UP,LOWER_UP> mtu 1500'
              ' qdisc noqueue master bond777 state UNKNOWN mode DEFAULT '
              'group default \\    link/ether 1a:38:3e:28:c0:32 brd '
              'ff:ff:ff:ff:ff:ff promiscuity 1 \\    dummy ',
              '150: bond777: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu '
              '1500 qdisc noqueue state UP mode DEFAULT group default \\   '
              ' link/ether 1a:38:3e:28:c0:32 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 1 \\    bond ',
              '151: bond777.555@bond777: <BROADCAST,MULTICAST,UP,LOWER_UP> '
              'mtu 1500 qdisc noqueue master foo state UP mode DEFAULT '
              'group default \\    link/ether 1a:38:3e:28:c0:32 brd '
              'ff:ff:ff:ff:ff:ff promiscuity 1 \\    vlan protocol 802.1Q '
              'id 555 <REORDER_HDR> ',
              '152: foo: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
              'noqueue state UP mode DEFAULT group default \\    link/ether'
              ' 1a:38:3e:28:c0:32 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\   '
              ' bridge ',
              '153: assaf@em1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop '
              'state DOWN mode DEFAULT group default \\    link/ether '
              '00:43:af:3e:e0:a1 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\    '
              'macvlan  mode vepa ')
     devices = [Link.fromText(line) for line in lines]
     self.assertEqual(len(devices), len(lines))
     self.assertEqual(devices[-3].vlanid, '555')
     self.assertEqual(devices[1].address, 'f0:de:f1:da:aa:e7')
     self.assertEqual(devices[-5].type, LinkType.DUMMY)
     self.assertEqual(devices[-3].master, devices[-2].name)
示例#8
0
 def testLinkFromF20Text(self):
     lines = ('1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state '
              'UNKNOWN mode DEFAULT group default \\    link/loopback '
              '00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 ',
              '2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
              'pfifo_fast state UP mode DEFAULT group default qlen 1000\\  '
              '  link/ether f0:de:f1:da:aa:e7 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 0 ',
              '3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
              'mq state UP mode DORMANT group default qlen 1000\\    '
              'link/ether 24:77:03:5b:a7:70 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 0 ',
              '9: ;vdsmdummy;: <BROADCAST,MULTICAST> mtu 1500 qdisc noop '
              'state DOWN mode DEFAULT group default \\    link/ether '
              '92:91:9b:9a:41:b9 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\    '
              'bridge ',
              '128: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu '
              '1500 qdisc noqueue state DOWN mode DEFAULT group default \\ '
              '   link/ether 56:62:c2:71:75:c0 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 0 \\    bond ',
              '148: dummy_999: <BROADCAST,NOARP,SLAVE,UP,LOWER_UP> mtu 1500'
              ' qdisc noqueue master bond777 state UNKNOWN mode DEFAULT '
              'group default \\    link/ether 1a:38:3e:28:c0:32 brd '
              'ff:ff:ff:ff:ff:ff promiscuity 1 \\    dummy ',
              '149: dummy_888: <BROADCAST,NOARP,SLAVE,UP,LOWER_UP> mtu 1500'
              ' qdisc noqueue master bond777 state UNKNOWN mode DEFAULT '
              'group default \\    link/ether 1a:38:3e:28:c0:32 brd '
              'ff:ff:ff:ff:ff:ff promiscuity 1 \\    dummy ',
              '150: bond777: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu '
              '1500 qdisc noqueue state UP mode DEFAULT group default \\   '
              ' link/ether 1a:38:3e:28:c0:32 brd ff:ff:ff:ff:ff:ff '
              'promiscuity 1 \\    bond ',
              '151: bond777.555@bond777: <BROADCAST,MULTICAST,UP,LOWER_UP> '
              'mtu 1500 qdisc noqueue master foo state UP mode DEFAULT '
              'group default \\    link/ether 1a:38:3e:28:c0:32 brd '
              'ff:ff:ff:ff:ff:ff promiscuity 1 \\    vlan protocol 802.1Q '
              'id 555 <REORDER_HDR> ',
              '152: foo: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
              'noqueue state UP mode DEFAULT group default \\    link/ether'
              ' 1a:38:3e:28:c0:32 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\   '
              ' bridge ',
              '153: assaf@em1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop '
              'state DOWN mode DEFAULT group default \\    link/ether '
              '00:43:af:3e:e0:a1 brd ff:ff:ff:ff:ff:ff promiscuity 0 \\    '
              'macvlan  mode vepa ')
     devices = [Link.fromText(line) for line in lines]
     self.assertEqual(len(devices), len(lines))
     self.assertEqual(devices[-3].vlanid, 555)
     self.assertEqual(devices[1].address, 'f0:de:f1:da:aa:e7')
     self.assertEqual(devices[-5].type, LinkType.DUMMY)
     self.assertEqual(devices[-3].master, devices[-2].name)