Files
distcloud/distributedcloud/dcorch/rpc/client.py
Hugo Brito c2c7ab93ef Update endpoint caches post network reconfig
After switching the management network to the admin network
we need to update the services endpoints cache of all
dcmanager, dcorch and cert-mon workers to the new admin value.

The fanout parameter is being added to the cast calls of the
RPC clients (dcorch and audit), this parameter makes the method
cast to all servers listening on a topic rather than just one
of them.

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 service endpoints are updated in all workers'
endpoint caches for the subcloud
PASS: Manage the subcloud and verify that both dcmanager and dcorch
audits are working as expected
PASS: Perform a Identity sync:
1. openstack --os-region-name SystemController user create <new_user>
--domain <domain> --project <project> --password <password>
2. Log in into subcloud and verify the new user: openstack user list
PASS: Verify that the master token is refreshed successfully after an hour

Story: 2010319
Task: 47556

Depends-On: https://review.opendev.org/c/starlingx/config/+/877323

Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
Change-Id: I149c864382b7c63d424f736bdb4eaac2a787b709
2023-03-14 11:44:15 -03:00

135 lines
5.0 KiB
Python

# Copyright (c) 2017-2023 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Client side of the DC Orchestrator RPC API.
"""
from oslo_log import log as logging
from dcorch.common import consts
from dcorch.common import messaging
LOG = logging.getLogger(__name__)
class EngineClient(object):
"""Client side of the DC orchestrator engine rpc API.
Version History:
1.0 - Initial version
"""
BASE_RPC_API_VERSION = '1.0'
def __init__(self):
self._client = messaging.get_rpc_client(
topic=consts.TOPIC_ORCH_ENGINE,
version=self.BASE_RPC_API_VERSION)
@staticmethod
def make_msg(method, **kwargs):
return method, kwargs
def call(self, ctxt, msg, version=None):
method, kwargs = msg
if version is not None:
client = self._client.prepare(version=version)
else:
client = self._client
return client.call(ctxt, method, **kwargs)
def cast(self, ctxt, msg, fanout=None, version=None):
method, kwargs = msg
if version or fanout:
client = self._client.prepare(fanout=fanout, version=version)
else:
client = self._client
return client.cast(ctxt, method, **kwargs)
def get_usage_for_project_and_user(self, ctxt, endpoint_type,
project_id, user_id=None):
return self.call(ctxt, self.make_msg('get_usage_for_project_and_user',
endpoint_type=endpoint_type,
project_id=project_id,
user_id=user_id))
def quota_sync_for_project(self, ctxt, project_id, user_id):
return self.cast(ctxt, self.make_msg('quota_sync_for_project',
project_id=project_id,
user_id=user_id))
def keypair_sync_for_user(self, ctxt, job_id, payload):
return self.cast(
ctxt,
self.make_msg('keypair_sync_for_user', job_id=job_id,
payload=payload))
def image_sync(self, ctxt, job_id, payload):
return self.cast(
ctxt,
self.make_msg('image_sync', job_id=job_id, payload=payload))
def add_subcloud(self, ctxt, subcloud_name, sw_version):
return self.call(
ctxt,
self.make_msg('add_subcloud', subcloud_name=subcloud_name,
sw_version=sw_version))
def del_subcloud(self, ctxt, subcloud_name):
return self.call(
ctxt,
self.make_msg('del_subcloud', subcloud_name=subcloud_name))
def update_subcloud_states(self, ctxt, subcloud_name, management_state,
availability_status):
return self.call(
ctxt,
self.make_msg('update_subcloud_states',
subcloud_name=subcloud_name,
management_state=management_state,
availability_status=availability_status))
def add_subcloud_sync_endpoint_type(self, ctxt, subcloud_name,
endpoint_type_list):
return self.cast(
ctxt,
self.make_msg('add_subcloud_sync_endpoint_type',
subcloud_name=subcloud_name,
endpoint_type_list=endpoint_type_list))
def remove_subcloud_sync_endpoint_type(self, ctxt, subcloud_name,
endpoint_type_list):
return self.cast(
ctxt,
self.make_msg('remove_subcloud_sync_endpoint_type',
subcloud_name=subcloud_name,
endpoint_type_list=endpoint_type_list))
def update_subcloud_version(self, ctxt, subcloud_name, sw_version):
return self.call(
ctxt,
self.make_msg('update_subcloud_version',
subcloud_name=subcloud_name, sw_version=sw_version))
def update_subcloud_endpoints(self, ctxt, subcloud_name, endpoints):
return self.cast(ctxt, self.make_msg(
'update_subcloud_endpoints', subcloud_name=subcloud_name,
endpoints=endpoints), fanout=True, version=self.BASE_RPC_API_VERSION)
# The sync job info has been written to the DB, alert the sync engine
# that there is work to do.
def sync_request(self, ctxt, endpoint_type):
return self.cast(
ctxt, self.make_msg('sync_request', endpoint_type=endpoint_type))