Handle region_name in openstack actions

User now could define the region for the openstack actions.
It could be done via API in X-Region-Name and X-Target-Region-Name
in case of multi-vim feature is used.

*API change*
X-Region-Name: Header added to execution create
X-Target-Region-Name: Header added to execution create

Change-Id: Icbf63962a481c1282b95359894fa6245e0e97bac
Related-Bug: #1633345
This commit is contained in:
Istvan Imre 2016-10-20 14:59:58 +02:00
parent 09b0f87a6a
commit 603cd4808c
3 changed files with 20 additions and 8 deletions

View File

@ -77,6 +77,7 @@ class MistralContext(BaseContext):
"auth_token",
"service_catalog",
"user_name",
"region_name",
"project_name",
"roles",
"is_admin",
@ -113,6 +114,7 @@ def context_from_headers_and_env(headers, env):
auth_token = params['auth_token']
auth_uri = params['auth_uri']
project_id = params['project_id']
region_name = params['region_name']
user_id = params['user_id']
user_name = params['user_name']
is_target = params['is_target']
@ -131,6 +133,7 @@ def context_from_headers_and_env(headers, env):
is_target=is_target,
service_catalog=service_catalog,
user_name=user_name,
region_name=region_name,
project_name=headers.get('X-Project-Name'),
roles=headers.get('X-Roles', "").split(","),
is_trust_scoped=False,
@ -150,6 +153,7 @@ def _extract_auth_params_from_headers(headers):
'project_id': headers.get('X-Target-Project-Id'),
'user_id': headers.get('X-Target-User-Id'),
'user_name': headers.get('X-Target-User-Name'),
'region_name': headers.get('X-Target-Region-Name'),
'is_target': True
}
if not params['auth_token']:
@ -171,6 +175,7 @@ def _extract_auth_params_from_headers(headers):
'project_id': headers.get('X-Project-Id'),
'user_id': headers.get('X-User-Id'),
'user_name': headers.get('X-User-Name'),
'region_name': headers.get('X-Region-Name'),
'is_target': False
}

View File

@ -70,7 +70,7 @@ def client_for_trusts(trust_id):
def get_endpoint_for_project(service_name=None, service_type=None):
if service_name is None and service_type is None:
raise Exception(
raise exceptions.MistralException(
"Either 'service_name' or 'service_type' must be provided."
)
@ -80,7 +80,8 @@ def get_endpoint_for_project(service_name=None, service_type=None):
service_endpoints = service_catalog.get_endpoints(
service_name=service_name,
service_type=service_type
service_type=service_type,
region_name=ctx.region_name
)
endpoint = None
@ -110,14 +111,12 @@ def get_endpoint_for_project(service_name=None, service_type=None):
break
if not endpoint:
raise Exception(
"No endpoints found [service_name=%s, service_type=%s]"
% (service_name, service_type)
raise exceptions.MistralException(
"No endpoints found [service_name=%s, service_type=%s,"
" region_name=%s]"
% (service_name, service_type, ctx.region_name)
)
else:
# TODO(rakhmerov): We may have more than one endpoint because
# TODO(rakhmerov): of regions and ideally we need a config option
# TODO(rakhmerov): for region
return endpoint

View File

@ -0,0 +1,8 @@
---
fixes:
- |
[`bug 1633345 <https://bugs.launchpad.net/mistral/+bug/1633345>`_]
User now could define the target region for the openstack actions.
It could be done via API in X-Region-Name and X-Target-Region-Name
in case of multi-vim feature is used.