本文整理汇总了Python中virttest.libvirt_xml.devices.disk.Disk.share方法的典型用法代码示例。如果您正苦于以下问题:Python Disk.share方法的具体用法?Python Disk.share怎么用?Python Disk.share使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virttest.libvirt_xml.devices.disk.Disk
的用法示例。
在下文中一共展示了Disk.share方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_vm_disk_xml
# 需要导入模块: from virttest.libvirt_xml.devices.disk import Disk [as 别名]
# 或者: from virttest.libvirt_xml.devices.disk.Disk import share [as 别名]
def get_vm_disk_xml(dev_type, dev_name, **options):
"""
Create a disk xml object and return it.
:param dev_type. Disk type.
:param dev_name. Disk device name.
:param options. Disk options.
:return: Disk xml object.
"""
# Create disk xml
disk_xml = Disk(type_name=dev_type)
disk_xml.device = options["disk_device"]
if options.has_key("sgio") and options["sgio"] != "":
disk_xml.sgio = options["sgio"]
disk_xml.device = "lun"
disk_xml.rawio = "no"
if dev_type == "block":
disk_attr = "dev"
else:
disk_attr = "file"
disk_xml.target = {'dev': options["target"],
'bus': options["bus"]}
disk_xml.source = disk_xml.new_disk_source(
**{'attrs': {disk_attr: dev_name}})
# Add driver options from parameters.
driver_dict = {"name": "qemu"}
if options.has_key("driver"):
for driver_option in options["driver"].split(','):
if driver_option != "":
d = driver_option.split('=')
logging.debug("disk driver option: %s=%s", d[0], d[1])
driver_dict.update({d[0].strip(): d[1].strip()})
disk_xml.driver = driver_dict
if options.has_key("share"):
if options["share"] == "shareable":
disk_xml.share = True
if options.has_key("readonly"):
if options["readonly"] == "readonly":
disk_xml.readonly = True
logging.debug("The disk xml is: %s" % disk_xml.xmltreefile)
return disk_xml