diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-31 22:56:35 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-31 22:56:50 -0500 |
commit | 71c4708528c635dcc12575d5e3118e01b32d46cc (patch) | |
tree | a6c4d4b172d353520eb71f2b13a5d1515f95a6b3 /mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap | |
parent | cd0963d829a73dc22b345be12379a2f8dd3a83e8 (diff) |
use OE from AAI with sdc
Updated the SDC API call with the ECOMP OE from AAI relationship
instead of VNF OE value.
Change-Id: I576ed83364f11213f36781c033f7c2d56f98f1c6
Issue-ID: SO-1451
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap')
5 files changed, 46 insertions, 24 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java index 6fd33a6afc..6a5de77c73 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.ws.rs.NotFoundException; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; @@ -33,7 +34,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.logger.MsoLogger; import org.springframework.stereotype.Component; @@ -51,7 +51,7 @@ public class AAIClientHelper { public AAIResultWrapper getAaiOperationalEnvironment(String id){ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); - uri.depth(Depth.ZERO); //Do not return relationships if any + uri.depth(Depth.ZERO); AAIResourcesClient client = this.getClient(); return client.get(uri, NotFoundException.class); } @@ -62,7 +62,7 @@ public class AAIClientHelper { * @param id = operationalEnvironmentId * @param AAIOperationalEnvironment object */ - public void updateAaiOperationalEnvironment(String id, AAIOperationalEnvironment aaiRequest){ + public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest){ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); AAIResourcesClient client = this.getClient(); @@ -87,7 +87,7 @@ public class AAIClientHelper { * Create an Operational Environment object in A&AI * @param AAIOperationalEnvironment object */ - public void createOperationalEnvironment(AAIOperationalEnvironment operationalEnvironment){ + public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment){ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId()); AAIResourcesClient client = this.getClient(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java index 23642bdfb4..dc6019c9cb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java @@ -20,15 +20,15 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.springframework.stereotype.Component; @Component public class AAIClientObjectBuilder { - public AAIOperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) { - AAIOperationalEnvironment env = new AAIOperationalEnvironment(); + public OperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) { + OperationalEnvironment env = new OperationalEnvironment(); env.setOperationalEnvironmentId(cloudOrchestrationRequest.getOperationalEnvironmentId()); env.setOperationalEnvironmentName(cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName()); env.setOperationalEnvironmentType(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index ac9a000d3b..1d2a445c40 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -21,11 +21,16 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.List; +import java.util.Optional; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; +import org.onap.aai.domain.yang.OperationalEnvironment; +import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipData; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -36,8 +41,10 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; +import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; +import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; import org.onap.so.logger.MessageEnum; @@ -54,6 +61,7 @@ public class ActivateVnfOperationalEnvironment { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; + private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; @Autowired private ActivateVnfDBHelper dbHelper; @@ -77,24 +85,39 @@ public class ActivateVnfOperationalEnvironment { * @return void - nothing */ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ - String operationalEnvironmentId = request.getOperationalEnvironmentId(); + String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId(); String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList(); - + + String ecompOperationalEnvironmentId = null; + AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId); + Optional<Relationships> optRelationships = wrapper.getRelationships(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + List<AAIResourceUri> operationalEnvironments = relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); + if (!operationalEnvironments.isEmpty()) { + ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); + } + } + msoLogger.debug(" vnfOperationalEnvironmentId : " + vnfOperationalEnvironmentId); + msoLogger.debug(" ecompOperationalEnvironmentId : " + ecompOperationalEnvironmentId); - AAIOperationalEnvironment operationalEnv = getAAIOperationalEnvironment(operationalEnvironmentId); + OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get(); String workloadContext = operationalEnv.getWorkloadContext(); msoLogger.debug(" aai workloadContext: " + workloadContext); if (!vidWorkloadContext.equals(workloadContext)) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); } + if (ecompOperationalEnvironmentId==null) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); + throw new ValidateException.Builder(" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + OPER_ENVIRONMENT_ID_KEY, + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + } - processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext); + processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext); } @@ -171,9 +194,8 @@ public class ActivateVnfOperationalEnvironment { * @param operationalEnvironmentId - String * @return operationalEnv - AAIOperationalEnvironment object */ - public AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { - AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - return aaiResult.asBean(AAIOperationalEnvironment.class).orElse(new AAIOperationalEnvironment()); + public AAIResultWrapper getAAIOperationalEnvironment(String operationalEnvironmentId) { + return aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java index e95db6b188..36226aae68 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java @@ -27,6 +27,7 @@ import javax.ws.rs.NotFoundException; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -37,7 +38,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder; import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstanceList; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.client.grm.GRMClient; import org.onap.so.client.grm.beans.OperationalInfo; import org.onap.so.client.grm.beans.Property; @@ -75,7 +75,7 @@ public class CreateVnfOperationalEnvironment { if (aaiResultWrapper.isEmpty()) { throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI"); } - AAIOperationalEnvironment aaiEnv = objectMapper.readValue(aaiResultWrapper.getJson(), AAIOperationalEnvironment.class); + OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get(); //Find ECOMP environments in GRM msoLogger.debug(" Start of GRM findRunningServicesAsString"); @@ -209,7 +209,7 @@ public class CreateVnfOperationalEnvironment { return tenantContext + "." + workloadContext + "." + serviceName; } - protected String getSearchKey(AAIOperationalEnvironment aaiEnv) { + protected String getSearchKey(OperationalEnvironment aaiEnv) { return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*"; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java index 2096011caa..977184e2c5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java @@ -24,6 +24,7 @@ import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -31,7 +32,6 @@ import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -51,7 +51,7 @@ public class DeactivateVnfOperationalEnvironment { public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { String operationalEnvironmentId = request.getOperationalEnvironmentId(); - AAIOperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId); + OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId); if (aaiOpEnv != null) { String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus(); @@ -81,9 +81,9 @@ public class DeactivateVnfOperationalEnvironment { } } - private AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { + private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - Optional<AAIOperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(AAIOperationalEnvironment.class); + Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class); return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null; } } |