• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python virt._gen_xml函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中salt.modules.virt._gen_xml函数的典型用法代码示例。如果您正苦于以下问题:Python _gen_xml函数的具体用法?Python _gen_xml怎么用?Python _gen_xml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_boot_default_dev

 def test_boot_default_dev(self):
     diskp = virt._disk_profile('default', 'kvm')
     nicp = virt._nic_profile('default', 'kvm')
     xml_data = virt._gen_xml(
         'hello',
         1,
         512,
         diskp,
         nicp,
         'kvm'
         )
     root = ET.fromstring(xml_data)
     self.assertEqual(root.find('os/boot').attrib['dev'], 'hd')
开发者ID:DaveQB,项目名称:salt,代码行数:13,代码来源:virt_test.py


示例2: test_boot_multiple_devs

 def test_boot_multiple_devs(self):
     diskp = virt._disk_profile('default', 'kvm')
     nicp = virt._nic_profile('default', 'kvm')
     xml_data = virt._gen_xml(
         'hello',
         1,
         512,
         diskp,
         nicp,
         'kvm',
         boot_dev='cdrom network'
         )
     root = ET.fromstring(xml_data)
     devs = root.findall('.//boot')
     self.assertTrue(len(devs) == 2)
开发者ID:DaveQB,项目名称:salt,代码行数:15,代码来源:virt_test.py


示例3: test_controller_for_kvm

 def test_controller_for_kvm(self):
     diskp = virt._disk_profile('default', 'kvm')
     nicp = virt._nic_profile('default', 'kvm')
     xml_data = virt._gen_xml(
         'hello',
         1,
         512,
         diskp,
         nicp,
         'kvm'
         )
     root = ET.fromstring(xml_data)
     controllers = root.findall('.//devices/controller')
     # There should be no controller
     self.assertTrue(len(controllers) == 0)
开发者ID:DaveQB,项目名称:salt,代码行数:15,代码来源:virt_test.py


示例4: test_gen_xml_for_serial_console

 def test_gen_xml_for_serial_console(self):
     diskp = virt._disk_profile('default', 'kvm')
     nicp = virt._nic_profile('default', 'kvm')
     xml_data = virt._gen_xml(
         'hello',
         1,
         512,
         diskp,
         nicp,
         'kvm',
         serial_type='pty',
         console=True
         )
     root = ET.fromstring(xml_data)
     self.assertEqual(root.find('devices/serial').attrib['type'], 'pty')
     self.assertEqual(root.find('devices/console').attrib['type'], 'pty')
开发者ID:DaveQB,项目名称:salt,代码行数:16,代码来源:virt_test.py


示例5: test_controller_for_esxi

 def test_controller_for_esxi(self):
     diskp = virt._disk_profile('default', 'esxi')
     nicp = virt._nic_profile('default', 'esxi')
     xml_data = virt._gen_xml(
         'hello',
         1,
         512,
         diskp,
         nicp,
         'esxi'
         )
     root = ET.fromstring(xml_data)
     controllers = root.findall('.//devices/controller')
     self.assertTrue(len(controllers) == 1)
     controller = controllers[0]
     self.assertEqual(controller.attrib['model'], 'lsilogic')
开发者ID:DaveQB,项目名称:salt,代码行数:16,代码来源:virt_test.py


示例6: test_gen_xml_for_telnet_console_unspecified_port

 def test_gen_xml_for_telnet_console_unspecified_port(self):
     diskp = virt._disk_profile('default', 'kvm')
     nicp = virt._nic_profile('default', 'kvm')
     xml_data = virt._gen_xml(
         'hello',
         1,
         512,
         diskp,
         nicp,
         'kvm',
         serial_type='tcp',
         console=True
         )
     root = ET.fromstring(xml_data)
     self.assertEqual(root.find('devices/serial').attrib['type'], 'tcp')
     self.assertEqual(root.find('devices/console').attrib['type'], 'tcp')
     self.assertIsInstance(int(root.find('devices/console/source').attrib['service']), int)
开发者ID:DaveQB,项目名称:salt,代码行数:17,代码来源:virt_test.py


示例7: test_gen_xml_for_kvm_custom_profile

    def test_gen_xml_for_kvm_custom_profile(self, disk_profile, nic_profile):
        diskp_yaml = '''
- first:
    size: 8192
    format: qcow2
    model: virtio
    pool: /var/lib/images
- second:
    size: 4096
    format: qcow2   # FIX remove line, currently test fails
    model: virtio   # FIX remove line, currently test fails
    pool: /var/lib/images
'''
        nicp_yaml = '''
- type: bridge
  name: eth1
  source: b2
  model: virtio
  mac: '00:00:00:00:00:00'
- name: eth2
  type: bridge
  source: b2
  model: virtio
  mac: '00:00:00:00:00:00'
'''
        disk_profile.return_value = yaml.load(diskp_yaml)
        nic_profile.return_value = yaml.load(nicp_yaml)
        diskp = virt._disk_profile('noeffect', 'kvm')
        nicp = virt._nic_profile('noeffect', 'kvm')
        xml_data = virt._gen_xml(
            'hello',
            1,
            512,
            diskp,
            nicp,
            'kvm',
            )
        root = ET.fromstring(xml_data)
        self.assertEqual(root.attrib['type'], 'kvm')
        self.assertEqual(root.find('vcpu').text, '1')
        self.assertEqual(root.find('memory').text, str(512 * 1024))
        self.assertEqual(root.find('memory').attrib['unit'], 'KiB')
        self.assertTrue(len(root.findall('.//disk')) == 2)
        self.assertTrue(len(root.findall('.//interface')) == 2)
