Skip to content

Commit 8957d30

Browse files
committed
Add create_pool
1 parent 0ff3b7b commit 8957d30

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

juju/model.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,25 @@ async def reset(self, force=False):
888888
lambda: len(self.machines) == 0
889889
)
890890

891+
async def create_storage_pool(self, name, provider_type, attributes=""):
892+
"""Create or define a storage pool.
893+
894+
:param str name: a pool name
895+
:param str provider_type: provider type (defaults to "kubernetes" for
896+
Kubernetes models)
897+
:param str attributes: attributes for configuration as space-separated pairs,
898+
e.g. tags, size, path, etc.
899+
:return:
900+
"""
901+
_attrs = [splt.split("=") for splt in attributes.split()]
902+
903+
storage_facade = client.StorageFacade.from_connection(self.connection)
904+
return await storage_facade.CreatePool(pools=[client.StoragePool(
905+
name=name,
906+
provider=provider_type,
907+
attrs=dict(_attrs)
908+
)])
909+
891910
async def remove_application(self, app_name, block_until_done=False):
892911
"""Removes the given application from the model.
893912

juju/tag.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ def user(username):
4343
def application(app_name):
4444
return _prefix('application-', app_name)
4545

46+
4647
def storage(app_name):
4748
return _prefix('storage-', app_name)
4849

50+
4951
def unit(unit_name):
5052
return _prefix('unit-', unit_name.replace('/', '-'))
5153

0 commit comments

Comments
 (0)