storage: fix Storage.clone and Storage.clone_volume
1. Volume.import_volume expect volume to be created first. 2. asyncio.wait do not accept generator, it must be concrete iterable.
This commit is contained in:
parent
1af7034d57
commit
910f793c61
@ -513,13 +513,22 @@ class Storage(object):
|
|||||||
src_volume = src_vm.volumes[name]
|
src_volume = src_vm.volumes[name]
|
||||||
msg = "Importing volume {!s} from vm {!s}"
|
msg = "Importing volume {!s} from vm {!s}"
|
||||||
self.vm.log.info(msg.format(src_volume.name, src_vm.name))
|
self.vm.log.info(msg.format(src_volume.name, src_vm.name))
|
||||||
|
|
||||||
|
# First create the destination volume
|
||||||
|
create_op_ret = dst.create()
|
||||||
|
# clone/import functions may be either synchronous or asynchronous
|
||||||
|
# in the later case, we need to wait for them to finish
|
||||||
|
if asyncio.iscoroutine(create_op_ret):
|
||||||
|
yield from create_op_ret
|
||||||
|
|
||||||
|
# Then import data from source volume
|
||||||
clone_op_ret = dst.import_volume(src_volume)
|
clone_op_ret = dst.import_volume(src_volume)
|
||||||
|
|
||||||
# clone/import functions may be either synchronous or asynchronous
|
# clone/import functions may be either synchronous or asynchronous
|
||||||
# in the later case, we need to wait for them to finish
|
# in the later case, we need to wait for them to finish
|
||||||
if asyncio.iscoroutine(clone_op_ret):
|
if asyncio.iscoroutine(clone_op_ret):
|
||||||
clone_op_ret = yield from clone_op_ret
|
yield from clone_op_ret
|
||||||
self.vm.volumes[name] = clone_op_ret
|
self.vm.volumes[name] = dst
|
||||||
return self.vm.volumes[name]
|
return self.vm.volumes[name]
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -528,8 +537,8 @@ class Storage(object):
|
|||||||
|
|
||||||
self.vm.volumes = {}
|
self.vm.volumes = {}
|
||||||
with VmCreationManager(self.vm):
|
with VmCreationManager(self.vm):
|
||||||
yield from asyncio.wait(self.clone_volume(src_vm, vol_name)
|
yield from asyncio.wait([self.clone_volume(src_vm, vol_name)
|
||||||
for vol_name in self.vm.volume_config.keys())
|
for vol_name in self.vm.volume_config.keys()])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def outdated_volumes(self):
|
def outdated_volumes(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user