summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorc00149107 <chenchuanyu@huawei.com>2017-10-27 10:44:46 +0800
committerc00149107 <chenchuanyu@huawei.com>2017-10-27 10:44:46 +0800
commitfca7fafd4b48b826581bd2b34111abf998e9cbbf (patch)
tree1e0fdf104e9404145eca1d1cbe989e0737d37dd5
parent4f6b6950eb4b0fd13f484df4954bfee62d9ee9af (diff)
Add Relationship for e2e service and NS
Add Relationship for e2e service and NS Change-Id: Id1bf6862b9d2325297e466d417dc1b169e157ff6 Issue-ID:SO-275 Signed-off-by: c00149107 <chenchuanyu@huawei.com>
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java46
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java12
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy77
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn4
4 files changed, 73 insertions, 66 deletions
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java
deleted file mode 100644
index 7f1a6daae5..0000000000
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.adapters.vfc;
-
-import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
-
-/**
- * Implement class of operating aai database table <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class AaiUtil {
-
- public static RestfulResponse addRelation(String globalSubsriberId, String serviceType,
- String serviceInstanceId, String resourceInstanceId) {
- // sent rest to aai to add relation for service and ns.
-
- return null;
- }
-
- public static RestfulResponse removeRelation(String globalSubsriberId, String serviceType,
- String serviceInstanceId, String resourceInstanceId) {
- // sent rest to aai to remove relation between service an ns.
- return null;
- }
-}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
index 94f4de391b..35c8eade0c 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
@@ -137,12 +137,7 @@ public class VfcManager {
DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION);
}
LOGGER.info("create ns -> end");
- LOGGER.info("save segment and operaton info -> begin");
- // Step 6: add relation between service and NS
- AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(),
- segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(),
- nsInstanceId);
- LOGGER.info("save segment and operation info -> end");
+
return createRsp;
}
@@ -181,11 +176,6 @@ public class VfcManager {
DriverExceptionID.FAIL_TO_DELETE_NS);
}
- // Step3: remove relation info between service and ns
- AaiUtil.removeRelation(nsOperationKey.getGlobalSubscriberId(), nsOperationKey.getServiceType(),
- nsOperationKey.getServiceId(), nsInstanceId);
- LOGGER.info("delete segment information -> end");
-
// Step4: update service segment operation status
nsOperInfo.setStatus(RequestsDbConstant.Status.FINISHED);
nsOperInfo.setErrorCode(String.valueOf(deleteRsp.getStatus()));
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 8354798345..2e62abd6f5 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
@@ -53,7 +53,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
-
+
/**
* Pre Process the BPMN Flow Request
* Inclouds:
@@ -118,7 +118,8 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
* create NS task
*/
public void createNetworkService(Execution execution) {
-
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** createNetworkService *****", isDebugEnabled)
String nsOperationKey = execution.getVariable("nsOperationKey");
String nsParameters = execution.getVariable("nsParameters");
String nsServiceName = execution.getVariable("nsServiceName")
@@ -137,13 +138,15 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
}
execution.setVariable("nsInstanceId", nsInstanceId)
-
+ utils.log("INFO"," *****Exit createNetworkService *****", isDebugEnabled)
}
/**
* instantiate NS task
*/
public void instantiateNetworkService(Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** instantiateNetworkService *****", isDebugEnabled)
String nsOperationKey = execution.getVariable("nsOperationKey");
String nsParameters = execution.getVariable("nsParameters");
String nsServiceName = execution.getVariable("nsServiceName")
@@ -163,13 +166,16 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
if(returnCode== "200"){
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
}
- execution.setVariable("jobId", nsInstanceId)
+ execution.setVariable("jobId", jobId)
+ utils.log("INFO"," *****Exit instantiateNetworkService *****", isDebugEnabled)
}
/**
* query NS task
*/
public void queryNSProgress(Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** queryNSProgress *****", isDebugEnabled)
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
String url = host + vfcUrl + "/jobs/" + jobId
@@ -181,24 +187,81 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
}
execution.setVariable("operationStatus", operationStatus)
+ utils.log("INFO"," *****Exit queryNSProgress *****", isDebugEnabled)
}
/**
* delay 5 sec
*/
public void timeDelay(Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
try {
Thread.sleep(5000);
} catch(InterruptedException e) {
- taskProcessor.utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
+ utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
}
}
/**
* finish NS task
*/
- public void finishNSCreate(Execution execution) {
- //no need to do anything util now
+ public void addNSRelationship(Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** addNSRelationship *****", isDebugEnabled)
+ String operationStatus = execution.getVariable("operationStatus")
+ if(operationStatus != "finished"){
+ utils.log("INFO"," create NS failed, so do not need to add relationship", isDebugEnabled)
+ return
+ }
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+ String serviceId = execution.getVariable("serviceId")
+ String nsInstanceId = execution.getVariable("nsInstanceId")
+ String addRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">
+ <related-to>service-instance</related-to>
+ <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId}</related-link>
+ <relationship-data>
+ <relationship-key>customer.global-customer-id</relationship-key>
+ <relationship-value>${globalSubscriberId}</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>service-subscription.service-type</relationship-key>
+ <relationship-value>${serviceType}</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>service-instance.service-instance-id</relationship-key>
+ <relationship-value>${nsInstanceId}</relationship-value>
+ </relationship-data>
+ </relationship>"""
+ String endpoint = execution.getVariable("URN_aai_endpoint")
+ String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship"
+ executeAAIPutCall(execution, url, addRelationPayload)
+ utils.log("INFO"," *****Exit addNSRelationship *****", isDebugEnabled)
+ }
+
+ public APIResponse executeAAIPutCall(Execution execution, String url, String payload){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO", " ======== Started Execute AAI Put Process ======== ", isDebugEnabled)
+ APIResponse apiResponse = null
+ try{
+ String uuid = utils.getRequestID()
+ utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled)
+ utils.log("INFO","URL to be used is: " + url, isDebugEnabled)
+ String userName = execution.getVariable("URN_aai_auth")
+ String password = execution.getVariable("URN_mso_msoKey")
+ String basicAuthCred = utils.getBasicAuth(userName,password)
+ RESTConfig config = new RESTConfig(url);
+ RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
+ if (basicAuthCred != null && !"".equals(basicAuthCred)) {
+ client.addAuthorizationHeader(basicAuthCred)
+ }
+ apiResponse = client.httpPut(payload)
+ utils.log("INFO","======== Completed Execute AAI Put Process ======== ", isDebugEnabled)
+ }catch(Exception e){
+ utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)
+ throw new BpmnError("MSOWorkflowException")
+ }
+ return apiResponse
}
/**
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn
index ffe9dcab3e..67b0f968fa 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn
@@ -80,12 +80,12 @@ dcsi.instantiateNetworkService(execution)]]></bpmn:script>
def dcsi = new DoCreateVFCNetworkServiceInstance()
dcsi.queryNSProgress(execution)]]></bpmn:script>
</bpmn:scriptTask>
- <bpmn:scriptTask id="finishNSCreate_Task" name="Finish NS Create">
+ <bpmn:scriptTask id="finishNSCreate_Task" name="Add NS RelationShip" scriptFormat="groovy">
<bpmn:incoming>operationFinished_SequenceFlow</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0cq2q6g</bpmn:outgoing>
<bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
def dcsi = new DoCreateVFCNetworkServiceInstance()
-dcsi.finishNSCreate(execution)]]></bpmn:script>
+dcsi.addNSRelationship(execution)]]></bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="SequenceFlow_0xqo13p" sourceRef="queryJob_Task" targetRef="ExclusiveGateway_15492gl" />
<bpmn:scriptTask id="timeDelay_Task" name="timeDelay" scriptFormat="groovy">