Update FmClient to accept the endpoint argument

This commit allows specifying the endpoint URL when creating a
FmClient instance. This eliminates the need for the 'get_endpoint()'
call within FmClient, avoiding an unnecessary request.

Test plan:
1. PASS: Unmanage a subcloud and verify that all sync status, except
   dc-cert are moved to unknown.
2. PASS: Manage a subcloud and verify that all sync status are in-sync.
3. PASS: Turn a subcloud off and verify that its availability and sync
   status are updated.
4. PASS: Turn a subcloud on and verify that its availability and sync
   status are updated.
5. PASS: Run dcmanager subcloud show when executing all of the steps
   above and verify that the firmware audit is updated correctly.
6. PASS: Apply a development patch in all of the subclouds and verify
   that they complete.

Story: 2011106
Task: 50412

Change-Id: I31469ac25495dbef316134c3830b510665ac41bc
Signed-off-by: Raphael Lima <Raphael.Lima@windriver.com>
This commit is contained in:
Raphael Lima
2024-06-19 15:10:00 -03:00
parent 222ba53911
commit 30b4b76315
5 changed files with 22 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2018-2021 Wind River Systems, Inc.
# Copyright (c) 2018-2021, 2024 Wind River Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@@ -29,14 +29,17 @@ API_VERSION = '1'
class FmClient(base.DriverBase):
"""Fault Management driver."""
def __init__(self, region, session,
endpoint_type=dccommon_consts.KS_ENDPOINT_DEFAULT):
def __init__(
self, region, session, endpoint_type=dccommon_consts.KS_ENDPOINT_DEFAULT,
endpoint=None
):
self.region_name = region
try:
self.fm = fmclient.Client(API_VERSION,
session=session,
region_name=region,
endpoint_type=endpoint_type)
endpoint_type=endpoint_type,
endpoint=endpoint)
except exceptions.ServiceUnavailable:
raise

View File

@@ -346,7 +346,10 @@ class SubcloudsController(object):
"""Get the deploy configuration insync status of the subcloud """
detected_alarms = None
try:
fm_client = FmClient(subcloud_name, keystone_client.session)
fm_client = FmClient(
subcloud_name, keystone_client.session,
endpoint=keystone_client.endpoint_cache.get_endpoint("fm")
)
detected_alarms = fm_client.get_alarms_by_id(
FM_ALARM_ID_UNSYNCHRONIZED_RESOURCE)
except Exception as ex:

View File

@@ -362,13 +362,13 @@ class SubcloudAuditWorkerManager(manager.Manager):
).keystone_client
admin_session = keystone_client.session
sysinv_client = SysinvClient(
subcloud_region,
admin_session,
endpoint=endpoint_cache.build_subcloud_endpoint(
subcloud_management_ip, "sysinv"
),
subcloud_region, admin_session,
endpoint=keystone_client.endpoint_cache.get_endpoint("sysinv")
)
fm_client = FmClient(
subcloud_region, admin_session,
endpoint=keystone_client.endpoint_cache.get_endpoint("fm")
)
fm_client = FmClient(subcloud_region, admin_session)
except keystone_exceptions.ConnectTimeout:
if avail_status_current == dccommon_consts.AVAILABILITY_OFFLINE:
LOG.debug("Identity or Platform endpoint for %s not "

View File

@@ -132,7 +132,8 @@ class BaseState(object, metaclass=abc.ABCMeta):
def get_fm_client(self, region_name):
keystone_client = self.get_keystone_client(region_name)
return FmClient(region_name, keystone_client.session)
endpoint = keystone_client.endpoint_cache.get_endpoint("fm")
return FmClient(region_name, keystone_client.session, endpoint=endpoint)
def get_patching_client(self, region_name=dccommon_consts.DEFAULT_REGION_NAME):
keystone_client = self.get_keystone_client(region_name)

View File

@@ -86,7 +86,9 @@ class OpenStackDriver(object):
self.fm_client = FmClient(
region_name,
self.keystone_client.session,
endpoint_type=dccommon_consts.KS_ENDPOINT_DEFAULT)
endpoint_type=dccommon_consts.KS_ENDPOINT_DEFAULT,
endpoint=self.keystone_client.endpoint_cache.get_endpoint("fm")
)
OpenStackDriver.os_clients_dict[region_name][
'fm'] = self.fm_client
except Exception as exception: