connection: Use shared default pool lookup logic

It wasn't abiding a different pool name pointing to our default
path
This commit is contained in:
Cole Robinson 2019-06-11 08:38:20 -04:00
parent 088657a2b8
commit 6e6a0b8a6a
2 changed files with 9 additions and 4 deletions

View File

@ -502,8 +502,11 @@ class vmmConnection(vmmGObject):
return self._get_flags_helper(vm, key, check_func) return self._get_flags_helper(vm, key, check_func)
def get_default_pool(self): def get_default_pool(self):
poolxml = virtinst.StoragePool.build_default_pool(
self.get_backend(), build=False)
if poolxml:
for p in self.list_pools(): for p in self.list_pools():
if p.get_name() == "default": if p.get_name() == poolxml.name:
return p return p
return None return None

View File

@ -196,7 +196,7 @@ class StoragePool(_StorageObject):
return ret return ret
@staticmethod @staticmethod
def build_default_pool(conn): def build_default_pool(conn, build=True):
""" """
Attempt to lookup the 'default' pool, but if it doesn't exist, Attempt to lookup the 'default' pool, but if it doesn't exist,
create it create it
@ -204,6 +204,8 @@ class StoragePool(_StorageObject):
poolxml = _lookup_default_pool(conn) poolxml = _lookup_default_pool(conn)
if poolxml: if poolxml:
return poolxml return poolxml
if not build:
return None
try: try:
name = "default" name = "default"