Example #1
0
def createVol(conn, poolobj, volname=None, input_vol=None, clone_vol=None):
    if volname is None:
        volname = poolobj.name() + "-vol"

    # Format here depends on libvirt-1.2.0 and later
    if clone_vol and conn.local_libvirt_version() < 1002000:
        logging.debug("skip clone compare")
        return

    alloc = 5 * 1024 * 1024 * 1024
    cap = 10 * 1024 * 1024 * 1024
    vol_inst = StorageVolume(conn)
    vol_inst.pool = poolobj
    vol_inst.name = volname
    vol_inst.capacity = cap
    vol_inst.allocation = alloc

    vol_inst.permissions.mode = "0700"
    vol_inst.permissions.owner = "10736"
    vol_inst.permissions.group = "10736"

    if input_vol:
        vol_inst.input_vol = input_vol
        vol_inst.sync_input_vol()
    elif clone_vol:
        vol_inst = StorageVolume(conn, parsexml=clone_vol.XMLDesc(0))
        vol_inst.input_vol = clone_vol
        vol_inst.sync_input_vol()
        vol_inst.name = volname

    vol_inst.validate()
    filename = os.path.join(basepath, vol_inst.name + ".xml")
    utils.diff_compare(vol_inst.get_xml_config(), filename)
    return vol_inst.install(meter=False)
Example #2
0
 def cb_cache_new_pool(poolobj):
     # Used by clonetest.py nvram-newpool test
     if poolobj.name() == "nvram-newpool":
         from virtinst import StorageVolume
         vol = StorageVolume(conn)
         vol.pool = poolobj
         vol.name = "clone-orig-vars.fd"
         vol.capacity = 1024 * 1024
         vol.install()
     conn._cache_new_pool_raw(poolobj)
Example #3
0
    def testMisc(self):
        # Misc coverage testing
        vol = StorageVolume(self.conn)
        self.assertTrue(vol.is_size_conflict()[0] is False)

        fullconn = utils.URIs.open_testdriver_cached()
        glusterpool = fullconn.storagePoolLookupByName("gluster-pool")
        diskpool = fullconn.storagePoolLookupByName("disk-pool")

        glustervol = StorageVolume(fullconn)
        glustervol.pool = glusterpool
        self.assertTrue(glustervol.supports_format() is True)

        diskvol = StorageVolume(fullconn)
        diskvol.pool = diskpool
        self.assertTrue(diskvol.supports_format() is False)

        glusterpool.destroy()
        StoragePool.ensure_pool_is_running(glusterpool)

        # Check pool collision detection
        self.assertEqual(StoragePool.find_free_name(fullconn, "gluster-pool"),
                         "gluster-pool-1")
Example #4
0
def testMisc():
    conn = utils.URIs.open_testdefault_cached()
    # Misc coverage testing
    vol = StorageVolume(conn)
    assert vol.is_size_conflict()[0] is False

    fullconn = utils.URIs.open_testdriver_cached()
    glusterpool = fullconn.storagePoolLookupByName("gluster-pool")
    diskpool = fullconn.storagePoolLookupByName("disk-pool")

    glustervol = StorageVolume(fullconn)
    glustervol.pool = glusterpool
    assert glustervol.supports_format() is False

    diskvol = StorageVolume(fullconn)
    diskvol.pool = diskpool
    assert diskvol.supports_format() is False

    glusterpool.destroy()
    StoragePool.ensure_pool_is_running(glusterpool)

    # Check pool collision detection
    name = StoragePool.find_free_name(fullconn, "gluster-pool")
    assert name == "gluster-pool-1"
Example #5
0
 def _make_stub_vol(self):
     self.vol = StorageVolume(self.conn.get_backend())
     self.vol.pool = self.parent_pool.get_backend()
Example #6
0
 def _make_stub_vol(self, xml=None):
     vol = StorageVolume(self.conn.get_backend(), parsexml=xml)
     vol.pool = self._parent_pool.get_backend()
     return vol
Example #7
0
 def _make_stub_vol(self):
     vol = StorageVolume(self.conn.get_backend())
     vol.pool = self._parent_pool.get_backend()
     return vol