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)
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)
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")
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"
def build_vol_install(conn, path, pool, size, sparse): # Path wasn't a volume. See if base of path is a managed # pool, and if so, setup a StorageVolume object if size is None: raise ValueError(_("Size must be specified for non " "existent volume path '%s'" % path)) logging.debug("Path '%s' is target for pool '%s'. " "Creating volume '%s'.", os.path.dirname(path), pool.name(), os.path.basename(path)) cap = (size * 1024 * 1024 * 1024) if sparse: alloc = 0 else: alloc = cap volinst = StorageVolume(conn) volinst.pool = pool volinst.name = os.path.basename(path) volinst.capacity = cap volinst.allocation = alloc return volinst
def _make_stub_vol(self, xml=None): vol = StorageVolume(self.conn.get_backend(), parsexml=xml) vol.pool = self._parent_pool.get_backend() return vol
def _make_stub_vol(self): vol = StorageVolume(self.conn.get_backend()) vol.pool = self._parent_pool.get_backend() return vol