Skip to content

Commit 000af36

Browse files
committed
Test and fixups for create/list pools
1 parent 1c3c9c5 commit 000af36

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

juju/model.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ async def create_storage_pool(self, name, provider_type, attributes=""):
900900
"""
901901
_attrs = [splt.split("=") for splt in attributes.split()]
902902

903-
storage_facade = client.StorageFacade.from_connection(self.connection)
903+
storage_facade = client.StorageFacade.from_connection(self.connection())
904904
return await storage_facade.CreatePool(pools=[client.StoragePool(
905905
name=name,
906906
provider=provider_type,
@@ -913,7 +913,7 @@ async def remove_storage_pool(self, name):
913913
:param str name:
914914
:return:
915915
"""
916-
storage_facade = client.StorageFacade.from_connection(self.connection)
916+
storage_facade = client.StorageFacade.from_connection(self.connection())
917917
return await storage_facade.RemovePool(pools=[name])
918918

919919
async def update_storage_pool(self, name, attributes=""):
@@ -927,7 +927,7 @@ async def update_storage_pool(self, name, attributes=""):
927927
if len(_attrs) == 0:
928928
raise JujuError("Expected at least one attribute to update")
929929

930-
storage_facade = client.StorageFacade.from_connection(self.connection)
930+
storage_facade = client.StorageFacade.from_connection(self.connection())
931931
return await storage_facade.UpdatePool(pools=[client.StoragePool(
932932
name=name,
933933
attrs=_attrs,
@@ -968,7 +968,7 @@ async def show_storage_details(self, *storage_ids):
968968
if not storage_ids:
969969
raise JujuError("Expected at least one storage ID")
970970

971-
storage_facade = client.StorageFacade.from_connection(self.connection)
971+
storage_facade = client.StorageFacade.from_connection(self.connection())
972972
res = await storage_facade.StorageDetails(entities=[client.Entity(tag.storage(s)) for s in storage_ids])
973973
return res.results
974974

@@ -978,9 +978,12 @@ async def list_storage_pools(self):
978978
:return:
979979
"""
980980
# TODO (cderici): Filter on pool type, name.
981-
storage_facade = client.StorageFacade.from_connection(self.connection)
982-
res = await storage_facade.ListPools(filters=[])
983-
return res.results
981+
storage_facade = client.StorageFacade.from_connection(self.connection())
982+
res = await storage_facade.ListPools(filters=[client.StoragePoolFilter()])
983+
err = res.results[0].error
984+
if err:
985+
raise JujuError(err.message)
986+
return [p.serialize() for p in res.results[0].storage_pools]
984987

985988
async def remove_storage(self, force=False, destroy_storage=False, *storage_ids):
986989
"""Removes storage from the model.
@@ -993,7 +996,7 @@ async def remove_storage(self, force=False, destroy_storage=False, *storage_ids)
993996
if not storage_ids:
994997
raise JujuError("Expected at least one storage ID")
995998

996-
storage_facade = client.StorageFacade.from_connection(self.connection)
999+
storage_facade = client.StorageFacade.from_connection(self.connection())
9971000
return await storage_facade.Remove(storage=[client.RemoveStorageInstance(
9981001
destroy_storage=destroy_storage,
9991002
force=False,

tests/integration/test_model.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,3 +1077,15 @@ async def test_list_storage(event_loop):
10771077
await model.list_storage(volume=True)
10781078

10791079
assert any([tag.storage("pgdata") in s['storage-tag'] for s in storages])
1080+
1081+
1082+
@base.bootstrapped
1083+
@pytest.mark.asyncio
1084+
async def test_storage_pools(event_loop):
1085+
async with base.CleanModel() as model:
1086+
await model.deploy('postgresql')
1087+
await model.wait_for_idle(status="active")
1088+
1089+
await model.create_storage_pool("test-pool", "lxd")
1090+
pools = await model.list_storage_pools()
1091+
assert "test-pool" in [p['name'] for p in pools]

0 commit comments

Comments
 (0)