diff --git a/juju/model.py b/juju/model.py index ada4ac29b..5bd317e8c 100644 --- a/juju/model.py +++ b/juju/model.py @@ -2218,6 +2218,13 @@ async def _deploy( app_facade = client.ApplicationFacade.from_connection(self.connection()) + # Prepare all storage constraints + storage = storage or dict() + storage = { + k: v if isinstance(v, client.Constraints) else parse_storage_constraint(v) + for k, v in storage.items() + } + if server_side_deploy: # Call DeployFromRepository app = client.DeployFromRepositoryArg( diff --git a/tests/integration/test_model.py b/tests/integration/test_model.py index e843a774d..cbc60bcb6 100644 --- a/tests/integration/test_model.py +++ b/tests/integration/test_model.py @@ -1248,6 +1248,21 @@ async def test_model_cache_update(): await controller.destroy_models(model_name) +@base.bootstrapped +async def test_deploy_with_storage(): + async with base.CleanModel() as model: + await model.deploy( + 'postgresql', + storage={"pgdata": {"size": 1024, "count": 1}}, + ) + await model.wait_for_idle(status="active") + storages = await model.list_storage() + await model.list_storage(filesystem=True) + await model.list_storage(volume=True) + + assert any([tag.storage("pgdata") in s['storage-tag'] for s in storages]) + + @base.bootstrapped async def test_add_storage(): pytest.skip("skip in favour of test_add_and_list_storage")