当前位置: 首页>>代码示例>>Python>>正文


Python VMModel.vm_get_os_metadata方法代码示例

本文整理汇总了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']
开发者ID:gouzongmei,项目名称:t1,代码行数:28,代码来源:vmifaces.py

示例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']
开发者ID:abhiramkulkarni,项目名称:kimchi,代码行数:49,代码来源:vmifaces.py

示例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']
开发者ID:k0da,项目名称:kimchi,代码行数:8,代码来源:vmstorages.py


注:本文中的kimchi.model.vms.VMModel.vm_get_os_metadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。