91 lines
3.2 KiB
Python
91 lines
3.2 KiB
Python
#
|
|
# Copyright (c) 2018-2021 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from sysinv.common import constants
|
|
from sysinv.common import utils
|
|
|
|
from sysinv.puppet import openstack
|
|
|
|
|
|
class SmPuppet(openstack.OpenstackBasePuppet):
|
|
"""Class to encapsulate puppet operations for sm configuration"""
|
|
|
|
SERVICE_NAME = 'smapi'
|
|
SERVICE_PORT = constants.PLATFORM_SMAPI_PARAMS_PORT
|
|
|
|
def get_static_config(self):
|
|
config = {
|
|
'platform::smapi::params::auth_username': self.SERVICE_NAME,
|
|
}
|
|
return config
|
|
|
|
def get_secure_static_config(self):
|
|
kspass = self._get_service_password(self.SERVICE_NAME)
|
|
|
|
config = {
|
|
'smapi::keystone::auth::password': kspass,
|
|
'smapi::keystone::authtoken::password': kspass,
|
|
'smapi::auth::auth_password': kspass,
|
|
'platform::smapi::params::keystone_password': kspass,
|
|
}
|
|
return config
|
|
|
|
def get_system_config(self):
|
|
ksuser = self._get_service_user_name(self.SERVICE_NAME)
|
|
|
|
host = (constants.CONTROLLER_FQDN
|
|
if utils.is_fqdn_ready_to_use()
|
|
else None)
|
|
|
|
config = {
|
|
'smapi::keystone::authtoken::username': ksuser,
|
|
'smapi::keystone::authtoken::auth_url': self._keystone_identity_uri(host),
|
|
'smapi::keystone::auth::auth_name': ksuser,
|
|
'smapi::keystone::auth::public_url': self.get_public_url(),
|
|
'smapi::keystone::auth::region': self._region_name(),
|
|
'smapi::keystone::auth::admin_url': self.get_admin_url(),
|
|
'smapi::keystone::auth::internal_url': self.get_internal_url(),
|
|
|
|
'platform::smapi::params::admin_url': self.get_admin_url(),
|
|
'platform::smapi::params::internal_url': self.get_internal_url(),
|
|
'platform::smapi::params::keystone_auth_url': self._keystone_identity_uri(host),
|
|
'platform::smapi::params::keystone_username': ksuser,
|
|
'platform::smapi::params::public_url': self.get_public_url(),
|
|
'platform::smapi::params::port': self.SERVICE_PORT,
|
|
'platform::smapi::params::region': self._region_name(),
|
|
}
|
|
|
|
return config
|
|
|
|
def get_host_config(self, host):
|
|
if (constants.CONTROLLER not in utils.get_personalities(host)):
|
|
return {}
|
|
|
|
if (utils.is_fqdn_ready_to_use() and
|
|
host.personality == constants.CONTROLLER):
|
|
if host.hostname == constants.CONTROLLER_0_HOSTNAME:
|
|
host_ip = constants.CONTROLLER_0_FQDN
|
|
elif host.hostname == constants.CONTROLLER_1_HOSTNAME:
|
|
host_ip = constants.CONTROLLER_1_FQDN
|
|
else:
|
|
address = self._get_address_by_name(
|
|
host.hostname, constants.NETWORK_TYPE_MGMT)
|
|
host_ip = address.address
|
|
config = {
|
|
'platform::smapi::params::bind_ip': host_ip,
|
|
}
|
|
|
|
return config
|
|
|
|
def get_public_url(self):
|
|
return self._format_public_endpoint(self.SERVICE_PORT)
|
|
|
|
def get_internal_url(self):
|
|
return self._format_private_endpoint(self.SERVICE_PORT)
|
|
|
|
def get_admin_url(self):
|
|
return self._format_admin_endpoint(self.SERVICE_PORT)
|