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


Python XMLBuilder.bios方法代码示例

本文整理汇总了Python中xmlbuilder.XMLBuilder.bios方法的典型用法代码示例。如果您正苦于以下问题:Python XMLBuilder.bios方法的具体用法?Python XMLBuilder.bios怎么用?Python XMLBuilder.bios使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlbuilder.XMLBuilder的用法示例。


在下文中一共展示了XMLBuilder.bios方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_node_xml

# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import bios [as 别名]
    def build_node_xml(self, node, emulator):
        """Generate node XML

        :type node: Node
        :type emulator: String
            :rtype : String
        """
        node_xml = XMLBuilder("domain", type=node.hypervisor)
        node_xml.name(
            self._get_name(node.environment and node.environment.name or '',
                           node.name))
        with node_xml.cpu(mode='host-model'):
            node_xml.model(fallback='forbid')
        node_xml.vcpu(str(node.vcpu))
        node_xml.memory(str(node.memory * 1024), unit='KiB')

        node_xml.clock(offset='utc')
        node_xml.clock.timer(
            name='hpet',
            present='yes' if self.driver.hpet else 'no')

        with node_xml.os:
            node_xml.type(node.os_type, arch=node.architecture)
            for boot_dev in json.loads(node.boot):
                node_xml.boot(dev=boot_dev)
            if self.driver.reboot_timeout:
                node_xml.bios(rebootTimeout='{0}'.format(
                    self.driver.reboot_timeout))

        with node_xml.devices:
            node_xml.emulator(emulator)
            if node.has_vnc:
                if node.vnc_password:
                    node_xml.graphics(
                        type='vnc',
                        listen='0.0.0.0',
                        autoport='yes',
                        passwd=node.vnc_password)
                else:
                    node_xml.graphics(
                        type='vnc',
                        listen='0.0.0.0',
                        autoport='yes')

            for disk_device in node.disk_devices:
                self._build_disk_device(node_xml, disk_device)
            for interface in node.interfaces:
                self._build_interface_device(node_xml, interface)
            with node_xml.video:
                node_xml.model(type='vga', vram='9216', heads='1')
            with node_xml.serial(type='pty'):
                node_xml.target(port='0')
            with node_xml.console(type='pty'):
                node_xml.target(type='serial', port='0')
        return str(node_xml)
开发者ID:unixboy,项目名称:fuel-devops,代码行数:57,代码来源:libvirt_xml_builder.py

示例2: build_node_xml

# 需要导入模块: from xmlbuilder import XMLBuilder [as 别名]
# 或者: from xmlbuilder.XMLBuilder import bios [as 别名]
    def build_node_xml(self, node, emulator):
        """Generate node XML

        :type node: Node
        :type emulator: String
            :rtype : String
        """
        node_xml = XMLBuilder("domain", type=node.hypervisor)
        node_xml.name(
            self._get_name(node.environment and node.environment.name or '',
                           node.name))
        if self.driver.use_host_cpu:
            node_xml.cpu(mode='host-passthrough')
        node_xml.vcpu(str(node.vcpu))
        node_xml.memory(str(node.memory * 1024), unit='KiB')

        if self.driver.use_hugepages:
            with node_xml.memoryBacking:
                node_xml.hugepages

        node_xml.clock(offset='utc')
        with node_xml.clock.timer(name='rtc',
                                  tickpolicy='catchup', track='wall'):
            node_xml.catchup(
                threshold='123',
                slew='120',
                limit='10000')
        node_xml.clock.timer(
            name='pit',
            tickpolicy='delay')
        node_xml.clock.timer(
            name='hpet',
            present='yes' if self.driver.hpet else 'no')

        with node_xml.os:
            node_xml.type(node.os_type, arch=node.architecture)
            for boot_dev in json.loads(node.boot):
                node_xml.boot(dev=boot_dev)
            if self.driver.reboot_timeout:
                node_xml.bios(rebootTimeout='{0}'.format(
                    self.driver.reboot_timeout))
            if node.should_enable_boot_menu:
                node_xml.bootmenu(enable='yes', timeout='3000')

        with node_xml.devices:
            node_xml.controller(type='usb', model='nec-xhci')
            node_xml.emulator(emulator)
            if node.has_vnc:
                if node.vnc_password:
                    node_xml.graphics(
                        type='vnc',
                        listen='0.0.0.0',
                        autoport='yes',
                        passwd=node.vnc_password)
                else:
                    node_xml.graphics(
                        type='vnc',
                        listen='0.0.0.0',
                        autoport='yes')

            for disk_device in node.disk_devices:
                self._build_disk_device(node_xml, disk_device)
            for interface in node.interfaces:
                self._build_interface_device(node_xml, interface)
            with node_xml.video:
                node_xml.model(type='vga', vram='9216', heads='1')
            with node_xml.serial(type='pty'):
                node_xml.target(port='0')
            with node_xml.console(type='pty'):
                node_xml.target(type='serial', port='0')
        return str(node_xml)
开发者ID:asledzinskiy,项目名称:fuel-devops,代码行数:73,代码来源:libvirt_xml_builder.py


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