diff options
-rw-r--r-- | aria/aria-rest-server/src/main/python/aria-rest/aria_rest/rest.py | 81 | ||||
-rw-r--r-- | aria/aria-rest-server/src/main/python/aria-rest/setup.py | 2 | ||||
-rw-r--r-- | docs/SO_R1_Interface.rst | 348 |
3 files changed, 415 insertions, 16 deletions
diff --git a/aria/aria-rest-server/src/main/python/aria-rest/aria_rest/rest.py b/aria/aria-rest-server/src/main/python/aria-rest/aria_rest/rest.py index fae6afcfe6..45fb4299d9 100644 --- a/aria/aria-rest-server/src/main/python/aria-rest/aria_rest/rest.py +++ b/aria/aria-rest-server/src/main/python/aria-rest/aria_rest/rest.py @@ -18,8 +18,7 @@ import os -from cStringIO import StringIO -from flask import Flask, render_template, request, jsonify +from flask import Flask, request, jsonify from flask_autodoc.autodoc import Autodoc from aria import install_aria_extensions from aria.parser import consumption @@ -34,6 +33,8 @@ from aria.utils import threading from aria.orchestrator.workflow_runner import WorkflowRunner from aria.orchestrator.workflows.executor.dry import DryExecutor import util +import tempfile +import shutil version_id = "0.1" route_base = "/api/" + version_id + "/" @@ -69,29 +70,75 @@ def index(): @aria.pass_logger def install_template(template_name, model_storage, resource_storage, plugin_manager, logger): + """ installs a template in Aria storage - """ - body = request.json - # Check body - if "service_template_path" in body: - service_template_path = body["service_template_path"] - else: - return "request body missing service_template_path", 501 + 3 modes possible: + + 1. PUT JSON body which points to a CSAR URL. Content-type must be + application/json. PUT data is a JSON object/map with the following + keys.: + * service_template_path (required): URL to CSAR + * service_template_filename (optional): service template file. + + 2. PUT with service template file body. Content-type must be + text/plain. + + 3. PUT with binary CSAR body. Content-type must be application/zip. + Optional query string arg "template_filename" can indicate the + service template filename in the CSAR. Defaults to + "service-template.yaml". + """ + + service_template_path = None + service_template_filename = "service-template.yaml" + + rtype = "unknown" + if request.is_json: + rtype = "json" + elif request.headers['Content-Type'] == "application/zip": + rtype = "zip" + suffix = ".csar" + elif request.headers['Content-Type'] == "text/plain": + rtype = "yaml" + suffix = ".yaml" + + if rtype == "zip" or rtype == "yaml": + with tempfile.NamedTemporaryFile(prefix = "ariatmp_", + suffix = suffix, + delete = False) as f: + f.write(request.data) + service_template_path = f.name + if request.headers['Content-Type'] == "application/zip": + if "template_filename" in request.args: + service_template_filename = request.args["template_filename"] + + elif rtype == "json": + + body = request.json + + # Check body + if "service_template_path" in body: + service_template_path = body["service_template_path"] + else: + return "request body missing service_template_path", 501 + + if "service_template_filename" in body: + service_template_filename = body["service_template_filename"] + else: + service_template_filename = "service-template.yaml" - if "service_template_filename" in body: - service_template_filename = body["service_template_filename"] else: - service_template_filename = "service-template.yaml" + return "Unrecognized content type",400 - service_template_path = service_template_utils.get( + service_template_file_path = service_template_utils.get( service_template_path, service_template_filename) core = Core(model_storage, resource_storage, plugin_manager) try: - core.create_service_template(service_template_path, + core.create_service_template(service_template_file_path, os.path.dirname(service_template_path), template_name) except storage_exceptions.StorageError as e: @@ -102,6 +149,12 @@ def install_template(template_name, model_storage, resource_storage, except Exception as e: logger.error("catchall exception") return e.message, 500 + finally: + # cleanup + if rtype == "zip" or rtype == "yaml": + os.remove(service_template_path) + if rtype == "zip": + shutil.rmtree(os.path.dirname(service_template_file_path)) return "service template installed", 200 diff --git a/aria/aria-rest-server/src/main/python/aria-rest/setup.py b/aria/aria-rest-server/src/main/python/aria-rest/setup.py index 4bb79cc1d9..81beb0f9a7 100644 --- a/aria/aria-rest-server/src/main/python/aria-rest/setup.py +++ b/aria/aria-rest-server/src/main/python/aria-rest/setup.py @@ -36,6 +36,6 @@ setup( install_requires=[ 'Flask==0.12.2', 'flask-autodoc==0.1.2', - 'apache-ariatosca==0.2.0' + 'apache-ariatosca==0.1.1' ] ) diff --git a/docs/SO_R1_Interface.rst b/docs/SO_R1_Interface.rst index 6ed8ebe583..ddac76b2f4 100644 --- a/docs/SO_R1_Interface.rst +++ b/docs/SO_R1_Interface.rst @@ -18,4 +18,350 @@ See :download:`UUI-SO_API_Specification_v0.1.docx` The interface between Multi VIM and SO:
-See :download:`SO_MultiCloud.xlsx`
\ No newline at end of file +See :download:`SO_MultiCloud.xlsx`
+
+SO APIs
+============
+
+UUI API
+----------------
+Create E2E service instance
+++++++++++++++++++++++++++++
+
++--------------------+-------------------------------------+
+|Interface Definition|Description |
++====================+=====================================+
+|URI |{serverRoot}/e2eServiceInstances/v3 |
++--------------------+-------------------------------------+
+|Operation Type |POST |
++--------------------+-------------------------------------+
+|Content-Type |multipart/form-data |
++--------------------+-------------------------------------+
+
+Request Body:
+
++---------+---------+-----------+--------------------------+-----------------------------+
+|Attribute|Qualifier|Cardinality|Content |Description |
++=========+=========+===========+==========================+=============================+
+|service |M |1 |Service Object |Content of service object. |
++---------+---------+-----------+--------------------------+-----------------------------+
+
+Service Object
+
++----------------+------------------+-------------------------------------------------+
+|Attribute |Content |Description |
++================+==================+=================================================+
+|name |String |Service instance name. |
++----------------+------------------+-------------------------------------------------+
+|description |String |Service instance description |
++----------------+------------------+-------------------------------------------------+
+|serviceDef ID |String |The service invariantUUID. It is defined in SDC. |
++----------------+------------------+-------------------------------------------------+
+|templateId |String |The service Template UUID. It is defined in SDC. |
++----------------+------------------+-------------------------------------------------+
+|parameters |Parameter Object |Parameter Object |
++----------------+------------------+-------------------------------------------------+
+
+Parameter Object
+
++----------------------+------------------+-----------------------------------------------------+
+|Attribute |Content |Description |
++======================+==================+=====================================================+
+|globalSubscriberId |String |The subscriber id. It is defined in AAI |
++----------------------+------------------+-----------------------------------------------------+
+|subscriberName |String |The subscriber name. It is defined in AAI |
++----------------------+------------------+-----------------------------------------------------+
+|serviceType |String |The service type. It is defined in AAI |
++----------------------+------------------+-----------------------------------------------------+
+|templateName |String |The service Template name |
++----------------------+------------------+-----------------------------------------------------+
+|resources |Parameter Object |This field manages parameters of resources |
++----------------------+------------------+-----------------------------------------------------+
+|resourceName |String |The resource name |
++----------------------+------------------+-----------------------------------------------------+
+|resouceDefId |String |The resource invariantUUID. It is defined in SDC. |
++----------------------+------------------+-----------------------------------------------------+
+|resourceId |String |The resource UUID. It is defined in SDC. |
++----------------------+------------------+-----------------------------------------------------+
+|nsParameters |String |Parameters for current resource object. |
++----------------------+------------------+-----------------------------------------------------+
+|locationConstraints |String |The DC location info for each VNF of current service |
++----------------------+------------------+-----------------------------------------------------+
+|vnfProfileId |String |VNFD id |
++----------------------+------------------+-----------------------------------------------------+
+|additionalParamForNs |String |The parameter for current resource |
++----------------------+------------------+-----------------------------------------------------+
+
+
+Response:
+
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+|serviceId |M |1 |String |Service instance ID. |
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operationId |M |1 |String |Service Operation ID. |
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+
+Delete E2E service instance
+++++++++++++++++++++++++++++
+
++--------------------+-----------------------------------------------+
+|Interface Definition|Description |
++====================+===============================================+
+|URI |{serverRoot}/e2eServiceInstances/v3/{serviceId}|
++--------------------+-----------------------------------------------+
+|Operation Type |DELETE |
++--------------------+-----------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+----------------------------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+========================================+
+|globalSubscriberId |M |1 |String |The subscriber id. It is defined in AAI |
++-------------------+---------+-----------+-------+----------------------------------------+
+|serviceType |M |1 |String |The service type. It is defined in AAI |
++-------------------+---------+-----------+-------+----------------------------------------+
+
+Response:
+
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operationId |M |1 |String |The operation id. |
++-------------+---------+-----------+-------+------------------------------------------------------------------------+
+
+Query E2E service operation result
+++++++++++++++++++++++++++
+
++--------------------+------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+========================================================================+
+|URI |{serverRoot}/e2eServiceInstances/v3/{serviceId}/operations/{operationId}|
++--------------------+------------------------------------------------------------------------+
+|Operation Type |GET |
++--------------------+------------------------------------------------------------------------+
+
+Request Parameters:
+
++--------------+---------+-----------+-------+--------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++==============+=========+===========+=======+==============+
+|serviceId |M |1 |Service instance ID. |
++--------------+---------+-----------+-------+--------------+
+|operationId |M |1 |Service Operation ID. |
++--------------+---------+-----------+-------+--------------+
+
+Response:
+
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operation |M |1 |String |Operation object identify. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operationId |M |1 |String |Operation ID. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operation |M |1 |String |Operation type, create|delete. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|result |M |1 |String |Operation result: finished, error, processing. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|reason |M |1 |String |If failing, need to write fail reason. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|userId |M |1 |String |Operation user ID. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operationContent |M |1 |String |The status detail of current operation which is being executing. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|progress |M |1 |String |Current operation progress. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|operateAt |M |1 |String |Time that it starts to execute operation. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+|finishedAt |M |1 |String |Time that it finished executing operation. |
++------------------+---------+-----------+-------+------------------------------------------------------------------------+
+
+AAI API
+----------------
+
+create or update an existing service-instance
++++++++++++++++++++++++++++++++++++++++++++++
+
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+====================================================================================================================================================================+
+|URI |/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}|
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Operation Type |PUT |
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+-----------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+=======================+
+|global-customer-id |M |1 |String |Global Customer ID |
++-------------------+---------+-----------+-------+-----------------------+
+|service-type |M |1 |String |Service Type |
++-------------------+---------+-----------+-------+-----------------------+
+|service-instance-id|M |1 |String |Service Instance ID |
++-------------------+---------+-----------+-------+-----------------------+
+
+Response:
+
++---------+---------+-----------+-------+-------------------+
+|Attribute|Qualifier|Cardinality|Content|Description |
++---------+---------+-----------+-------+-------------------+
+|HTTP code|M |1 |Integer|HTTP response code |
++---------+---------+-----------+-------+-------------------+
+
+delete an existing service-instance
++++++++++++++++++++++++++++++++++++
+
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+====================================================================================================================================================================+
+|URI |/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}|
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Operation Type |DELETE |
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+-----------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+=======================+
+|global-customer-id |M |1 |String |Global Customer ID |
++-------------------+---------+-----------+-------+-----------------------+
+|service-type |M |1 |String |Service Type |
++-------------------+---------+-----------+-------+-----------------------+
+|service-instance-id|M |1 |String |Service Instance ID |
++-------------------+---------+-----------+-------+-----------------------+
+
+Response:
+
++---------+---------+-----------+-------+-------------------+
+|Attribute|Qualifier|Cardinality|Content|Description |
++---------+---------+-----------+-------+-------------------+
+|HTTP code|M |1 |Integer|HTTP response code |
++---------+---------+-----------+-------+-------------------+
+
+get service-instances
++++++++++++++++++++++
+
++--------------------+-----------------------------------------------------------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+=============================================================================================================================+
+|URI |/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances|
++--------------------+-----------------------------------------------------------------------------------------------------------------------------+
+|Operation Type |GET |
++--------------------+-----------------------------------------------------------------------------------------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+-----------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+=======================+
+|global-customer-id |M |1 |String |Global Customer ID |
++-------------------+---------+-----------+-------+-----------------------+
+|service-type |M |1 |String |Service Type |
++-------------------+---------+-----------+-------+-----------------------+
+
+Response:
+
++-----------------+---------+-----------+----------------+-------------------+
+|Attribute |Qualifier|Cardinality|Content |Description |
++-----------------+---------+-----------+----------------+-------------------+
+|service-instances|M |1 |ServiceInstances|Service Instances |
++-----------------+---------+-----------+----------------+-------------------+
+
+get service-instance
+++++++++++++++++++++
+
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+====================================================================================================================================================================+
+|URI |/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}|
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Operation Type |GET |
++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+-----------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+=======================+
+|global-customer-id |M |1 |String |Global Customer ID |
++-------------------+---------+-----------+-------+-----------------------+
+|service-type |M |1 |String |Service Type |
++-------------------+---------+-----------+-------+-----------------------+
+|service-instance-id|M |1 |String |Service instance ID |
++-------------------+---------+-----------+-------+-----------------------+
+
+Response:
+
++-----------------+---------+-----------+----------------+-------------------+
+|Attribute |Qualifier|Cardinality|Content |Description |
++-----------------+---------+-----------+----------------+-------------------+
+|service-instance |M |1 |ServiceInstance |Service Instance |
++-----------------+---------+-----------+----------------+-------------------+
+
+see node definition for valid relationships
++++++++++++++++++++++++++++++++++++++++++++
+
++--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+===================================================================================================================================================================================================+
+|URI |/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}/relationship-list/relationship|
++--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Operation Type |PUT |
++--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+-----------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+=======================+
+|global-customer-id |M |1 |String |Global Customer ID |
++-------------------+---------+-----------+-------+-----------------------+
+|service-type |M |1 |String |Service Type |
++-------------------+---------+-----------+-------+-----------------------+
+|service-instance-id|M |1 |String |Service instance ID |
++-------------------+---------+-----------+-------+-----------------------+
+
+Response:
+
++---------+---------+-----------+-------+-------------------+
+|Attribute|Qualifier|Cardinality|Content|Description |
++---------+---------+-----------+-------+-------------------+
+|HTTP code|M |1 |Integer|HTTP response code |
++---------+---------+-----------+-------+-------------------+
+
+delete an existing relationship
++++++++++++++++++++++++++++++++
+
++--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Interface Definition|Description |
++====================+===================================================================================================================================================================================================+
+|URI |/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}/relationship-list/relationship|
++--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|Operation Type |DELETE |
++--------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+Request Parameters:
+
++-------------------+---------+-----------+-------+-----------------------+
+|Attribute |Qualifier|Cardinality|Content|Description |
++===================+=========+===========+=======+=======================+
+|global-customer-id |M |1 |String |Global Customer ID |
++-------------------+---------+-----------+-------+-----------------------+
+|service-type |M |1 |String |Service Type |
++-------------------+---------+-----------+-------+-----------------------+
+|service-instance-id|M |1 |String |Service instance ID |
++-------------------+---------+-----------+-------+-----------------------+
+
+Response:
+
++---------+---------+-----------+-------+-------------------+
+|Attribute|Qualifier|Cardinality|Content|Description |
++---------+---------+-----------+-------+-------------------+
+|HTTP code|M |1 |Integer|HTTP response code |
++---------+---------+-----------+-------+-------------------+
\ No newline at end of file |