本文整理汇总了Python中kimchi.model.vms.VMModel.vm_get_os_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python VMModel.vm_get_os_metadata方法的具体用法?Python VMModel.vm_get_os_metadata怎么用?Python VMModel.vm_get_os_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kimchi.model.vms.VMModel
的用法示例。
在下文中一共展示了VMModel.vm_get_os_metadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from kimchi.model.vms import VMModel [as 别名]
# 或者: from kimchi.model.vms.VMModel import vm_get_os_metadata [as 别名]
def create(self, vm, params):
conn = self.conn.get()
networks = conn.listNetworks() + conn.listDefinedNetworks()
if params["type"] == "network" and params["network"] not in networks:
raise InvalidParameter("KCHVMIF0002E",
{'name': vm, 'network': params["network"]})
dom = VMModel.get_vm(vm, self.conn)
if DOM_STATE_MAP[dom.info()[0]] != "shutoff":
raise InvalidOperation("KCHVMIF0003E")
macs = (iface.mac.get('address')
for iface in self.get_vmifaces(vm, self.conn))
while True:
params['mac'] = VMIfacesModel.random_mac()
if params['mac'] not in macs:
break
os_data = VMModel.vm_get_os_metadata(dom, self.caps.metadata_support)
os_distro, os_version = os_data
xml = get_iface_xml(params, conn.getInfo()[0], os_distro, os_version)
dom.attachDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_CURRENT)
return params['mac']
示例2: create
# 需要导入模块: from kimchi.model.vms import VMModel [as 别名]
# 或者: from kimchi.model.vms.VMModel import vm_get_os_metadata [as 别名]
def create(self, vm, params):
conn = self.conn.get()
networks = conn.listNetworks() + conn.listDefinedNetworks()
networks = map(lambda x: x.decode('utf-8'), networks)
if params['type'] == 'network':
network = params.get("network")
if network is None:
raise MissingParameter('KCHVMIF0007E')
if network not in networks:
raise InvalidParameter('KCHVMIF0002E',
{'name': vm, 'network': network})
macs = (iface.mac.get('address')
for iface in self.get_vmifaces(vm, self.conn))
# user defined customized mac address
if 'mac' in params and params['mac']:
# make sure it is unique
if params['mac'] in macs:
raise InvalidParameter('KCHVMIF0009E',
{'name': vm, 'mac': params['mac']})
# otherwise choose a random mac address
else:
while True:
params['mac'] = VMIfacesModel.random_mac()
if params['mac'] not in macs:
break
dom = VMModel.get_vm(vm, self.conn)
os_data = VMModel.vm_get_os_metadata(dom)
os_version, os_distro = os_data
xml = get_iface_xml(params, conn.getInfo()[0], os_distro, os_version)
flags = 0
if dom.isPersistent():
flags |= libvirt.VIR_DOMAIN_AFFECT_CONFIG
if DOM_STATE_MAP[dom.info()[0]] != "shutoff":
flags |= libvirt.VIR_DOMAIN_AFFECT_LIVE
dom.attachDeviceFlags(xml, flags)
return params['mac']
示例3: _get_device_bus
# 需要导入模块: from kimchi.model.vms import VMModel [as 别名]
# 或者: from kimchi.model.vms.VMModel import vm_get_os_metadata [as 别名]
def _get_device_bus(dev_type, dom):
try:
version, distro = VMModel.vm_get_os_metadata(dom)
except:
version, distro = ('unknown', 'unknown')
return lookup(distro, version)[dev_type+'_bus']