Browse Source

Enable helm/armada plugin delivery with the application

This creates a new package spec called python-k8sapp-openstack that will
hold all the stevedore plugins needed to support the application. This
spec will build two packages python-k8sapp-openstack and
python-k8sapp-openstack-wheels.

These packages are included in the build dependencies for the
stx-openstack-helm application package build where the wheels file is
included in the application tarball.

The helm and armada plugins have been relocated to this repo and
provided in a k8sapp_openstack python module. This module will be
extracted from the wheels and installed on the platform via the sysinv
application framework. The module will be made available when the
application is enabled.

Change-Id: I342308fbff23d29bfdf64a07dbded4bae01b79fd
Depends-On: https://review.opendev.org/#/c/688191/
Story: 2006537
Task: 36978
Signed-off-by: Robert Church <robert.church@windriver.com>
changes/90/688190/7
Robert Church 2 years ago
parent
commit
949dd5aa77
  1. 1
      centos_pkg_dirs
  2. 9
      python-k8sapp-openstack/centos/build_srpm.data
  3. 65
      python-k8sapp-openstack/centos/python-k8sapp-openstack.spec
  4. 35
      python-k8sapp-openstack/k8sapp_openstack/.gitignore
  5. 4
      python-k8sapp-openstack/k8sapp_openstack/.stestr.conf
  6. 202
      python-k8sapp-openstack/k8sapp_openstack/LICENSE
  7. 7
      python-k8sapp-openstack/k8sapp_openstack/README.rst
  8. 5
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/__init__.py
  9. 19
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/armada/__init__.py
  10. 187
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/armada/manifest_openstack.py
  11. 5
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/common/__init__.py
  12. 37
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/common/constants.py
  13. 19
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/__init__.py
  14. 86
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/aodh.py
  15. 68
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/barbican.py
  16. 101
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/ceilometer.py
  17. 263
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/cinder.py
  18. 68
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/dcdbsync.py
  19. 57
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/fm_rest_api.py
  20. 67
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/garbd.py
  21. 180
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/glance.py
  22. 69
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/gnocchi.py
  23. 79
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/heat.py
  24. 35
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/helm_toolkit.py
  25. 128
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/horizon.py
  26. 93
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/ingress.py
  27. 168
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/ironic.py
  28. 297
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/keystone.py
  29. 107
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/keystone_api_proxy.py
  30. 52
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/libvirt.py
  31. 40
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/magnum.py
  32. 66
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/mariadb.py
  33. 37
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/memcached.py
  34. 338
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/neutron.py
  35. 33
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/nginx_ports_control.py
  36. 602
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/nova.py
  37. 71
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/nova_api_proxy.py
  38. 546
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/openstack.py
  39. 52
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/openvswitch.py
  40. 70
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/panko.py
  41. 64
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/placement.py
  42. 80
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/rabbitmq.py
  43. 55
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/swift.py
  44. 5
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/tests/__init__.py
  45. 38
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/tests/test_cinder.py
  46. 35
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/tests/test_nova.py
  47. 49
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/tests/test_nova_api_proxy.py
  48. 54
      python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/tests/test_plugins.py
  49. 287
      python-k8sapp-openstack/k8sapp_openstack/pylint.rc
  50. 2
      python-k8sapp-openstack/k8sapp_openstack/requirements.txt
  51. 69
      python-k8sapp-openstack/k8sapp_openstack/setup.cfg
  52. 12
      python-k8sapp-openstack/k8sapp_openstack/setup.py
  53. 28
      python-k8sapp-openstack/k8sapp_openstack/test-requirements.txt
  54. 200
      python-k8sapp-openstack/k8sapp_openstack/tox.ini
  55. 5
      python-k8sapp-openstack/k8sapp_openstack/upper-constraints.txt
  56. 12
      stx-openstack-helm/centos/build_srpm.data
  57. 1
      stx-openstack-helm/centos/stx-openstack-helm.spec

1
centos_pkg_dirs

@ -1,3 +1,4 @@
openstack-helm
openstack-helm-infra
stx-openstack-helm
python-k8sapp-openstack

9
python-k8sapp-openstack/centos/build_srpm.data

@ -0,0 +1,9 @@
SRC_DIR="k8sapp_openstack"
# Bump the version by the previous version value prior to decoupling as this
# will align the GITREVCOUNT value to increment the version by one. Remove this
# (i.e. reset to 0) on then next major version changes when TIS_BASE_SRCREV
# changes. This version should align with the version of the helm charts in
# stx-openstack-helm
TIS_BASE_SRCREV=8d3452a5e864339101590e542c24c375bb3808fb
TIS_PATCH_VER=GITREVCOUNT+20

65
python-k8sapp-openstack/centos/python-k8sapp-openstack.spec

