Merge "Removing pod argument for activate_vif method."

This commit is contained in:
Zuul 2020-06-24 15:13:54 +00:00 committed by Gerrit Code Review
commit b99f6a85f1
12 changed files with 19 additions and 26 deletions

View File

@ -388,7 +388,7 @@ class PodVIFDriver(DriverBase, metaclass=abc.ABCMeta):
raise NotImplementedError()
@abc.abstractmethod
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
"""Updates VIF to become active.
Implementing drivers should update the specified `vif` object's
@ -403,7 +403,6 @@ class PodVIFDriver(DriverBase, metaclass=abc.ABCMeta):
This method may be called before, after or while the VIF is being
plugged by the CNI plugin.
:param pod: dict containing Kubernetes Pod object
:param vif: VIF object as returned by `PodVIFDriver.request_vif`
"""
raise NotImplementedError()

View File

@ -64,7 +64,7 @@ class NestedDpdkPodVIFDriver(nested_vif.NestedPodVIFDriver):
vif.id, vm_id)
raise
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
# NOTE(danil): new virtual interface was created in nova instance
# during request_vif call, thus if it was not created successfully
# an exception o_exc.SDKException would be throwed. During binding

View File

@ -85,7 +85,7 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
LOG.warning("Unable to release port %s as it no longer exists.",
vif.id)
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
# NOTE(mchiappe): there is no way to get feedback on the actual
# interface creation or activation as no plugging can happen for this
# interface type. However the status of the port is not relevant as

View File

@ -77,7 +77,7 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
def release_vif(self, pod, vif, project_id=None, security_groups=None):
clients.get_network_client().delete_port(vif.id)
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
if vif.active:
return

View File

@ -69,7 +69,7 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
self._reduce_remaining_sriov_vfs(pod, physnet)
return vif
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
vif.active = True
def _get_physnet_subnet_mapping(self):

View File

@ -117,8 +117,8 @@ class NoopVIFPool(base.VIFPoolDriver):
def release_vif(self, pod, vif, *argv):
self._drv_vif.release_vif(pod, vif, *argv)
def activate_vif(self, pod, vif):
self._drv_vif.activate_vif(pod, vif)
def activate_vif(self, vif):
self._drv_vif.activate_vif(vif)
def update_vif_sgs(self, pod, sgs):
self._drv_vif.update_vif_sgs(pod, sgs)
@ -166,8 +166,8 @@ class BaseVIFPool(base.VIFPoolDriver, metaclass=abc.ABCMeta):
def set_vif_driver(self, driver):
self._drv_vif = driver
def activate_vif(self, pod, vif):
self._drv_vif.activate_vif(pod, vif)
def activate_vif(self, vif):
self._drv_vif.activate_vif(vif)
def update_vif_sgs(self, pod, sgs):
self._drv_vif.update_vif_sgs(pod, sgs)
@ -1068,9 +1068,9 @@ class MultiVIFPool(base.VIFPoolDriver):
vif_drv_alias = self._get_vif_drv_alias(vif)
self._vif_drvs[vif_drv_alias].release_vif(pod, vif, *argv)
def activate_vif(self, pod, vif):
def activate_vif(self, vif):
vif_drv_alias = self._get_vif_drv_alias(vif)
self._vif_drvs[vif_drv_alias].activate_vif(pod, vif)
self._vif_drvs[vif_drv_alias].activate_vif(vif)
def update_vif_sgs(self, pod, sgs):
pod_vif_type = self._get_pod_vif_type(pod)

View File

@ -145,7 +145,7 @@ class VIFHandler(k8s_base.ResourceEventHandler):
driver_utils.update_port_pci_info(pod, vif)
if not vif.active:
try:
self._drv_vif_pool.activate_vif(pod, vif)
self._drv_vif_pool.activate_vif(vif)
changed = True
except os_exc.ResourceNotFound:
LOG.debug("Port not found, possibly already "

View File

@ -219,10 +219,9 @@ class TestNestedDpdkVIFDriver(test_base.TestCase):
def test_activate_vif(self, active_value):
cls = nested_dpdk_vif.NestedDpdkPodVIFDriver
m_driver = mock.Mock(spec=cls)
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = active_value
cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)
self.assertEqual(vif.active, True)

View File

@ -230,11 +230,10 @@ class TestNestedMacvlanPodVIFDriver(test_base.TestCase):
def test_activate_vif(self, active_value):
cls = nested_macvlan_vif.NestedMacvlanPodVIFDriver
m_driver = mock.Mock(spec=cls)
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = active_value
cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)
self.assertEqual(vif.active, True)

View File

@ -184,7 +184,6 @@ class NeutronPodVIFDriver(test_base.TestCase):
m_driver = mock.Mock(spec=cls)
os_net = self.useFixture(k_fix.MockNetworkClient()).client
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = False
port = mock.MagicMock()
@ -192,7 +191,7 @@ class NeutronPodVIFDriver(test_base.TestCase):
port.__getitem__.return_value = kl_const.PORT_STATUS_ACTIVE
os_net.get_port.return_value = port
cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)
os_net.get_port.assert_called_once_with(vif.id)
self.assertTrue(vif.active)
@ -202,11 +201,10 @@ class NeutronPodVIFDriver(test_base.TestCase):
m_driver = mock.Mock(spec=cls)
os_net = self.useFixture(k_fix.MockNetworkClient()).client
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = True
cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)
os_net.get_port.assert_not_called()
@ -215,7 +213,6 @@ class NeutronPodVIFDriver(test_base.TestCase):
m_driver = mock.Mock(spec=cls)
os_net = self.useFixture(k_fix.MockNetworkClient()).client
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = False
port = mock.MagicMock()
@ -224,7 +221,7 @@ class NeutronPodVIFDriver(test_base.TestCase):
os_net.get_port.return_value = port
self.assertRaises(k_exc.ResourceNotReady, cls.activate_vif,
m_driver, pod, vif)
m_driver, vif)
def _test_get_port_request(self, m_to_fips, security_groups,
m_get_device_id, m_get_port_name, m_get_host_id,

View File

@ -71,11 +71,10 @@ class TestSriovVIFDriver(test_base.TestCase):
cls = drvs.SriovVIFDriver
m_driver = mock.Mock(spec=cls)
pod = mock.sentinel.pod
vif = mock.Mock()
vif.active = False
cls.activate_vif(m_driver, pod, vif)
cls.activate_vif(m_driver, vif)
self.assertEqual(True, vif.active)
@mock.patch('kuryr_kubernetes.os_vif_util.osvif_to_neutron_fixed_ips')

View File

@ -247,7 +247,7 @@ class TestVIFHandler(test_base.TestCase):
m_get_pod_state.assert_called_once_with(self._pod)
m_update_pci.assert_called_once_with(self._pod, self._vif)
self._activate_vif.assert_called_once_with(self._pod, self._vif)
self._activate_vif.assert_called_once_with(self._vif)
self._set_pod_state.assert_called_once_with(self._pod, self._state)
self._request_vif.assert_not_called()
self._request_additional_vifs.assert_not_called()