devicedisk: Add set_vol_install

And use it in places where we don't need set_create_storage
This commit is contained in:
Cole Robinson 2014-12-05 20:12:35 -05:00
parent 2acbf52ce3
commit 210ab4d8e0
3 changed files with 7 additions and 6 deletions

View File

@ -1585,7 +1585,7 @@ class ParserDisk(VirtCLIParser):
vol_install = VirtualDisk.build_vol_install(
self.guest.conn, newvolname, poolobj, size, sparse,
fmt=fmt, backing_store=backing_store)
inst.set_create_storage(vol_install=vol_install)
inst.set_vol_install(vol_install)
if not inst.target:
skip_targets = [d.target for d in self.guest.get_devices("disk")]

View File

@ -509,6 +509,11 @@ class VirtualDisk(VirtualDevice):
self._change_backend(None, vol_object)
self._set_xmlpath(self.path)
def set_vol_install(self, vol_install):
self._storage_creator = diskbackend.StorageCreator(self.conn,
None, None, vol_install, None, None, None, None, None)
self._set_xmlpath(self.path)
def get_vol_object(self):
return self._storage_backend.get_vol_object()
def get_vol_install(self):

View File

@ -106,9 +106,6 @@ def _upload_file(conn, meter, destpool, src):
# Build placeholder volume
size = os.path.getsize(src)
basename = os.path.basename(src)
xmlobj = StoragePool(conn, parsexml=destpool.XMLDesc(0))
poolpath = xmlobj.target_path
name = StorageVolume.find_free_name(destpool, basename)
if name != basename:
logging.debug("Generated non-colliding volume name %s", name)
@ -117,8 +114,7 @@ def _upload_file(conn, meter, destpool, src):
(float(size) / 1024.0 / 1024.0 / 1024.0), True)
disk = VirtualDisk(conn)
disk.path = os.path.join(poolpath, name)
disk.set_create_storage(vol_install=vol_install)
disk.set_vol_install(vol_install)
disk.validate()
disk.setup(meter=meter)