Merge "Check interface presence in new namespace" into stable/ussuri
This commit is contained in:
commit
55de7e5471
@ -456,6 +456,8 @@ class IpLinkCommand(IpDeviceCommandBase):
|
|||||||
privileged.set_link_attribute(
|
privileged.set_link_attribute(
|
||||||
self.name, self._parent.namespace, net_ns_fd=namespace)
|
self.name, self._parent.namespace, net_ns_fd=namespace)
|
||||||
self._parent.namespace = namespace
|
self._parent.namespace = namespace
|
||||||
|
common_utils.wait_until_true(lambda: self.exists, timeout=5,
|
||||||
|
sleep=0.5)
|
||||||
|
|
||||||
def set_name(self, name):
|
def set_name(self, name):
|
||||||
privileged.set_link_attribute(
|
privileged.set_link_attribute(
|
||||||
|
@ -1100,3 +1100,14 @@ class GetDevicesWithIpTestCase(functional_base.BaseSudoTestCase):
|
|||||||
ip_addresses = self._remove_loopback_interface(ip_addresses)
|
ip_addresses = self._remove_loopback_interface(ip_addresses)
|
||||||
ip_addresses = self._remove_ipv6_scope_link(ip_addresses)
|
ip_addresses = self._remove_ipv6_scope_link(ip_addresses)
|
||||||
self.assertEqual(0, len(ip_addresses))
|
self.assertEqual(0, len(ip_addresses))
|
||||||
|
|
||||||
|
|
||||||
|
class IpLinkCommandTestCase(IpLibTestFramework):
|
||||||
|
|
||||||
|
def test_set_netns(self):
|
||||||
|
device_name = ('int_' + uuidutils.generate_uuid())[
|
||||||
|
:constants.DEVICE_NAME_MAX_LEN]
|
||||||
|
device = ip_lib.IPDevice(device_name, kind='dummy')
|
||||||
|
device.link.create()
|
||||||
|
namespace = self.useFixture(net_helpers.NamespaceFixture())
|
||||||
|
device.link.set_netns(namespace.name)
|
||||||
|
@ -658,8 +658,9 @@ class TestIpLinkCommand(TestIPCmdBase):
|
|||||||
set_link_attribute.assert_called_once_with(
|
set_link_attribute.assert_called_once_with(
|
||||||
self.parent.name, self.parent.namespace, state='down')
|
self.parent.name, self.parent.namespace, state='down')
|
||||||
|
|
||||||
|
@mock.patch.object(priv_lib, 'interface_exists', return_value=True)
|
||||||
@mock.patch.object(priv_lib, 'set_link_attribute')
|
@mock.patch.object(priv_lib, 'set_link_attribute')
|
||||||
def test_set_netns(self, set_link_attribute):
|
def test_set_netns(self, set_link_attribute, *args):
|
||||||
original_namespace = self.parent.namespace
|
original_namespace = self.parent.namespace
|
||||||
self.link_cmd.set_netns('foo')
|
self.link_cmd.set_netns('foo')
|
||||||
set_link_attribute.assert_called_once_with(
|
set_link_attribute.assert_called_once_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user