Skip to content

Commit

Permalink
Merge pull request #197 from gboutry/feat/images-sync
Browse files Browse the repository at this point in the history
Implement images-sync
  • Loading branch information
hemanthnakkina authored Apr 22, 2024
2 parents 3df7e36 + a668c70 commit a2ed542
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ software:
channel: 2024.1/candidate
config:
snap-channel: 2024.1/candidate
openstack-images-sync-k8s:
channel: 2024.1/candidate
ovn-central-k8s:
channel: 24.03/candidate
ovn-relay-k8s:
Expand Down
2 changes: 2 additions & 0 deletions manifests/edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ software:
channel: 2024.1/edge
config:
snap-channel: 2024.1/edge
openstack-images-sync-k8s:
channel: 2024.1/edge
ovn-central-k8s:
channel: 24.03/edge
ovn-relay-k8s:
Expand Down
Empty file.
105 changes: 105 additions & 0 deletions sunbeam-python/sunbeam/plugins/images_sync/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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

import click
from packaging.version import Version
from rich.console import Console

from sunbeam.jobs.deployment import Deployment
from sunbeam.plugins.interface.v1.openstack import (
ApplicationChannelData,
OpenStackControlPlanePlugin,
TerraformPlanLocation,
)
from sunbeam.versions import OPENSTACK_CHANNEL

LOG = logging.getLogger(__name__)
console = Console()


class ImagesSyncPlugin(OpenStackControlPlanePlugin):
version = Version("0.0.1")

def __init__(self, deployment: Deployment) -> None:
super().__init__(
"images-sync",
deployment,
tf_plan_location=TerraformPlanLocation.SUNBEAM_TERRAFORM_REPO,
)

def manifest_defaults(self) -> dict:
"""Manifest plugin part in dict format."""
return {
"charms": {
"openstack-images-sync-k8s": {"channel": OPENSTACK_CHANNEL},
}
}

def manifest_attributes_tfvar_map(self) -> dict:
"""Manifest attributes terraformvars map."""
return {
self.tfplan: {
"charms": {
"openstack-images-sync-k8s": {
"channel": "images-sync-channel",
"revision": "images-sync-revision",
"config": "images-sync-config",
}
}
}
}

def set_application_names(self) -> list:
"""Application names handled by the terraform plan."""
return ["images-sync"]

def set_tfvars_on_enable(self) -> dict:
"""Set terraform variables to enable the application."""
return {
"enable-images-sync": True,
}

def set_tfvars_on_disable(self) -> dict:
"""Set terraform variables to disable the application."""
return {"enable-images-sync": False}

def set_tfvars_on_resize(self) -> dict:
"""Set terraform variables to resize the application."""
return {}

@click.command()
def enable_plugin(self) -> None:
"""Enable images-sync service."""
super().enable_plugin()

@click.command()
def disable_plugin(self) -> None:
"""Disable images-sync service."""
super().disable_plugin()

@property
def k8s_application_data(self):
return {
"images-sync": ApplicationChannelData(
channel=OPENSTACK_CHANNEL,
tfvars_channel_var=None,
),
}

@property
def tfvars_channel_var(self):
return "images-sync-channel"
6 changes: 6 additions & 0 deletions sunbeam-python/sunbeam/plugins/plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ sunbeam-plugins:
path: sunbeam.plugins.validation.plugin.ValidationPlugin
supported_architectures:
- amd64
- name: "images-sync"
version: "0.0.1"
description: "Plugin for syncing images from a simplestreams source"
path: sunbeam.plugins.images_sync.plugin.ImagesSyncPlugin
supported_architectures:
- amd64

0 comments on commit a2ed542

Please sign in to comment.