Merge "Truncate IPDevice's name to interface max size"
This commit is contained in:
commit
f46cba17f0
@ -268,7 +268,7 @@ class IPWrapper(SubProcessBase):
|
||||
class IPDevice(SubProcessBase):
|
||||
def __init__(self, name, namespace=None):
|
||||
super(IPDevice, self).__init__(namespace=namespace)
|
||||
self.name = name
|
||||
self._name = name
|
||||
self.link = IpLinkCommand(self)
|
||||
self.addr = IpAddrCommand(self)
|
||||
self.route = IpRouteCommand(self)
|
||||
@ -360,6 +360,16 @@ class IPDevice(SubProcessBase):
|
||||
cmd = 'net.ipv6.conf.%s.disable_ipv6=1' % sysctl_name
|
||||
return self._sysctl([cmd])
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
if self._name:
|
||||
return self._name[:constants.DEVICE_NAME_MAX_LEN]
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
|
||||
|
||||
class IpCommandBase(object):
|
||||
COMMAND = ''
|
||||
@ -948,8 +958,7 @@ def device_exists_with_ips_and_mac(device_name, ip_cidrs, mac, namespace=None):
|
||||
|
||||
def get_device_mac(device_name, namespace=None):
|
||||
"""Return the MAC address of the device."""
|
||||
dev = device_name[:constants.DEVICE_NAME_MAX_LEN]
|
||||
return IPDevice(dev, namespace=namespace).link.address
|
||||
return IPDevice(device_name, namespace=namespace).link.address
|
||||
|
||||
|
||||
def get_routing_table(ip_version, namespace=None):
|
||||
|
Loading…
Reference in New Issue
Block a user