From 2b419cf230f027a994d798ca108983cf31f02d3f Mon Sep 17 00:00:00 2001 From: Joao Victor Portal Date: Mon, 28 Mar 2022 14:52:26 -0300 Subject: [PATCH] Fix missing headers in NFV VIM API requests The missing data about username, user_domain_name and tenant is passed as argument in sw_update methods imported from NFV code. Test Plan: PASS: Successfully deploy a Standard (duplex with 2 workers) using an image with this commit present and verify that Horizon interface is working. PASS: In the deployed environment, using Horizon interface, successfully get the patch strategy present in the system. PASS: In the deployed environment, using Horizon interface, execute the actions create/apply/abort/delete of patch orchestration and verify in "/var/log/nfv-vim-api.log" that the requests of patch strategy are processed with the fields "user", "tenant" and "domain" correctly filled. Story: 2009824 Task: 44870 Depends-On: https://review.opendev.org/c/starlingx/nfv/+/835652 Signed-off-by: Joao Victor Portal Change-Id: I7e03f9c0f9d3b1ccc4eaf237e065a61618bb7d01 --- .../starlingx_dashboard/api/vim.py | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/vim.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/vim.py index d904465d..7b0180e0 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/vim.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/vim.py @@ -29,40 +29,59 @@ STRATEGY_SW_UPGRADE = 'sw-upgrade' class Client(object): - def __init__(self, url, token_id): + def __init__(self, url, token_id, username=None, user_domain_name=None, + tenant=None): self.url = url self.token_id = token_id + self.username = username + self.user_domain_name = user_domain_name + self.tenant = tenant def get_strategy(self, strategy_name): - return sw_update.get_strategies(self.token_id, self.url, strategy_name) + # pylint: disable=too-many-function-args + return sw_update.get_strategies(self.token_id, self.url, strategy_name, + self.username, self.user_domain_name, + self.tenant) def create_strategy( self, strategy_name, controller_apply_type, storage_apply_type, swift_apply_type, worker_apply_type, max_parallel_worker_hosts, default_instance_action, alarm_restrictions): + # pylint: disable=too-many-function-args return sw_update.create_strategy( self.token_id, self.url, strategy_name, controller_apply_type, storage_apply_type, swift_apply_type, worker_apply_type, max_parallel_worker_hosts, - default_instance_action, alarm_restrictions) + default_instance_action, alarm_restrictions, self.username, + self.user_domain_name, self.tenant) def delete_strategy(self, strategy_name, force): + # pylint: disable=too-many-function-args return sw_update.delete_strategy(self.token_id, self.url, - strategy_name, force) + strategy_name, force, + self.username, self.user_domain_name, + self.tenant) def apply_strategy(self, strategy_name, stage_id): + # pylint: disable=too-many-function-args return sw_update.apply_strategy(self.token_id, self.url, strategy_name, - stage_id) + stage_id, self.username, + self.user_domain_name, self.tenant) def abort_strategy(self, strategy_name, stage_id): + # pylint: disable=too-many-function-args return sw_update.abort_strategy(self.token_id, self.url, strategy_name, - stage_id) + stage_id, self.username, + self.user_domain_name, self.tenant) def _sw_update_client(request): o = urlparse(base.url_for(request, 'nfv')) url = "://".join((o.scheme, o.netloc)) - return Client(url, token_id=request.user.token.id) + return Client(url, token_id=request.user.token.id, + username=request.user.username, + user_domain_name=request.user.user_domain_name, + tenant=request.user.tenant_name) def get_strategy(request, strategy_name):