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 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