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 <Joao.VictorPortal@windriver.com> Change-Id: I7e03f9c0f9d3b1ccc4eaf237e065a61618bb7d01
This commit is contained in:
parent
ddbf79f02c
commit
2b419cf230
|
@ -29,40 +29,59 @@ STRATEGY_SW_UPGRADE = 'sw-upgrade'
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
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.url = url
|
||||||
self.token_id = token_id
|
self.token_id = token_id
|
||||||
|
self.username = username
|
||||||
|
self.user_domain_name = user_domain_name
|
||||||
|
self.tenant = tenant
|
||||||
|
|
||||||
def get_strategy(self, strategy_name):
|
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(
|
def create_strategy(
|
||||||
self, strategy_name, controller_apply_type, storage_apply_type,
|
self, strategy_name, controller_apply_type, storage_apply_type,
|
||||||
swift_apply_type, worker_apply_type, max_parallel_worker_hosts,
|
swift_apply_type, worker_apply_type, max_parallel_worker_hosts,
|
||||||
default_instance_action, alarm_restrictions):
|
default_instance_action, alarm_restrictions):
|
||||||
|
# pylint: disable=too-many-function-args
|
||||||
return sw_update.create_strategy(
|
return sw_update.create_strategy(
|
||||||
self.token_id, self.url, strategy_name, controller_apply_type,
|
self.token_id, self.url, strategy_name, controller_apply_type,
|
||||||
storage_apply_type,
|
storage_apply_type,
|
||||||
swift_apply_type, worker_apply_type, max_parallel_worker_hosts,
|
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):
|
def delete_strategy(self, strategy_name, force):
|
||||||
|
# pylint: disable=too-many-function-args
|
||||||
return sw_update.delete_strategy(self.token_id, self.url,
|
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):
|
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,
|
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):
|
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,
|
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):
|
def _sw_update_client(request):
|
||||||
o = urlparse(base.url_for(request, 'nfv'))
|
o = urlparse(base.url_for(request, 'nfv'))
|
||||||
url = "://".join((o.scheme, o.netloc))
|
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):
|
def get_strategy(request, strategy_name):
|
||||||
|
|
Loading…
Reference in New Issue