diff options
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main')
5 files changed, 167 insertions, 175 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index cfdc0e9bfa..2b2d62239c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -27,6 +27,12 @@ import groovy.json.* import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.domain.ServiceInstance import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.Resource +import org.openecomp.mso.bpmn.core.domain.AllottedResource +import org.openecomp.mso.bpmn.core.domain.NetworkResource +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.common.recipe.ResourceInput +import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -42,6 +48,8 @@ import org.openecomp.mso.rest.RESTConfig import java.util.List; import java.util.UUID; +import javax.mail.Quota.Resource; + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.json.JSONObject; @@ -400,11 +408,11 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceInstanceId", serviceId) execution.setVariable("operationId", operationId) execution.setVariable("operationType", operationType) - String incomingRequest = execution.getVariable("uuiRequest") - String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") - List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + List<Resource> resourceList = serviceDecomposition.getServiceResources() + for(String resource : resourceList){ - resourceTemplateUUIDs = resourceTemplateUUIDs + jsonUtil.getJsonValue(resource, "resourceId") + ":" + resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" } def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" @@ -491,41 +499,34 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { if (networks == null) { utils.log("INFO", "No matching networks in Catalog DB for serviceModelUUID=" + serviceModelUUID, isDebugEnabled) } - String incomingRequest = execution.getVariable("uuiRequest") - String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") - List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) - // Only one match herenetwork - List<String> nsResources = new ArrayList<String>() - List<String> wanResources = new ArrayList<String>() - List<String> resourceSequence = new ArrayList<String>() - for(String resource : resourceList){ - String resourceName = jsonUtil.getJsonValue(resource, "resourceName") - String resourceUUID = jsonUtil.getJsonValue(resource, "resourceId") - //check is network. - boolean isNetwork = false; - if(networks != null){ - for(int i = 0; i < networks.size(); i++){ - String networkUUID = jsonUtil.getJsonValueForKey(networks.get(i), "modelVersionId") - if(StringUtils.equals(resourceUUID, networkUUID)){ - isNetwork = true - break - } - } - } - if(isNetwork){ - wanResources.add(resourceName) - }else{ - nsResources.add(resourceName) - } + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + //we use VF to define a network service + List<VnfResource> vnfResourceList= serviceDecomposition.getServiceVnfs() + + //here wan is defined as a network resource + List<NetworkResource> networkResourceList = serviceDecomposition.getServiceNetworks() + + //allotted resource + List<AllottedResource> arResourceList= serviceDecomposition.getServiceAllottedResources() + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List<Resource> sequencedResourceList = new ArrayList<Resource>(); + if(null != vnfResourceList){ + sequencedResourceList.addAll(vnfResourceList) + } + if(null != networkResourceList){ + sequencedResourceList.addAll(networkResourceList) + } + if(null != arResourceList){ + sequencedResourceList.addAll(arResourceList) } - resourceSequence.addAll(nsResources) - resourceSequence.addAll(wanResources) - String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + + String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true" execution.setVariable("isContainsWanResource", isContainsWanResource) execution.setVariable("currentResourceIndex", 0) - execution.setVariable("resourceSequence", resourceSequence) - utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) - execution.setVariable("wanResources", wanResources) + execution.setVariable("sequencedResourceList", sequencedResourceList) + utils.log("INFO", "sequencedResourceList: " + sequencedResourceList, isDebugEnabled) utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled) } @@ -533,15 +534,9 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) def currentIndex = execution.getVariable("currentResourceIndex") - List<String> resourceSequence = execution.getVariable("resourceSequence") - List<String> wanResources = execution.getVariable("wanResources") - String resourceName = resourceSequence.get(currentIndex) - execution.setVariable("resourceType",resourceName) - if(wanResources.contains(resourceName)){ - execution.setVariable("controllerInfo", "SDN-C") - }else{ - execution.setVariable("controllerInfo", "VF-C") - } + List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + utils.log("INFO", "Now we deal with resouce:" + currentResource.getModelInfo().getModelName(), isDebugEnabled) utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) } @@ -554,8 +549,8 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { def currentIndex = execution.getVariable("currentResourceIndex") def nextIndex = currentIndex + 1 execution.setVariable("currentResourceIndex", nextIndex) - List<String> resourceSequence = execution.getVariable("resourceSequence") - if(nextIndex >= resourceSequence.size()){ + List<String> sequencedResourceList = execution.getVariable("sequencedResourceList") + if(nextIndex >= sequencedResourceList.size()){ execution.setVariable("allResourceFinished", "true") }else{ execution.setVariable("allResourceFinished", "false") @@ -569,4 +564,59 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { public void postConfigRequest(execution){ //now do noting } + + public void prepareResourceRecipeRequest(execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled) + ResourceInput resourceInput = new ResourceInput() + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String resourceInstanceName = resourceType + "_" + serviceInstanceName + resourceInput.setResourceInstanceName(resourceInstanceName) + utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + resourceInput.setGlobalSubscriberId(globalSubscriberId) + resourceInput.setServiceType(serviceType) + resourceInput.setServiceInstanceId(serviceInstanceId) + resourceInput.setOperationId(operationId) + resourceInput.setOperationType(operationType); + def currentIndex = execution.getVariable("currentResourceIndex") + List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid() + resourceInput.setResourceCustomizationUuid(resourceCustomizationUuid); + String resourceInvariantUuid = currentResource.getModelInfo().getModelInvariantUuid() + resourceInput.setResourceInvariantUuid(resourceInvariantUuid) + String resourceUuid = currentResource.getModelInfo().getModelUuid() + resourceInput.setResourceUuid(resourceUuid) + + String incomingRequest = execution.getVariable("uuiRequest") + String resourcesStr = jsonUtil.getJsonValue(incomingRequest, "service.parameters.resources") + String serviceRequestInputs = jsonUtil.getJsonValue(incomingRequest, "service.parameters.requestInputs") + String serviceDescription = jsonUtil.getJsonValue(incomingRequest, "service.description") + resourceInput.setResourceInstanceDes(serviceDescription) + utils.log("INFO", "Prepare Resource Request:" + resourceInput.toString(), isDebugEnabled) + List<String> resourceList = jsonUtil.StringArrayToList(execution, resourcesStr) + String locationConstraints = "" + String resourceRequestInputs = "" + for(String resource : resourceList){ + String resourceUuidTmp = jsonUtil.getJsonValue(resource, "resourceUuid") + String resourceCustomizationUuidTmp = jsonUtil.getJsonValue(resource, "resourceCustomizationUuid") + if(StringUtils.equals(resourceUuidTmp, resourceUuid) && StringUtils.equals(resourceCustomizationUuidTmp, resourceCustomizationUuid)){ + + String resourceParameters = jsonUtil.getJsonValue(resource, "parameters") + locationConstraints = jsonUtil.getJsonValue(resourceParameters, "locationConstraints") + resourceRequestInputs = jsonUtil.getJsonValue(resourceParameters, "requestInputs") + } + } + //set the requestInputs from tempalte To Be Done + //String resourceParameters = ResourceRequestBuilder.buildRequestParameters() + String resourceParameters = "" + resourceInput.setResourceParameters(resourceParameters) + execution.setVariable("resourceInput", resourceInput) + utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled) + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index 38a44ab1f6..0749c789b4 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -24,9 +24,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -43,7 +41,6 @@ import org.openecomp.mso.bpmn.core.PropertyConfiguration; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.RequestsDatabase; import org.openecomp.mso.requestsdb.RequestsDbConstant; import org.openecomp.mso.requestsdb.ResourceOperationStatus; import org.slf4j.Logger; @@ -62,12 +59,12 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private static final Logger logger = LoggerFactory.getLogger(AbstractSdncOperationTask.class); private static final String DEFAULT_MSB_IP = "127.0.0.1"; - private static final int DEFAULT_MSB_Port = 80; + private static final int DEFAULT_MSB_PORT = 80; private static final String SDCADAPTOR_INPUTS = "resourceParameters"; + private static final String TOPOLOGY_PROPERTIES = "topology.properties"; public static final String ONAP_IP = "ONAP_IP"; - private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); - private static final String postBodyTemplate = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n"+ + private static final String POST_BODY_TEMPLATE = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n"+ " <ns:updateResourceOperationStatus>\n"+ " <errorCode>$errorCode</errorCode>\n"+ " <jobId>$jobId</jobId>\n"+ @@ -80,7 +77,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { " <statusDescription>$statusDescription</statusDescription>\n"+ " </ns:updateResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; - private static final String getBodyTemplate = " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n" + + private static final String GET_BODY_TEMPLATE = " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n" + " <ns:getResourceOperationStatus>\n" + " <operationId>$operationId</operationId>\n" + " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n" + @@ -98,7 +95,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); logger.info("AbstractSdncOperationTask.updateResOperStatus end!"); - //requestsDB.updateResOperStatus(resourceOperationStatus); } protected String getPostbody(Object inputEntity) { @@ -108,7 +104,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); postBody = objectMapper.writeValueAsString(inputEntity); } catch (JsonProcessingException e) { - e.printStackTrace(); + logger.error(e.getStackTrace().toString()); } return postBody; } @@ -118,24 +114,20 @@ public abstract class AbstractSdncOperationTask extends BaseTask { String result = null; String errorMsg; - label91: { - try(CloseableHttpClient httpClient = HttpClients.createDefault()) { - CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); - result = EntityUtils.toString(closeableHttpResponse.getEntity()); - logger.info("result = {}", result); -// LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, result.toString(), "SDNC", ""); - if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) { - logger.info("exception: fail for status code = {}", closeableHttpResponse.getStatusLine().getStatusCode()); - throw new RouteException(result, "SERVICE_GET_ERR"); - } - - closeableHttpResponse.close(); - break label91; - } catch (IOException e) { - errorMsg = url + ":httpPostWithJSON connect faild"; - logger.info("exception: POST_CONNECT_FAILD : {}", errorMsg); - throwsRouteException(errorMsg, e, "POST_CONNECT_FAILD"); + try(CloseableHttpClient httpClient = HttpClients.createDefault()) { + CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); + result = EntityUtils.toString(closeableHttpResponse.getEntity()); + logger.info("result = {}", result); + if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) { + logger.info("exception: fail for status code = {}", closeableHttpResponse.getStatusLine().getStatusCode()); + throw new RouteException(result, "SERVICE_GET_ERR"); } + + closeableHttpResponse.close(); + } catch (IOException e) { + errorMsg = url + ":httpPostWithJSON connect faild"; + logger.info("exception: POST_CONNECT_FAILD : {}", errorMsg); + throwsRouteException(errorMsg, e, "POST_CONNECT_FAILD"); } logger.info("AbstractSdncOperationTask.httpPost end!"); @@ -150,7 +142,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private String getPostStringBody(ResourceOperationStatus resourceOperationStatus) { logger.info("AbstractSdncOperationTask.getPostStringBody begin!"); - String postBody = postBodyTemplate; + String postBody = POST_BODY_TEMPLATE; postBody = postBody.replace("$errorCode", resourceOperationStatus.getErrorCode()); postBody = postBody.replace("$jobId", resourceOperationStatus.getJobId()); postBody = postBody.replace("$operType", resourceOperationStatus.getOperType()); @@ -166,7 +158,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private String getGetStringBody(String serviceId, String operationId, String resourceTemplateUUID) { logger.info("AbstractSdncOperationTask.getGetStringBody begin!"); - String getBody = getBodyTemplate; + String getBody = GET_BODY_TEMPLATE; getBody = getBody.replace("$operationId", operationId); getBody = getBody.replace("$resourceTemplateUUID", resourceTemplateUUID); getBody = getBody.replace("$serviceId", serviceId); @@ -186,35 +178,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { ResourceOperationStatus resourceOperationStatus = getResourceOperationStatusFromXmlString(result); logger.info("AbstractSdncOperationTask.getResourceOperationStatus end!"); return resourceOperationStatus; - - //return requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID); - } - - private String httpGet(String url, HttpGet httpGet) throws RouteException { - logger.info("AbstractSdncOperationTask.httpGet begin!"); - String result = ""; - String errorMsg; - try(CloseableHttpClient httpClient = HttpClients.createDefault()) { - CloseableHttpResponse e = httpClient.execute(httpGet); - result = EntityUtils.toString(e.getEntity()); - logger.info("result = {}", result); - if (e.getStatusLine().getStatusCode() != 200) { - logger.info("exception: fail for status code = {}", e.getStatusLine().getStatusCode()); - throw new RouteException(result, "SERVICE_GET_ERR"); - } - e.close(); - } catch (ClientProtocolException e) { - errorMsg = url + ":httpGetWithJSON connect faild"; - logger.info("exception: GET_CONNECT_FAILD {}", errorMsg); - throwsRouteException(errorMsg, e, "GET_CONNECT_FAILD"); - } catch (IOException e) { - errorMsg = url + ":httpGetWithJSON connect faild"; - logger.info("exception: GET_CONNECT_FAILD {}", errorMsg); - throwsRouteException(errorMsg, e, "GET_CONNECT_FAILD"); - } - - logger.info("AbstractSdncOperationTask.httpGet end!"); - return result; } private ResourceOperationStatus getResourceOperationStatusFromXmlString(String result) { @@ -233,33 +196,30 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return resourceOperationStatus; } - private String getValueByName(String Name, String xml) { - if (!StringUtils.isBlank(xml) && xml.contains(Name)) { - String start = "<" + Name + ">"; - String end = "</" + Name + ">"; + private String getValueByName(String name, String xml) { + if (!StringUtils.isBlank(xml) && xml.contains(name)) { + String start = "<" + name + ">"; + String end = "</" + name + ">"; return xml.substring(xml.indexOf(start), xml.indexOf(end)).replace(start, ""); } return ""; } - protected static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + protected static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); @Override public void execute(DelegateExecution execution) { logger.info("AbstractSdncOperationTask.execute begin!"); - GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(execution); -// updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!"); + GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(); try { Map<String, String> inputs = getInputs(execution); -// updateProgress(execution, null, null, "30", "getGenericResourceApiClient finished!"); sendRestrequestAndHandleResponse(execution, inputs, genericResourceApiClient); execution.setVariable("SDNCA_SuccessIndicator", true); -// updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); } catch (Exception e) { logger.info("exception: AbstractSdncOperationTask.fail!"); logger.error("exception: AbstractSdncOperationTask.fail!:", e); - e.printStackTrace(); + logger.error(e.getStackTrace().toString()); execution.setVariable("SDNCA_SuccessIndicator", false); updateProgress(execution, RequestsDbConstant.Status.ERROR, null, "100", "sendRestrequestAndHandleResponse finished!"); @@ -279,9 +239,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { String key = iterator.next(); inputs.put(key, paras.getString(key)); } -/* if (paras.keys().hasNext()) { - paras.keySet().stream().forEach(key -> inputs.put(key, paras.getString((String) key))); - }*/ } logger.info("AbstractSdncOperationTask.getInputs end!"); return inputs; @@ -321,14 +278,14 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } catch (Exception exception) { logger.info("exception: AbstractSdncOperationTask.updateProgress fail!"); logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception); - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString()); + msoLogger.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString()); } } protected boolean isSend2SdncDirectly() { logger.info("AbstractSdncOperationTask.isSend2SdncDirectly begin!"); - Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties"); + Map<String, String> properties = PropertyConfiguration.getInstance().getProperties(TOPOLOGY_PROPERTIES); if (properties != null) { String sdncIp = properties.get("sdnc-ip"); String sdncPort = properties.get("sdnc-port"); @@ -365,11 +322,10 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return returnPort; } - private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) { + private GenericResourceApi getGenericResourceApiClient() { logger.info("AbstractSdncOperationTask.getGenericResourceApiClient begin!"); -// updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!"); String msbIp = System.getenv().get(ONAP_IP); - int msbPort = DEFAULT_MSB_Port; + int msbPort = DEFAULT_MSB_PORT; Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties"); if (properties != null) { if (StringUtils.isBlank(msbIp) || !isIp(msbIp)) { @@ -380,7 +336,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } String strMsbPort = properties.get("msb-port"); if (StringUtils.isBlank(strMsbPort)) { - strMsbPort = getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_Port)); + strMsbPort = getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_PORT)); } msbPort = Integer.valueOf(strMsbPort); } @@ -402,19 +358,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return vlaue; } } catch (Exception e) { - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); - } - return defaultValue; - } - - private Integer getInteger(DelegateExecution execution, String name, Integer defaultValue) { - Integer vlaue = (Integer) execution.getVariable(name); - try { - if (vlaue != null) { - return vlaue; - } - } catch (Exception e) { - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); + msoLogger.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); } return defaultValue; } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java index 60bc83b0ea..25c85f7394 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java @@ -42,7 +42,7 @@ import java.util.Map; * Created by 10112215 on 2017/9/20. */ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask { - private static final Logger logger = LoggerFactory.getLogger(SdncNetworkTopologyOperationTask.class); + private static final Logger sdncLogger = LoggerFactory.getLogger(SdncNetworkTopologyOperationTask.class); private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; @@ -51,7 +51,7 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, GenericResourceApi genericResourceApiClient) throws Exception { - logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "40", "sendRestrequestAndHandleResponse begin!"); NetworkRpcInputEntityBuilder builder = new NetworkRpcInputEntityBuilder(); RpcNetworkTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); @@ -63,41 +63,41 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); saveOutput(execution, outputEntity); } else { - Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); + send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); - logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse end!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse end!"); } - private void Send2SdncDirectly(String defaulAuth, + private void send2SdncDirectly(String defaulAuth, RpcNetworkTopologyOperationInputEntity inputEntity) throws RouteException { - logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly begin!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); + msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); - logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly end!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly end!"); } - private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws Exception { - logger.info("SdncNetworkTopologyOperationTask.saveOutput begin!"); + private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws RouteException { + sdncLogger.info("SdncNetworkTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { String processKey = getProcessKey(execution); - int errorCode = Integer.valueOf(responseCode); + int errorCode = Integer.parseInt(responseCode); String errorMessage = output.getOutput().getResponseMessage(); WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); execution.setVariable("SDNCA_SuccessIndicator", workflowException); updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), "100", errorMessage); - logger.info("exception: SdncNetworkTopologyOperationTask.saveOutput fail!"); - throw new Exception(""); + sdncLogger.info("exception: SdncNetworkTopologyOperationTask.saveOutput fail!"); + throw new RouteException(); } - - logger.info("SdncNetworkTopologyOperationTask.saveOutput end!"); + + sdncLogger.info("SdncNetworkTopologyOperationTask.saveOutput end!"); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java index 602894475c..130c97e273 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java @@ -42,7 +42,7 @@ import java.util.Map; * Created by 10112215 on 2017/9/26. */ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask { - private static final Logger logger = LoggerFactory.getLogger(SdncServiceTopologyOperationTask.class); + private static final Logger sdncLogger = LoggerFactory.getLogger(SdncServiceTopologyOperationTask.class); private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation"; @@ -51,7 +51,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, GenericResourceApi genericResourceApiClient) throws Exception { - logger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); + sdncLogger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); // updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder(); RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); @@ -63,39 +63,39 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask // updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); saveOutput(execution, outputEntity); } else { - Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); + send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } - logger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse end!"); + sdncLogger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse end!"); } - private void Send2SdncDirectly(String defaulAuth, + private void send2SdncDirectly(String defaulAuth, RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException { - logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly begin!"); + sdncLogger.info("SdncServiceTopologyOperationTask.send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); + msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); - logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly end!"); + sdncLogger.info("SdncServiceTopologyOperationTask.send2SdncDirectly end!"); } private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception { - logger.info("SdncServiceTopologyOperationTask.saveOutput begin!"); + sdncLogger.info("SdncServiceTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { String processKey = getProcessKey(execution); - int errorCode = Integer.valueOf(responseCode); + int errorCode = Integer.parseInt(responseCode); String errorMessage = output.getOutput().getResponseMessage(); WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); execution.setVariable("SDNCA_SuccessIndicator", workflowException); // updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage); - logger.info("exception: SdncServiceTopologyOperationTask.saveOutput fail!"); - throw new Exception(""); + sdncLogger.info("exception: SdncServiceTopologyOperationTask.saveOutput fail!"); + throw new RouteException(); } - logger.info("SdncServiceTopologyOperationTask.saveOutput end!"); + sdncLogger.info("SdncServiceTopologyOperationTask.saveOutput end!"); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java index 49d702d1ee..add87b131e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java @@ -41,7 +41,7 @@ import java.util.Map; public class SdncUnderlayVpnOperationClient { private static final String DEFAULT_MSB_IP = "127.0.0.1"; - private static final int DEFAULT_MSB_Port = 10081; + private static final int DEFAULT_MSB_PORT = 10081; private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); private String serviceId; @@ -54,11 +54,11 @@ public class SdncUnderlayVpnOperationClient { public boolean excute(String msbIp, int msbPort, Map<String, String> inputs, - String serviceId_i, - String operationId_i, + String iServiceID, + String iOperationID, String resourceTemplateUUID_i){ - serviceId = serviceId_i; - operationId = operationId_i; + serviceId = iServiceID; + operationId = iOperationID; resourceTemplateUUID = resourceTemplateUUID_i; GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(msbIp, msbPort); updateProgress(RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!"); @@ -72,15 +72,13 @@ public class SdncUnderlayVpnOperationClient { updateProgress(null, null, "50", "RequestBody build finished!"); RpcNetworkTopologyOperationOutputEntity networkRpcOutputEntiy = null; try { - networkRpcOutputEntiy = genericResourceApiClient.postNetworkTopologyOperation - (HeaderUtil.DefaulAuth ,body).execute().body(); + genericResourceApiClient.postNetworkTopologyOperation(HeaderUtil.DefaulAuth ,body).execute().body(); } catch (Exception e) { logger.debug("Exception: ", e); updateProgress(RequestsDbConstant.Status.ERROR, null, null, "sendRestrequestAndHandleResponse exception:" + e.getMessage()); return false; } updateProgress(null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveOutput(networkRpcOutputEntiy); updateProgress(RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); return true; } @@ -90,7 +88,7 @@ public class SdncUnderlayVpnOperationClient { msbIp = DEFAULT_MSB_IP; } if (msbPort <= 0) { - msbPort = DEFAULT_MSB_Port; + msbPort = DEFAULT_MSB_PORT; } MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort); RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient); @@ -117,7 +115,7 @@ public class SdncUnderlayVpnOperationClient { requestsDB.updateResOperStatus(resourceOperationStatus); } - private void saveOutput(RpcNetworkTopologyOperationOutputEntity output) { - + private void saveOutput() { + // Not implemented. } } |