Add interface kind property
- Add a new property to IPDevice to allow us to identify the kind of the interface. This change is required as an out of tree interface driver which supports operations on a per-physnet basis needs to be aware of the kind of interface an interface driver created in order to correlate between an interface driver and an interface created by it. Change-Id: Icbdb011a639475f416ca1b98fdf3ce2f52482c7c Partial-Bug: #1834176
This commit is contained in:
parent
261be89fc6
commit
b51ba4b283
@ -499,6 +499,10 @@ class IpLinkCommand(IpDeviceCommandBase):
|
||||
def alias(self):
|
||||
return self.attributes.get('alias')
|
||||
|
||||
@property
|
||||
def link_kind(self):
|
||||
return self.attributes.get('link_kind')
|
||||
|
||||
@property
|
||||
def attributes(self):
|
||||
return privileged.get_link_attributes(self.name,
|
||||
|
@ -394,7 +394,8 @@ def get_link_attributes(device, namespace):
|
||||
'brd': link.get_attr('IFLA_BROADCAST'),
|
||||
'link/ether': link.get_attr('IFLA_ADDRESS'),
|
||||
'alias': link.get_attr('IFLA_IFALIAS'),
|
||||
'allmulticast': bool(link['flags'] & ifinfmsg.IFF_ALLMULTI)
|
||||
'allmulticast': bool(link['flags'] & ifinfmsg.IFF_ALLMULTI),
|
||||
'link_kind': link.get_nested('IFLA_LINKINFO', 'IFLA_INFO_KIND')
|
||||
}
|
||||
|
||||
|
||||
|
@ -592,3 +592,23 @@ class RouteTestCase(functional_base.BaseSudoTestCase):
|
||||
priv_ip_lib.add_ip_route(self.namespace, None, ip_version,
|
||||
device=self.device_name, via=_ip)
|
||||
self._check_gateway(_ip)
|
||||
|
||||
|
||||
class GetLinkAttributesTestCase(functional_base.BaseSudoTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(GetLinkAttributesTestCase, self).setUp()
|
||||
self.namespace = self.useFixture(net_helpers.NamespaceFixture()).name
|
||||
self.device_name = 'test_device'
|
||||
ip_lib.IPWrapper(self.namespace).add_dummy(self.device_name)
|
||||
self.device = ip_lib.IPDevice(self.device_name, self.namespace)
|
||||
self.pyroute_dev = priv_ip_lib.get_link_devices(
|
||||
self.namespace, ifname=self.device_name)
|
||||
self.assertEqual(1, len(self.pyroute_dev))
|
||||
self.pyroute_dev = self.pyroute_dev[0]
|
||||
|
||||
def test_get_link_attribute_kind(self):
|
||||
ifla_linkinfo = ip_lib.get_attr(self.pyroute_dev, 'IFLA_LINKINFO')
|
||||
ifla_link_kind = ip_lib.get_attr(ifla_linkinfo, 'IFLA_INFO_KIND')
|
||||
self.assertEqual('dummy', ifla_link_kind)
|
||||
self.assertEqual(ifla_link_kind, self.device.link.link_kind)
|
||||
|
Loading…
Reference in New Issue
Block a user