diff options
-rw-r--r-- | config/common_config.yaml | 2 | ||||
-rwxr-xr-x | config/osdf_config.yaml | 54 | ||||
-rw-r--r-- | docker/Dockerfile | 2 | ||||
-rw-r--r-- | osdf/optimizers/placementopt/conductor/conductor.py | 8 | ||||
-rw-r--r-- | osdf/optimizers/placementopt/conductor/remote_opt_processor.py | 4 | ||||
-rwxr-xr-x | osdf/templates/plc_opt_response.jsont | 2 | ||||
-rwxr-xr-x | osdfapp.py | 9 | ||||
-rw-r--r-- | test/placement-tests/request_placement.json | 82 | ||||
-rw-r--r-- | test/test_process_placement_opt.py | 15 |
9 files changed, 142 insertions, 36 deletions
diff --git a/config/common_config.yaml b/config/common_config.yaml index 67fd8be..5790042 100644 --- a/config/common_config.yaml +++ b/config/common_config.yaml @@ -5,7 +5,7 @@ osdf_system: external: 8698 # clients use this port on DockerHost osdf_ip_default: 0.0.0.0 # # Important Note: At deployment time, we need to ensure the port mapping is done -# ssl_context: ['./../etc/sniromanager.crt', './../etc/sniromanager.key'] +# ssl_context: ['./../etc/osdf_aaf.crt', './../etc/osdf_aaf.key'] osdf_temp: # special configuration required for "workarounds" or testing local_policies: diff --git a/config/osdf_config.yaml b/config/osdf_config.yaml index 69ebdf0..1a20d3c 100755 --- a/config/osdf_config.yaml +++ b/config/osdf_config.yaml @@ -1,34 +1,42 @@ -osdfUserNameForSO: "" # The OSDF Manager username for MSO. -odfPasswordForSO: "" # The OSDF Manager password for MSO. - -# msoUrl: "" # The SO url for call back. This will be part of the request, so no need +# Credentials for SO soUsername: "" # SO username for call back. soPassword: "" # SO password for call back. -conductorUrl: "https://OOF-HAS-CONDUCTOR-HOST:8091" -conductorUsername: "CONDUCTOR-USER" -conductorPassword: "CONDUCTOR-PASSWD" +# Credentials for Conductor +conductorUrl: https://localhost:8091/v1/plans/ +conductorUsername: admin1 +conductorPassword: plan.15 conductorPingWaitTime: 60 # seconds to wait before calling the conductor retry URL conductorMaxRetries: 30 # if we don't get something in 30 minutes, give up # Policy Platform -- requires ClientAuth, Authorization, and Environment -policyPlatformUrl: https://POLICY-URL:8081/pdp/getConfig # Policy Dev platform URL +policyPlatformUrl: http://onap-pdp:8081/pdp/api/getConfig # Policy Dev platform URL policyPlatformEnv: TEST # Environment for policy platform -policyPlatformUsername: POLICY-USER # Policy platform username. -policyPlatformPassword: POLICY-PASSWD # Policy platform password. -policyClientUsername: POLICY-CLIENT-USER # For use with ClientAuth -policyClientPassword: POLICY-CLIENT-PASSWD # For use with ClientAuth +policyPlatformUsername: testpdp # Policy platform username. +policyPlatformPassword: alpha123 # Policy platform password. +policyClientUsername: python # For use with ClientAuth +policyClientPassword: test # For use with ClientAuth + +# Credentials for DMaaP +messageReaderHosts: NA +messageReaderTopic: NA +messageReaderAafUserId: NA +messageReaderAafPassword: NA + +# Credentials for SDC +sdcUrl: NA +sdcUsername: NA +sdcPassword: NA +sdcONAPInstanceID: NA -messageReaderHosts: https://DMAAP-HOST1:3905,https://DMAAP-HOST2:3905,https://DMAAP-HOST3:3905 -messageReaderTopic: org.onap.oof.osdf.multicloud -messageReaderAafUserId: DMAAP-OSDF-MC-USER -messageReaderAafPassword: DMAAP-OSDF-MC-PASSWD +# Credentials for the OOF placement service - Generic +osdfPlacementUsername: test +osdfPlacementPassword: testpwd -sdcUrl: https://SDC-HOST:8443/sdc/v1/catalog -sdcUsername: SDC-OSDF-USER -sdcPassword: SDC-OSDF-PASSWD -sdcONAPInstanceID: ONAP-OSDF +# Credentials for the OOF placement service - SO +osdfPlacementSOUsername: so_test +osdfPlacementSOPassword: so_testpwd -osdfPlacementUrl: "http://127.0.0.1:24699/osdf/api/v2/placement" -osdfPlacementUsername: "test" -osdfPlacementPassword: "testpwd" +# Credentials for the OOF CM scheduling service - Generic +osdfCMSchedulerUsername: test1 +osdfCMSchedulerPassword: testpwd1
\ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 6c73196..7a38ad8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -34,6 +34,8 @@ RUN apt-get update -y \ && easy_install3 pip \ && pip install --upgrade virtualenv pip wheel +RUN ln -s /usr/bin/python3.5 /usr/bin/python + # Minizinc RUN wget -q $MZN_DL_URL -O mz.tgz \ && tar xzf mz.tgz \ diff --git a/osdf/optimizers/placementopt/conductor/conductor.py b/osdf/optimizers/placementopt/conductor/conductor.py index 663857b..49e7bfc 100644 --- a/osdf/optimizers/placementopt/conductor/conductor.py +++ b/osdf/optimizers/placementopt/conductor/conductor.py @@ -135,7 +135,7 @@ def conductor_response_processor(conductor_response, raw_response, req_id): solution = { 'resourceModuleName': resource, 'serviceResourceId': reco[resource].get('service_resource_id', ""), - 'solution': {"identifier": c['inventory_type'], + 'solution': {"identifier": name_map.get(c['inventory_type'], c['inventory_type']), 'identifiers': [c['candidate_id']], 'cloudOwner': c.get('cloud_owner', "")}, 'assignmentInfo': [] @@ -154,7 +154,7 @@ def conductor_response_processor(conductor_response, raw_response, req_id): debug_log.debug("The key[{}] is not mapped and will not be returned in assignment info".format(key)) composite_solutions.append(solution) - request_state = conductor_response['plans'][0]['status'] + request_status = conductor_response['plans'][0]['status'] transaction_id = raw_response.headers.get('transaction_id', "") status_message = conductor_response.get('plans')[0].get('message', "") @@ -166,7 +166,7 @@ def conductor_response_processor(conductor_response, raw_response, req_id): resp = { "transactionId": transaction_id, "requestId": req_id, - "requestState": request_state, + "requestStatus": request_status, "statusMessage": status_message, "solutions": solution_info } @@ -188,6 +188,6 @@ def conductor_no_solution_processor(conductor_response, raw_response, request_id templ = Template(open(template_placement_response).read()) return json.loads(templ.render(composite_solutions=[], requestId=request_id, license_solutions=[], transactionId=raw_response.headers.get('transaction_id', ""), - requestState="completed", statusMessage=status_message, json=json)) + requestStatus="completed", statusMessage=status_message, json=json)) 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/osdf/templates/plc_opt_response.jsont b/osdf/templates/plc_opt_response.jsont index 2bd9f71..e5709e7 100755 --- a/osdf/templates/plc_opt_response.jsont +++ b/osdf/templates/plc_opt_response.jsont @@ -1,7 +1,7 @@ { "requestId": "{{requestId}}", "transactionId": "{{transacationId}}", - "requestState": "{{requestState}}", + "requestStatus": "{{requestStatus}}", "statusMessage": "{{statusMessage}}" "solutions": { "placementSolutions": {{ json.dumps(composite_solutions) }}, @@ -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() |