本文整理匯總了Python中vnc_api.vnc_api.VirtualMachineInterface.set_virtual_machine方法的典型用法代碼示例。如果您正苦於以下問題:Python VirtualMachineInterface.set_virtual_machine方法的具體用法?Python VirtualMachineInterface.set_virtual_machine怎麽用?Python VirtualMachineInterface.set_virtual_machine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vnc_api.vnc_api.VirtualMachineInterface
的用法示例。
在下文中一共展示了VirtualMachineInterface.set_virtual_machine方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_vmi
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import set_virtual_machine [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: create_virtual_machine
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import set_virtual_machine [as 別名]
def create_virtual_machine(self, name, vn, ipaddress):
vm = VirtualMachine(name)
self._vnc_lib.virtual_machine_create(vm)
VirtualMachineKM.locate(vm.uuid)
vmi = VirtualMachineInterface(
parent_type='virtual-machine', fq_name=[name, '0'])
vmi.set_virtual_machine(vm)
vmi.set_virtual_network(vn)
self._vnc_lib.virtual_machine_interface_create(vmi)
VirtualMachineInterfaceKM.locate(vmi.uuid)
ip = InstanceIp(vm.name + '.0')
ip.set_virtual_machine_interface(vmi)
ip.set_virtual_network(vn)
ip.set_instance_ip_address(ipaddress)
self._vnc_lib.instance_ip_create(ip)
InstanceIpKM.locate(ip.uuid)
return vm, vmi, ip
示例3: create_virtual_machine
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import set_virtual_machine [as 別名]
def create_virtual_machine(self, name, vn, ipaddress):
vm = VirtualMachine(name)
self._vnc_lib.virtual_machine_create(vm)
VirtualMachineKM.locate(vm.uuid)
vmi = VirtualMachineInterface(
parent_type='virtual-machine', fq_name=[name, '0'])
vmi.set_virtual_machine(vm)
vmi.set_virtual_network(vn)
if DBBaseKM.is_nested():
vmi.set_virtual_machine_interface_bindings(
KeyValuePairs([KeyValuePair('host_id', 'WHATEVER')]))
self._vnc_lib.virtual_machine_interface_create(vmi)
VirtualMachineInterfaceKM.locate(vmi.uuid)
ip = InstanceIp(vm.name + '.0')
ip.set_virtual_machine_interface(vmi)
ip.set_virtual_network(vn)
ip.set_instance_ip_address(ipaddress)
self._vnc_lib.instance_ip_create(ip)
InstanceIpKM.locate(ip.uuid)
return vm, vmi, ip
示例4: _create_vmi
# 需要導入模塊: from vnc_api.vnc_api import VirtualMachineInterface [as 別名]
# 或者: from vnc_api.vnc_api.VirtualMachineInterface import set_virtual_machine [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