Update cert-mon dc token cache post network config

After switching the management network to the admin network,
we need to update the cert-mon sysinv endpoint in the
dc token cache to sync the dc certificate.

Test Plan:
PASS: dcmanager subcloud update (using admin network parameters)
1. Endpoints for the subcloud updated with admin ip value
2. subcloud availability = online
PASS: Verify that the subcloud is online shortly after succesful
completion of subcloud_update playbook
PASS: Verify that the cert-mon sysinv endpoint is updated
PASS: Manage the subcloud and verify that dc-cert_sync_status is
in-sync as expected

Story: 2010319
Task: 47645

Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
Change-Id: Ia69e81597af2efec4a8e2496ae239fd73c864654
This commit is contained in:
Hugo Brito 2023-03-13 18:48:14 -03:00
parent 2115645e26
commit 82fe8698f1
4 changed files with 40 additions and 0 deletions

View File

@ -428,6 +428,14 @@ class CertificateMonManager(periodic_task.PeriodicTasks):
subcloud_audit_queue.SubcloudAuditData(subcloud_name),
allow_requeue=allow_requeue)
def subcloud_sysinv_endpoint_update(self, subcloud_name, sysinv_url):
dc_token = self.dc_token_cache.get_token()
subcloud_sysinv_url = utils.dc_get_subcloud_sysinv_url(
subcloud_name, dc_token)
if subcloud_sysinv_url != sysinv_url:
utils.dc_update_subcloud_sysinv_url(
subcloud_name, sysinv_url, dc_token)
def monitor_cert(self, monitor):
while True:
# never exit until exit signal received

View File

@ -120,3 +120,8 @@ class CertificateMonitorService(service.Service):
LOG.info("%s is managed. An audit is queued"
% subcloud_name)
self.manager.audit_subcloud(subcloud_name)
def subcloud_sysinv_endpoint_update(self, ctxt, subcloud_name, endpoint):
"""Update sysinv endpoint of dc token cache"""
LOG.info("Update subloud: %s sysinv endpoint" % subcloud_name)
self.manager.subcloud_sysinv_endpoint_update(subcloud_name, endpoint)

View File

@ -152,6 +152,13 @@ def dc_get_subcloud_sysinv_url(subcloud_name, dc_token):
raise Exception('Cannot find sysinv endpoint for %s' % subcloud_name)
def dc_update_subcloud_sysinv_url(subcloud_name, sysinv_url, dc_token):
dc_token.update_service_admin_url(constants.SERVICE_TYPE_PLATFORM,
constants.SYSINV_USERNAME,
subcloud_name,
sysinv_url)
def dc_get_service_endpoint_url(token,
service_name='dcmanager',
service_type='dcmanager',

View File

@ -81,6 +81,26 @@ class Token(object):
return self._get_service_url(service_type, service_name, 'admin',
region_name)
def update_service_admin_url(
self, service_type, service_name, region_name, endpoint):
"""Update the catalog of a service for the administrative url"""
return self._set_service_url(service_type, service_name,
'admin', region_name, endpoint)
def _set_service_url(self, service_type, service_name, interface_type,
region_name, new_endpoint):
"""Update the url of a service in a region"""
if region_name is None:
region_name = self.region_name
for catalog in self.data['token']['catalog']:
if (catalog['type'] == service_type and
catalog['name'] == service_name and
catalog['endpoints']):
for endpoint in catalog['endpoints']:
if (endpoint['interface'] == interface_type
and endpoint['region'] == region_name):
endpoint['url'] = new_endpoint
def get_service_internal_url(self,
service_type,
service_name,