forked from gnuoy/snap-openstack
-
Notifications
You must be signed in to change notification settings - Fork 36
[WIP] Cloudkitty initial #581
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
Draft
mv-2112
wants to merge
1
commit into
canonical:main
Choose a base branch
from
mv-2112:Cloudkitty-initial
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,30 @@ | ||
| # Cloudkitty service | ||
|
|
||
| This feature provides Rating (billing) service for Sunbeam. It's based on [Cloudkitty](https://docs.openstack.org/cloudkitty/latest/), rating solution for OpenStack. | ||
|
|
||
| ## Installation | ||
|
|
||
| To enable the Rating service, you need an already bootstraped Sunbeam instance. Then, you can install the feature with: | ||
|
|
||
| ```bash | ||
| sunbeam enable rating | ||
| ``` | ||
|
|
||
| ## Contents | ||
|
|
||
| This feature will install the following services: | ||
| - Cloudkitty: Rating service for OpenStack [charm](https://opendev.org/openstack/sunbeam-charms/src/branch/main/charms/cloudkitty-k8s) [ROCK](https://github.com/canonical/ubuntu-openstack-rocks/tree/main/rocks/cloudkitty-consolidated) | ||
| - MySQL Router for Cloudkitty [charm](https://github.com/canonical/mysql-router-k8s-operator) [ROCK](https://github.com/canonical/charmed-mysql-rock) | ||
| - MySQL Instance in the case of a multi-mysql installation (for large deployments) [charm](https://github.com/canonical/mysql-k8s-operator) [ROCK](https://github.com/canonical/charmed-mysql-rock) | ||
|
|
||
| Services are constituted of charms, i.e. operator code, and ROCKs, the corresponding OCI images. | ||
|
|
||
| The Cloudkitty charm currently supports Storage V1, Gnocchi and Ceilometer telemetry with other options to be enhanced at a later date. | ||
|
|
||
| ## Removal | ||
|
|
||
| To remove the feature, run: | ||
|
|
||
| ```bash | ||
| sunbeam disable rating | ||
| ``` |
Empty file.
This file contains hidden or 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,99 @@ | ||
| # SPDX-FileCopyrightText: 2023 - Canonical Ltd | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import logging | ||
|
|
||
| import click | ||
| from packaging.version import Version | ||
|
|
||
| from sunbeam.core.common import RiskLevel | ||
| from sunbeam.core.deployment import Deployment | ||
| from sunbeam.core.manifest import CharmManifest, FeatureConfig, SoftwareConfig | ||
| from sunbeam.features.interface.v1.base import FeatureRequirement | ||
| from sunbeam.features.interface.v1.openstack import ( | ||
| OpenStackControlPlaneFeature, | ||
| TerraformPlanLocation, | ||
| ) | ||
| from sunbeam.utils import click_option_show_hints, pass_method_obj | ||
| from sunbeam.versions import OPENSTACK_CHANNEL | ||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class RatingFeature(OpenStackControlPlaneFeature): | ||
| version = Version("0.0.1") | ||
| requires = {FeatureRequirement("telemetry")} | ||
| risk_availability = RiskLevel.BETA | ||
|
|
||
| name = "rating" | ||
| tf_plan_location = TerraformPlanLocation.SUNBEAM_TERRAFORM_REPO | ||
|
|
||
| def default_software_overrides(self) -> SoftwareConfig: | ||
| """Feature software configuration.""" | ||
| return SoftwareConfig( | ||
| charms={"cloudkitty-k8s": CharmManifest(channel=OPENSTACK_CHANNEL)} | ||
| ) | ||
|
|
||
| def manifest_attributes_tfvar_map(self) -> dict: | ||
| """Manifest attributes terraformvars map.""" | ||
| return { | ||
| self.tfplan: { | ||
| "charms": { | ||
| "cloudkitty-k8s": { | ||
| "channel": "cloudkitty-channel", | ||
| "revision": "cloudkitty-revision", | ||
| "config": "cloudkitty-config", | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def set_application_names(self, deployment: Deployment) -> list: | ||
| """Application names handled by the terraform plan.""" | ||
| apps = ["cloudkitty", "cloudkitty-mysql-router"] | ||
| if self.get_database_topology(deployment) == "multi": | ||
| apps.extend(["cloudkitty-mysql"]) | ||
|
|
||
| return apps | ||
|
|
||
| def set_tfvars_on_enable( | ||
| self, deployment: Deployment, config: FeatureConfig | ||
| ) -> dict: | ||
| """Set terraform variables to enable the application.""" | ||
| return { | ||
| "enable-cloudkitty": True, | ||
| **self.add_horizon_plugin_to_tfvars(deployment, "cloudkitty"), | ||
| } | ||
|
|
||
| def set_tfvars_on_disable(self, deployment: Deployment) -> dict: | ||
| """Set terraform variables to disable the application.""" | ||
| return { | ||
| "enable-cloudkitty": False, | ||
| **self.remove_horizon_plugin_from_tfvars(deployment, "cloudkitty"), | ||
| } | ||
|
|
||
| def set_tfvars_on_resize( | ||
| self, deployment: Deployment, config: FeatureConfig | ||
| ) -> dict: | ||
| """Set terraform variables to resize the application.""" | ||
| return {} | ||
|
|
||
| def get_database_charm_processes(self) -> dict[str, dict[str, int]]: | ||
| """Returns the database processes accessing this service.""" | ||
| return { | ||
| "cloudkitty": {"cloudkitty-k8s": 2}, | ||
| } | ||
|
|
||
| @click.command() | ||
| @click_option_show_hints | ||
| @pass_method_obj | ||
| def enable_cmd(self, deployment: Deployment, show_hints: bool) -> None: | ||
| """Enable Rating service.""" | ||
| self.enable_feature(deployment, FeatureConfig(), show_hints) | ||
|
|
||
| @click.command() | ||
| @click_option_show_hints | ||
| @pass_method_obj | ||
| def disable_cmd(self, deployment: Deployment, show_hints: bool) -> None: | ||
| """Disable Rating service.""" | ||
| self.disable_feature(deployment, show_hints) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.