Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify parse_storage_constraint or client.Constraints during deploy #1079

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,13 @@ async def _deploy(self, charm_url, application, series, config,

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(
Expand All @@ -2116,7 +2123,7 @@ async def _deploy(self, charm_url, application, series, config,
devices=devices,
dryrun=False,
placement=placement,
storage={k: parse_storage_constraint(v) for k, v in (storage or dict()).items()},
storage=storage,
trust=trust,
base=charm_origin.base,
channel=channel,
Expand Down Expand Up @@ -2151,7 +2158,7 @@ async def _deploy(self, charm_url, application, series, config,
endpoint_bindings=endpoint_bindings,
num_units=num_units,
resources=resources,
storage={k: parse_storage_constraint(v) for k, v in (storage or dict()).items()},
storage=storage,
placement=placement,
devices=devices,
attach_storage=attach_storage,
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,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')
Expand Down