Add tenant parameter in API request methods
This parameter was not added before because it was not needed in NFV code, but it will be used in Horizon and Distcloud code. The test plan is the same of the already merged change https://review.opendev.org/c/starlingx/nfv/+/833910. Test Plan: PASS: Successfully deploy a Distributed Cloud (1 subcloud) using an image with this commit present and verify in the contents of "/var/log/nfv-vim-api.log" that the NFV VIM API server started successfully in the central cloud and in the subcloud. PASS: In the deployed subcloud, execute command "sw-manager patch-strategy show" and check that the command was successful. PASS: In the deployed subcloud, execute each of the following commands and check that the log of the received requests are present in "/var/log/nfv-vim-api.log" with the fields "user", "tenant" and "domain" correctly filled: sw-manager patch-strategy apply sw-manager patch-strategy abort sw-manager patch-strategy create sw-manager patch-strategy delete PASS: In the deployed central cloud, create and execute a patch-strategy using dcmanager CLI to verify the compatibility with the changes. PASS: In the deployed central cloud, create and execute a patch-strategy using Horizon interface to verify the compatibility with the changes. PASS: Successfully build package "nfv" as Debian package. Story: 2009824 Task: 44878 Signed-off-by: Joao Victor Portal <Joao.VictorPortal@windriver.com> Change-Id: I2774b36081de77f358a9713d0f3cf5992525ee91
This commit is contained in:
parent
8040bccbfb
commit
c00de2e482
|
@ -180,7 +180,7 @@ def _get_strategy_object_from_response(response):
|
||||||
|
|
||||||
|
|
||||||
def get_strategies(token_id, url, strategy_name, username=None,
|
def get_strategies(token_id, url, strategy_name, username=None,
|
||||||
user_domain_name=None):
|
user_domain_name=None, tenant=None):
|
||||||
"""
|
"""
|
||||||
Software Update - Get Strategies
|
Software Update - Get Strategies
|
||||||
"""
|
"""
|
||||||
|
@ -189,7 +189,8 @@ def get_strategies(token_id, url, strategy_name, username=None,
|
||||||
api_cmd_headers = dict()
|
api_cmd_headers = dict()
|
||||||
if username:
|
if username:
|
||||||
api_cmd_headers['X-User'] = username
|
api_cmd_headers['X-User'] = username
|
||||||
api_cmd_headers['X-Tenant'] = username
|
if tenant:
|
||||||
|
api_cmd_headers['X-Tenant'] = tenant
|
||||||
if user_domain_name:
|
if user_domain_name:
|
||||||
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
||||||
api_cmd_headers['X-Auth-Token'] = token_id
|
api_cmd_headers['X-Auth-Token'] = token_id
|
||||||
|
@ -202,7 +203,7 @@ def get_strategies(token_id, url, strategy_name, username=None,
|
||||||
|
|
||||||
|
|
||||||
def get_strategy(token_id, url, strategy_name, strategy_uuid, username=None,
|
def get_strategy(token_id, url, strategy_name, strategy_uuid, username=None,
|
||||||
user_domain_name=None):
|
user_domain_name=None, tenant=None):
|
||||||
"""
|
"""
|
||||||
Software Update - Get Strategy
|
Software Update - Get Strategy
|
||||||
"""
|
"""
|
||||||
|
@ -212,7 +213,8 @@ def get_strategy(token_id, url, strategy_name, strategy_uuid, username=None,
|
||||||
api_cmd_headers = dict()
|
api_cmd_headers = dict()
|
||||||
if username:
|
if username:
|
||||||
api_cmd_headers['X-User'] = username
|
api_cmd_headers['X-User'] = username
|
||||||
api_cmd_headers['X-Tenant'] = username
|
if tenant:
|
||||||
|
api_cmd_headers['X-Tenant'] = tenant
|
||||||
if user_domain_name:
|
if user_domain_name:
|
||||||
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
||||||
api_cmd_headers['X-Auth-Token'] = token_id
|
api_cmd_headers['X-Auth-Token'] = token_id
|
||||||
|
@ -236,6 +238,7 @@ def create_strategy(token_id,
|
||||||
alarm_restrictions,
|
alarm_restrictions,
|
||||||
username=None,
|
username=None,
|
||||||
user_domain_name=None,
|
user_domain_name=None,
|
||||||
|
tenant=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""
|
"""
|
||||||
Software Update - Create Strategy
|
Software Update - Create Strategy
|
||||||
|
@ -246,7 +249,8 @@ def create_strategy(token_id,
|
||||||
api_cmd_headers['Content-Type'] = "application/json"
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
if username:
|
if username:
|
||||||
api_cmd_headers['X-User'] = username
|
api_cmd_headers['X-User'] = username
|
||||||
api_cmd_headers['X-Tenant'] = username
|
if tenant:
|
||||||
|
api_cmd_headers['X-Tenant'] = tenant
|
||||||
if user_domain_name:
|
if user_domain_name:
|
||||||
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
||||||
api_cmd_headers['X-Auth-Token'] = token_id
|
api_cmd_headers['X-Auth-Token'] = token_id
|
||||||
|
@ -297,7 +301,7 @@ def create_strategy(token_id,
|
||||||
|
|
||||||
|
|
||||||
def delete_strategy(token_id, url, strategy_name, force=False,
|
def delete_strategy(token_id, url, strategy_name, force=False,
|
||||||
username=None, user_domain_name=None):
|
username=None, user_domain_name=None, tenant=None):
|
||||||
"""
|
"""
|
||||||
Software Update - Delete Strategy
|
Software Update - Delete Strategy
|
||||||
"""
|
"""
|
||||||
|
@ -307,7 +311,8 @@ def delete_strategy(token_id, url, strategy_name, force=False,
|
||||||
api_cmd_headers['Content-Type'] = "application/json"
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
if username:
|
if username:
|
||||||
api_cmd_headers['X-User'] = username
|
api_cmd_headers['X-User'] = username
|
||||||
api_cmd_headers['X-Tenant'] = username
|
if tenant:
|
||||||
|
api_cmd_headers['X-Tenant'] = tenant
|
||||||
if user_domain_name:
|
if user_domain_name:
|
||||||
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
||||||
api_cmd_headers['X-Auth-Token'] = token_id
|
api_cmd_headers['X-Auth-Token'] = token_id
|
||||||
|
@ -327,7 +332,7 @@ def delete_strategy(token_id, url, strategy_name, force=False,
|
||||||
|
|
||||||
|
|
||||||
def apply_strategy(token_id, url, strategy_name, stage_id=None,
|
def apply_strategy(token_id, url, strategy_name, stage_id=None,
|
||||||
username=None, user_domain_name=None):
|
username=None, user_domain_name=None, tenant=None):
|
||||||
"""
|
"""
|
||||||
Software Update - Apply Strategy
|
Software Update - Apply Strategy
|
||||||
"""
|
"""
|
||||||
|
@ -337,7 +342,8 @@ def apply_strategy(token_id, url, strategy_name, stage_id=None,
|
||||||
api_cmd_headers['Content-Type'] = "application/json"
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
if username:
|
if username:
|
||||||
api_cmd_headers['X-User'] = username
|
api_cmd_headers['X-User'] = username
|
||||||
api_cmd_headers['X-Tenant'] = username
|
if tenant:
|
||||||
|
api_cmd_headers['X-Tenant'] = tenant
|
||||||
if user_domain_name:
|
if user_domain_name:
|
||||||
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
||||||
api_cmd_headers['X-Auth-Token'] = token_id
|
api_cmd_headers['X-Auth-Token'] = token_id
|
||||||
|
@ -358,7 +364,7 @@ def apply_strategy(token_id, url, strategy_name, stage_id=None,
|
||||||
|
|
||||||
|
|
||||||
def abort_strategy(token_id, url, strategy_name, stage_id, username=None,
|
def abort_strategy(token_id, url, strategy_name, stage_id, username=None,
|
||||||
user_domain_name=None):
|
user_domain_name=None, tenant=None):
|
||||||
"""
|
"""
|
||||||
Software Update - Abort Strategy
|
Software Update - Abort Strategy
|
||||||
"""
|
"""
|
||||||
|
@ -368,7 +374,8 @@ def abort_strategy(token_id, url, strategy_name, stage_id, username=None,
|
||||||
api_cmd_headers['Content-Type'] = "application/json"
|
api_cmd_headers['Content-Type'] = "application/json"
|
||||||
if username:
|
if username:
|
||||||
api_cmd_headers['X-User'] = username
|
api_cmd_headers['X-User'] = username
|
||||||
api_cmd_headers['X-Tenant'] = username
|
if tenant:
|
||||||
|
api_cmd_headers['X-Tenant'] = tenant
|
||||||
if user_domain_name:
|
if user_domain_name:
|
||||||
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
api_cmd_headers['X-User-Domain-Name'] = user_domain_name
|
||||||
api_cmd_headers['X-Auth-Token'] = token_id
|
api_cmd_headers['X-Auth-Token'] = token_id
|
||||||
|
|
|
@ -211,6 +211,7 @@ def create_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
||||||
default_instance_action,
|
default_instance_action,
|
||||||
alarm_restrictions,
|
alarm_restrictions,
|
||||||
os_username, os_user_domain_name,
|
os_username, os_user_domain_name,
|
||||||
|
os_username,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
if not strategy:
|
if not strategy:
|
||||||
raise Exception("Strategy creation failed")
|
raise Exception("Strategy creation failed")
|
||||||
|
@ -235,7 +236,8 @@ def delete_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
||||||
|
|
||||||
success = sw_update.delete_strategy(token.get_id(), url,
|
success = sw_update.delete_strategy(token.get_id(), url,
|
||||||
strategy_name, force,
|
strategy_name, force,
|
||||||
os_username, os_user_domain_name)
|
os_username, os_user_domain_name,
|
||||||
|
os_username)
|
||||||
if success:
|
if success:
|
||||||
print("Strategy deleted")
|
print("Strategy deleted")
|
||||||
return
|
return
|
||||||
|
@ -260,7 +262,8 @@ def apply_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
||||||
|
|
||||||
strategy = sw_update.apply_strategy(token.get_id(), url,
|
strategy = sw_update.apply_strategy(token.get_id(), url,
|
||||||
strategy_name, stage_id,
|
strategy_name, stage_id,
|
||||||
os_username, os_user_domain_name)
|
os_username, os_user_domain_name,
|
||||||
|
os_username)
|
||||||
if not strategy:
|
if not strategy:
|
||||||
if stage_id is None:
|
if stage_id is None:
|
||||||
raise Exception("Strategy apply failed")
|
raise Exception("Strategy apply failed")
|
||||||
|
@ -287,7 +290,8 @@ def abort_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
||||||
|
|
||||||
strategy = sw_update.abort_strategy(token.get_id(), url,
|
strategy = sw_update.abort_strategy(token.get_id(), url,
|
||||||
strategy_name, stage_id,
|
strategy_name, stage_id,
|
||||||
os_username, os_user_domain_name)
|
os_username, os_user_domain_name,
|
||||||
|
os_username)
|
||||||
if not strategy:
|
if not strategy:
|
||||||
if stage_id is None:
|
if stage_id is None:
|
||||||
raise Exception("Strategy abort failed")
|
raise Exception("Strategy abort failed")
|
||||||
|
@ -313,7 +317,8 @@ def show_strategy(os_auth_uri, os_project_name, os_project_domain_name,
|
||||||
raise ValueError("NFV-VIM URL is invalid")
|
raise ValueError("NFV-VIM URL is invalid")
|
||||||
|
|
||||||
strategy = sw_update.get_strategies(token.get_id(), url, strategy_name,
|
strategy = sw_update.get_strategies(token.get_id(), url, strategy_name,
|
||||||
os_username, os_user_domain_name)
|
os_username, os_user_domain_name,
|
||||||
|
os_username)
|
||||||
if not strategy:
|
if not strategy:
|
||||||
print("No strategy available")
|
print("No strategy available")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue