diff --git a/juju/model.py b/juju/model.py index ab5bb88d3..45faa99e2 100644 --- a/juju/model.py +++ b/juju/model.py @@ -29,6 +29,7 @@ from .client import client, connector from .client.overrides import Caveat, Macaroon from .constraints import parse as parse_constraints +from .constraints import parse_storage_constraint from .controller import Controller, ConnectedController from .delta import get_entity_class, get_entity_delta from .errors import JujuAPIError, JujuError, JujuModelConfigError, JujuBackupError @@ -2115,7 +2116,7 @@ async def _deploy(self, charm_url, application, series, config, devices=devices, dryrun=False, placement=placement, - storage=storage, + storage={k: parse_storage_constraint(v) for k, v in (storage or dict()).items()}, trust=trust, base=charm_origin.base, channel=channel, @@ -2150,7 +2151,7 @@ async def _deploy(self, charm_url, application, series, config, endpoint_bindings=endpoint_bindings, num_units=num_units, resources=resources, - storage=storage, + storage={k: parse_storage_constraint(v) for k, v in (storage or dict()).items()}, placement=placement, devices=devices, attach_storage=attach_storage, diff --git a/tests/integration/bundle/bundle-with-storage-constraint.yaml b/tests/integration/bundle/bundle-with-storage-constraint.yaml new file mode 100644 index 000000000..4fd78612b --- /dev/null +++ b/tests/integration/bundle/bundle-with-storage-constraint.yaml @@ -0,0 +1,11 @@ +name: bundle-with-storage-constraint + +series: jammy + +applications: + postgresql: + charm: postgresql + num_units: 1 + channel: 14/stable + storage: + pgdata: lxd,8G diff --git a/tests/integration/test_model.py b/tests/integration/test_model.py index b078cc8db..d10e3fbbe 100644 --- a/tests/integration/test_model.py +++ b/tests/integration/test_model.py @@ -211,6 +211,18 @@ async def test_deploy_invalid_bundle(): await model.deploy(str(bundle_path)) +@base.bootstrapped +@pytest.mark.bundle +async def test_deploy_bundle_with_storage_constraint(): + bundle_path = INTEGRATION_TEST_DIR / 'bundle' / 'bundle-with-storage-constraint.yaml' + + async with base.CleanModel() as model: + await model.deploy(bundle_path) + await wait_for_bundle(model, bundle_path) + storage = await model.list_storage() + assert len(storage) == 1 + + @base.bootstrapped async def test_deploy_local_charm(): charm_path = TESTS_DIR / 'charm'