Merge "Configure dcmanager user for endpoint_cache"

This commit is contained in:
Zuul
2020-06-19 13:49:46 +00:00
committed by Gerrit Code Review
5 changed files with 77 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ from sysinv.common import constants as sysinv_constants
# have been applied, so only the static entries from tsconfig can be used
# (the platform.conf file will not have been updated with dynamic values).
from tsconfig.tsconfig import SW_VERSION
# from tsconfig.tsconfig import SW_VERSION_20_06
from tsconfig.tsconfig import PLATFORM_PATH
from tsconfig.tsconfig import KEYRING_PATH
from tsconfig.tsconfig import PLATFORM_CONF_FILE
@@ -671,6 +672,29 @@ def migrate_hiera_data(from_release, to_release):
'platform::client::credentials::params::keyring_file':
os.path.join(KEYRING_PATH, '.CREDENTIAL'),
})
# Add dcmanager and sysinv user id as well as service project id to
# the static.yaml on subclouds
# comment out the following untested code for now
# if to_release == SW_VERSION_20_06 and cutils.is_subcloud():
# dm_user_id = cutils.get_keystone_user_id('dcmanager')
# sysinv_user_id = cutils.get_keystone_user_id('sysinv')
# service_project_id = cutils.get_keystone_project_id('services')
# if dm_user_id:
# static_config.update({
# 'platform::dcmanager::bootstrap::dc_dcmanager_user_id':
# dm_user_id
# })
# if sysinv_user_id:
# static_config.update({
# 'platform::sysinv::bootstrap::dc_sysinv_user_id':
# sysinv_user_id
# })
# if service_project_id:
# static_config.update({
# 'openstack::keystone::bootstrap::dc_services_project_id':
# service_project_id
# })
with open(static_file, 'w') as yaml_file:
yaml.dump(static_config, yaml_file, default_flow_style=False)

View File

@@ -10,6 +10,8 @@ Utilities
import glob
import os
import psycopg2
from psycopg2.extras import RealDictCursor
import shutil
import subprocess
import time
@@ -25,6 +27,7 @@ from controllerconfig.common import constants
from controllerconfig.common.exceptions import ValidateFail
from oslo_log import log
LOG = log.getLogger(__name__)
DEVNULL = open(os.devnull, 'w')
@@ -404,3 +407,36 @@ def ip_version_to_string(ip_version):
return "IPv6"
else:
return "IP"
def is_subcloud():
conn = psycopg2.connect("dbname='sysinv' user='postgres'")
with conn:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute("SELECT * from i_system")
system = cur.fetchone()
return system['distributed_cloud_role'] == 'subcloud'
def get_keystone_user_id(user_name):
""" Get the a keystone user id by name"""
conn = psycopg2.connect("dbname='keystone' user='postgres'")
with conn:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute("SELECT user_id FROM local_user WHERE name=%s" %
user_name)
user_id = cur.fetchone()
return user_id['user_id']
def get_keystone_project_id(project_name):
""" Get the a keystone project id by name"""
conn = psycopg2.connect("dbname='keystone' user='postgres'")
with conn:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute("SELECT id FROM project WHERE name=%s" %
project_name)
project_id = cur.fetchone()
return project_id['id']