diff --git a/orchestration/api/instances.py b/orchestration/api/instances.py index c8073dc..a2b4564 100644 --- a/orchestration/api/instances.py +++ b/orchestration/api/instances.py @@ -43,6 +43,13 @@ def instance_ops(tenant_id=''): c = Connector().morph() content = request.get_json() + AUTH_TOKEN = request.headers.get('X-Auth-Token') + + # TODO: Need to check, When orchestration APIs authentication + # is implemented + if AUTH_TOKEN == '' or AUTH_TOKEN is None: + err_msg = 'Bad Request. Authentication Token is missing' + return jsonify(err_msg), Apiconstants.HTTP_ERR_BAD_REQUEST if tenant_id == '': err_msg = 'bad URL. tenant id is empty' @@ -91,6 +98,7 @@ def instance_ops(tenant_id=''): logger.info("no user_id provided. Exception [%s]", str(e)) content['parameters']['tenant_id'] = tenant_id + content['parameters']['auth_token'] = AUTH_TOKEN try: rc, ret = c.execute_action(content) if(rc != Apiconstants.HTTP_CREATED): @@ -120,6 +128,7 @@ def instance_ops(tenant_id=''): service_map['created_at'] = service_obj['created_at'] service_map['updated_at'] = service_obj['updated_at'] service_map['input'] = ret_json['parameters'] + del service_map['input']['auth_token'] wf_hash = {} wf_hash['id'] = ret_json['id'] @@ -250,6 +259,8 @@ def wf_ops(tenant_id='', instance_id=''): status, output = _update_status_and_output(service['id']) service['status'] = status service['output'] = output + service['service_id'] = service['service_definition_id'] + del service['service_definition_id'] else: try: ret = get_service(None, instance_id) @@ -261,6 +272,8 @@ def wf_ops(tenant_id='', instance_id=''): status, output = _update_status_and_output(instance_id) ret['status'] = status ret['output'] = output + ret['service_id'] = ret['service_definition_id'] + del ret['service_definition_id'] logger.debug("returning list of workflows: %s" % (ret)) return jsonify(ret), 200 diff --git a/orchestration/api/services.py b/orchestration/api/services.py index a8ad134..3126c1f 100644 --- a/orchestration/api/services.py +++ b/orchestration/api/services.py @@ -77,6 +77,7 @@ def get_services(tenant_id='', service_id=''): def add_services(tenant_id=''): payload = request.get_json() service_data = json.loads(json.dumps(payload)) + service_data['tenant_id'] = tenant_id wf_def_sources = service_data['workflows'] # Validate the request sent diff --git a/tests/unit/api/test_instances.py b/tests/unit/api/test_instances.py index f5ae84b..66c896c 100644 --- a/tests/unit/api/test_instances.py +++ b/tests/unit/api/test_instances.py @@ -18,7 +18,8 @@ def test_post_instance(client): type_mime = 'application/json' - header = {'Content-Type': type_mime, 'Accept': type_mime} + header = {'Content-Type': type_mime, 'Accept': type_mime, + 'X-Auth-Token': 'abcde'} data = { "service_id": "26ab0773-fc5a-4211-a8e9-8e61ff16fa42", "action": "opensds.migration-bucket", @@ -32,8 +33,7 @@ def test_post_instance(client): "description": "Migration_test_orchestration", "destBackend": "hw-backend", "srcBucketName": "aws-orchestrate", - "destBucketName": "hw-orchestrate", - "auth_token": "abcde" + "destBucketName": "hw-orchestrate" } } url = '/v1beta/xyz/orchestration/instances'