本文整理汇总了Python中ci.tests.general.general.General.get_os方法的典型用法代码示例。如果您正苦于以下问题:Python General.get_os方法的具体用法?Python General.get_os怎么用?Python General.get_os使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ci.tests.general.general.General
的用法示例。
在下文中一共展示了General.get_os方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_vm
# 需要导入模块: from ci.tests.general.general import General [as 别名]
# 或者: from ci.tests.general.general.General import get_os [as 别名]
def create_vm(self, name, ram=1024, small=False):
"""
Create a Virtual Machine
:param name: Name of the Virtual Machine
:param ram: Amount of RAM
:param small: Small
:return: None
"""
os_name = General.get_os()
bootdisk_path_remote = General.get_os_info(os_name + '_small' if small else os_name)['bootdisk_location']
vm_path = '/'.join([self.mountpoint, name])
if not os.path.exists(vm_path):
os.mkdir(vm_path)
if small:
bootdisk_path = '/'.join([self.mountpoint, name, "bootdiskfast.raw"])
else:
bootdisk_path = '/'.join([self.mountpoint, name, "bootdisk.raw"])
if not os.path.exists(bootdisk_path):
template_server = General.get_template_server()
bootdisk_url = urlparse.urljoin(template_server, bootdisk_path_remote)
logging.log(1, 'Template url: {0}'.format(bootdisk_url))
logging.log(1, 'Bootdisk path: {0}'.format(bootdisk_path))
GeneralHypervisor.download_to_vpool(bootdisk_url, bootdisk_path)
# When running with devstack need to set kvm group
if GeneralOpenStack.is_openstack_present():
General.execute_command("chgrp kvm {0}".format(bootdisk_path))
cmd = "virt-install --connect qemu:///system -n {name} -r {ram} --disk {bootdisk_path},device=disk,format=raw,bus=virtio --import --graphics vnc,listen=0.0.0.0 --vcpus=1 --network network=default,mac=RANDOM,model=e1000 --boot hd"
cmd = cmd.format(name=name,
bootdisk_path=bootdisk_path,
ram=ram)
out, error, _ = General.execute_command(cmd)
logging.log(1, 'cmd: ---')
logging.log(1, cmd)
logging.log(1, 'stdout: ---')
logging.log(1, 'stdout: ---')
logging.log(1, out)
logging.log(1, 'stderr: ---')
logging.log(1, error)