Skip to content

Commit c70e133

Browse files
committed
Add base argument to model.Deploy
1 parent fcb9de2 commit c70e133

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

juju/model.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ async def debug_log(
16041604
async def deploy(
16051605
self, entity_url, application_name=None, bind=None,
16061606
channel=None, config=None, constraints=None, force=False,
1607-
num_units=1, overlays=[], plan=None, resources=None, series=None,
1607+
num_units=1, overlays=[], base=None, resources=None, series=None,
16081608
storage=None, to=None, devices=None, trust=False, attach_storage=[]):
16091609
"""Deploy a new service or bundle.
16101610
@@ -1620,9 +1620,9 @@ async def deploy(
16201620
an unsupported series
16211621
:param int num_units: Number of units to deploy
16221622
:param [] overlays: Bundles to overlay on the primary bundle, applied in order
1623-
:param str plan: Plan under which to deploy charm
1623+
:param str base: The base on which to deploy
16241624
:param dict resources: <resource name>:<file path> pairs
1625-
:param str series: Series on which to deploy
1625+
:param str series: Series on which to deploy DEPRECATED: use --base (with Juju 3.1)
16261626
:param dict storage: Storage constraints TODO how do these look?
16271627
:param to: Placement directive as a string. For example:
16281628
@@ -1675,10 +1675,12 @@ async def deploy(
16751675
identifier = res.identifier
16761676

16771677
charm_series = series
1678+
charm_origin = res.origin
1679+
charm_origin.base = utils.parse_base_arg(base) if base else None
16781680

16791681
if res.is_bundle:
16801682
handler = BundleHandler(self, trusted=trust, forced=force)
1681-
await handler.fetch_plan(url, res.origin, overlays=overlays)
1683+
await handler.fetch_plan(url, charm_origin, overlays=overlays)
16821684
await handler.execute_plan()
16831685
extant_apps = {app for app in self.applications}
16841686
pending_apps = handler.applications - extant_apps
@@ -1698,11 +1700,12 @@ async def deploy(
16981700
# XXX: we're dropping local resources here, but we don't
16991701
# actually support them yet anyway
17001702
if not res.is_local:
1701-
add_charm_res = await self._add_charm(identifier, res.origin)
1703+
add_charm_res = await self._add_charm(identifier, charm_origin)
17021704
if isinstance(add_charm_res, dict):
17031705
# This is for backwards compatibility for older
17041706
# versions where AddCharm returns a dictionary
1705-
charm_origin = add_charm_res.get('charm_origin', res.origin)
1707+
charm_origin = add_charm_res.get('charm_origin',
1708+
charm_origin)
17061709
else:
17071710
charm_origin = add_charm_res.charm_origin
17081711
if Schema.CHARM_HUB.matches(url.schema):
@@ -1718,15 +1721,13 @@ async def deploy(
17181721
else:
17191722
# We have a local charm dir that needs to be uploaded
17201723
charm_dir = os.path.abspath(os.path.expanduser(identifier))
1721-
charm_origin = res.origin
1722-
base = None
1723-
17241724
metadata = utils.get_local_charm_metadata(charm_dir)
17251725
charm_series = charm_series or await get_charm_series(metadata,
17261726
self)
1727-
base = utils.get_local_charm_base(
1728-
charm_series, channel, metadata, charm_dir, client.Base)
1729-
charm_origin.base = base
1727+
if not base:
1728+
charm_origin.base = utils.get_local_charm_base(
1729+
charm_series, channel, metadata, charm_dir, client.Base)
1730+
17301731
if not application_name:
17311732
application_name = metadata['name']
17321733
if not application_name:

tests/integration/test_model.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ async def test_deploy_from_ch_with_invalid_series(event_loop):
336336
pass
337337

338338

339+
@base.bootstrapped
340+
@pytest.mark.asyncio
341+
async def test_deploy_with_base(event_loop):
342+
async with base.CleanModel() as model:
343+
await model.deploy("ubuntu", base="ubuntu@22.04")
344+
await model.wait_for_idle(status='active')
345+
346+
339347
@base.bootstrapped
340348
@pytest.mark.asyncio
341349
async def test_add_machine(event_loop):

0 commit comments

Comments
 (0)