diff --git a/sysinv/sysinv/sysinv/sysinv/cert_mon/certificate_mon_manager.py b/sysinv/sysinv/sysinv/sysinv/cert_mon/certificate_mon_manager.py index ba8185bc63..3b8b9f1403 100644 --- a/sysinv/sysinv/sysinv/sysinv/cert_mon/certificate_mon_manager.py +++ b/sysinv/sysinv/sysinv/sysinv/cert_mon/certificate_mon_manager.py @@ -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 diff --git a/sysinv/sysinv/sysinv/sysinv/cert_mon/service.py b/sysinv/sysinv/sysinv/sysinv/cert_mon/service.py index dc61ff6a42..34452494d9 100644 --- a/sysinv/sysinv/sysinv/sysinv/cert_mon/service.py +++ b/sysinv/sysinv/sysinv/sysinv/cert_mon/service.py @@ -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) diff --git a/sysinv/sysinv/sysinv/sysinv/cert_mon/utils.py b/sysinv/sysinv/sysinv/sysinv/cert_mon/utils.py index af24bf3066..98e5c50695 100644 --- a/sysinv/sysinv/sysinv/sysinv/cert_mon/utils.py +++ b/sysinv/sysinv/sysinv/sysinv/cert_mon/utils.py @@ -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', diff --git a/sysinv/sysinv/sysinv/sysinv/openstack/common/keystone_objects.py b/sysinv/sysinv/sysinv/sysinv/openstack/common/keystone_objects.py index 8383d82418..91923ed220 100644 --- a/sysinv/sysinv/sysinv/sysinv/openstack/common/keystone_objects.py +++ b/sysinv/sysinv/sysinv/sysinv/openstack/common/keystone_objects.py @@ -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,