+++ /dev/null
-/*-
- * ============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;
- }
-}
ExceptionUtil exceptionUtil = new ExceptionUtil()\r
\r
JsonUtils jsonUtil = new JsonUtils()\r
-\r
+ \r
/**\r
* Pre Process the BPMN Flow Request\r
* Inclouds:\r
* create NS task\r
*/\r
public void createNetworkService(Execution execution) {\r
- \r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ utils.log("INFO"," ***** createNetworkService *****", isDebugEnabled)\r
String nsOperationKey = execution.getVariable("nsOperationKey");\r
String nsParameters = execution.getVariable("nsParameters");\r
String nsServiceName = execution.getVariable("nsServiceName")\r
nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")\r
}\r
execution.setVariable("nsInstanceId", nsInstanceId)\r
- \r
+ utils.log("INFO"," *****Exit createNetworkService *****", isDebugEnabled)\r
}\r
\r
/**\r
* instantiate NS task\r
*/\r
public void instantiateNetworkService(Execution execution) {\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ utils.log("INFO"," ***** instantiateNetworkService *****", isDebugEnabled)\r
String nsOperationKey = execution.getVariable("nsOperationKey");\r
String nsParameters = execution.getVariable("nsParameters");\r
String nsServiceName = execution.getVariable("nsServiceName")\r
if(returnCode== "200"){\r
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")\r
}\r
- execution.setVariable("jobId", nsInstanceId)\r
+ execution.setVariable("jobId", jobId)\r
+ utils.log("INFO"," *****Exit instantiateNetworkService *****", isDebugEnabled)\r
}\r
\r
/**\r
* query NS task\r
*/\r
public void queryNSProgress(Execution execution) {\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ utils.log("INFO"," ***** queryNSProgress *****", isDebugEnabled)\r
String jobId = execution.getVariable("jobId")\r
String nsOperationKey = execution.getVariable("nsOperationKey");\r
String url = host + vfcUrl + "/jobs/" + jobId\r
operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")\r
}\r
execution.setVariable("operationStatus", operationStatus)\r
+ utils.log("INFO"," *****Exit queryNSProgress *****", isDebugEnabled)\r
}\r
\r
/**\r
* delay 5 sec \r
*/\r
public void timeDelay(Execution execution) {\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
try {\r
Thread.sleep(5000);\r
} catch(InterruptedException e) { \r
- taskProcessor.utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)\r
+ utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)\r
}\r
}\r
\r
/**\r
* finish NS task\r
*/\r
- public void finishNSCreate(Execution execution) {\r
- //no need to do anything util now\r
+ public void addNSRelationship(Execution execution) {\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ utils.log("INFO"," ***** addNSRelationship *****", isDebugEnabled)\r
+ String operationStatus = execution.getVariable("operationStatus")\r
+ if(operationStatus != "finished"){\r
+ utils.log("INFO"," create NS failed, so do not need to add relationship", isDebugEnabled)\r
+ return\r
+ }\r
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")\r
+ String serviceType = execution.getVariable("serviceType")\r
+ String serviceId = execution.getVariable("serviceId")\r
+ String nsInstanceId = execution.getVariable("nsInstanceId")\r
+ String addRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">\r
+ <related-to>service-instance</related-to>\r
+ <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId}</related-link>\r
+ <relationship-data>\r
+ <relationship-key>customer.global-customer-id</relationship-key>\r
+ <relationship-value>${globalSubscriberId}</relationship-value>\r
+ </relationship-data>\r
+ <relationship-data>\r
+ <relationship-key>service-subscription.service-type</relationship-key>\r
+ <relationship-value>${serviceType}</relationship-value>\r
+ </relationship-data>\r
+ <relationship-data>\r
+ <relationship-key>service-instance.service-instance-id</relationship-key>\r
+ <relationship-value>${nsInstanceId}</relationship-value>\r
+ </relationship-data> \r
+ </relationship>"""\r
+ String endpoint = execution.getVariable("URN_aai_endpoint") \r
+ String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship"\r
+ executeAAIPutCall(execution, url, addRelationPayload)\r
+ utils.log("INFO"," *****Exit addNSRelationship *****", isDebugEnabled)\r
+ }\r
+ \r
+ public APIResponse executeAAIPutCall(Execution execution, String url, String payload){\r
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+ utils.log("INFO", " ======== Started Execute AAI Put Process ======== ", isDebugEnabled) \r
+ APIResponse apiResponse = null\r
+ try{\r
+ String uuid = utils.getRequestID()\r
+ utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled) \r
+ utils.log("INFO","URL to be used is: " + url, isDebugEnabled) \r
+ String userName = execution.getVariable("URN_aai_auth")\r
+ String password = execution.getVariable("URN_mso_msoKey")\r
+ String basicAuthCred = utils.getBasicAuth(userName,password)\r
+ RESTConfig config = new RESTConfig(url);\r
+ RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");\r
+ if (basicAuthCred != null && !"".equals(basicAuthCred)) {\r
+ client.addAuthorizationHeader(basicAuthCred)\r
+ }\r
+ apiResponse = client.httpPut(payload)\r
+ utils.log("INFO","======== Completed Execute AAI Put Process ======== ", isDebugEnabled) \r
+ }catch(Exception e){\r
+ utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled) \r
+ throw new BpmnError("MSOWorkflowException")\r
+ }\r
+ return apiResponse\r
}\r
\r
/**\r