Merge "Refactoring helm plugins class hierarchy"

This commit is contained in:
Zuul
2021-12-15 22:16:56 +00:00
committed by Gerrit Code Review
9 changed files with 43 additions and 55 deletions
@@ -10,6 +10,7 @@
""" System inventory Armada manifest operator."""
from oslo_log import log as logging
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm.aodh import AodhHelm
from k8sapp_openstack.helm.barbican import BarbicanHelm
from k8sapp_openstack.helm.ceilometer import CeilometerHelm
@@ -49,7 +50,7 @@ LOG = logging.getLogger(__name__)
class OpenstackArmadaManifestOperator(base.ArmadaManifestOperator):
APP = constants.HELM_APP_OPENSTACK
APP = app_constants.HELM_APP_OPENSTACK
ARMADA_MANIFEST = 'openstack-manifest'
CHART_GROUP_PSP_ROLEBINDING = 'openstack-psp-rolebinding'
@@ -4,6 +4,11 @@
# SPDX-License-Identifier: Apache-2.0
#
from sysinv.common import constants
HELM_APP_OPENSTACK = constants.HELM_APP_OPENSTACK
# Helm: Supported charts:
# These values match the names in the chart package's Chart.yaml
HELM_CHART_AODH = 'aodh'
@@ -4,29 +4,23 @@
# SPDX-License-Identifier: Apache-2.0
#
from k8sapp_openstack.common import constants as app_constants
from sysinv.common import constants
from sysinv.common import exception
from sysinv.common import utils
from sysinv.helm import common
from sysinv.helm import base
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class GarbdHelm(base.BaseHelm):
class GarbdHelm(openstack.BaseHelm):
"""Class to encapsulate helm operations for the galera arbitrator chart"""
# The service name is used to build the standard docker image location.
# It is intentionally "mariadb" and not "garbd" as they both use the
# same docker image.
SERVICE_NAME = app_constants.HELM_CHART_MARIADB
CHART = app_constants.HELM_CHART_GARBD
SUPPORTED_NAMESPACES = \
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
SUPPORTED_APP_NAMESPACES = {
constants.HELM_APP_OPENSTACK:
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
}
def _is_enabled(self, app_name, chart_name, namespace):
# First, see if this chart is enabled by the user then adjust based on
@@ -4,26 +4,24 @@
# SPDX-License-Identifier: Apache-2.0
#
from k8sapp_openstack.common import constants as app_constants
from sysinv.common import constants
from sysinv.common import exception
from sysinv.helm import common
from sysinv.helm import base
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class IngressHelm(base.BaseHelm):
class IngressHelm(openstack.BaseHelm):
"""Class to encapsulate helm operations for the ingress chart"""
CHART = app_constants.HELM_CHART_INGRESS
SUPPORTED_NAMESPACES = base.BaseHelm.SUPPORTED_NAMESPACES + [
common.HELM_NS_KUBE_SYSTEM,
common.HELM_NS_OPENSTACK
SUPPORTED_NAMESPACES = openstack.BaseHelm.SUPPORTED_NAMESPACES + [
common.HELM_NS_KUBE_SYSTEM
]
SUPPORTED_APP_NAMESPACES = {
constants.HELM_APP_OPENSTACK:
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_KUBE_SYSTEM,
common.HELM_NS_OPENSTACK]
app_constants.HELM_APP_OPENSTACK:
openstack.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_KUBE_SYSTEM]
}
def get_overrides(self, namespace=None):
@@ -4,13 +4,14 @@
# SPDX-License-Identifier: Apache-2.0
#
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
from sysinv.common import constants
from sysinv.common import exception
from sysinv.helm import common
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class KeystoneApiProxyHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the keystone api proxy chart"""
@@ -4,23 +4,17 @@
# SPDX-License-Identifier: Apache-2.0
#
from k8sapp_openstack.common import constants as app_constants
from sysinv.common import constants
from sysinv.common import exception
from sysinv.helm import common
from sysinv.helm import base
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class MemcachedHelm(base.BaseHelm):
class MemcachedHelm(openstack.BaseHelm):
"""Class to encapsulate helm operations for the memcached chart"""
CHART = app_constants.HELM_CHART_MEMCACHED
SUPPORTED_NAMESPACES = \
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
SUPPORTED_APP_NAMESPACES = {
constants.HELM_APP_OPENSTACK:
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
}
def get_overrides(self, namespace=None):
overrides = {
@@ -12,11 +12,9 @@ import os
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from k8sapp_openstack.common import constants as app_constants
from oslo_log import log
from oslo_serialization import jsonutils
from sqlalchemy.orm.exc import NoResultFound
from sysinv.common import constants
from sysinv.common import exception
from sysinv.common import kubernetes
@@ -25,19 +23,26 @@ from sysinv.common.storage_backend_conf import K8RbdProvisioner
from sysinv.helm import base
from sysinv.helm import common
from k8sapp_openstack.common import constants as app_constants
LOG = log.getLogger(__name__)
class OpenstackBaseHelm(base.BaseHelm):
"""Class to encapsulate Openstack service operations for helm"""
class BaseHelm(base.BaseHelm):
"""Class to encapsulate Openstack related service operations for helm"""
SUPPORTED_NAMESPACES = \
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
SUPPORTED_APP_NAMESPACES = {
constants.HELM_APP_OPENSTACK:
app_constants.HELM_APP_OPENSTACK:
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
}
class OpenstackBaseHelm(BaseHelm):
"""Class to encapsulate Openstack service operations for helm"""
SYSTEM_CONTROLLER_SERVICES = [
app_constants.HELM_CHART_KEYSTONE_API_PROXY,
]
@@ -4,31 +4,19 @@
# SPDX-License-Identifier: Apache-2.0
#
from k8sapp_openstack.common import constants as app_constants
from sysinv.common import constants
from sysinv.common import exception
from sysinv.helm import base
from sysinv.helm import common
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
class PSPRolebindingHelm(base.BaseHelm):
class PSPRolebindingHelm(openstack.BaseHelm):
"""Class to encapsulate helm operations for the psp rolebinding chart"""
SUPPORTED_NAMESPACES = \
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
SUPPORTED_APP_NAMESPACES = {
constants.HELM_APP_OPENSTACK:
base.BaseHelm.SUPPORTED_NAMESPACES + [common.HELM_NS_OPENSTACK]
}
CHART = app_constants.HELM_CHART_PSP_ROLEBINDING
SERVICE_NAME = 'psp-rolebinding'
def get_namespaces(self):
return self.SUPPORTED_NAMESPACES
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {}
@@ -8,9 +8,11 @@ from sysinv.tests.db import base as dbbase
from sysinv.tests.db import utils as dbutils
from sysinv.tests.helm.test_helm import HelmOperatorTestSuiteMixin
from k8sapp_openstack.common import constants as app_constants
class K8SAppOpenstackAppMixin(object):
app_name = constants.HELM_APP_OPENSTACK
app_name = app_constants.HELM_APP_OPENSTACK
path_name = app_name + '.tgz'
def setUp(self):