本文整理汇总了Python中pycalico.datastore_datatypes.Endpoint.provision_veth方法的典型用法代码示例。如果您正苦于以下问题:Python Endpoint.provision_veth方法的具体用法?Python Endpoint.provision_veth怎么用?Python Endpoint.provision_veth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalico.datastore_datatypes.Endpoint
的用法示例。
在下文中一共展示了Endpoint.provision_veth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_container_add
# 需要导入模块: from pycalico.datastore_datatypes import Endpoint [as 别名]
# 或者: from pycalico.datastore_datatypes.Endpoint import provision_veth [as 别名]
def test_container_add(self):
with patch_object(self.plugin, "_validate_container_state", autospec=True) as m_validate_container_state, patch(
"calico_kubernetes.calico_kubernetes.netns.PidNamespace", autospec=True
) as m_pid_ns, patch_object(self.plugin, "_assign_container_ip", autospec=True) as m_assign_ip:
# Set up mock objs
self.m_datastore_client.get_endpoint.side_effect = KeyError
endpoint = Endpoint(TEST_HOST, TEST_ORCH_ID, "1234", "5678", "active", "mac")
endpoint.provision_veth = Mock()
endpoint.provision_veth.return_value = "new_mac"
self.m_datastore_client.create_endpoint.return_value = endpoint
# Set up arguments
container_name = "container_name"
self.plugin.docker_id = container_name
pid = "pid"
ip = IPAddress("1.1.1.1")
interface = "eth0"
m_assign_ip.return_value = ip
# Call method under test
return_value = self.plugin._container_add(pid, interface)
# Assert call parameters
self.m_datastore_client.get_endpoint.assert_called_once_with(
hostname=TEST_HOST, orchestrator_id=TEST_ORCH_ID, workload_id=self.plugin.docker_id
)
m_validate_container_state.assert_called_once_with(container_name)
self.m_datastore_client.create_endpoint.assert_called_once_with(
TEST_HOST, TEST_ORCH_ID, self.plugin.docker_id, [ip]
)
self.m_datastore_client.set_endpoint.assert_called_once_with(endpoint)
endpoint.provision_veth.assert_called_once_with(m_pid_ns(pid), interface)
# Verify method output
assert_equal(endpoint.mac, "new_mac")
assert_equal(return_value, endpoint)