diff options
author | Max Benjamin <max.benjamin@att.com> | 2019-06-06 17:37:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-06 17:37:59 +0000 |
commit | c4b90365d5c117bc6fd64af421a1468539a8aec3 (patch) | |
tree | 7b81c7516ecb099c880c3d878c1f828f3785fe23 /bpmn/MSOCommonBPMN/src/main/java/org/onap | |
parent | fd0b48f7130300c70395742341a0cec2487bd6fa (diff) | |
parent | 560e84158798cb884de65e3cf33ab657f0e6e6df (diff) |
Merge "Merge remote-tracking branch 'origin/dublin' into 'origin/master'"
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/onap')
9 files changed, 281 insertions, 7 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java index 3b768cbc3b..9e9c4b5cfa 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java @@ -24,11 +24,14 @@ import java.util.Optional; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersHealthCheck; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersQuiesce; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersResumeTraffic; +import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersDistributeTraffic; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersUpgrade; import org.onap.so.bpmn.appc.payload.beans.HealthCheckAction; import org.onap.so.bpmn.appc.payload.beans.QuiesceTrafficAction; import org.onap.so.bpmn.appc.payload.beans.RequestParametersHealthCheck; import org.onap.so.bpmn.appc.payload.beans.ResumeTrafficAction; +import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficAction; +import org.onap.so.bpmn.appc.payload.beans.DistributeTrafficCheckAction; import org.onap.so.bpmn.appc.payload.beans.SnapshotAction; import org.onap.so.bpmn.appc.payload.beans.StartStopAction; import org.onap.so.bpmn.appc.payload.beans.UpgradeAction; @@ -56,6 +59,38 @@ public class PayloadClient { return Optional.of(mapper.writeValueAsString(payloadResult)); } + public static Optional<String> distributeTrafficFormat(Optional<String> payload, String vnfName) + throws JsonProcessingException { + DistributeTrafficAction payloadResult = new DistributeTrafficAction(); + ConfigurationParametersDistributeTraffic configParams = new ConfigurationParametersDistributeTraffic(); + String payloadString = payload.isPresent() ? payload.get() : ""; + String bookName = JsonUtils.getJsonValue(payloadString, "book_name"); + String nodeList = JsonUtils.getJsonValue(payloadString, "node_list"); + String fileParameterContent = JsonUtils.getJsonValue(payloadString, "file_parameter_content"); + configParams.setBookName(bookName); + configParams.setNodeList(nodeList); + configParams.setFileParameterContent(fileParameterContent); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional<String> distributeTrafficCheckFormat(Optional<String> payload, String vnfName) + throws JsonProcessingException { + DistributeTrafficCheckAction payloadResult = new DistributeTrafficCheckAction(); + ConfigurationParametersDistributeTraffic configParams = new ConfigurationParametersDistributeTraffic(); + String payloadString = payload.isPresent() ? payload.get() : ""; + String bookName = JsonUtils.getJsonValue(payloadString, "book_name"); + String nodeList = JsonUtils.getJsonValue(payloadString, "node_list"); + String fileParameterContent = JsonUtils.getJsonValue(payloadString, "file_parameter_content"); + configParams.setBookName(bookName); + configParams.setNodeList(nodeList); + configParams.setFileParameterContent(fileParameterContent); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + public static Optional<String> resumeTrafficFormat(String vnfName) throws JsonProcessingException { ResumeTrafficAction payloadResult = new ResumeTrafficAction(); ConfigurationParametersResumeTraffic configParams = new ConfigurationParametersResumeTraffic(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java new file mode 100644 index 0000000000..a4ffdbfdba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersDistributeTraffic.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"vnf_name", "book_name", "node_list", "file_parameter_content"}) +public class ConfigurationParametersDistributeTraffic { + @JsonProperty("vnf_name") + private String vnfName; + @JsonProperty("book_name") + private String bookName; + @JsonProperty("node_list") + private String nodeList; + @JsonProperty("file_parameter_content") + private String fileParameterContent; + + @JsonProperty("vnf_name") + public String getVnfName() { + return vnfName; + } + + @JsonProperty("vnf_name") + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + @JsonProperty("book_name") + public String getBookName() { + return bookName; + } + + @JsonProperty("book_name") + public void setBookName(String bookName) { + this.bookName = bookName; + } + + @JsonProperty("node_list") + public String getNodeList() { + return nodeList; + } + + @JsonProperty("node_list") + public void setNodeList(String nodeList) { + this.nodeList = nodeList; + } + + @JsonProperty("file_parameter_content") + public String getFileParameterContent() { + return fileParameterContent; + } + + @JsonProperty("file_parameter_content") + public void setFileParameterContent(String fileParameterContent) { + this.fileParameterContent = fileParameterContent; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java new file mode 100644 index 0000000000..9b7856e33f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficAction.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Orange Intellectual Property. 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.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"configuration-parameters"}) +public class DistributeTrafficAction { + + @JsonProperty("configuration-parameters") + private ConfigurationParametersDistributeTraffic configurationParameters; + + @JsonProperty("configuration-parameters") + public ConfigurationParametersDistributeTraffic getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configuration-parameters") + public void setConfigurationParameters(ConfigurationParametersDistributeTraffic configurationParameters) { + this.configurationParameters = configurationParameters; + } +} + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java new file mode 100644 index 0000000000..b9831a90c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/DistributeTrafficCheckAction.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Orange Intellectual Property. 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.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"configuration-parameters"}) +public class DistributeTrafficCheckAction { + + @JsonProperty("configuration-parameters") + private ConfigurationParametersDistributeTraffic configurationParameters; + + @JsonProperty("configuration-parameters") + public ConfigurationParametersDistributeTraffic getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configuration-parameters") + public void setConfigurationParameters(ConfigurationParametersDistributeTraffic configurationParameters) { + this.configurationParameters = configurationParameters; + } +} + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java index 14327a3583..a558057979 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java @@ -55,7 +55,26 @@ public class ModelInfoGenericVnf extends ModelInfoMetadata implements Serializab private String MultiStageDesign; @JsonProperty("created") private String Created; + @JsonProperty("blueprintName") + private String blueprintName; + @JsonProperty("blueprintVersion") + private String blueprintVersion; + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } public String getToscaNodeType() { return ToscaNodeType; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 86f7eeb2cd..2fc84b5dde 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -350,7 +350,9 @@ public class BBInputSetupMapperLayer { public RequestContext mapRequestContext(RequestDetails requestDetails) { RequestContext context = new RequestContext(); - modelMapper.map(requestDetails.getRequestInfo(), context); + if (null != requestDetails.getRequestInfo()) { + modelMapper.map(requestDetails.getRequestInfo(), context); + } org.onap.so.serviceinstancebeans.RequestParameters requestParameters = requestDetails.getRequestParameters(); if (null != requestParameters) { context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType()); @@ -393,7 +395,11 @@ public class BBInputSetupMapperLayer { protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) { OrchestrationContext context = new OrchestrationContext(); - context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback())); + if (requestDetails.getRequestInfo() != null) { + context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback())); + } else { + context.setIsRollbackEnabled(false); + } return context; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java index 86bbead9a4..b76316bf0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -57,8 +57,13 @@ public class ExtractPojosForBB { GenericVnf vnf; switch (key) { case SERVICE_INSTANCE_ID: - result = lookupObjectInList(gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), - value); + if (gBBInput.getCustomer().getServiceSubscription() == null + && gBBInput.getServiceInstance() != null) { + result = Optional.of((T) gBBInput.getServiceInstance()); + } else { + result = lookupObjectInList( + gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), value); + } break; case GENERIC_VNF_ID: serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java index eccd81217f..b97b9ac1ca 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java @@ -68,6 +68,12 @@ public class ApplicationControllerAction { case QuiesceTraffic: appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); break; + case DistributeTraffic: + appCStatus = distributeTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); + break; + case DistributeTrafficCheck: + appCStatus = distributeTrafficCheckAction(msoRequestId, vnfId, payload, vnfName, controllerType); + break; case HealthCheck: appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress, controllerType); break; @@ -91,8 +97,6 @@ public class ApplicationControllerAction { break; case ConfigModify: case ConfigScaleOut: - case DistributeTraffic: - case DistributeTrafficCheck: appCStatus = payloadAction(action, msoRequestId, vnfId, payload, controllerType); break; case UpgradePreCheck: @@ -158,6 +162,29 @@ public class ApplicationControllerAction { return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); } + private Status distributeTrafficAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, + String controllerType) + throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + if (!(payload.isPresent())) { + throw new IllegalArgumentException("Payload is not present for " + Action.DistributeTraffic.toString()); + } + payload = PayloadClient.distributeTrafficFormat(payload, vnfName); + return client.vnfCommand(Action.DistributeTraffic, msoRequestId, vnfId, Optional.empty(), payload, + controllerType); + } + + private Status distributeTrafficCheckAction(String msoRequestId, String vnfId, Optional<String> payload, + String vnfName, String controllerType) + throws JsonProcessingException, IllegalArgumentException, ApplicationControllerOrchestratorException { + if (!(payload.isPresent())) { + throw new IllegalArgumentException( + "Payload is not present for " + Action.DistributeTrafficCheck.toString()); + } + payload = PayloadClient.distributeTrafficCheckFormat(payload, vnfName); + return client.vnfCommand(Action.DistributeTrafficCheck, msoRequestId, vnfId, Optional.empty(), payload, + controllerType); + } + private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName, String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException { Optional<String> payload = PayloadClient.resumeTrafficFormat(vnfName); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 6bfa67502d..5498b5be31 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -34,6 +34,7 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOu import org.onap.so.client.PreconditionFailedException; import org.onap.so.client.RestPropertiesLoader; import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,6 +59,12 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; + /** + * indicate exception thrown. + */ + private static final String EXCEPTION = "Exception"; + + private final AtomicReference<String> cdsResponse = new AtomicReference<>(); @Autowired @@ -132,7 +139,15 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { } if (cdsResponse != null) { - execution.setVariable("CDSStatus", cdsResponse.get()); + String cdsResponseStatus = cdsResponse.get(); + execution.setVariable("CDSStatus", cdsResponseStatus); + + /** + * throw CDS failed exception. + */ + if (cdsResponseStatus != SUCCESS) { + throw new BadResponseException("CDS call failed with status: " + cdsResponseStatus); + } } } catch (Exception ex) { @@ -177,6 +192,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { public void onError(Throwable t) { Status status = Status.fromThrowable(t); logger.error("Failed processing blueprint {}", status, t); + cdsResponse.set(EXCEPTION); } } |