本文整理匯總了Python中vnc_api.vnc_api.VirtualMachineInterface.uuid方法的典型用法代碼示例。如果您正苦於以下問題:Python VirtualMachineInterface.uuid方法的具體用法?Python VirtualMachineInterface.uuid怎麽用?Python VirtualMachineInterface.uuid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vnc_api.vnc_api.VirtualMachineInterface
的用法示例。
在下文中一共展示了VirtualMachineInterface.uuid方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_vmi
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import uuid [as 別名]
def _create_vmi(self, pod_task_id, vm_obj, vn_obj):
proj_fq_name = vnc_mesos_config.cluster_project_fq_name('default')
proj_obj = self._vnc_lib.project_read(fq_name=proj_fq_name)
vmi_prop = None
obj_uuid = str(uuid.uuid1())
vmi_obj = VirtualMachineInterface(
name=vm_obj.name, parent_obj=proj_obj,
virtual_machine_interface_properties=vmi_prop,
display_name=vm_obj.name)
vmi_obj.uuid = obj_uuid
vmi_obj.set_virtual_network(vn_obj)
vmi_obj.set_virtual_machine(vm_obj)
vmi_obj.add_annotations(KeyValuePair(key='index', value='0/1'))
vmi_obj.port_security_enabled = True
VirtualMachineInterfaceMM.add_annotations(self, vmi_obj, pod_task_id)
try:
vmi_uuid = self._vnc_lib.virtual_machine_interface_create(vmi_obj)
except RefsExistError:
vmi_uuid = self._vnc_lib.virtual_machine_interface_update(vmi_obj)
VirtualMachineInterfaceMM.locate(vmi_uuid)
return vmi_uuid
示例2: test_create_pool
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import uuid [as 別名]
def test_create_pool(self):
tenant_id = _uuid()
pool_id = _uuid()
vip_id = _uuid()
subnet_id = _uuid()
api = self.api_server
project = Project(name='test')
project.uuid = tenant_id
template = ServiceTemplate('lb-test', project)
template.uuid = _uuid()
pool_attrs = LoadbalancerPoolType()
pool_attrs.subnet_id = subnet_id
pool = LoadbalancerPool(
pool_id, project, loadbalancer_pool_properties=pool_attrs)
pool.uuid = pool_id
vip_attrs = VirtualIpType()
vip_attrs.subnet_id = subnet_id
vip_attrs.address = '127.0.0.1'
vip = VirtualIp(vip_id, project, virtual_ip_properties=vip_attrs)
vip.uuid = vip_id
vip.set_loadbalancer_pool(pool)
vnet = VirtualNetwork('test', project)
vnet.uuid = _uuid()
vmi = VirtualMachineInterface(vip_id, project)
vmi.uuid = _uuid()
vmi.set_virtual_network(vnet)
iip = InstanceIp(vip_id, instance_ip_address='127.0.0.1')
iip.uuid = _uuid()
iip.set_virtual_machine_interface(vmi)
iip_refs = [
{'to': iip.get_fq_name(), 'uuid': iip.uuid}
]
vmi.get_instance_ip_back_refs = mock.Mock()
vmi.get_instance_ip_back_refs.return_value = iip_refs
vip.set_virtual_machine_interface(vmi)
api.virtual_service_template_read = template
api.loadbalancer_pool_read.return_value = pool
api.virtual_ip_read.return_value = vip
api.kv_retrieve.return_value = '%s %s' % (vnet.uuid, subnet_id)
api.virtual_machine_interface_read.return_value = vmi
api.instance_ip_read.return_value = iip
api.service_instance_read.side_effect = NoIdError('404')
context = {}
pool_data = {
'id': pool_id,
'vip_id': vip_id
}
self.driver.create_pool(context, pool_data)
api.service_instance_create.assert_called_with(mock.ANY)
示例3: _create_vmi
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import uuid [as 別名]
def _create_vmi(self, pod_name, pod_namespace, pod_id, vm_obj, vn_obj,
parent_vmi, idx, nw_name=''):
proj_fq_name = vnc_kube_config.cluster_project_fq_name(pod_namespace)
proj_obj = self._vnc_lib.project_read(fq_name=proj_fq_name)
vmi_prop = None
if self._is_pod_nested() and parent_vmi:
# Pod is nested.
# Allocate a vlan-id for this pod from the vlan space managed
# in the VMI of the underlay VM.
parent_vmi = VirtualMachineInterfaceKM.get(parent_vmi.uuid)
vlan_id = parent_vmi.alloc_vlan()
vmi_prop = VirtualMachineInterfacePropertiesType(
sub_interface_vlan_tag=vlan_id)
obj_uuid = str(uuid.uuid1())
name = VncCommon.make_name(pod_name, obj_uuid)
vmi_obj = VirtualMachineInterface(
name=name, parent_obj=proj_obj,
virtual_machine_interface_properties=vmi_prop,
display_name=name)
vmi_obj.uuid = obj_uuid
vmi_obj.set_virtual_network(vn_obj)
vmi_obj.set_virtual_machine(vm_obj)
self._associate_security_groups(vmi_obj, proj_obj, pod_namespace)
vmi_obj.port_security_enabled = True
VirtualMachineInterfaceKM.add_annotations(self, vmi_obj, pod_namespace,
pod_name, index=idx, network=nw_name)
try:
vmi_uuid = self._vnc_lib.virtual_machine_interface_create(vmi_obj)
except RefsExistError:
vmi_uuid = self._vnc_lib.virtual_machine_interface_update(vmi_obj)
VirtualMachineInterfaceKM.locate(vmi_uuid)
return vmi_uuid