當前位置: 首頁>>代碼示例>>Python>>正文


Python VirtualDisk.wants_storage_creation方法代碼示例

本文整理匯總了Python中virtinst.VirtualDisk.wants_storage_creation方法的典型用法代碼示例。如果您正苦於以下問題:Python VirtualDisk.wants_storage_creation方法的具體用法?Python VirtualDisk.wants_storage_creation怎麽用?Python VirtualDisk.wants_storage_creation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在virtinst.VirtualDisk的用法示例。


在下文中一共展示了VirtualDisk.wants_storage_creation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _make_guest

# 需要導入模塊: from virtinst import VirtualDisk [as 別名]
# 或者: from virtinst.VirtualDisk import wants_storage_creation [as 別名]
def _make_guest(installer=None, conn=None):
    if conn is None:
        conn = _default_conn

    g = virtinst.Guest(conn)
    g.type = "kvm"
    g.name = "TestGuest"
    g.memory = int(200 * 1024)
    g.maxmemory = int(400 * 1024)
    g.uuid = "12345678-1234-1234-1234-123456789012"
    gdev = virtinst.VirtualGraphics(conn)
    gdev.type = "vnc"
    gdev.keymap = "ja"
    g.add_device(gdev)
    g.features.pae = False
    g.vcpus = 5

    if not installer:
        installer = _make_installer(conn=conn)
    g.installer = installer
    g.emulator = "/usr/lib/xen/bin/qemu-dm"
    g.os.arch = "i686"
    g.os.os_type = "hvm"

    g.add_default_input_device()
    g.add_default_console_device()
    g.add_device(virtinst.VirtualAudio(g.conn))

    # Floppy disk
    path = "/dev/default-pool/testvol1.img"
    d = VirtualDisk(conn)
    d.path = path
    d.device = d.DEVICE_FLOPPY
    d.validate()
    g.add_device(d)

    # File disk
    path = "/dev/default-pool/new-test-suite.img"
    d = virtinst.VirtualDisk(conn)
    d.path = path

    if d.wants_storage_creation():
        parent_pool = d.get_parent_pool()
        vol_install = virtinst.VirtualDisk.build_vol_install(conn,
            os.path.basename(path), parent_pool, .0000001, True)
        d.set_vol_install(vol_install)

    d.validate()
    g.add_device(d)

    # Block disk
    path = "/dev/disk-pool/diskvol1"
    d = virtinst.VirtualDisk(conn)
    d.path = path
    d.validate()
    g.add_device(d)

    # Network device
    dev = virtinst.VirtualNetworkInterface(conn)
    dev.macaddr = "22:22:33:44:55:66"
    dev.type = virtinst.VirtualNetworkInterface.TYPE_VIRTUAL
    dev.source = "default"
    g.add_device(dev)

    return g
開發者ID:aenertia,項目名稱:virt-manager,代碼行數:67,代碼來源:xmlconfig.py


注:本文中的virtinst.VirtualDisk.wants_storage_creation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。