@ -0,0 +1,65 @@
%global pypi_name k8sapp-openstack
%global sname k8sapp_openstack
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: Openstack K8S app
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-pbr
BuildRequires: python2-pip
BuildRequires: python2-wheel
%description
StarlingX sysinv extensions: Openstack K8S app
%package -n python2-%{pypi_name}
Summary: StarlingX sysinv extensions: Openstack K8S app
Requires: python-pbr >= 2.0.0
Requires: sysinv >= 1.0
%description -n python2-%{pypi_name}
StarlingX sysinv extensions: Openstack K8S app
%prep
%setup
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%build
export PBR_VERSION=%{version}
%{__python2} setup.py build
%py2_build_wheel
%install
export PBR_VERSION=%{version}.%{tis_patch_ver}
export SKIP_PIP_INSTALL=1
%{__python2} setup.py install --skip-build --root %{buildroot}
mkdir -p ${RPM_BUILD_ROOT}/plugins
install -m 644 dist/*.whl ${RPM_BUILD_ROOT}/plugins/
%files
%{python2_sitelib}/%{sname}
%{python2_sitelib}/%{sname}-*.egg-info
%package wheels
Summary: %{name} wheels
%description wheels
Contains python wheels for %{name}
%files wheels
/plugins/*
%changelog
* Wed Sep 20 2019 Robert Church <robert.church@windriver.com>
- Initial version

35
python-k8sapp-openstack/k8sapp_openstack/.gitignore

@ -0,0 +1,35 @@
# Compiled files
*.py[co]
*.a
*.o
*.so
# Sphinx
_build
doc/source/api/
# Packages/installer info
*.egg
*.egg-info
dist
build
eggs
parts
var
sdist
develop-eggs
.installed.cfg
# Other
*.DS_Store
.stestr
.testrepository
.tox
.venv
.*.swp
.coverage
bandit.xml
cover
AUTHORS
ChangeLog
*.sqlite

4
python-k8sapp-openstack/k8sapp_openstack/.stestr.conf

@ -0,0 +1,4 @@
[DEFAULT]
test_path=./k8sapp_openstack/tests
top_dir=./k8sapp_openstack
#parallel_class=True

202
python-k8sapp-openstack/k8sapp_openstack/LICENSE

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2019 Wind River Systems, Inc.
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.

7
python-k8sapp-openstack/k8sapp_openstack/README.rst

@ -0,0 +1,7 @@
k8sapp-openstack
================
This project contains StarlingX Kubernetes application specific python plugins
for the openstack application. These plugins are required to integrate the
openstack application into the StarlingX application framework and to support
the various StarlingX deployments.

5
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/__init__.py

@ -0,0 +1,5 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#

19
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/armada/__init__.py

@ -0,0 +1,19 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import yaml
class quoted_str(str):
pass
# force strings to be single-quoted to avoid interpretation as numeric values
def quoted_presenter(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style="'")
yaml.add_representer(quoted_str, quoted_presenter)

187
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/armada/manifest_openstack.py

@ -0,0 +1,187 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# All Rights Reserved.
#
""" System inventory Armada manifest operator."""
from oslo_log import log as logging
from k8sapp_openstack.helm.aodh import AodhHelm
from k8sapp_openstack.helm.barbican import BarbicanHelm
from k8sapp_openstack.helm.ceilometer import CeilometerHelm
from k8sapp_openstack.helm.cinder import CinderHelm
from k8sapp_openstack.helm.dcdbsync import DcdbsyncHelm
from k8sapp_openstack.helm.fm_rest_api import FmRestApiHelm
from k8sapp_openstack.helm.garbd import GarbdHelm
from k8sapp_openstack.helm.glance import GlanceHelm
from k8sapp_openstack.helm.gnocchi import GnocchiHelm
from k8sapp_openstack.helm.heat import HeatHelm
from k8sapp_openstack.helm.horizon import HorizonHelm
from k8sapp_openstack.helm.ingress import IngressHelm
from k8sapp_openstack.helm.ironic import IronicHelm
from k8sapp_openstack.helm.keystone import KeystoneHelm
from k8sapp_openstack.helm.keystone_api_proxy import KeystoneApiProxyHelm
from k8sapp_openstack.helm.libvirt import LibvirtHelm
from k8sapp_openstack.helm.magnum import MagnumHelm
from k8sapp_openstack.helm.mariadb import MariadbHelm
from k8sapp_openstack.helm.memcached import MemcachedHelm
from k8sapp_openstack.helm.neutron import NeutronHelm
from k8sapp_openstack.helm.nginx_ports_control import NginxPortsControlHelm
from k8sapp_openstack.helm.nova import NovaHelm
from k8sapp_openstack.helm.nova_api_proxy import NovaApiProxyHelm
from k8sapp_openstack.helm.openvswitch import OpenvswitchHelm
from k8sapp_openstack.helm.panko import PankoHelm
from k8sapp_openstack.helm.placement import PlacementHelm
from k8sapp_openstack.helm.rabbitmq import RabbitmqHelm
from k8sapp_openstack.helm.swift import SwiftHelm
from sysinv.common import constants
from sysinv.common import exception
from sysinv.helm import manifest_base as base
LOG = logging.getLogger(__name__)
class OpenstackArmadaManifestOperator(base.ArmadaManifestOperator):
APP = constants.HELM_APP_OPENSTACK
ARMADA_MANIFEST = 'armada-manifest'
CHART_INGRESS_KS = CHART_GROUP_INGRESS_KS = 'kube-system-ingress'
CHART_GROUP_INGRESS_OS = 'openstack-ingress'
CHART_GROUP_MAGNUM = 'openstack-magnum'
CHART_GROUP_MARIADB = 'openstack-mariadb'
CHART_GROUP_MEMCACHED = 'openstack-memcached'
CHART_GROUP_RABBITMQ = 'openstack-rabbitmq'
CHART_GROUP_KEYSTONE = 'openstack-keystone'
CHART_GROUP_KS_API_PROXY = 'openstack-keystone-api-proxy'
CHART_GROUP_BARBICAN = 'openstack-barbican'
CHART_GROUP_GLANCE = 'openstack-glance'
CHART_GROUP_SWIFT = 'openstack-ceph-rgw'
CHART_GROUP_CINDER = 'openstack-cinder'
CHART_GROUP_FM_REST_API = 'openstack-fm-rest-api'
CHART_GROUP_COMPUTE_KIT = 'openstack-compute-kit'
CHART_GROUP_HEAT = 'openstack-heat'
CHART_GROUP_HORIZON = 'openstack-horizon'
CHART_GROUP_TELEMETRY = 'openstack-telemetry'
CHART_GROUP_DCDBSYNC = 'openstack-dcdbsync'
CHART_GROUPS_LUT = {
AodhHelm.CHART: CHART_GROUP_TELEMETRY,
BarbicanHelm.CHART: CHART_GROUP_BARBICAN,
CeilometerHelm.CHART: CHART_GROUP_TELEMETRY,
CinderHelm.CHART: CHART_GROUP_CINDER,
FmRestApiHelm.CHART: CHART_GROUP_FM_REST_API,
GarbdHelm.CHART: CHART_GROUP_MARIADB,
GlanceHelm.CHART: CHART_GROUP_GLANCE,
GnocchiHelm.CHART: CHART_GROUP_TELEMETRY,
HeatHelm.CHART: CHART_GROUP_HEAT,
HorizonHelm.CHART: CHART_GROUP_HORIZON,
IngressHelm.CHART: CHART_GROUP_INGRESS_OS,
IronicHelm.CHART: CHART_GROUP_COMPUTE_KIT,
KeystoneHelm.CHART: CHART_GROUP_KEYSTONE,
KeystoneApiProxyHelm.CHART: CHART_GROUP_KS_API_PROXY,
LibvirtHelm.CHART: CHART_GROUP_COMPUTE_KIT,
MagnumHelm.CHART: CHART_GROUP_MAGNUM,
MariadbHelm.CHART: CHART_GROUP_MARIADB,
MemcachedHelm.CHART: CHART_GROUP_MEMCACHED,
NeutronHelm.CHART: CHART_GROUP_COMPUTE_KIT,
NginxPortsControlHelm.CHART: CHART_GROUP_INGRESS_OS,
NovaHelm.CHART: CHART_GROUP_COMPUTE_KIT,
NovaApiProxyHelm.CHART: CHART_GROUP_COMPUTE_KIT,
OpenvswitchHelm.CHART: CHART_GROUP_COMPUTE_KIT,
PankoHelm.CHART: CHART_GROUP_TELEMETRY,
PlacementHelm.CHART: CHART_GROUP_COMPUTE_KIT,
RabbitmqHelm.CHART: CHART_GROUP_RABBITMQ,
SwiftHelm.CHART: CHART_GROUP_SWIFT,
DcdbsyncHelm.CHART: CHART_GROUP_DCDBSYNC,
}
CHARTS_LUT = {
AodhHelm.CHART: 'openstack-aodh',
BarbicanHelm.CHART: 'openstack-barbican',
CeilometerHelm.CHART: 'openstack-ceilometer',
CinderHelm.CHART: 'openstack-cinder',
GarbdHelm.CHART: 'openstack-garbd',
FmRestApiHelm.CHART: 'openstack-fm-rest-api',
GlanceHelm.CHART: 'openstack-glance',
GnocchiHelm.CHART: 'openstack-gnocchi',
HeatHelm.CHART: 'openstack-heat',
HorizonHelm.CHART: 'openstack-horizon',
IngressHelm.CHART: 'openstack-ingress',
IronicHelm.CHART: 'openstack-ironic',
KeystoneHelm.CHART: 'openstack-keystone',
KeystoneApiProxyHelm.CHART: 'openstack-keystone-api-proxy',
LibvirtHelm.CHART: 'openstack-libvirt',
MagnumHelm.CHART: 'openstack-magnum',
MariadbHelm.CHART: 'openstack-mariadb',
MemcachedHelm.CHART: 'openstack-memcached',
NeutronHelm.CHART: 'openstack-neutron',
NginxPortsControlHelm.CHART: 'openstack-nginx-ports-control',
NovaHelm.CHART: 'openstack-nova',
NovaApiProxyHelm.CHART: 'openstack-nova-api-proxy',
OpenvswitchHelm.CHART: 'openstack-openvswitch',
PankoHelm.CHART: 'openstack-panko',
PlacementHelm.CHART: 'openstack-placement',
RabbitmqHelm.CHART: 'openstack-rabbitmq',
SwiftHelm.CHART: 'openstack-ceph-rgw',
DcdbsyncHelm.CHART: 'openstack-dcdbsync',
}
def platform_mode_manifest_updates(self, dbapi, mode):
""" Update the application manifest based on the platform
This is used for
:param dbapi: DB api object
:param mode: mode to control how to apply the application manifest
"""
if mode == constants.OPENSTACK_RESTORE_DB:
# During application restore, first bring up
# MariaDB service.
self.manifest_chart_groups_set(
self.ARMADA_MANIFEST,
[self.CHART_GROUP_INGRESS_KS,
self.CHART_GROUP_INGRESS_OS,
self.CHART_GROUP_MARIADB])
elif mode == constants.OPENSTACK_RESTORE_STORAGE:
# After MariaDB data is restored, restore Keystone,
# Glance and Cinder.
self.manifest_chart_groups_set(
self.ARMADA_MANIFEST,
[self.CHART_GROUP_INGRESS_KS,
self.CHART_GROUP_INGRESS_OS,
self.CHART_GROUP_MARIADB,
self.CHART_GROUP_MEMCACHED,
self.CHART_GROUP_RABBITMQ,
self.CHART_GROUP_KEYSTONE,
self.CHART_GROUP_GLANCE,
self.CHART_GROUP_CINDER])
else:
# When mode is OPENSTACK_RESTORE_NORMAL or None,
# bring up all the openstack services.
try:
system = dbapi.isystem_get_one()
except exception.NotFound:
LOG.exception("System %s not found.")
raise
if (system.distributed_cloud_role ==
constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER):
# remove the chart_groups not needed in this configuration
self.manifest_chart_groups_delete(
self.ARMADA_MANIFEST, self.CHART_GROUP_SWIFT)
self.manifest_chart_groups_delete(
self.ARMADA_MANIFEST, self.CHART_GROUP_COMPUTE_KIT)
self.manifest_chart_groups_delete(
self.ARMADA_MANIFEST, self.CHART_GROUP_HEAT)
self.manifest_chart_groups_delete(
self.ARMADA_MANIFEST, self.CHART_GROUP_TELEMETRY)

5
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/common/__init__.py

@ -0,0 +1,5 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#

37
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/common/constants.py

@ -0,0 +1,37 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Helm: Supported charts:
# These values match the names in the chart package's Chart.yaml
HELM_CHART_AODH = 'aodh'
HELM_CHART_BARBICAN = 'barbican'
HELM_CHART_CEILOMETER = 'ceilometer'
HELM_CHART_CINDER = 'cinder'
HELM_CHART_FM_REST_API = 'fm-rest-api'
HELM_CHART_GARBD = 'garbd'
HELM_CHART_GLANCE = 'glance'
HELM_CHART_GNOCCHI = 'gnocchi'
HELM_CHART_HEAT = 'heat'
HELM_CHART_HELM_TOOLKIT = 'helm-toolkit'
HELM_CHART_HORIZON = 'horizon'
HELM_CHART_INGRESS = 'ingress'
HELM_CHART_IRONIC = 'ironic'
HELM_CHART_KEYSTONE = 'keystone'
HELM_CHART_KEYSTONE_API_PROXY = 'keystone-api-proxy'
HELM_CHART_LIBVIRT = 'libvirt'
HELM_CHART_MAGNUM = 'magnum'
HELM_CHART_MARIADB = 'mariadb'
HELM_CHART_MEMCACHED = 'memcached'
HELM_CHART_NEUTRON = 'neutron'
HELM_CHART_NGINX_PORTS_CONTROL = "nginx-ports-control"
HELM_CHART_NOVA = 'nova'
HELM_CHART_NOVA_API_PROXY = 'nova-api-proxy'
HELM_CHART_OPENVSWITCH = 'openvswitch'
HELM_CHART_PANKO = 'panko'
HELM_CHART_PLACEMENT = 'placement'
HELM_CHART_RABBITMQ = 'rabbitmq'
HELM_CHART_SWIFT = 'ceph-rgw'
HELM_CHART_DCDBSYNC = 'dcdbsync'

19
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/__init__.py

@ -0,0 +1,19 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import yaml
class quoted_str(str):
pass
# force strings to be single-quoted to avoid interpretation as numeric values
def quoted_presenter(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style="'")
yaml.add_representer(quoted_str, quoted_presenter)

86
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/aodh.py

@ -0,0 +1,86 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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 exception
from sysinv.helm import common
class AodhHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the aodh chart"""
CHART = app_constants.HELM_CHART_AODH
SERVICE_NAME = app_constants.HELM_CHART_AODH
AUTH_USERS = ['aodh']
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': self._get_pod_overrides(),
'conf': self._get_conf_overrides(),
'endpoints': self._get_endpoints_overrides()
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_pod_overrides(self):
overrides = {
'replicas': {
'api': self._num_controllers(),
'evaluator': self._num_controllers(),
'listener': self._num_controllers(),
'notifier': self._num_controllers()
}
}
return overrides
def _get_conf_overrides(self):
return {
'aodh': {
'service_credentials': {
'region_name': self._region_name()
}
}
}
def _get_endpoints_overrides(self):
return {
'identity': {
'auth': self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'alarming': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
'port': self._get_endpoints_port_api_public_overrides(),
'scheme': self._get_endpoints_scheme_public_overrides(),
},
'oslo_cache': {
'auth': {
'memcache_secret_key':
self._get_common_password('auth_memcache_key')
}
},
'oslo_db': {
'auth': self._get_endpoints_oslo_db_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
'oslo_messaging': {
'auth': self._get_endpoints_oslo_messaging_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
}

68
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/barbican.py

@ -0,0 +1,68 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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 exception
from sysinv.helm import common
class BarbicanHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the barbican chart"""
CHART = app_constants.HELM_CHART_BARBICAN
AUTH_USERS = ['barbican']
SERVICE_NAME = app_constants.HELM_CHART_BARBICAN
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': {
'replicas': {
'api': self._num_controllers()
}
},
'endpoints': self._get_endpoints_overrides(),
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_endpoints_overrides(self):
return {
'identity': {
'auth': self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'key_manager': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
'port': self._get_endpoints_port_api_public_overrides(),
'scheme': self._get_endpoints_scheme_public_overrides(),
},
'oslo_db': {
'auth': self._get_endpoints_oslo_db_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
'oslo_cache': {
'auth': {
'memcache_secret_key':
self._get_common_password('auth_memcache_key')
}
},
'oslo_messaging': {
'auth': self._get_endpoints_oslo_messaging_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
}

101
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/ceilometer.py

@ -0,0 +1,101 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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 exception
from sysinv.common import utils
from sysinv.helm import common
class CeilometerHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the ceilometer chart"""
CHART = app_constants.HELM_CHART_CEILOMETER
SERVICE_NAME = app_constants.HELM_CHART_CEILOMETER
AUTH_USERS = ['ceilometer']
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': self._get_pod_overrides(),
'conf': self._get_conf_overrides(),
'manifests': self._get_manifests_overrides(),
'endpoints': self._get_endpoints_overrides(),
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_pod_overrides(self):
return {
'replicas': {
'central': self._num_controllers(),
'notification': self._num_controllers()
}
}
def _get_manifests_overrides(self):
manifests_overrides = {}
if utils.is_virtual():
manifests_overrides.update({'daemonset_ipmi': False})
return manifests_overrides
def _get_conf_overrides(self):
return {
'ceilometer': {
'notification': {
'messaging_urls': {
'values': self._get_notification_messaging_urls()
}
},
'meter': {
'meter_definitions_dirs': '/etc/ceilometer/meters.d'
}
}
}
def _get_notification_messaging_urls(self):
rabbit_user = 'rabbitmq-admin'
rabbit_pass = self._get_common_password(rabbit_user)
rabbit_paths = ['/ceilometer', '/cinder', '/glance', '/nova', '/keystone', '/neutron', '/heat']
messaging_urls = []
for rabbit_path in rabbit_paths:
messaging_urls += \
['rabbit://%s:%s@rabbitmq.openstack.svc.cluster.local:5672%s' %
(rabbit_user, rabbit_pass, rabbit_path)]
return messaging_urls
def _get_endpoints_overrides(self):
return {
'identity': {
'auth': self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'oslo_cache': {
'auth': {
'memcache_secret_key':
self._get_common_password('auth_memcache_key')
}
},
'oslo_messaging': {
'auth': self._get_endpoints_oslo_messaging_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
}
def get_region_name(self):
return self._get_service_region_name(self.SERVICE_NAME)

263
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/cinder.py

@ -0,0 +1,263 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
import tsconfig.tsconfig as tsc
from sysinv.common import constants
from sysinv.common import exception
from sysinv.common.storage_backend_conf import StorageBackendConfig
from sysinv.helm import common
class CinderHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the cinder chart"""
CHART = app_constants.HELM_CHART_CINDER
SERVICE_NAME = app_constants.HELM_CHART_CINDER
SERVICE_TYPE = 'volume'
AUTH_USERS = ['cinder']
def _get_mount_overrides(self):
overrides = {
'volumes': [],
'volumeMounts': []
}
overrides['volumes'].append({
'name': 'newvolume',
'hostPath': {'path': tsc.IMAGE_CONVERSION_PATH}
})
overrides['volumeMounts'].append({
'name': 'newvolume',
'mountPath': tsc.IMAGE_CONVERSION_PATH
})
return overrides
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': {
'mounts': {
'cinder_volume': {
'cinder_volume': self._get_mount_overrides()
}
},
'replicas': {
'api': self._num_controllers(),
'volume': self._num_controllers(),
'scheduler': self._num_controllers(),
'backup': self._num_controllers()
}
},
'conf': {
'cinder': self._get_conf_cinder_overrides(),
'ceph': self._get_conf_ceph_overrides(),
'backends': self._get_conf_backends_overrides(),
},
'endpoints': self._get_endpoints_overrides(),
'ceph_client': self._get_ceph_client_overrides()
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_conf_ceph_overrides(self):
ceph_backend = self._get_primary_ceph_backend()
if not ceph_backend:
return {}
primary_tier_name =\
constants.SB_TIER_DEFAULT_NAMES[constants.SB_TIER_TYPE_CEPH]
replication, min_replication =\
StorageBackendConfig.get_ceph_pool_replication(self.dbapi)
pools = {}
for backend in self.dbapi.storage_ceph_get_list():
if backend.tier_name == primary_tier_name:
pool_name = constants.CEPH_POOL_VOLUMES_NAME
else:
pool_name = "%s-%s" % (constants.CEPH_POOL_VOLUMES_NAME,
backend.tier_name)
rule_name = "{0}{1}{2}".format(
backend.tier_name, constants.CEPH_CRUSH_TIER_SUFFIX,
"-ruleset").replace('-', '_')
pool = {
'replication': replication,
'crush_rule': rule_name.encode('utf8', 'strict'),
'chunk_size': constants.CEPH_POOL_VOLUMES_CHUNK_SIZE,
'app_name': constants.CEPH_POOL_VOLUMES_APP_NAME
}
pools[pool_name.encode('utf8', 'strict')] = pool
if backend.name == constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH]:
# Backup uses the same replication and crush rule as
# the default storage backend
pools['backup'] = dict(pool)
return {
'monitors': self._get_formatted_ceph_monitor_ips(),
'admin_keyring': 'null',
'pools': pools
}
def _get_conf_cinder_overrides(self):
# Get all the internal CEPH backends.
backends = self.dbapi.storage_backend_get_list_by_type(
backend_type=constants.SB_TYPE_CEPH)
conf_cinder = {
'DEFAULT': {
'enabled_backends': ','.join(
str(b.name.encode('utf8', 'strict').decode('utf-8')) for b in backends)
},
}
current_host_fs_list = self.dbapi.host_fs_get_list()
chosts = self.dbapi.ihost_get_by_personality(constants.CONTROLLER)
chosts_fs = [fs for fs in current_host_fs_list
if fs['name'] == constants.FILESYSTEM_NAME_IMAGE_CONVERSION]
# conversion overrides should be generated only if each controller node
# configured has the conversion partition added
if len(chosts) == len(chosts_fs):
conf_cinder['DEFAULT']['image_conversion_dir'] = \
tsc.IMAGE_CONVERSION_PATH
# Always set the default_volume_type to the volume type associated with the
# primary Ceph backend/tier which is available on all StarlingX platform
# configurations. This will guarantee that any Cinder API requests for
# this value will be fulfilled as part of determining a safe volume type to
# use during volume creation. This can be overrides by the user when/if
# additional backends are added to the platform.
default = next(
(b.name for b in backends
if b.name == constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH]), None)
if default:
conf_cinder['DEFAULT']['default_volume_type'] = \
default.encode('utf8', 'strict')
return conf_cinder
def _get_conf_backends_overrides(self):
conf_backends = {}
# We don't use the chart's default backends.
conf_backends['rbd1'] = ""
# Get tier info.
tiers = self.dbapi.storage_tier_get_list()
primary_tier_name =\
constants.SB_TIER_DEFAULT_NAMES[constants.SB_TIER_TYPE_CEPH]
# We support primary and secondary CEPH tiers.
backends = self.dbapi.storage_backend_get_list_by_type(
backend_type=constants.SB_TYPE_CEPH)
# No data if there are no CEPH backends.
if not backends:
return {}
for bk in backends:
bk_name = bk.name.encode('utf8', 'strict')
tier = next((t for t in tiers if t.forbackendid == bk.id), None)
if not tier:
raise Exception("No tier present for backend %s" % bk_name)
if tier.name == primary_tier_name:
rbd_pool = constants.CEPH_POOL_VOLUMES_NAME
else:
rbd_pool = "%s-%s" % (constants.CEPH_POOL_VOLUMES_NAME,
tier.name)
conf_backends[bk_name] = {
'image_volume_cache_enabled': 'True',
'volume_backend_name': bk_name,
'volume_driver': 'cinder.volume.drivers.rbd.RBDDriver',
'rbd_pool': rbd_pool.encode('utf8', 'strict'),
'rbd_user': 'cinder',
'rbd_ceph_conf':
(constants.CEPH_CONF_PATH +
constants.SB_TYPE_CEPH_CONF_FILENAME),
}
return conf_backends
def _get_endpoints_overrides(self):
return {
'identity': {
'auth':
self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'oslo_db': {
'auth': self._get_endpoints_oslo_db_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
'oslo_cache': {
'auth': {
'memcache_secret_key':
self._get_common_password('auth_memcache_key')
}
},
'oslo_messaging': {
'auth': self._get_endpoints_oslo_messaging_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
'volume': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
'port': self._get_endpoints_port_api_public_overrides(),
'scheme': self._get_endpoints_scheme_public_overrides(),
},
'volumev2': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
'port': self._get_endpoints_port_api_public_overrides(),
'scheme': self._get_endpoints_scheme_public_overrides(),
},
'volumev3': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
'port': self._get_endpoints_port_api_public_overrides(),
'scheme': self._get_endpoints_scheme_public_overrides(),
},
}
def _get_primary_ceph_backend(self):
try:
backend = self.dbapi.storage_backend_get_by_name(
constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH])
except Exception:
backend = None
pass
return backend
def get_region_name(self):
return self._get_service_region_name(self.SERVICE_NAME)
def get_service_name_v2(self):
return self._get_configured_service_name(self.SERVICE_NAME, 'v2')
def get_service_type_v2(self):
service_type = self._get_configured_service_type(
self.SERVICE_NAME, 'v2')
if service_type is None:
return self.SERVICE_TYPE + 'v2'
else:
return service_type

68
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/dcdbsync.py

@ -0,0 +1,68 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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
class DcdbsyncHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the dcdbsync chart"""
CHART = app_constants.HELM_CHART_DCDBSYNC
AUTH_USERS = ['dcdbsync']
SERVICE_NAME = app_constants.HELM_CHART_DCDBSYNC
def _is_enabled(self, app_name, chart_name, namespace):
# First, see if this chart is enabled by the user then adjust based on
# system conditions
enabled = super(DcdbsyncHelm, self)._is_enabled(
app_name, chart_name, namespace)
if enabled \
and (self._distributed_cloud_role() !=
constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER) \
and (self._distributed_cloud_role() !=
constants.DISTRIBUTED_CLOUD_ROLE_SUBCLOUD):
enabled = False
return enabled
def execute_manifest_updates(self, operator):
if self._is_enabled(operator.APP,
self.CHART, common.HELM_NS_OPENSTACK):
operator.manifest_chart_groups_insert(
operator.ARMADA_MANIFEST,
operator.CHART_GROUPS_LUT[self.CHART])
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'endpoints': self._get_endpoints_overrides(),
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_endpoints_overrides(self):
return {
'identity': {
'auth': self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'dcorch_dbsync': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
},
}

57
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/fm_rest_api.py

@ -0,0 +1,57 @@
#
# SPDX-License-Identifier: Apache-2.0
#
from oslo_log import log as logging
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import openstack
from sysinv.common import exception
from sysinv.helm import common
LOG = logging.getLogger(__name__)
class FmRestApiHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the fm-rest-api chart"""
CHART = app_constants.HELM_CHART_FM_REST_API
SERVICE_NAME = app_constants.HELM_CHART_FM_REST_API
AUTH_USERS = ['fm']
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'endpoints': self._get_endpoints_overrides(),
'pod': {
'replicas': {
'api': self._num_controllers()
},
},
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_endpoints_overrides(self):
fm_service_name = self._operator.chart_operators[
app_constants.HELM_CHART_FM_REST_API].SERVICE_NAME
return {
'identity': {
'auth': self._get_endpoints_identity_overrides(
fm_service_name, self.AUTH_USERS),
},
'oslo_db': {
'auth': self._get_endpoints_oslo_db_overrides(
fm_service_name, self.AUTH_USERS)
},
}

67
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/garbd.py

@ -0,0 +1,67 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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
class GarbdHelm(base.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
# system conditions
enabled = super(GarbdHelm, self)._is_enabled(
app_name, chart_name, namespace)
# If there are fewer than 2 controllers or we're on AIO-DX or we are on
# distributed cloud system controller, we'll use a single mariadb server
# and so we don't want to run garbd.
if enabled and (self._num_controllers() < 2 or
utils.is_aio_duplex_system(self.dbapi) or
(self._distributed_cloud_role() ==
constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER)):
enabled = False
return enabled
def execute_manifest_updates(self, operator):
# On application load this chart is enabled in the mariadb chart group
if not self._is_enabled(operator.APP,
self.CHART, common.HELM_NS_OPENSTACK):
operator.chart_group_chart_delete(
operator.CHART_GROUPS_LUT[self.CHART],
operator.CHARTS_LUT[self.CHART])
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides

180
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/glance.py

@ -0,0 +1,180 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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.common.storage_backend_conf import StorageBackendConfig
from sysinv.helm import common
# Info used in the Glance Helm chart.
RBD_STORE_USER = 'images'
class GlanceHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the glance chart"""
CHART = app_constants.HELM_CHART_GLANCE
SERVICE_NAME = app_constants.HELM_CHART_GLANCE
SERVICE_TYPE = 'image'
AUTH_USERS = ['glance']
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': self._get_pod_overrides(),
'endpoints': self._get_endpoints_overrides(),
'storage': self._get_storage_overrides(),
'conf': self._get_conf_overrides(),
'bootstrap': self._get_bootstrap_overrides(),
'ceph_client': self._get_ceph_client_overrides(),
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_pod_overrides(self):
replicas_count = 1
ceph_backend = self._get_primary_ceph_backend()
if ceph_backend:
replicas_count = self._num_controllers()
return {
'replicas': {
'api': replicas_count,
}
}
def _get_endpoints_overrides(self):
return {
'image': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
app_constants.HELM_CHART_GLANCE),
'scheme': self._get_endpoints_scheme_public_overrides(),
'port': self._get_endpoints_port_api_public_overrides(),
},
'identity': {
'auth': self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'oslo_cache': {
'auth': {
'memcache_secret_key':
self._get_common_password('auth_memcache_key')
}
},
'oslo_messaging': {
'auth': self._get_endpoints_oslo_messaging_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
'oslo_db': {
'auth': self._get_endpoints_oslo_db_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
}
def _get_storage_overrides(self):
ceph_backend = self._get_primary_ceph_backend()
if not ceph_backend:
return 'pvc'
return constants.GLANCE_BACKEND_RBD # radosgw| rbd | swift | pvc
def _get_ceph_overrides(self):
conf_ceph = {
'admin_keyring': self._get_ceph_password(
self.SERVICE_NAME, 'admin_keyring'
),
'monitors': self._get_formatted_ceph_monitor_ips()
}
return conf_ceph
def _get_conf_overrides(self):
ceph_backend = self._get_primary_ceph_backend()
if not ceph_backend:
rbd_store_pool = ""
rbd_store_user = ""
replication = 1
else:
rbd_store_pool = constants.CEPH_POOL_IMAGES_NAME
rbd_store_user = RBD_STORE_USER
replication, min_replication = \
StorageBackendConfig.get_ceph_pool_replication(self.dbapi)
# Only the primary Ceph tier is used for the glance images pool
rule_name = "{0}{1}{2}".format(
constants.SB_TIER_DEFAULT_NAMES[
constants.SB_TIER_TYPE_CEPH],
constants.CEPH_CRUSH_TIER_SUFFIX,
"-ruleset").replace('-', '_')
conf = {
'glance': {
'DEFAULT': {
'graceful_shutdown': True,
'show_image_direct_url': True,
},
'glance_store': {
'filesystem_store_datadir': constants.GLANCE_IMAGE_PATH,
'rbd_store_pool': rbd_store_pool,
'rbd_store_user': rbd_store_user,
'rbd_store_replication': replication,
'rbd_store_crush_rule': rule_name,
}
}
}
if ceph_backend:
conf['ceph'] = self._get_ceph_overrides()
return conf
def _get_bootstrap_overrides(self):
# By default, prevent the download and creation of the Cirros image.
# TODO: Remove if/when pulling from external registries is supported.
bootstrap = {
'enabled': False
}
return bootstrap
def _get_primary_ceph_backend(self):
try:
backend = self.dbapi.storage_backend_get_by_name(
constants.SB_DEFAULT_NAMES[constants.SB_TYPE_CEPH])
except exception.StorageBackendNotFoundByName:
backend = None
pass
return backend
def get_region_name(self):
return self._get_service_region_name(self.SERVICE_NAME)
def get_service_name(self):
return self._get_configured_service_name(self.SERVICE_NAME)
def get_service_type(self):
service_type = self._get_configured_service_type(self.SERVICE_NAME)
if service_type is None:
return self.SERVICE_TYPE
else:
return service_type

69
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/gnocchi.py

@ -0,0 +1,69 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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 exception
from sysinv.helm import common
class GnocchiHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the gnocchi chart"""
CHART = app_constants.HELM_CHART_GNOCCHI
SERVICE_NAME = app_constants.HELM_CHART_GNOCCHI
AUTH_USERS = ['gnocchi']
def get_overrides(self, namespace=None):
overrides = {
common.HELM_NS_OPENSTACK: {
'pod': self._get_pod_overrides(),
'endpoints': self._get_endpoints_overrides(),
'ceph_client': self._get_ceph_client_overrides(),
}
}
if namespace in self.SUPPORTED_NAMESPACES:
return overrides[namespace]
elif namespace:
raise exception.InvalidHelmNamespace(chart=self.CHART,
namespace=namespace)
else:
return overrides
def _get_pod_overrides(self):
return {
'replicas': {
'api': self._num_controllers()
}
}
def _get_endpoints_overrides(self):
return {
'identity': {
'auth': self._get_endpoints_identity_overrides(
self.SERVICE_NAME, self.AUTH_USERS),
},
'metric': {
'host_fqdn_override':
self._get_endpoints_host_fqdn_overrides(
self.SERVICE_NAME),
'port': self._get_endpoints_port_api_public_overrides(),
'scheme': self._get_endpoints_scheme_public_overrides(),
},
'oslo_cache': {
'auth': {
'memcache_secret_key':
self._get_common_password('auth_memcache_key')
}
},
'oslo_db': {
'auth': self._get_endpoints_oslo_db_overrides(
self.SERVICE_NAME, self.AUTH_USERS)
},
}

79
python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/helm/heat.py

@ -0,0 +1,79 @@
#
# Copyright (c) 2019-2020 Wind River Systems, Inc.
#
# 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 exception
from sysinv.helm import common
class HeatHelm(openstack.OpenstackBaseHelm):
"""Class to encapsulate helm operations for the heat chart"""
CHART = app_constants.HELM_CHART_HEAT
SERVICE_NAME = app_constants.HELM_CHART_HEAT
AUTH_USERS = ['heat', 'heat_trustee', 'heat_stack_user']
def get_overrides(self, namespace=None):