From 2d59800cf61a90e2a80902186bdce3b28e5ae14d Mon Sep 17 00:00:00 2001 From: vrvarma Date: Wed, 3 Apr 2019 14:15:29 -0400 Subject: Initial model changes and api changes for pci-opt PCI-OPT model changes for ANR optimization PCI-OPT swagger document changes for pci/anr optimization Change-Id: I2eb9447db7b3b73bc6cfd9b3e0aba7fed0aaabd6 Signed-off-by: vrvarma Issue-ID: OPTFRA-416 --- docs/sections/swaggerdoc/oof-osdf-has-api.json | 1309 +++++++++++++++--------- osdf/models/api/pciOptimizationRequest.py | 6 + osdf/models/api/pciOptimizationResponse.py | 6 + osdf/optimizers/pciopt/solver/optimizer.py | 6 +- osdfapp.py | 34 +- 5 files changed, 842 insertions(+), 519 deletions(-) diff --git a/docs/sections/swaggerdoc/oof-osdf-has-api.json b/docs/sections/swaggerdoc/oof-osdf-has-api.json index 2fe2b97..16e9ab1 100644 --- a/docs/sections/swaggerdoc/oof-osdf-has-api.json +++ b/docs/sections/swaggerdoc/oof-osdf-has-api.json @@ -1,587 +1,902 @@ { - "swagger" : "2.0", - "info" : { - "description" : "This is the ONAP OOF OSDF (Optimization Service Design Framework) API", - "version" : "1.0.0", - "title" : "OSDF API", - "contact" : { - "email" : "frank.sandoval@oamtechnologies.com" + "swagger": "2.0", + "info": { + "description": "This is the ONAP OOF OSDF (Optimization Service Design Framework) API", + "version": "1.0.0", + "title": "OSDF API", + "contact": { + "email": "frank.sandoval@oamtechnologies.com" }, - "license" : { - "name" : "Apache 2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, - "securityDefinitions" : { - "basicAuth" : { - "type" : "basic", - "description" : "HTTP Basic Auth" + "securityDefinitions": { + "basicAuth": { + "type": "basic", + "description": "HTTP Basic Auth" } }, - "security" : [ { - "basicAuth" : [ ] - } ], - "paths" : { - "/v2/placement" : { - "post" : { - "summary" : "create/update a placement", - "operationId" : "createPlacement", - "description" : "create/update a placement", - "consumes" : [ "application/json" ], - "produces" : [ "application/json" ], - "parameters" : [ { - "in" : "body", - "name" : "placementRequest", - "description" : "placement request", - "schema" : { - "$ref" : "#/definitions/PlacementRequest" + "security": [ + { + "basicAuth": [] + } + ], + "paths": { + "/v2/placement": { + "post": { + "summary": "create/update a placement", + "operationId": "createPlacement", + "description": "create/update a placement", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "placementRequest", + "description": "placement request", + "schema": { + "$ref": "#/definitions/PlacementRequest" + } + } + ], + "responses": { + "201": { + "description": "An optimization solution is found." + }, + "202": { + "description": "An optimization request is accepted" + }, + "400": { + "description": "bad request" + }, + "401": { + "description": "Request body is not compliant with the API definition" + }, + "404": { + "description": "The server cannot find the requested URI" + }, + "405": { + "description": "The requested method is not supported by a server." + }, + "500": { + "description": "The server encountered an internal server error or timed out" + } + } + } + }, + "/api/oof/placement/v1": { + "$ref": "#/paths/~1v2~1placement" + }, + "/api/oof/v1/pci": { + "post": { + "summary": "Initiate PCI/ANR Optimization", + "operationId": "initiatePCIOptRequest", + "description": "Initiate PCI/ANR Optimization", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "PCIOptimizationRequest", + "description": "PCI request", + "schema": { + "$ref": "#/definitions/PCIOptRequest" + } } - } ], - "responses" : { - "201" : { - "description" : "An optimization solution is found." + ], + "responses": { + "201": { + "description": "An optimization solution is found." }, - "202" : { - "description" : "An optimization request is accepted" + "202": { + "description": "An optimization request is accepted" }, - "400" : { - "description" : "bad request" + "400": { + "description": "bad request" }, - "401" : { - "description" : "Request body is not compliant with the API definition" + "401": { + "description": "Request body is not compliant with the API definition" }, - "404" : { - "description" : "The server cannot find the requested URI" + "404": { + "description": "The server cannot find the requested URI" }, - "405" : { - "description" : "The requested method is not supported by a server." + "405": { + "description": "The requested method is not supported by a server." }, - "500" : { - "description" : "The server encountered an internal server error or timed out" + "500": { + "description": "The server encountered an internal server error or timed out" } } } + }, + "/api/oof/pci/v1": { + "$ref": "#/paths/~1api~1oof~1v1~1pci" } }, - "definitions" : { - "PlacementRequest" : { - "type" : "object", - "required" : [ "requestInfo", "placementInfo", "licenseInfo", "serviceInfo" ], - "properties" : { - "requestInfo" : { - "$ref" : "#/definitions/RequestInfo" - }, - "placementInfo" : { - "$ref" : "#/definitions/PlacementInfo" - }, - "licenseInfo" : { - "$ref" : "#/definitions/LicenseInfo" - }, - "serviceInfo" : { - "$ref" : "#/definitions/ServiceInfo" + "definitions": { + "PlacementRequest": { + "type": "object", + "required": [ + "requestInfo", + "placementInfo", + "licenseInfo", + "serviceInfo" + ], + "properties": { + "requestInfo": { + "$ref": "#/definitions/RequestInfo" + }, + "placementInfo": { + "$ref": "#/definitions/PlacementInfo" + }, + "licenseInfo": { + "$ref": "#/definitions/LicenseInfo" + }, + "serviceInfo": { + "$ref": "#/definitions/ServiceInfo" } } }, - "RequestInfo" : { - "type" : "object", - "required" : [ "transactionId", "requestId", "callbackUrl", "sourceId", "requestType", "optimizers", "timeout" ], - "properties" : { - "transactionId" : { - "type" : "string", - "format" : "uuid", - "description" : "unique ID to track an ONAP transaction", - "example" : "d290f1ee-6c54-4b01-90e6-d701748f0851" - }, - "requestId" : { - "type" : "string", - "format" : "uuid", - "description" : "A unique ID to track multiple requests associated with a transaction", - "example" : "d290f1ee-6c54-4b01-90e6-d701748f0851" - }, - "callbackUrl" : { - "type" : "string", - "format" : "url", - "description" : "The end point of a callback service where recommendations are posted.", - "example" : "myDomain.com/myCallback" - }, - "callbackHeader" : { - "type" : "string", - "description" : "JSON blob. The header information a client expecting in a async callback.", - "example" : { - "blob" : "content" + "RequestInfo": { + "type": "object", + "required": [ + "transactionId", + "requestId", + "callbackUrl", + "sourceId", + "requestType", + "optimizers", + "timeout" + ], + "properties": { + "transactionId": { + "type": "string", + "format": "uuid", + "description": "unique ID to track an ONAP transaction", + "example": "d290f1ee-6c54-4b01-90e6-d701748f0851" + }, + "requestId": { + "type": "string", + "format": "uuid", + "description": "A unique ID to track multiple requests associated with a transaction", + "example": "d290f1ee-6c54-4b01-90e6-d701748f0851" + }, + "callbackUrl": { + "type": "string", + "format": "url", + "description": "The end point of a callback service where recommendations are posted.", + "example": "myDomain.com/myCallback" + }, + "callbackHeader": { + "type": "string", + "description": "JSON blob. The header information a client expecting in a async callback.", + "example": { + "blob": "content" } }, - "sourceId" : { - "type" : "string", - "description" : "The unique ID of a client making an optimization call.", - "example" : "d290f1ee-6c54-4b01-90e6-d701748f0851" - }, - "requestType" : { - "type" : "string", - "enum" : [ "create", "update", "delete" ], - "description" : "The type of a request", - "example" : "create" - }, - "numSolutions" : { - "type" : "integer", - "description" : "Expected number of solutions.", - "example" : 1 - }, - "optimizers" : { - "type" : "array", - "items" : { - "type" : "string", - "enum" : [ "placement" ] - }, - "description" : "A list of optimization services.", - "example" : "placement" - }, - "timeout" : { - "type" : "integer", - "description" : "A tolerance window (in second) for expecting solutions.", - "example" : 5 + "sourceId": { + "type": "string", + "description": "The unique ID of a client making an optimization call.", + "example": "d290f1ee-6c54-4b01-90e6-d701748f0851" + }, + "requestType": { + "type": "string", + "enum": [ + "create", + "update", + "delete" + ], + "description": "The type of a request", + "example": "create" + }, + "numSolutions": { + "type": "integer", + "description": "Expected number of solutions.", + "example": 1 + }, + "optimizers": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "placement", + "pci", + "pci-anr" + ] + }, + "description": "A list of optimization services.", + "example": [ + "placement" + ] + }, + "timeout": { + "type": "integer", + "description": "A tolerance window (in second) for expecting solutions.", + "example": 5 } } }, - "PlacementInfo" : { - "type" : "object", - "required" : [ "requestParameters", "placementDemands" ], - "properties" : { - "requestParameters" : { - "type" : "string", - "description" : "JSON blob. A service ordering information", - "example" : { - "blob" : "content" + "PlacementInfo": { + "type": "object", + "required": [ + "requestParameters", + "placementDemands" + ], + "properties": { + "requestParameters": { + "type": "string", + "description": "JSON blob. A service ordering information", + "example": { + "blob": "content" } }, - "placementDemands" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/PlacementDemand" + "placementDemands": { + "type": "array", + "items": { + "$ref": "#/definitions/PlacementDemand" }, - "description" : "The resource information for a placement service" + "description": "The resource information for a placement service" }, - "subscriberInfo" : { - "type" : "object", - "items" : { - "$ref" : "#/definitions/SubscriberInfo" + "subscriberInfo": { + "type": "object", + "items": { + "$ref": "#/definitions/SubscriberInfo" }, - "description" : "The information of a service subscriber." + "description": "The information of a service subscriber." } } }, - "PlacementDemand" : { - "type" : "object", - "required" : [ "resourceModuleName", "serviceResourceId", "resourceModelInfo" ], - "properties" : { - "resourceModuleName" : { - "type" : "string", - "description" : "A resource name as defined in a service mode", - "example" : "myResourceName" - }, - "serviceResourceId" : { - "type" : "string", - "description" : "A unique resource Id with a local scope between client and OOF.", - "example" : "myResourceId" - }, - "givenPlacement" : { - "type" : "object", - "additionalProperties" : { - "type" : "object", - "properties" : { - "key" : { - "type" : "string" + "PlacementDemand": { + "type": "object", + "required": [ + "resourceModuleName", + "serviceResourceId", + "resourceModelInfo" + ], + "properties": { + "resourceModuleName": { + "type": "string", + "description": "A resource name as defined in a service mode", + "example": "myResourceName" + }, + "serviceResourceId": { + "type": "string", + "description": "A unique resource Id with a local scope between client and OOF.", + "example": "myResourceId" + }, + "givenPlacement": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "key": { + "type": "string" }, - "value" : { - "type" : "string" + "value": { + "type": "string" } } }, - "description" : "placement parameters defined in the ordering system, keyname include tenantId", - "example" : { - "tenantId" : "1" + "description": "placement parameters defined in the ordering system, keyname include tenantId", + "example": { + "tenantId": "1" } }, - "resourceModelInfo" : { - "$ref" : "#/definitions/ModelMetaData", - "description" : "Resource model information as defined in SDC" + "resourceModelInfo": { + "$ref": "#/definitions/ModelMetaData" + }, + "existingCandidates": { + "$ref": "#/definitions/Candidates" }, - "existingCandidates" : { - "$ref" : "#/definitions/Candidates", - "description" : "The existing placement information of a resource." + "excludedCandidates": { + "$ref": "#/definitions/Candidates" }, - "excludedCandidates" : { - "$ref" : "#/definitions/Candidates", - "description" : "Candidates that need to be excluded from solutions." + "requiredCandidates": { + "$ref": "#/definitions/Candidates" + } + } + }, + "ModelMetaData": { + "type": "object", + "required": [ + "modelInvariantId", + "modelVersionId" + ], + "properties": { + "modelInvariantId": { + "type": "string", + "description": "A model invariant Id as defined in a service model.", + "example": "my model invariant Id" + }, + "modelVersionId": { + "type": "string", + "description": "A unique model Id as defined in a service model.", + "example": "my unique model Id" + }, + "modelName": { + "type": "string", + "description": "A model name as defined in a service model", + "example": "my model name" + }, + "modelType": { + "type": "string", + "description": "A model type as defined in a service model.", + "example": "my model type" + }, + "modelVersion": { + "type": "string", + "description": "A model version as defined in a service model.", + "example": "my model version" + }, + "modelCustomizationName": { + "type": "string", + "description": "A model customization name as defined in a service model.", + "example": "my model customization" + } + } + }, + "Candidates": { + "type": "object", + "required": [ + "identifierType", + "identifiers" + ], + "properties": { + "identifierType": { + "type": "string", + "enum": [ + "service_instance_id", + "vnf_name", + "cloud_region_id" + ], + "description": "The type of a candidate.", + "example": "service_instance_id" + }, + "identifiers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of identifiers.", + "example": "candidateId" }, - "requiredCandidates" : { - "$ref" : "#/definitions/Candidates", - "description" : "Candidates that must be included in solutions." + "cloudOwner": { + "type": "string", + "description": "The name of a cloud owner. Only required if identifierType is cloud_region_id", + "example": "cloud_owner" + } + } + }, + "SubscriberInfo": { + "type": "object", + "required": [ + "globalSubscriberId", + "subscriberName", + "subscriberCommonSiteId" + ], + "properties": { + "globalSubscriberId": { + "type": "string", + "description": "An ID of a subscriber.", + "example": "subscriber_id" + }, + "subscriberName": { + "type": "string", + "description": "The name of a subscriber. If the name is not known, the value must be 'unknown'", + "example": "subscriber_name" + }, + "subscriberCommonSiteId": { + "type": "string", + "description": "Id representing a subscriber location", + "example": "subscriber_location_id" } } }, - "ModelMetaData" : { - "type" : "object", - "required" : [ "modelInvariantId", "modelVersionId" ], - "properties" : { - "modelInvariantId" : { - "type" : "string", - "description" : "A model invariant Id as defined in a service model.", - "example" : "my model invariant Id" - }, - "modelVersionId" : { - "type" : "string", - "description" : "A unique model Id as defined in a service model.", - "example" : "my unique model Id" - }, - "modelName" : { - "type" : "string", - "description" : "A model name as defined in a service model", - "example" : "my model name" - }, - "modelType" : { - "type" : "string", - "description" : "A model type as defined in a service model.", - "example" : "my model type" - }, - "modelVersion" : { - "type" : "string", - "description" : "A model version as defined in a service model.", - "example" : "my model version" - }, - "modelCustomizationName" : { - "type" : "string", - "description" : "A model customization name as defined in a service model.", - "example" : "my model customization" + "LicenseInfo": { + "type": "object", + "required": [ + "licenseDemands" + ], + "properties": { + "licenseDemands": { + "type": "array", + "items": { + "$ref": "#/definitions/LicenseDemands" + }, + "description": "A list of resources for license selection" + } + } + }, + "LicenseDemands": { + "type": "object", + "required": [ + "resourceModuleName", + "serviceResourceId", + "resourceModelInfo" + ], + "properties": { + "resourceModuleName": { + "type": "string", + "description": "A resource name as defined in a service model.", + "example": "service_instance_id" + }, + "serviceResourceId": { + "type": "string", + "description": "A unique resource Id with a local scope between client and OOF.", + "example": "service_instance_id" + }, + "resourceModelInfo": { + "$ref": "#/definitions/ModelMetaData" + }, + "existingLicenses": { + "$ref": "#/definitions/LicenseModel" + } + } + }, + "LicenseModel": { + "type": "object", + "required": [ + "entitlementPoolUUID", + "licenseKeyGroupUUID" + ], + "properties": { + "entitlementPoolUUID": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "description": "Entitlement pool UUIDs associated with a resource.", + "example": "candidateId" + }, + "licenseKeyGroupUUID": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "description": "License key groups associated with a resource", + "example": "candidateId" } } }, - "Candidates" : { - "type" : "object", - "required" : [ "identifierType", "identifiers" ], - "properties" : { - "identifierType" : { - "type" : "string", - "enum" : [ "service_instance_id", "vnf_name", "cloud_region_id" ], - "description" : "The type of a candidate.", - "example" : "service_instance_id" - }, - "identifiers" : { - "type" : "array", - "items" : { - "type" : "string" - }, - "description" : "A list of identifiers.", - "example" : "candidateId" - }, - "cloudOwner" : { - "type" : "string", - "description" : "The name of a cloud owner. Only required if identifierType is cloud_region_id", - "example" : "cloud_owner" + "SynchronousResponse": { + "type": "object", + "required": [ + "requestId", + "transactionId", + "requestStatus" + ], + "properties": { + "requestId": { + "type": "string", + "format": "uuid", + "description": "A unique Id for an ONAP transaction", + "example": "ONAP transaction id" + }, + "transactionId": { + "type": "string", + "format": "uuid", + "description": "A unique ID to track multiple requests associated with a transaction.", + "example": "requests id" + }, + "statusMessage": { + "type": "string", + "description": "Reasoning if a requestStatus is failure.", + "example": "requestStatus" + }, + "requestStatus": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of a request.", + "example": "success" } } }, - "SubscriberInfo" : { - "type" : "object", - "required" : [ "globalSubscriberId", "subscriberName", "subscriberCommonSiteId" ], - "properties" : { - "globalSubscriberId" : { - "type" : "string", - "description" : "An ID of a subscriber.", - "example" : "subscriber_id" - }, - "subscriberName" : { - "type" : "string", - "description" : "The name of a subscriber. If the name is not known, the value must be 'unknown'", - "example" : "subscriber_name" - }, - "subscriberCommonSiteId" : { - "type" : "string", - "description" : "Id representing a subscriber location", - "example" : "subscriber_location_id" + "PlacementAsynchronousResponse": { + "type": "object", + "required": [ + "requestId", + "transactionId", + "requestStatus", + "solutions" + ], + "properties": { + "requestId": { + "type": "string", + "format": "uuid", + "description": "A unique Id for an ONAP transaction", + "example": "ONAP transaction id" + }, + "transactionId": { + "type": "string", + "format": "uuid", + "description": "A unique ID to track multiple requests associated with a transaction.", + "example": "requests id" + }, + "statusMessage": { + "type": "string", + "description": "Reasoning if a requestStatus is failure.", + "example": "requestStatus" + }, + "requestStatus": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of a request.", + "example": "success" + }, + "solutions": { + "$ref": "#/definitions/Solutions" + } + } + }, + "Solutions": { + "type": "object", + "required": [ + "placementSolutions", + "licenseSolutions" + ], + "properties": { + "placementSolutions": { + "type": "array", + "items": { + "$ref": "#/definitions/ComprehensiveSolution" + }, + "description": "A list of placement solutions." + }, + "licenseSolutions": { + "type": "array", + "items": { + "$ref": "#/definitions/LicenseSolution" + }, + "description": "A list of license solutions." } } }, - "LicenseInfo" : { - "type" : "object", - "required" : [ "licenseDemands" ], - "properties" : { - "licenseDemands" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/LicenseDemands" - }, - "description" : "A list of resources for license selection" + "ComprehensiveSolution": { + "type": "object", + "required": [ + "placementSolutions" + ], + "properties": { + "placementSolutions": { + "type": "array", + "items": { + "$ref": "#/definitions/PlacementSolution" + }, + "description": "A list of placement solutions." } } }, - "LicenseDemands" : { - "type" : "object", - "required" : [ "resourceModuleName", "serviceResourceId", "resourceModelInfo" ], - "properties" : { - "resourceModuleName" : { - "type" : "string", - "description" : "A resource name as defined in a service model.", - "example" : "service_instance_id" - }, - "serviceResourceId" : { - "type" : "string", - "description" : "A unique resource Id with a local scope between client and OOF.", - "example" : "service_instance_id" - }, - "resourceModelInfo" : { - "$ref" : "#/definitions/ModelMetaData", - "description" : "Resource model information as defined in a service model." - }, - "existingLicenses" : { - "$ref" : "#/definitions/LicenseModel", - "description" : "Existing license information assigned to a resource." + "PlacementSolution": { + "type": "object", + "required": [ + "resourceModuleName", + "serviceResourceId", + "identifierType", + "identifier" + ], + "properties": { + "resourceModuleName": { + "type": "string", + "description": "The name of a resource as defined in the service model", + "example": "resource name" + }, + "serviceResourceId": { + "type": "string", + "description": "A resource Id as defined in a service model.", + "example": "resource id" + }, + "identifierType": { + "type": "string", + "enum": [ + "service_instance_id" + ], + "description": "The type of a candidate.", + "example": "candidate type" + }, + "identifier": { + "type": "string", + "description": "The id of a candidate.", + "example": "candidate id" + }, + "assignmentInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/AssignmentInfo" + }, + "description": "Additional information related to a candidate." } } }, - "LicenseModel" : { - "type" : "object", - "required" : [ "entitlementPoolUUID", "licenseKeyGroupUUID" ], - "properties" : { - "entitlementPoolUUID" : { - "type" : "array", - "items" : { - "type" : "string", - "format" : "uuid" - }, - "description" : "Entitlement pool UUIDs associated with a resource.", - "example" : "candidateId" - }, - "licenseKeyGroupUUID" : { - "type" : "array", - "items" : { - "type" : "string", - "format" : "uuid" - }, - "description" : "License key groups associated with a resource", - "example" : "candidateId" + "AssignmentInfo": { + "type": "object", + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "type": "string", + "description": "An attribute name", + "example": "attribute name" + }, + "value": { + "type": "string", + "description": "An attribute value.", + "example": "attribute value" } } }, - "SynchronousResponse" : { - "type" : "object", - "required" : [ "requestId", "transactionId", "requestStatus" ], - "properties" : { - "requestId" : { - "type" : "string", - "format" : "uuid", - "description" : "A unique Id for an ONAP transaction", - "example" : "ONAP transaction id" - }, - "transactionId" : { - "type" : "string", - "format" : "uuid", - "description" : "A unique ID to track multiple requests associated with a transaction.", - "example" : "requests id" - }, - "statusMessage" : { - "type" : "string", - "description" : "Reasoning if a requestStatus is failure.", - "example" : "requestStatus" - }, - "requestStatus" : { - "type" : "string", - "enum" : [ "success", "failure" ], - "description" : "The status of a request.", - "example" : "success" + "LicenseSolution": { + "type": "object", + "required": [ + "resourceModuleName", + "serviceResourceId", + "entitlementPoolUUID", + "licenseKeyGroupUUID", + "entitlementPoolInvariantUUID", + "licenseKeyGroupInvariantUUID" + ], + "properties": { + "resourceModuleName": { + "type": "string", + "description": "A resource name as defined in a service", + "example": "resource name" + }, + "serviceResourceId": { + "type": "string", + "description": "A resource Id as defined in a service.", + "example": "resource Id" + }, + "entitlementPoolUUID": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "description": "A list of entitlementPoolUUIDs", + "example": "entitlementPoolUUID" + }, + "licenseKeyGroupUUID": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "description": "A list of licenseKeyGroupUUID.", + "example": "licenseKeyGroupUUID" + }, + "entitlementPoolInvariantUUID": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "description": "A list of entitlementPoolInvariantUUID", + "example": "entitlementPoolInvariantUUID" + }, + "licenseKeyGroupInvariantUUID": { + "type": "array", + "items": { + "type": "string", + "format": "uuid" + }, + "description": "A list of licenseKeyGroupInvariantUUID", + "example": "licenseKeyGroupInvariantUUID" } } }, - "AsynchronousResponse" : { - "type" : "object", - "required" : [ "requestId", "transactionId", "requestStatus", "solutions" ], - "properties" : { - "requestId" : { - "type" : "string", - "format" : "uuid", - "description" : "A unique Id for an ONAP transaction", - "example" : "ONAP transaction id" - }, - "transactionId" : { - "type" : "string", - "format" : "uuid", - "description" : "A unique ID to track multiple requests associated with a transaction.", - "example" : "requests id" - }, - "statusMessage" : { - "type" : "string", - "description" : "Reasoning if a requestStatus is failure.", - "example" : "requestStatus" - }, - "requestStatus" : { - "type" : "string", - "enum" : [ "success", "failure" ], - "description" : "The status of a request.", - "example" : "success" - }, - "solutions" : { - "$ref" : "#/definitions/Solutions", - "description" : "Solutions related to a request." + "ServiceInfo": { + "type": "object", + "required": [ + "serviceInstanceId", + "modelInfo", + "serviceName" + ], + "properties": { + "serviceInstanceId": { + "type": "string", + "description": "A service instance id associated with a request.", + "example": "service_instance_id" + }, + "modelInfo": { + "$ref": "#/definitions/ModelMetaData" + }, + "serviceName": { + "type": "string", + "description": "The name of a service", + "example": "service_name" } } }, - "Solutions" : { - "type" : "object", - "required" : [ "placementSolutions", "licenseSolutions" ], - "properties" : { - "placementSolutions" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/ComprehensiveSolution" - }, - "description" : "A list of placement solutions." - }, - "licenseSolutions" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/LicenseSolution" - }, - "description" : "A list of license solutions." + "PCIOptRequest": { + "type": "object", + "required": [ + "requestInfo", + "cellInfo" + ], + "properties": { + "requestInfo": { + "$ref": "#/definitions/RequestInfo" + }, + "cellInfo": { + "$ref": "#/definitions/CellInfo" } } }, - "ComprehensiveSolution" : { - "type" : "object", - "required" : [ "placementSolutions" ], - "properties" : { - "placementSolutions" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/PlacementSolution" - }, - "description" : "A list of placement solutions." + "CellInfo": { + "type": "object", + "required": [ + "networkId", + "cellIdList", + "anrInputList", + "trigger" + ], + "properties": { + "networkId": { + "type": "string", + "description": "Id of network requiring PCI optimization", + "example": 100 + }, + "cellIdList": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of cellIds triggering need for PCI optimization (eg.potential confusion)", + "example": [ + "cell0001", + "cell0002" + ] + }, + "anrInputList": { + "type": "array", + "items": { + "$ref": "#/definitions/ANRInfo" + }, + "description": "A list of ANR Input." + }, + "trigger": { + "type": "string", + "description": "Type of trigger causing need for PCI optimization", + "example": "NbrListChange" } } }, - "PlacementSolution" : { - "type" : "object", - "required" : [ "resourceModuleName", "serviceResourceId", "identifierType", "identifier" ], - "properties" : { - "resourceModuleName" : { - "type" : "string", - "description" : "The name of a resource as defined in the service model", - "example" : "resource name" - }, - "serviceResourceId" : { - "type" : "string", - "description" : "A resource Id as defined in a service model.", - "example" : "resource id" - }, - "identifierType" : { - "type" : "string", - "enum" : [ "service_instance_id" ], - "description" : "The type of a candidate.", - "example" : "candidate type" - }, - "identifier" : { - "type" : "string", - "description" : "The id of a candidate.", - "example" : "candidate id" - }, - "assignmentInfo" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/AssignmentInfo" - }, - "description" : "Additional information related to a candidate." + "PCIAsynchronousResponse": { + "type": "object", + "required": [ + "requestId", + "transactionId", + "requestStatus", + "solutions" + ], + "properties": { + "requestId": { + "type": "string", + "format": "uuid", + "description": "A unique Id for an ONAP transaction", + "example": "ONAP transaction id" + }, + "transactionId": { + "type": "string", + "format": "uuid", + "description": "A unique ID to track multiple requests associated with a transaction.", + "example": "requests id" + }, + "statusMessage": { + "type": "string", + "description": "Reasoning if a requestStatus is failure.", + "example": "requestStatus" + }, + "requestStatus": { + "type": "string", + "enum": [ + "success", + "failure" + ], + "description": "The status of a request.", + "example": "success" + }, + "solutions": { + "$ref": "#/definitions/PCIANRSolutions" } } }, - "AssignmentInfo" : { - "type" : "object", - "required" : [ "key", "value" ], - "properties" : { - "key" : { - "type" : "string", - "description" : "An attribute name", - "example" : "attribute name" - }, - "value" : { - "type" : "string", - "description" : "An attribute value.", - "example" : "attribute value" + "PCIANRSolutions": { + "type": "object", + "required": [ + "networkId", + "pciSolutions", + "anrSolutions" + ], + "properties": { + "networkId": { + "type": "string", + "description": "Id of network requiring PCI optimization", + "example": 100 + }, + "pciSolutions": { + "type": "array", + "items": { + "$ref": "#/definitions/PCISolution" + }, + "description": "A list of PCI solutions." + }, + "anrSolutions": { + "type": "array", + "items": { + "$ref": "#/definitions/ANRInfo" + }, + "description": "A list of ANR solutions." } } }, - "LicenseSolution" : { - "type" : "object", - "required" : [ "resourceModuleName", "serviceResourceId", "entitlementPoolUUID", "licenseKeyGroupUUID", "entitlementPoolInvariantUUID", "licenseKeyGroupInvariantUUID" ], - "properties" : { - "resourceModuleName" : { - "type" : "string", - "description" : "A resource name as defined in a service", - "example" : "resource name" - }, - "serviceResourceId" : { - "type" : "string", - "description" : "A resource Id as defined in a service.", - "example" : "resource Id" - }, - "entitlementPoolUUID" : { - "type" : "array", - "items" : { - "type" : "string", - "format" : "uuid" - }, - "description" : "A list of entitlementPoolUUIDs", - "example" : "entitlementPoolUUID" - }, - "licenseKeyGroupUUID" : { - "type" : "array", - "items" : { - "type" : "string", - "format" : "uuid" - }, - "description" : "A list of licenseKeyGroupUUID.", - "example" : "licenseKeyGroupUUID" - }, - "entitlementPoolInvariantUUID" : { - "type" : "array", - "items" : { - "type" : "string", - "format" : "uuid" - }, - "description" : "A list of entitlementPoolInvariantUUID", - "example" : "entitlementPoolInvariantUUID" - }, - "licenseKeyGroupInvariantUUID" : { - "type" : "array", - "items" : { - "type" : "string", - "format" : "uuid" - }, - "description" : "A list of licenseKeyGroupInvariantUUID", - "example" : "licenseKeyGroupInvariantUUID" + "PCISolution": { + "type": "object", + "required": [ + "cellId", + "pci" + ], + "properties": { + "cellId": { + "type": "string", + "description": "cellId with modified PCI value", + "example": "cell0001" + }, + "pci": { + "type": "integer", + "description": "New PCI value for cellId", + "example": 1 } } }, - "ServiceInfo" : { - "type" : "object", - "required" : [ "serviceInstanceId", "modelInfo", "serviceName" ], - "properties" : { - "serviceInstanceId" : { - "type" : "string", - "description" : "A service instance id associated with a request.", - "example" : "service_instance_id" - }, - "modelInfo" : { - "$ref" : "#/definitions/ModelMetaData", - "description" : "A list of identifiers." - }, - "serviceName" : { - "type" : "string", - "description" : "The name of a service", - "example" : "service_name" + "ANRInfo": { + "type": "object", + "required": [ + "cellId", + "removeableNeighbors" + ], + "properties": { + "cellId": { + "type": "string", + "description": "cellId with modified PCI value", + "example": "cell0001" + }, + "removeableNeighbors": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of neighbors to be removed", + "example": [ + "cell0002", + "cell0003" + ] } } } }, - "schemes" : [ "https" ], - "host" : "virtserver.swaggerhub.com", - "basePath" : "/oof-osdf/v1" + "schemes": [ + "https" + ], + "host": "virtserver.swaggerhub.com", + "basePath": "/oof-osdf/v1" } \ No newline at end of file diff --git a/osdf/models/api/pciOptimizationRequest.py b/osdf/models/api/pciOptimizationRequest.py index 47b4eba..6cb34c7 100644 --- a/osdf/models/api/pciOptimizationRequest.py +++ b/osdf/models/api/pciOptimizationRequest.py @@ -35,10 +35,16 @@ class RequestInfo(OSDFModel): timeout = IntType() +class ANRInfo(OSDFModel): + cellId = StringType(required=True) + removeableNeighbors = ListType(StringType()) + + class CellInfo(OSDFModel): """Information specific to CellInfo """ networkId = StringType(required=True) cellIdList = ListType(StringType(required=True)) + anrInputList = ListType(ModelType(ANRInfo), min_size=1) trigger = StringType() diff --git a/osdf/models/api/pciOptimizationResponse.py b/osdf/models/api/pciOptimizationResponse.py index 876c380..71d0986 100644 --- a/osdf/models/api/pciOptimizationResponse.py +++ b/osdf/models/api/pciOptimizationResponse.py @@ -27,9 +27,15 @@ class PCISolution(OSDFModel): pci = IntType(required=True) +class ANRSolution(OSDFModel): + cellId = StringType(required=True) + removeableNeighbors = ListType(StringType()) + + class Solution(OSDFModel): networkId = StringType(required=True) pciSolutions = ListType(ListType(ModelType(PCISolution), min_size=1)) + anrSolutions = ListType(ListType(ModelType(ANRSolution), min_size=1)) class PCIOptimizationResponse(OSDFModel): diff --git a/osdf/optimizers/pciopt/solver/optimizer.py b/osdf/optimizers/pciopt/solver/optimizer.py index 5a1a5c2..2825536 100644 --- a/osdf/optimizers/pciopt/solver/optimizer.py +++ b/osdf/optimizers/pciopt/solver/optimizer.py @@ -65,8 +65,7 @@ def add_to_neighbor_list(network_cell_info, cell, neighbor_list): host_id = cell['id'] nbr_id = get_id(network_cell_info, nbr['cellId']) if nbr_id and host_id != nbr_id: - entry = sorted([host_id, nbr_id]) - neighbor_list.add((entry[0], entry[1])) + neighbor_list.add((host_id, nbr_id)) def get_second_level_neighbor(network_cell_info): @@ -75,8 +74,7 @@ def get_second_level_neighbor(network_cell_info): comb_list = build_second_level_list(network_cell_info, cell) for comb in comb_list: if comb[0] and comb[1]: - s = sorted(comb) - second_neighbor_list.add((s[0], s[1])) + second_neighbor_list.add((comb[0], comb[1])) return sorted(second_neighbor_list) diff --git a/osdfapp.py b/osdfapp.py index 9449bc9..a83adb7 100755 --- a/osdfapp.py +++ b/osdfapp.py @@ -20,37 +20,32 @@ OSDF Manager Main Flask Application """ +import json import sys +import traceback +from optparse import OptionParser from threading import Thread # for scaling up, may need celery with RabbitMQ or redis +import pydevd from flask import Flask, request, Response, g +from requests import RequestException +from schematics.exceptions import DataError -import osdf -import pydevd -import json import osdf.adapters.aaf.sms as sms -import osdf.adapters.policy.interface -import osdf.config.credentials -import osdf.config.loader -import osdf.operation.error_handling import osdf.operation.responses -import traceback -from schematics.exceptions import DataError -from requests import RequestException -from optparse import OptionParser from osdf.adapters.policy.interface import get_policies from osdf.config.base import osdf_config -from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt -from osdf.webapp.appcontroller import auth_basic -from osdf.operation.exceptions import BusinessException -from osdf.operation.error_handling import request_exception_to_json_body, internal_error_message from osdf.logging.osdf_logging import MH, audit_log, error_log, debug_log -from osdf.models.api.placementRequest import PlacementAPI from osdf.models.api.pciOptimizationRequest import PCIOptimizationAPI +from osdf.models.api.placementRequest import PlacementAPI +from osdf.operation.error_handling import request_exception_to_json_body, internal_error_message +from osdf.operation.exceptions import BusinessException from osdf.operation.responses import osdf_response_for_request_accept as req_accept -from osdf.optimizers.routeopt.simple_route_opt import RouteOpt from osdf.optimizers.pciopt.pci_opt_processor import process_pci_optimation +from osdf.optimizers.placementopt.conductor.remote_opt_processor import process_placement_opt +from osdf.optimizers.routeopt.simple_route_opt import RouteOpt from osdf.utils import api_data_utils +from osdf.webapp.appcontroller import auth_basic ERROR_TEMPLATE = osdf.ERROR_TEMPLATE @@ -148,7 +143,9 @@ def do_route_calc(): audit_log.info("Calculate Route request received!") return RouteOpt().getRoute(request_json) + @app.route("/api/oof/v1/pci", methods=["POST"]) +@app.route("/api/oof/pci/v1", methods=["POST"]) @auth_basic.login_required def do_pci_optimization(): request_json = request.get_json() @@ -156,7 +153,7 @@ def do_pci_optimization(): g.request_id = req_id audit_log.info(MH.received_request(request.url, request.remote_addr, json.dumps(request_json))) PCIOptimizationAPI(request_json).validate() - #disable policy retrieval + # disable policy retrieval # policies = get_policies(request_json, "pciopt") audit_log.info(MH.new_worker_thread(req_id, "[for pciopt]")) t = Thread(target=process_pci_optimation, args=(request_json, osdf_config, None)) @@ -175,6 +172,7 @@ def internal_failure(error): response.status_code = 500 return response + def get_options(argv): program_version_string = '%%prog %s' % "v1.0" program_longdesc = "" -- cgit 1.2.3-korg