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):
|
class IPDevice(SubProcessBase):
|
||||||
def __init__(self, name, namespace=None):
|
def __init__(self, name, namespace=None):
|
||||||
super(IPDevice, self).__init__(namespace=namespace)
|
super(IPDevice, self).__init__(namespace=namespace)
|
||||||
self.name = name
|
self._name = name
|
||||||
self.link = IpLinkCommand(self)
|
self.link = IpLinkCommand(self)
|
||||||
self.addr = IpAddrCommand(self)
|
self.addr = IpAddrCommand(self)
|
||||||
self.route = IpRouteCommand(self)
|
self.route = IpRouteCommand(self)
|
||||||
|
@ -360,6 +360,16 @@ class IPDevice(SubProcessBase):
|
||||||
cmd = 'net.ipv6.conf.%s.disable_ipv6=1' % sysctl_name
|
cmd = 'net.ipv6.conf.%s.disable_ipv6=1' % sysctl_name
|
||||||
return self._sysctl([cmd])
|
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):
|
class IpCommandBase(object):
|
||||||
COMMAND = ''
|
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):
|
def get_device_mac(device_name, namespace=None):
|
||||||
"""Return the MAC address of the device."""
|
"""Return the MAC address of the device."""
|
||||||
dev = device_name[:constants.DEVICE_NAME_MAX_LEN]
|
return IPDevice(device_name, namespace=namespace).link.address
|
||||||
return IPDevice(dev, namespace=namespace).link.address
|
|
||||||
|
|
||||||
|
|
||||||
def get_routing_table(ip_version, namespace=None):
|
def get_routing_table(ip_version, namespace=None):
|
||||||
|
|
Loading…
Reference in New Issue