开发者ID:DaveQB,项目名称:salt,代码行数:44,代码来源:virt_test.py


示例8: test_gen_xml_for_esxi_custom_profile

    def test_gen_xml_for_esxi_custom_profile(self, disk_profile, nic_profile):
        diskp_yaml = '''
- first:
    size: 8192
    format: vmdk
    model: scsi
    pool: datastore1
- second:
    size: 4096
    format: vmdk  # FIX remove line, currently test fails
    model: scsi   # FIX remove line, currently test fails
    pool: datastore2
'''
        nicp_yaml = '''
- type: bridge
  name: eth1
  source: ONENET
  model: e1000
  mac: '00:00:00:00:00:00'
- name: eth2
  type: bridge
  source: TWONET
  model: e1000
  mac: '00:00:00:00:00:00'
'''
        disk_profile.return_value = yaml.load(diskp_yaml)
        nic_profile.return_value = yaml.load(nicp_yaml)
        diskp = virt._disk_profile('noeffect', 'esxi')
        nicp = virt._nic_profile('noeffect', 'esxi')
        xml_data = virt._gen_xml(
            'hello',
            1,
            512,
            diskp,
            nicp,
            'esxi',
            )
        root = ET.fromstring(xml_data)
        self.assertEqual(root.attrib['type'], 'vmware')
        self.assertEqual(root.find('vcpu').text, '1')
        self.assertEqual(root.find('memory').text, str(512 * 1024))
        self.assertEqual(root.find('memory').attrib['unit'], 'KiB')
        self.assertTrue(len(root.findall('.//disk')) == 2)
        self.assertTrue(len(root.findall('.//interface')) == 2)
开发者ID:DaveQB,项目名称:salt,代码行数:44,代码来源:virt_test.py


示例9: test_gen_xml_for_kvm_default_profile

    def test_gen_xml_for_kvm_default_profile(self):
        diskp = virt._disk_profile('default', 'kvm')
        nicp = virt._nic_profile('default', 'kvm')
        xml_data = virt._gen_xml(
            'hello',
            1,
            512,
            diskp,
            nicp,
            'kvm',
            )
        root = ET.fromstring(xml_data)
        self.assertEqual(root.attrib['type'], 'kvm')
        self.assertEqual(root.find('vcpu').text, '1')
        self.assertEqual(root.find('memory').text, str(512 * 1024))
        self.assertEqual(root.find('memory').attrib['unit'], 'KiB')

        disks = root.findall('.//disk')
        self.assertEqual(len(disks), 1)
        disk = disks[0]
        self.assertTrue(disk.find('source').attrib['file'].startswith('/'))
        self.assertTrue('hello/system' in disk.find('source').attrib['file'])
        self.assertEqual(disk.find('target').attrib['dev'], 'vda')
        self.assertEqual(disk.find('target').attrib['bus'], 'virtio')
        self.assertEqual(disk.find('driver').attrib['name'], 'qemu')
        self.assertEqual(disk.find('driver').attrib['type'], 'qcow2')

        interfaces = root.findall('.//interface')
        self.assertEqual(len(interfaces), 1)
        iface = interfaces[0]
        self.assertEqual(iface.attrib['type'], 'bridge')
        self.assertEqual(iface.find('source').attrib['bridge'], 'br0')
        self.assertEqual(iface.find('model').attrib['type'], 'virtio')

        mac = iface.find('mac').attrib['address']
        self.assertTrue(
              re.match('^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$', mac, re.I))
开发者ID:DaveQB,项目名称:salt,代码行数:37,代码来源:virt_test.py


示例10: test_gen_xml_for_esxi_default_profile

    def test_gen_xml_for_esxi_default_profile(self):
        diskp = virt._disk_profile('default', 'esxi')
        nicp = virt._nic_profile('default', 'esxi')
        xml_data = virt._gen_xml(
            'hello',
            1,
            512,
            diskp,
            nicp,
            'esxi',
            )
        root = ET.fromstring(xml_data)
        self.assertEqual(root.attrib['type'], 'vmware')
        self.assertEqual(root.find('vcpu').text, '1')
        self.assertEqual(root.find('memory').text, str(512 * 1024))
        self.assertEqual(root.find('memory').attrib['unit'], 'KiB')

        disks = root.findall('.//disk')
        self.assertEqual(len(disks), 1)
        disk = disks[0]
        self.assertTrue('[0]' in disk.find('source').attrib['file'])
        self.assertTrue('hello/system' in disk.find('source').attrib['file'])
        self.assertEqual(disk.find('target').attrib['dev'], 'sda')
        self.assertEqual(disk.find('target').attrib['bus'], 'scsi')
        self.assertEqual(disk.find('address').attrib['unit'], '0')

        interfaces = root.findall('.//interface')
        self.assertEqual(len(interfaces), 1)
        iface = interfaces[0]
        self.assertEqual(iface.attrib['type'], 'bridge')
        self.assertEqual(iface.find('source').attrib['bridge'], 'DEFAULT')
        self.assertEqual(iface.find('model').attrib['type'], 'e1000')

        mac = iface.find('mac').attrib['address']
        self.assertTrue(
              re.match('^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$', mac, re.I))
开发者ID:DaveQB,项目名称:salt,代码行数:36,代码来源:virt_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python virt._nic_profile函数代码示例发布时间:2022-05-27
下一篇:
Python virt._disk_profile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap