本文整理汇总了Python中contrail_vrouter_api.vrouter_api.ContrailVRouterApi._uuid_string_to_hex方法的典型用法代码示例。如果您正苦于以下问题:Python ContrailVRouterApi._uuid_string_to_hex方法的具体用法?Python ContrailVRouterApi._uuid_string_to_hex怎么用?Python ContrailVRouterApi._uuid_string_to_hex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类contrail_vrouter_api.vrouter_api.ContrailVRouterApi
的用法示例。
在下文中一共展示了ContrailVRouterApi._uuid_string_to_hex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VRouterApiTest
# 需要导入模块: from contrail_vrouter_api.vrouter_api import ContrailVRouterApi [as 别名]
# 或者: from contrail_vrouter_api.vrouter_api.ContrailVRouterApi import _uuid_string_to_hex [as 别名]
class VRouterApiTest(unittest.TestCase):
def setUp(self):
self._api = ContrailVRouterApi()
def test_create_port(self):
mock_client = mock.Mock()
self._api._rpc_client_instance = mock.MagicMock(
name='rpc_client_instance')
self._api._rpc_client_instance.return_value = mock_client
self._api.add_port(str(uuid.uuid1()), str(uuid.uuid1()), 'tapX',
'aa:bb:cc:ee:ff:00')
self.assertTrue(mock_client.AddPort.called)
def test_delete_port(self):
mock_client = mock.Mock()
self._api._rpc_client_instance = mock.MagicMock(
name='rpc_client_instance')
self._api._rpc_client_instance.return_value = mock_client
vm_uuid = uuid.uuid1()
vif_uuid = uuid.uuid1()
self._api.add_port(str(vm_uuid), str(vif_uuid), 'tapX',
'aa:bb:cc:ee:ff:00')
self.assertTrue(mock_client.AddPort.called)
self.assertTrue(self._api._ports[vif_uuid])
self._api.delete_port(str(vif_uuid))
self.assertTrue(mock_client.DeletePort.called)
def test_resynchronize(self):
self._api._rpc_client_instance = mock.MagicMock(
name='rpc_client_instance')
self._api._rpc_client_instance.return_value = None
vm_uuid = str(uuid.uuid1())
vif_uuid = str(uuid.uuid1())
port1 = ttypes.Port(self._api._uuid_string_to_hex(vif_uuid),
self._api._uuid_string_to_hex(vm_uuid),
'tapX', '0.0.0.0', [0] * 16, 'aa:bb:cc:ee:ff:00')
self._api.add_port(vm_uuid, vif_uuid, 'tapX', 'aa:bb:cc:ee:ff:00')
mock_client = mock.Mock()
self._api._rpc_client_instance.return_value = mock_client
self._api.periodic_connection_check()
mock_client.AddPort.assert_called_with([port1])
def test_resynchronize_multi_ports(self):
self._api._rpc_client_instance = mock.MagicMock(
name='rpc_client_instance')
self._api._rpc_client_instance.return_value = None
vm_uuid = str(uuid.uuid1())
vif_uuid = str(uuid.uuid1())
port1 = ttypes.Port(self._api._uuid_string_to_hex(vif_uuid),
self._api._uuid_string_to_hex(vm_uuid),
'tapX', '0.0.0.0', [0] * 16, 'aa:bb:cc:ee:ff:00')
self._api.add_port(vm_uuid, vif_uuid, 'tapX', 'aa:bb:cc:ee:ff:00')
vm_uuid = str(uuid.uuid1())
vif_uuid = str(uuid.uuid1())
port2 = ttypes.Port(self._api._uuid_string_to_hex(vif_uuid),
self._api._uuid_string_to_hex(vm_uuid),
'tapY', '0.0.0.0', [0] * 16, '11:22:33:44:55:66')
self._api.add_port(vm_uuid, vif_uuid, 'tapY', '11:22:33:44:55:66')
mock_client = mock.Mock()
self._api._rpc_client_instance.return_value = mock_client
self._api.connect()
self._api._resynchronize()
mock_client.AddPort.assert_called_with([port1, port2])
def test_additional_arguments(self):
mock_client = mock.Mock()
self._api._rpc_client_instance = mock.MagicMock(
name='rpc_client_instance')
self._api._rpc_client_instance.return_value = mock_client
vif_uuid = uuid.uuid1()
network_uuid = uuid.uuid1()
project_id = uuid.uuid1().hex
self._api.add_port(str(uuid.uuid1()), str(vif_uuid), 'tapX',
'aa:bb:cc:ee:ff:00',
network_uuid=str(network_uuid),
vm_project_id=project_id)
self.assertTrue(mock_client.AddPort.called)
port = self._api._ports[vif_uuid]
self.assertEqual(self._api._uuid_to_hex(network_uuid),
port.vn_id)
self.assertEqual(self._api._uuid_string_to_hex(project_id),
port.vm_project_id)