Skip to content

Commit

Permalink
kvm: browse through pools when deleting a template
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jan 17, 2019
1 parent 5654bb9 commit 8788e71
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions kvirt/kvm/__init__.py
Expand Up @@ -1475,7 +1475,6 @@ def reserve_dns(self, name, nets=[], domain=None, ip=None, alias=[], force=False
:param force:
:return:
"""
print("prout")
conn = self.conn
net = nets[0]
if isinstance(net, dict):
Expand Down Expand Up @@ -2276,15 +2275,14 @@ def delete_image(self, image):
conn = self.conn
shortname = os.path.basename(image)
for poolname in conn.listStoragePools():
if self.get_pool_path(poolname) == os.path.dirname(image):
try:
pool = conn.storagePoolLookupByName(poolname)
volume = pool.storageVolLookupByName(shortname)
except:
return {'result': 'failure', 'reason': 'pool not found'}
volume.delete(0)
pool.refresh(0)
return {'result': 'success'}
try:
pool = conn.storagePoolLookupByName(poolname)
volume = pool.storageVolLookupByName(shortname)
volume.delete(0)
pool.refresh(0)
return {'result': 'success'}
except:
continue
return {'result': 'failure', 'reason': 'Image %s not found' % image}

def add_image(self, image, pool, cmd=None, name=None, size=1):
Expand Down

0 comments on commit 8788e71

Please sign in to comment.