Update helm overrides for ceph on simplex installs

Consolidate the code related to obtaining formatted ceph monitor
addresses used in the chart overrides. Since this is common
functionality for the rbd_provisioner, glance, and cinder charts, move
the core functions to the helm base class.

In the case of the k8s AIO simplex, it has a single monitor that cannot
use the defined mgmt IP address on the loopback interface. The address
will be moved to use the OAM interface in the platform puppet code so
align the behavior of the helm charts as well with this update.

Change-Id: I3dbae1438e787391bc8c9f39f555cb5860d02cf7
Story: 2003909
Task: 27084
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church 2018-10-28 19:51:53 -04:00
parent 0d92352aec
commit e715aa2369
4 changed files with 47 additions and 40 deletions

View File

@ -8,7 +8,10 @@ import abc
import os
import six
from sysinv.common import constants
from sysinv.common import exception
from sysinv.common import utils
from sysinv.common.storage_backend_conf import StorageBackendConfig
from sysinv.openstack.common import log as logging
from . import common
@ -22,6 +25,7 @@ class BaseHelm(object):
"""Base class to encapsulate helm operations for chart overrides"""
DEFAULT_REGION_NAME = 'RegionOne'
CEPH_MON_SERVICE_PORT = 6789
def __init__(self, operator):
self._operator = operator
@ -135,3 +139,40 @@ class BaseHelm(object):
def _num_computes(self):
return self._count_hosts_by_label(common.LABEL_COMPUTE)
def _get_address_by_name(self, name, networktype):
"""
Retrieve an address entry by name and scoped by network type
"""
addresses = self.context.setdefault('_address_names', {})
address_name = utils.format_address_name(name, networktype)
address = addresses.get(address_name)
if address is None:
address = self.dbapi.address_get_by_name(address_name)
addresses[address_name] = address
return address
def _get_oam_address(self):
address = self._get_address_by_name(
constants.CONTROLLER_HOSTNAME, constants.NETWORK_TYPE_OAM)
return address.address
def _system_mode(self):
return self.dbapi.isystem_get_one().system_mode
def _get_ceph_monitor_ips(self):
if self._system_mode() == constants.SYSTEM_MODE_SIMPLEX:
monitors = [self._get_oam_address()]
else:
monitors = StorageBackendConfig.get_ceph_mon_ip_addresses(
self.dbapi).values()
return monitors
def _get_formatted_ceph_monitor_ips(self):
port = self.CEPH_MON_SERVICE_PORT
monitor_ips = self._get_ceph_monitor_ips()
formatted_monitor_ips = [
utils._format_ceph_mon_address(mon, port) for mon in monitor_ips
]
return formatted_monitor_ips

View File

@ -72,10 +72,6 @@ class CinderHelm(openstack.OpenstackBaseHelm):
if not ceph_backend:
return {}
# Get Ceph monitors.
ceph_mon_ips = StorageBackendConfig.get_ceph_mon_ip_addresses(
self.dbapi).values()
replication, min_replication =\
StorageBackendConfig.get_ceph_pool_replication(self.dbapi)
@ -84,11 +80,7 @@ class CinderHelm(openstack.OpenstackBaseHelm):
ruleset = 0
conf_ceph = {
'monitors': [
"%s:6789" % ceph_mon_ips[0],
"%s:6789" % ceph_mon_ips[1],
"%s:6789" % ceph_mon_ips[2]
],
'monitors': self._get_formatted_ceph_monitor_ips(),
'admin_keyring': 'null',
'pools': {
'backup': {

View File

@ -6,8 +6,6 @@
from sysinv.common import constants
from sysinv.common import exception
from sysinv.common import utils as cutils
from sysinv.common.storage_backend_conf import StorageBackendConfig
from sysinv.openstack.common import log as logging
from . import common
@ -116,19 +114,11 @@ class GlanceHelm(openstack.OpenstackBaseHelm):
return constants.GLANCE_BACKEND_RBD # radosgw| rbd | swift | pvc
def _get_ceph_overrides(self):
SERVICE_PORT_MON = 6789
# Get Ceph monitors.
ceph_mon_ips = StorageBackendConfig.get_ceph_mon_ip_addresses(
self.dbapi).values()
conf_ceph = {
'admin_keyring': self._get_ceph_password(
self.SERVICE_NAME, 'admin_keyring'
),
'monitors': [
cutils._format_ceph_mon_address(ceph_mon_ips[0], SERVICE_PORT_MON),
cutils._format_ceph_mon_address(ceph_mon_ips[1], SERVICE_PORT_MON),
cutils._format_ceph_mon_address(ceph_mon_ips[2], SERVICE_PORT_MON),
]
'monitors': self._get_formatted_ceph_monitor_ips()
}
return conf_ceph

View File

@ -4,11 +4,8 @@
# SPDX-License-Identifier: Apache-2.0
#
import netaddr
from sysinv.common import constants
from sysinv.common import exception
from sysinv.common.storage_backend_conf import StorageBackendConfig
from sysinv.common.storage_backend_conf import K8RbdProvisioner
from sysinv.openstack.common import log as logging
@ -49,18 +46,11 @@ class RbdProvisionerHelm(base.BaseHelm):
if not rbd_provisioner_bks:
return {} # ceph is not configured
ceph_mon_ips = StorageBackendConfig.get_ceph_mon_ip_addresses(
self.dbapi).values()
classdefaults = {
"monitors": [
self._format_ceph_mon_address(ceph_mon_ips[0]),
self._format_ceph_mon_address(ceph_mon_ips[1]),
self._format_ceph_mon_address(ceph_mon_ips[2])
],
"adminId": constants.K8S_RBD_PROV_USER_NAME,
"adminSecretName": constants.K8S_RBD_PROV_ADMIN_SECRET_NAME
}
"monitors": self._get_formatted_ceph_monitor_ips(),
"adminId": constants.K8S_RBD_PROV_USER_NAME,
"adminSecretName": constants.K8S_RBD_PROV_ADMIN_SECRET_NAME
}
classes = []
for bk in rbd_provisioner_bks:
@ -86,9 +76,3 @@ class RbdProvisionerHelm(base.BaseHelm):
namespace=namespace)
else:
return overrides
def _format_ceph_mon_address(self, ip_address):
if netaddr.IPAddress(ip_address).version == constants.IPV4_FAMILY:
return '%s:%d' % (ip_address, self.SERVICE_PORT_MON)
else:
return '[%s]:%d' % (ip_address, self.SERVICE_PORT_MON)