summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdf/optimizers/placementopt/conductor/remote_opt_processor.py4
-rwxr-xr-xosdfapp.py9
-rw-r--r--test/placement-tests/request_placement.json82
-rw-r--r--test/test_process_placement_opt.py15
4 files changed, 103 insertions, 7 deletions
diff --git a/osdf/optimizers/placementopt/conductor/remote_opt_processor.py b/osdf/optimizers/placementopt/conductor/remote_opt_processor.py
index 3e89205..614eca3 100644
--- a/osdf/optimizers/placementopt/conductor/remote_opt_processor.py
+++ b/osdf/optimizers/placementopt/conductor/remote_opt_processor.py
@@ -47,7 +47,7 @@ def process_placement_opt(request_json, policies, osdf_config):
license_info = license_optim(request_json)
# Conductor only handles placement, only call Conductor if placementDemands exist
- if request_json.get('licenseInfo', {}).get('licenseDemands'):
+ if request_json.get('placementInfo', {}).get('placementDemands'):
metrics_log.info(MH.requesting("placement/conductor", req_id))
placement_response = conductor.request(request_json, osdf_config, policies)
if license_info: # Attach license solution if it exists
@@ -56,7 +56,7 @@ def process_placement_opt(request_json, policies, osdf_config):
placement_response = {
"transactionId": transaction_id,
"requestId": req_id,
- "requestState": "complete",
+ "requestStatus": "completed",
"statusMessage": "License selection completed successfully",
"solutionInfo": {"licenseInfo": license_info}
}
diff --git a/osdfapp.py b/osdfapp.py
index 62062fc..09a89b0 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -45,6 +45,7 @@ from requests import RequestException
from schematics.exceptions import DataError
from osdf.logging.osdf_logging import MH, audit_log, error_log, debug_log
from osdf.models.api.placementRequest import PlacementAPI
+from osdf.operation.responses import osdf_response_for_request_accept as req_accept
ERROR_TEMPLATE = osdf.ERROR_TEMPLATE
@@ -116,11 +117,9 @@ def do_placement_opt():
t = Thread(target=process_placement_opt, args=(request_json, policies, osdf_config))
t.start()
audit_log.info(MH.accepted_valid_request(req_id, request))
- return osdf.operation.responses.osdf_response_for_request_accept(request_id=req_id,
- transaction_id=request_json['transactionId'],
- request_status="accepted",
- status_message="")
-
+ return req_accept(request_id=req_id,
+ transaction_id=request_json['requestInfo']['transactionId'],
+ request_status="accepted", status_message="")
@app.errorhandler(500)
def internal_failure(error):
diff --git a/test/placement-tests/request_placement.json b/test/placement-tests/request_placement.json
new file mode 100644
index 0000000..ca92911
--- /dev/null
+++ b/test/placement-tests/request_placement.json
@@ -0,0 +1,82 @@
+{
+ "requestInfo": {
+ "transactionId": "xxx-xxx-xxxx",
+ "requestId": "yyy-yyy-yyyy",
+ "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/",
+ "sourceId": "SO",
+ "requestType": "create",
+ "numSolutions": 1,
+ "optimizers": ["placement"],
+ "timeout": 600
+ },
+ "placementInfo": {
+ "requestParameters": { "customerLatitude": 32.89748, "customerLongitude": -97.040443, "customerName": "xyz" },
+ "subscriberInfo": {"globalSubscriberId": "xxx-xx-xxx", "subscriberName": "subscriber_x"},
+ "placementDemands": [
+ {
+ "resourceModuleName": "vGMuxInfra",
+ "serviceResourceId": "vGMuxInfra-xx",
+ "tenantId": "vGMuxInfra-tenant",
+ "resourceModelInfo": {
+ "modelInvariantId": "vGMuxInfra-modelInvariantId",
+ "modelVersionId": "vGMuxInfra-versionId",
+ "modelName": "vGMuxInfra-model",
+ "modelType": "resource",
+ "modelVersion": "1.0",
+ "modelCustomizationName": "vGMuxInfra-customeModelName"
+ }
+ },
+ {
+ "resourceModuleName": "vG",
+ "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e",
+ "tenantId": "vG-tenant",
+ "resourceModelInfo": {
+ "modelInvariantId": "vG-modelInvariantId",
+ "modelVersionId": "vG-versionId",
+ "modelName": "vG-model",
+ "modelType": "resource",
+ "modelVersion": "1.0",
+ "modelCustomizationName": "vG-customeModelName"
+ },
+ "existingCandidates": [
+ {
+ "identifierType": "serviceInstanceId",
+ "cloudOwner": "",
+ "identifiers": ["gjhd-098-fhd-987"]
+ }
+ ],
+ "excludedCandidates": [
+ {
+ "identifierType": "serviceInstanceId",
+ "cloudOwner": "",
+ "identifiers": ["gjhd-098-fhd-987"]
+ },
+ {
+ "identifierType": "vimId",
+ "cloudOwner": "vmware",
+ "identifiers": ["NYMDT67"]
+ }
+ ],
+ "requiredCandidates": [
+ {
+ "identifierType": "vimId",
+ "cloudOwner": "amazon",
+ "identifiers": ["TXAUS219"]
+ }
+ ]
+ }
+ ]
+ },
+ "serviceInfo": {
+ "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec",
+ "serviceName": "vCPE",
+ "modelInfo": {
+ "modelInvariantId": "vCPE-invariantId",
+ "modelVersionId": "vCPE-versionId",
+ "modelName": "vCPE-model",
+ "modelType": "service",
+ "modelVersion": "1.0",
+ "modelCustomizationName": "vCPE-customeModelName"
+ }
+ }
+} \ No newline at end of file
diff --git a/test/test_process_placement_opt.py b/test/test_process_placement_opt.py
index e5dc65e..3219675 100644
--- a/test/test_process_placement_opt.py
+++ b/test/test_process_placement_opt.py
@@ -62,6 +62,21 @@ class TestProcessPlacementOpt(unittest.TestCase):
templ_string = process_placement_opt(request_json, policies, local_config)
+ def test_process_placement_opt_placementDemand(self):
+ main_dir = ""
+ parameter_data_file = main_dir + "test/placement-tests/request_placement.json"
+ policy_data_path = main_dir + "test/policy-local-files/"
+ local_config_file = main_dir + "config/common_config.yaml"
+
+ valid_policies_list_file = policy_data_path + '/' + 'meta-valid-policies.txt'
+ valid_policies_files = local_policies.get_policy_names_from_file(valid_policies_list_file)
+
+ request_json = json_from_file(parameter_data_file)
+ policies = [json_from_file(policy_data_path + '/' + name) for name in valid_policies_files]
+ local_config = yaml_from_file(local_config_file)
+ templ_string = process_placement_opt(request_json, policies, local_config)
+
+
if __name__ == "__main__":
unittest.main()