-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add refreshing to install * add refresh command * add default acceptance to refresh * add charm upgrades * liniting and formatting * renaming * refactor * update readme * rollback features from sunbeam latest to sunbeam anvil * format again * more linting * remove unused imports * include openstack client * fetch manifest correctly * remove clear manifest * Roll our own upgrades to stop sunbeam issues * subordinate unit * remove openstack * use manifest path, not manifest * update job definitions * move refresh to correct filepath * add prompts back to postgresql * remove extra refresh * license and moving
- Loading branch information
Showing
11 changed files
with
437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Copyright (c) 2024 Canonical Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
import click | ||
from rich.console import Console | ||
from sunbeam.jobs.common import ( | ||
run_plan, | ||
) | ||
from sunbeam.jobs.juju import JujuHelper | ||
from sunbeam.jobs.manifest import AddManifestStep | ||
|
||
from anvil.commands.upgrades.intra_channel import LatestInChannelCoordinator | ||
from anvil.jobs.manifest import Manifest | ||
from anvil.provider.local.deployment import LocalDeployment | ||
|
||
LOG = logging.getLogger(__name__) | ||
console = Console() | ||
|
||
|
||
@click.command() | ||
@click.option( | ||
"-m", | ||
"--manifest", | ||
"manifest_path", | ||
help="Manifest file.", | ||
type=click.Path(exists=True, dir_okay=False, path_type=Path), | ||
) | ||
@click.pass_context | ||
def refresh( | ||
ctx: click.Context, | ||
manifest_path: Path | None = None, | ||
) -> None: | ||
"""Refresh deployment. | ||
Refresh the deployment and allow passing new configuration options. | ||
""" | ||
|
||
deployment: LocalDeployment = ctx.obj | ||
client = deployment.get_client() | ||
|
||
manifest = None | ||
if manifest_path: | ||
manifest = Manifest.load( | ||
deployment, manifest_file=manifest_path, include_defaults=True | ||
) | ||
run_plan([AddManifestStep(client, manifest)], console) | ||
|
||
if not manifest: | ||
LOG.debug("Getting latest manifest from cluster db") | ||
manifest = Manifest.load_latest_from_clusterdb( | ||
deployment, include_defaults=True | ||
) | ||
|
||
LOG.debug( | ||
f"Manifest used for refresh - deployment preseed: {manifest.deployment_config}" | ||
) | ||
LOG.debug( | ||
f"Manifest used for refresh - software: {manifest.software_config}" | ||
) | ||
jhelper = JujuHelper(deployment.get_connected_controller()) | ||
|
||
a = LatestInChannelCoordinator( | ||
deployment, | ||
client, | ||
jhelper, | ||
manifest, | ||
) | ||
a.run_plan() | ||
|
||
click.echo("Refresh complete.") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (c) 2024 Canonical Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
|
||
from rich.console import Console | ||
from rich.status import Status | ||
from sunbeam.jobs.common import ( | ||
BaseStep, | ||
Result, | ||
ResultType, | ||
) | ||
from sunbeam.jobs.deployment import Deployment | ||
|
||
from anvil.jobs.plugin import PluginManager | ||
|
||
LOG = logging.getLogger(__name__) | ||
console = Console() | ||
|
||
|
||
class UpgradePlugins(BaseStep): | ||
def __init__( | ||
self, | ||
deployment: Deployment, | ||
upgrade_release: bool = False, | ||
): | ||
"""Upgrade plugins. | ||
:client: Helper for interacting with clusterd | ||
:upgrade_release: Whether to upgrade channel | ||
""" | ||
super().__init__("Validation", "Running pre-upgrade validation") | ||
self.deployment = deployment | ||
self.upgrade_release = upgrade_release | ||
|
||
def run(self, status: Status | None = None) -> Result: | ||
PluginManager.update_plugins( | ||
self.deployment, | ||
repos=["core"], | ||
upgrade_release=self.upgrade_release, | ||
) | ||
return Result(ResultType.COMPLETED) |
Oops, something went wrong.