Skip to content
Closed
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
8 changes: 2 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ jobs:
- "3.3/stable"
- "3.4/stable"
- "3.5/stable"
# A bunch of tests fail with juju.errors.JujuError: base: ubuntu@15.04/stable
# * test_subordinate_units
# * test_destroy_unit
# * test_ssh
# * ...
# - "3.6/beta"
- "3.6/candidate"
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down Expand Up @@ -149,6 +144,7 @@ jobs:
- "3.3/stable"
- "3.4/stable"
- "3.5/stable"
- "3.6/candidate"
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions juju/client/facade_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"Backups": (3,),
"Block": (2,),
"Bundle": (6,),
"Charms": (6,),
"Charms": (6, 7),
"Client": (6, 7, 8),
"Cloud": (7,),
"Controller": (11, 12),
Expand Down Expand Up @@ -45,7 +45,7 @@
}

# Manual list of facades present in schemas + codegen which python-libjuju does not yet support
excluded_facade_versions: Dict[str, Sequence[int]] = {"Charms": (7,)}
excluded_facade_versions: Dict[str, Sequence[int]] = {}


# We don't generate code for these, as we can never use them.
Expand Down
55 changes: 37 additions & 18 deletions juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import websockets
import yaml

from . import jasyncio, provisioner, tag, utils
from . import jasyncio, provisioner, tag, utils, version
from .annotationhelper import _get_annotations, _set_annotations
from .bundle import BundleHandler, get_charm_series, is_local_charm
from .charmhub import CharmHub
Expand Down Expand Up @@ -56,7 +56,6 @@
from .secrets import create_secret_data, read_secret_data
from .tag import application as application_tag
from .url import URL, Schema
from .version import DEFAULT_ARCHITECTURE

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -468,7 +467,7 @@ async def resolve(
architecture,
app_name=None,
channel=None,
series=None,
series: str | None = None,
revision=None,
entity_url=None,
force=False,
Expand Down Expand Up @@ -1731,7 +1730,7 @@ async def deploy(
force=False,
num_units=1,
overlays=[],
base=None,
base: str | None = None,
resources=None,
series=None,
revision=None,
Expand Down Expand Up @@ -1810,6 +1809,11 @@ async def deploy(
if schema not in self.deploy_types:
raise JujuError(f"unknown deploy type {schema}, expected charmhub or local")

if series and base:
derisked = base.split("/")[0]
if derisked != version.SERIES_TO_BASE.get(series):
raise JujuError(f"Incompatible {series=} and {base=}")

model_conf = await self.get_config()
res = await self.deploy_types[schema].resolve(
entity,
Expand Down Expand Up @@ -1966,7 +1970,7 @@ async def _add_charm(self, charm_url, origin):
)

async def _resolve_charm(
self, url, origin, force=False, series=None, model_config=None
self, url, origin, force=False, series: str | None = None, model_config=None
):
"""Calls Charms.ResolveCharms to resolve all the fields of the
charm_origin and also the url and the supported_series
Expand Down Expand Up @@ -2011,21 +2015,36 @@ async def _resolve_charm(
if result.error:
raise JujuError(f"resolving {url} : {result.error.message}")

# TODO (cderici) : supported_bases
supported_series = result.get(
"supported_series", result.unknown_fields["supported-series"]
)
resolved_origin = result.charm_origin
charm_url = URL.parse(result.url)

# run the series selector to get a series for the base
selected_series = utils.series_selector(
series, charm_url, model_config, supported_series, force
)
result.charm_origin.base = utils.get_base_from_origin_or_channel(
resolved_origin, selected_series
)
charm_url.series = selected_series
if "supported-series" in result.unknown_fields:
# Legacy code path for Charms v6, that is Juju < 3.3.0
supported_series: list[str] = result.unknown_fields["supported-series"]
# run the series selector to get a series for the base
selected_series = utils.series_selector(
series, charm_url, model_config, supported_series, force
)
result.charm_origin.base = utils.get_base_from_origin_or_channel(
resolved_origin, selected_series
)
charm_url.series = selected_series
else:
# FIXME use base instead
...

if series:
# FIXME: redo this
# Ugh this ugly,
# series is valid against Juju 3.0~3.2.x
# base is valid against Juju 3.3~4.x
# we should convert back and forth really...
warnings.warn(
"series= argument is deprecated, use base= instead",
DeprecationWarning,
stacklevel=4,
)
# FIXME actually use the argument

return charm_url, resolved_origin

Expand All @@ -2045,7 +2064,7 @@ async def _resolve_architecture(self, url=None):
if "arch" in constraints:
return constraints["arch"]

return DEFAULT_ARCHITECTURE
return version.DEFAULT_ARCHITECTURE

async def _add_charmhub_resources(
self, application, entity_url, origin, overrides=None
Expand Down
6 changes: 5 additions & 1 deletion juju/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,11 @@ def user_requested(series_arg, supported_series, force):


def series_selector(
series_arg="", charm_url=None, model_config=None, supported_series=[], force=False
series_arg: str | None = "",
charm_url=None,
model_config=None,
supported_series=[],
force=False,
):
"""Select series to deploy on.

Expand Down
17 changes: 16 additions & 1 deletion juju/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
# Licensed under the Apache V2, see LICENCE file for details.
"""Client version definitions."""

LTS_RELEASES = ["jammy", "focal", "bionic", "xenial", "trusty", "precise"]
LTS_RELEASES = ["noble", "jammy", "focal", "bionic", "xenial", "trusty", "precise"]

SERIES_TO_BASE = {
"noble": "ubuntu@24.04",
"jammy": "ubuntu@22.04",
"focal": "ubuntu@20.04",
"bionic": "ubuntu@18.04",
"xenial": "ubuntu@16.04",
"trusty": "ubuntu@14.04",
"precise": "ubuntu@12.04",
"groovy": "ubuntu@20.10",
"disco": "ubuntu@19.04",
"cosmic": "ubuntu@18.10",
"artful": "ubuntu@17.10",
"vivid": "ubuntu@15.04",
}

DEFAULT_ARCHITECTURE = "amd64"

Expand Down
Loading