From: Kalpesh Chaniyara Date: Tue, 15 Aug 2017 18:10:34 +0000 (+0530) Subject: Initial commit for Sequence Generator X-Git-Tag: v1.2.0~128 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=appc.git;a=commitdiff_plain;h=5b7590935559fe9e286a703dc662a60b47b7ed1a Initial commit for Sequence Generator Added sequence generator for start and stop action with dependency model Removed java check style from json files from license maven plugin JIRA Issues : APPC-33,APPC-106 Issue-Id : APPC-106 Change-Id: I7f12d39b705d77d559790a10b914b8108f5faa5e Signed-off-by: Kalpesh Chaniyara --- diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml b/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml new file mode 100644 index 000000000..415ae4e33 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/pom.xml @@ -0,0 +1,193 @@ + + + 4.0.0 + + org.openecomp.appc + appc-sequence-generator + 1.1.0-SNAPSHOT + + appc-sequence-generator-bundle + appc-sequence-generator-bundle + bundle + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + appc-sequence-generator-bundle + + org.openecomp.appc.seqgen.* + org.openecomp.appc.domainmodel.lcm,*;resolution:=optional + * + true + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + config + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${jmxGeneratorPath} + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + ${salGeneratorPath} + + + true + + + + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + ${odl.sal.api.gen.plugin.version} + jar + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${odl.yang.jmx.generator.version} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/initial/appc-sequence-generator.xml + xml + config + + + + + + + + + + + + junit + junit + test + + + org.opendaylight.controller + config-api + + + org.opendaylight.controller + sal-binding-config + + + org.opendaylight.controller + sal-binding-api + + + org.opendaylight.controller + sal-common-util + + + sal-test-model + org.opendaylight.controller + test + + + sal-rest-connector + org.opendaylight.netconf + test + + + org.opendaylight.controller + sal-binding-broker-impl + test + + + org.opendaylight.controller + sal-binding-broker-impl + tests + ${odl.mdsal.version} + test-jar + test + + + org.openecomp.appc + appc-dg-dependency-model + ${project.version} + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + org.openecomp.sdnc.core + sli-common + + + org.openecomp.sdnc.core + sli-provider + + + org.openecomp.appc + appc-dg-domain-model-lib + ${project.version} + + + org.openecomp.appc + domain-model-lib + ${project.version} + + + + org.openecomp.appc + appc-sequence-generator-model + ${project.version} + + + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModule.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModule.java new file mode 100644 index 000000000..7fa1dcb4e --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModule.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.impl.rev170706; + +import org.openecomp.appc.seqgen.provider.SequenceGeneratorProvider; + +public class SequenceGeneratorModule extends org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.impl.rev170706.AbstractSequenceGeneratorModule { + public SequenceGeneratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public SequenceGeneratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.impl.rev170706.SequenceGeneratorModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + final SequenceGeneratorProvider provider = new SequenceGeneratorProvider(getDataBrokerDependency(), getNotificationServiceDependency(), getRpcRegistryDependency()); + return new AutoCloseable() { + + @Override + public void close() throws Exception { + provider.close(); + } + }; + } + +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModuleFactory.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModuleFactory.java new file mode 100644 index 000000000..3ebba2076 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModuleFactory.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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========================================================= + */ + +/* +* Generated file +* +* Generated from: yang module name: sequence-generator-impl yang module local name: sequence-generator-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Aug 10 15:48:17 IST 2017 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.impl.rev170706; +public class SequenceGeneratorModuleFactory extends org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.impl.rev170706.AbstractSequenceGeneratorModuleFactory { + +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/SequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/SequenceGenerator.java new file mode 100644 index 000000000..0eba668ef --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/SequenceGenerator.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen; + + +import org.openecomp.appc.dg.objects.VnfcFlowModel; +import org.openecomp.appc.exceptions.APPCException; +import org.openecomp.appc.seqgen.objects.SequenceGeneratorInput; +import org.openecomp.appc.seqgen.objects.Transaction; + +import java.util.List; +import java.util.Map; + +/** + * Sequence Generator API generates runtime sequence for LCM operations execution + */ +public interface SequenceGenerator { + /** + * + * @param input Sequence Generator Input containing request info, vnf capabilites and tunable parameters + * @return returns runtime sequence for LCM operation execution + * @throws APPCException + */ + List generateSequence(SequenceGeneratorInput input) throws APPCException; +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/SequenceGeneratorPlugin.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/SequenceGeneratorPlugin.java new file mode 100644 index 000000000..2264751cf --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/SequenceGeneratorPlugin.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.dgplugin; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +import java.util.Map; + +public interface SequenceGeneratorPlugin extends SvcLogicJavaPlugin{ + + void generateSequence(Map params, SvcLogicContext context); +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java new file mode 100644 index 000000000..6671203e7 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java @@ -0,0 +1,243 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.dgplugin.impl; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.dg.objects.*; +import org.openecomp.appc.domainmodel.Vnf; +import org.openecomp.appc.domainmodel.Vnfc; +import org.openecomp.appc.domainmodel.Vserver; +import org.openecomp.appc.domainmodel.lcm.VNFOperation; +import org.openecomp.appc.exceptions.APPCException; +import org.openecomp.appc.seqgen.SequenceGenerator; +import org.openecomp.appc.seqgen.dgplugin.SequenceGeneratorPlugin; +import org.openecomp.appc.seqgen.impl.SequenceGeneratorFactory; +import org.openecomp.appc.seqgen.objects.Constants; +import org.openecomp.appc.seqgen.objects.SequenceGeneratorInput; +import org.openecomp.appc.seqgen.objects.Transaction; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import java.io.IOException; +import java.util.*; + +public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(SequenceGeneratorPluginImpl.class); + + @Override + public void generateSequence(Map params, SvcLogicContext context) { + ObjectMapper objectMapper = new ObjectMapper(); + String inputJSON = context.getAttribute("inputJSON"); + logger.debug("Input to Sequence Generator " + inputJSON); + try { + SequenceGeneratorInput sequenceGeneratorInput = buildSequenceGeneratorInput(inputJSON); + List sequence = generateSequence(sequenceGeneratorInput); + String output = objectMapper.writeValueAsString(sequence); + logger.debug("Sequence Generator Output " + output); + + context.setAttribute("output", output); + } catch (Exception e) { + logger.error("Error generating sequence", e); + context.setAttribute("error-code", "401"); + context.setAttribute("error-message", "Error generating sequence " + e.getMessage()); + } + } + + private SequenceGeneratorInput buildSequenceGeneratorInput(String inputJson) throws IOException, APPCException { + ObjectMapper objectMapper = new ObjectMapper(); + SequenceGeneratorInput sequenceGeneratorInput ; + objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); + objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + sequenceGeneratorInput = objectMapper.readValue(inputJson, SequenceGeneratorInput.class); + + InventoryModel inventoryModel = buildInventoryModel(inputJson); + sequenceGeneratorInput.setInventoryModel(inventoryModel); + + VnfcDependencyModel dependencyModel = buildDependencyModel(inputJson); + sequenceGeneratorInput.setDependencyModel(dependencyModel); + + return sequenceGeneratorInput; + } + private List generateSequence(SequenceGeneratorInput sequenceGeneratorInput) throws APPCException { + if (sequenceGeneratorInput.getRequestInfo() == null) { + throw new APPCException("Request info is not provided in the input"); + } + String action = sequenceGeneratorInput.getRequestInfo().getAction(); + VNFOperation operation = VNFOperation.findByString(action); + if (operation == null) { + throw new APPCException("Invalid Action " + action); + } + SequenceGenerator sequenceGenerator = SequenceGeneratorFactory.getInstance().createSequenceGenerator(operation); + return sequenceGenerator.generateSequence(sequenceGeneratorInput); + } + + // Dependency model is an optional attribute and may contain null values + private VnfcDependencyModel buildDependencyModel(String inputJson) throws IOException, APPCException { + Set> dependency = new HashSet<>(); + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + JsonNode rootNode = objectMapper.readTree(inputJson); + JsonNode vnfcs = getVnfcsNode(rootNode); + if (vnfcs != null) { + for (JsonNode vnfcNode : vnfcs) { + String vnfcType = readVnfcType(vnfcNode); + String mandatory = readMandatory(vnfcNode); + String resilience = readResilience(vnfcNode); + Vnfc vnfc = new Vnfc(vnfcType, resilience, null, Boolean.parseBoolean(mandatory)); + Node currentNode = getNode(dependency, vnfcType); + if (currentNode == null) { + currentNode = new Node<>(vnfc); + dependency.add(currentNode); + } else { + currentNode.getChild().setMandatory(Boolean.valueOf(mandatory)); + currentNode.getChild().setResilienceType(resilience); + } + JsonNode parents = vnfcNode.get("parents"); + for (JsonNode parent : parents) { + String parentVnfcType = parent.asText(); + Node parentNode = getNode(dependency, parentVnfcType); + if (parentNode != null) { + currentNode.addParent(parentNode.getChild()); + } else { + Vnfc parentVnfc = new Vnfc(parentVnfcType, null, null, false); + parentNode = new Node<>(parentVnfc); + currentNode.addParent(parentVnfc); + dependency.add(parentNode); + } + } + + } + return new VnfcDependencyModel(dependency); + } + return null; + } + + private String readResilience(JsonNode vnfcNode) { + String resilience = null; + if (vnfcNode.get("resilience") != null) { + resilience = vnfcNode.get("resilience").asText(); + } + return resilience; + } + + private String readMandatory(JsonNode vnfcNode) { + String mandatory ; + JsonNode mandatoryNode = vnfcNode.get("mandatory"); + if (mandatoryNode == null) { + mandatory = "false"; + } else { + mandatory = mandatoryNode.asText(); + } + return mandatory; + } + + private String readVnfcType(JsonNode vnfcNode) throws APPCException { + JsonNode vnfcTypeNode = vnfcNode.get(Constants.VNFC_TYPE); + if (vnfcTypeNode == null) { + throw new APPCException("vnfc-type is not available in dependency info"); + } + return vnfcTypeNode.asText(); + } + + private JsonNode getVnfcsNode(JsonNode rootNode) { + JsonNode dependencyInfo = rootNode.get("dependency-info"); + JsonNode vnfcs = null; + if (dependencyInfo != null) { + vnfcs = dependencyInfo.get("vnfcs"); + } + return vnfcs; + } + + private Node getNode(Set> dependency, String vnfcType) { + for (Node node : dependency) { + if (node.getChild().getVnfcType().equals(vnfcType)) { + return node; + } + } + return null; + } + + private InventoryModel buildInventoryModel(String inputJson) throws IOException, APPCException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + JsonNode jsonNode = objectMapper.readTree(inputJson); + JsonNode inventoryInfo = jsonNode.get("inventory-info"); + if (inventoryInfo == null) { + throw new APPCException("inventory-info is not provided in the input"); + } + JsonNode vnfInfo = inventoryInfo.get("vnf-info"); + if (vnfInfo == null) { + throw new APPCException("vnf-info is not provided in the input"); + } + + String vnfId = vnfInfo.get("vnf-id").asText(); + String vnfType = vnfInfo.get("vnf-type").asText(); + String vnfVersion = vnfInfo.get("vnf-version").asText(); + + Vnf vnf = new Vnf(vnfId, vnfType, vnfVersion); + + JsonNode vms = vnfInfo.get("vm"); + + Map> vfcs = new HashMap<>(); + for (JsonNode vm : vms) { + if(vm.get("vserver-id")== null){ + throw new APPCException("vserver-id not found "); + } + String vserverId = vm.get("vserver-id").asText(); + Vserver vserver = new Vserver(null, null, vserverId, null, null); + JsonNode vnfc = vm.get("vnfc"); + if (vnfc.get("vnfc-name") == null) { + throw new APPCException("vnfc-name not found for vserver " + vserverId); + } + String vnfcName = vnfc.get("vnfc-name").asText(); + if (vnfc.get("vnfc-type") == null) { + throw new APPCException("vnfc-type not found for vserver " + vserverId); + } + String vnfcType = vnfc.get("vnfc-type").asText(); + if (StringUtils.isEmpty(vnfcType)) { + throw new APPCException("vserver " + vserverId + " is not associated with any vnfc"); + } + Vnfc vfc = new Vnfc(vnfcType, null, vnfcName); + List vServers = vfcs.get(vfc); + if (vServers == null) { + vServers = new LinkedList<>(); + vfcs.put(vfc, vServers); + } + vServers.add(vserver); + } + + for (Map.Entry> entry : vfcs.entrySet()) { + Vnfc vnfc = entry.getKey(); + List vServers = vfcs.get(vnfc); + vnfc.addVms(vServers); + vnf.addVnfc(vnfc); + } + + return new InventoryModel(vnf); + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/SequenceGeneratorFactory.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/SequenceGeneratorFactory.java new file mode 100644 index 000000000..5d41fffe1 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/SequenceGeneratorFactory.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.impl; + +import org.openecomp.appc.domainmodel.lcm.VNFOperation; +import org.openecomp.appc.exceptions.APPCException; +import org.openecomp.appc.seqgen.SequenceGenerator; + +public class SequenceGeneratorFactory { + + private static class ReferenceHolder { + private static SequenceGeneratorFactory instance = new SequenceGeneratorFactory(); + private ReferenceHolder(){ + + } + } + + private SequenceGeneratorFactory(){ + + } + + public static SequenceGeneratorFactory getInstance(){ + return ReferenceHolder.instance; + } + + public SequenceGenerator createSequenceGenerator(VNFOperation operation) throws APPCException { + switch (operation){ + case Start: + return new StartSequenceGenerator(); + case Stop: + return new StopSequenceGenerator(); + default: + throw new APPCException("Sequence Generator does not support operation " + operation.name()); + } + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java new file mode 100644 index 000000000..acdeddd30 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java @@ -0,0 +1,291 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.impl; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.dg.flowbuilder.FlowBuilder; +import org.openecomp.appc.dg.flowbuilder.impl.FlowBuilderFactory; +import org.openecomp.appc.dg.objects.FlowStrategies; +import org.openecomp.appc.dg.objects.InventoryModel; +import org.openecomp.appc.dg.objects.VnfcDependencyModel; +import org.openecomp.appc.dg.objects.VnfcFlowModel; +import org.openecomp.appc.domainmodel.Vnfc; +import org.openecomp.appc.domainmodel.Vserver; +import org.openecomp.appc.exceptions.APPCException; +import org.openecomp.appc.seqgen.SequenceGenerator; +import org.openecomp.appc.seqgen.objects.*; + +import java.util.*; + +import static org.openecomp.appc.seqgen.objects.Constants.*; + +public class StartSequenceGenerator implements SequenceGenerator { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(StartSequenceGenerator.class); + + private List generateSequenceWithOutDependency(SequenceGeneratorInput input) throws APPCException { + + List transactionList = new LinkedList<>(); + Integer transactionId = 1; + List invVnfcList = input.getInventoryModel().getVnf().getVnfcs(); + boolean singleTransaction=checkSingleTransaction(invVnfcList); + for (Vnfc vnfc : invVnfcList) { + List vms = vnfc.getVserverList(); + List transactionIds = new LinkedList<>(); + for (Vserver vm : vms) { + Transaction transaction = new Transaction(); + transaction.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transaction.setAction(Action.START.getActionType()); + transaction.setActionLevel(ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transaction.setActionIdentifier(actionIdentifier); + transaction.setPayload(input.getRequestInfo().getPayload()); + if(!singleTransaction){ + updateResponse(transaction); + } + + transactionList.add(transaction); + } + } + return transactionList; + } + + private boolean checkSingleTransaction(List invVnfcList) { + int vServerCount=0; + for(Vnfc vnfc : invVnfcList) { + List vms = vnfc.getVserverList(); + vServerCount=vServerCount+vms.size(); + } + return vServerCount <= 1; + } + + private void updateResponse(Transaction transaction) { + Response ignoreResponse = new Response(); + ignoreResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map ignoreAction = new HashMap<>(); + ignoreAction.put(ResponseAction.IGNORE.getAction(), Boolean.TRUE.toString()); + ignoreResponse.setResponseAction(ignoreAction); + transaction.addResponse(ignoreResponse); + } + + private List generateSequenceWithDependencyModel(VnfcFlowModel flowModel, SequenceGeneratorInput input) throws APPCException { + Integer waitTime = readWaitTime(input); + Integer retryCount = readRetryCount(input); + List transactionList = new LinkedList<>(); + Integer transactionId = 1; + Iterator> itr = flowModel.getModelIterator(); + while (itr.hasNext()) { + List vnfcs = itr.next(); + for (Vnfc vnfc : vnfcs) { + List vms = vnfc.getVserverList(); + List transactionIds = new LinkedList<>(); + transactionId = updateTransactions(input, transactionList, transactionId, vms, transactionIds); + + boolean startApplicationSupported = readApplicationStartCapability(input); + transactionId = checkAndUpdateStartApplication(input, transactionList, transactionId, vnfc, transactionIds, startApplicationSupported); + + boolean healthCheckSupported = readHealthCheckCapabilites(input.getCapability()); + transactionId = checkAndUpdateHealthCheck(input, waitTime, retryCount, transactionList, transactionId, vnfc, healthCheckSupported); + } + } + return transactionList; + } + + private Integer checkAndUpdateHealthCheck(SequenceGeneratorInput input, Integer waitTime, Integer retryCount, List transactionList, Integer transactionId, Vnfc vnfc, boolean healthCheckSupported) { + if (healthCheckSupported) { + Transaction healthCheckTransaction = new Transaction(); + healthCheckTransaction.setTransactionId(transactionId++); + healthCheckTransaction.setAction(Action.HEALTH_CHECK.getActionType()); + healthCheckTransaction.setActionLevel(ActionLevel.VNFC.getAction()); + ActionIdentifier healthCheckActionIdentifier = new ActionIdentifier(); + healthCheckActionIdentifier.setVnfcName(vnfc.getVnfcName()); + healthCheckTransaction.setActionIdentifier(healthCheckActionIdentifier); + healthCheckTransaction.setPayload(input.getRequestInfo().getPayload()); + + Response retryResponse = new Response(); + retryResponse.setResponseMessage(ResponseMessage.UNHEALTHY.getResponse()); + Map retryAction = new HashMap<>(); + retryAction.put(ResponseAction.RETRY.getAction(), retryCount.toString()); + retryAction.put(ResponseAction.WAIT.getAction(), waitTime.toString()); + retryResponse.setResponseAction(retryAction); + healthCheckTransaction.addResponse(retryResponse); + + Response healthyResponse = new Response(); + healthyResponse.setResponseMessage(ResponseMessage.HEALTHY.getResponse()); + Map healthyAction = new HashMap<>(); + healthyAction.put(ResponseAction.CONTINUE.getAction().toLowerCase(), Boolean.TRUE.toString()); + healthyResponse.setResponseAction(healthyAction); + healthCheckTransaction.addResponse(healthyResponse); + + Response failureResponse = new Response(); + failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map failureResonseAction = new HashMap<>(); + failureResonseAction.put(ResponseAction.STOP.getAction(), Boolean.TRUE.toString()); + failureResponse.setResponseAction(failureResonseAction); + healthCheckTransaction.addResponse(failureResponse); + transactionList.add(healthCheckTransaction); + } + return transactionId; + } + + private Integer checkAndUpdateStartApplication(SequenceGeneratorInput input, List transactionList, Integer transactionId, Vnfc vnfc, List transactionIds, boolean startApplicationSupported) { + if (startApplicationSupported) { + Transaction startAppTransaction = new Transaction(); + startAppTransaction.setTransactionId(transactionId++); + startAppTransaction.setAction(Action.START_APPLICATION.getActionType()); + startAppTransaction.setActionLevel(ActionLevel.VNFC.getAction()); + ActionIdentifier startActionIdentifier = new ActionIdentifier(); + startActionIdentifier.setVnfcName(vnfc.getVnfcName()); + startAppTransaction.setActionIdentifier(startActionIdentifier); + startAppTransaction.setPayload(input.getRequestInfo().getPayload()); + + List preCheckOptions = new LinkedList<>(); + for (Integer vmTransactionId : transactionIds) { + setPreCheckOptions(preCheckOptions, vmTransactionId); + } + startAppTransaction.setPreCheckOperator(PreCheckOperator.ANY.getOperator()); + startAppTransaction.setPrecheckOptions(preCheckOptions); + transactionList.add(startAppTransaction); + } + return transactionId; + } + + private Integer updateTransactions(SequenceGeneratorInput input, List transactionList, Integer transactionId, List vms, List transactionIds) { + for (Vserver vm : vms) { + Transaction transaction = new Transaction(); + transaction.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transaction.setAction(Action.START.getActionType()); + transaction.setActionLevel(ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transaction.setActionIdentifier(actionIdentifier); + transaction.setPayload(input.getRequestInfo().getPayload()); + + updateResponse(transaction); + transactionList.add(transaction); + } + return transactionId; + } + + private void setPreCheckOptions(List preCheckOptions, Integer vmTransactionId) { + PreCheckOption option = new PreCheckOption(); + option.setPreTransactionId(vmTransactionId); + option.setParamName("status"); + option.setParamValue("success"); + preCheckOptions.add(option); + } + + @Override + public List generateSequence(SequenceGeneratorInput input) throws APPCException { + if(input.getRequestInfo().getActionLevel().equals(ActionLevel.VM.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VNFC.getAction())|| + input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VF_MODULE.getAction())) { + if (input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction()) && input.getDependencyModel() != null) { + FlowStrategies flowStrategy = readStartFlowStrategy(input); + VnfcFlowModel flowModel = buildFlowModel(input.getInventoryModel() + , input.getDependencyModel(), flowStrategy); + logger.debug("Flow Model " + flowModel); + return generateSequenceWithDependencyModel(flowModel, input); + } else { + logger.info("Generating sequence without dependency model"); + return generateSequenceWithOutDependency(input); + } + }throw new APPCException("Invalid action level "+input.getRequestInfo().getActionLevel()); + } + + private VnfcFlowModel buildFlowModel(InventoryModel inventoryModel, VnfcDependencyModel dependencyModel, FlowStrategies flowStrategy) throws APPCException { + FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder(flowStrategy); + if (flowBuilder == null) { + throw new APPCException("Flow Strategy not supported " + flowStrategy); + } + return flowBuilder.buildFlowModel(dependencyModel, inventoryModel); + } + + private FlowStrategies readStartFlowStrategy(SequenceGeneratorInput sequenceGeneratorInput) throws APPCException { + Map tunableParams = sequenceGeneratorInput.getTunableParams(); + FlowStrategies strategy; + String strategyStr = null; + if (tunableParams != null) { + strategyStr = tunableParams.get(Constants.STRATEGY); + if (StringUtils.isBlank(strategyStr)) { + return FlowStrategies.FORWARD; + } + + strategy = FlowStrategies.findByString(strategyStr); + if (strategy != null) { + return strategy; + } + } + throw new APPCException("Invalid Strategy " + strategyStr); + } + + private boolean readHealthCheckCapabilites(Map> capabilities) { + if (capabilities != null) { + List vnfcCapabilities = capabilities.get(CapabilityLevel.VNFC.getLevel()); + if (vnfcCapabilities != null) + return vnfcCapabilities.stream() + .anyMatch(p -> Capabilties.HEALTH_CHECK.getCapability().equalsIgnoreCase(p)); + } + return false; + } + + private boolean readApplicationStartCapability(SequenceGeneratorInput input) { + Map> capability = input.getCapability(); + if (capability != null) { + List vnfcCapabilities = capability.get(CapabilityLevel.VNFC.getLevel()); + if (vnfcCapabilities != null) + return vnfcCapabilities.stream().anyMatch(p -> Capabilties.START_APPLICATION.getCapability().equalsIgnoreCase(p)); + } + return false; + } + + private Integer readRetryCount(SequenceGeneratorInput input) throws APPCException { + String paramValStr = input.getTunableParams().get(RETRY_COUNT); + if (StringUtils.isEmpty(paramValStr)) { + return RETRY_COUNT_VALUE; + } + try { + return Integer.parseInt(paramValStr); + } catch (NumberFormatException e) { + String message = "Invalid Number for Retry Count " + paramValStr; + logger.error(message, e); + throw new APPCException(message); + } + } + + private Integer readWaitTime(SequenceGeneratorInput input) throws APPCException { + String paramValStr = input.getTunableParams().get(WAIT_TIME); + if (StringUtils.isEmpty(paramValStr)) { + return WAIT_TIME_VALUE; + } + try { + return Integer.parseInt(paramValStr); + } catch (NumberFormatException e) { + String message = "Invalid Number for Wait Time " + paramValStr; + logger.error(message, e); + throw new APPCException(message); + } + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java new file mode 100644 index 000000000..6dec0e61f --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.impl; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.dg.flowbuilder.FlowBuilder; +import org.openecomp.appc.dg.flowbuilder.impl.FlowBuilderFactory; +import org.openecomp.appc.dg.objects.FlowStrategies; +import org.openecomp.appc.dg.objects.InventoryModel; +import org.openecomp.appc.dg.objects.VnfcDependencyModel; +import org.openecomp.appc.dg.objects.VnfcFlowModel; +import org.openecomp.appc.domainmodel.Vnfc; +import org.openecomp.appc.domainmodel.Vserver; +import org.openecomp.appc.exceptions.APPCException; +import org.openecomp.appc.seqgen.SequenceGenerator; +import org.openecomp.appc.seqgen.objects.*; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.*; + +import static org.openecomp.appc.seqgen.objects.Constants.*; + +public class StopSequenceGenerator implements SequenceGenerator { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(StartSequenceGenerator.class); + + @Override + public List generateSequence(SequenceGeneratorInput input) throws APPCException { + if(input.getRequestInfo().getActionLevel().equals(ActionLevel.VM.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VNFC.getAction())|| + input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VF_MODULE.getAction())) { + if (input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction()) && input.getDependencyModel() != null) { + FlowStrategies flowStrategy = readStopFlowStrategy(input); + VnfcFlowModel flowModel = buildFlowModel(input.getInventoryModel() + , input.getDependencyModel(), flowStrategy); + logger.debug("Flow Model " + flowModel); + return generateSequenceWithDependencyModel(flowModel, input); + } else { + logger.info("Generating sequence without dependency model"); + return generateSequenceWithOutDependency(input); + } + }throw new APPCException("Invalid action level "+input.getRequestInfo().getActionLevel()); + + } + private List generateSequenceWithOutDependency(SequenceGeneratorInput input){ + List transactionList = new LinkedList<>(); + Integer transactionId = 1; + List transactionIds = new LinkedList<>(); + List invVnfcList = input.getInventoryModel().getVnf().getVnfcs(); + boolean singleTransaction=checkSingleTransaction(invVnfcList); + for (Vnfc vnfc : invVnfcList) { + List vms = vnfc.getVserverList(); + for(Vserver vm:vms){ + Transaction transaction = new Transaction(); + transaction.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transaction.setAction(Action.STOP.getActionType()); + transaction.setActionLevel(ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transaction.setActionIdentifier(actionIdentifier); + transaction.setPayload(input.getRequestInfo().getPayload()); + if(!singleTransaction){ + updateStopResponse(transaction); + } + transactionList.add(transaction); + } + } + return transactionList; + } + + private void updateStopResponse(Transaction transaction) { + Response failureResponse = new Response(); + failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map failureAction = new HashMap<>(); + failureAction.put(ResponseAction.IGNORE.getAction(),Boolean.TRUE.toString()); + failureResponse.setResponseAction(failureAction); + transaction.addResponse(failureResponse); + } + private boolean checkSingleTransaction(List invVnfcList) { + int vServerCount=0; + for(Vnfc vnfc : invVnfcList) { + List vms = vnfc.getVserverList(); + vServerCount=vServerCount+vms.size(); + } + return vServerCount <= 1; + } + + private List generateSequenceWithDependencyModel(VnfcFlowModel flowModel,SequenceGeneratorInput input){ + List transactionList = new LinkedList<>(); + Integer transactionId = 1; + List transactionIds = new LinkedList<>(); + Iterator> itr = flowModel.getModelIterator(); + while (itr.hasNext()){ + List vnfcs = itr.next(); + for(Vnfc vnfc:vnfcs){ + boolean stopApplicationSupported = readApplicationStopCapability(input); + if(stopApplicationSupported){ + Transaction stopAppTransaction = new Transaction(); + stopAppTransaction.setTransactionId(transactionId++); + stopAppTransaction.setAction(Action.STOP_APPLICATION.getActionType()); + stopAppTransaction.setActionLevel(ActionLevel.VNFC.getAction()); + ActionIdentifier stopActionIdentifier = new ActionIdentifier(); + stopActionIdentifier .setVnfcName(vnfc.getVnfcName()); + stopAppTransaction.setActionIdentifier(stopActionIdentifier ); + stopAppTransaction.setPayload(input.getRequestInfo().getPayload()); + updateStopResponse(stopAppTransaction); + transactionList.add(stopAppTransaction); + } + List vms = vnfc.getVserverList(); + for(Vserver vm:vms){ + Transaction transaction = new Transaction(); + transaction.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transaction.setAction(Action.STOP.getActionType()); + transaction.setActionLevel(ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transaction.setActionIdentifier(actionIdentifier); + transaction.setPayload(input.getRequestInfo().getPayload()); + + updateStopResponse(transaction); + transactionList.add(transaction); + } + } + } + return transactionList; + } + + private VnfcFlowModel buildFlowModel(InventoryModel inventoryModel, VnfcDependencyModel dependencyModel, FlowStrategies flowStrategy) throws APPCException { + FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder(flowStrategy); + if (flowBuilder == null) { + throw new APPCException("Flow Strategy not supported " + flowStrategy); + } + return flowBuilder.buildFlowModel(dependencyModel, inventoryModel); + } + + private FlowStrategies readStopFlowStrategy(SequenceGeneratorInput sequenceGeneratorInput) throws APPCException { + Map tunableParams = sequenceGeneratorInput.getTunableParams(); + FlowStrategies strategy; + String strategyStr = null; + if (tunableParams != null) { + strategyStr = tunableParams.get(Constants.STRATEGY); + if (StringUtils.isBlank(strategyStr)) { + return FlowStrategies.REVERSE; + } + strategy = FlowStrategies.findByString(strategyStr); + if (strategy != null) { + return strategy; + } + } + throw new APPCException("Invalid Strategy " + strategyStr); + } + private boolean readApplicationStopCapability(SequenceGeneratorInput input) { + Map> capability = input.getCapability(); + if(capability!= null){ + List vnfcCapabilities = capability.get(Constants.CapabilityLevel.VNFC.getLevel()); + if(vnfcCapabilities!=null) + return vnfcCapabilities.stream().anyMatch(p -> Capabilties.STOP_APPLICATION.getCapability().equalsIgnoreCase(p)); + } + return false; + } + + +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/ActionIdentifier.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/ActionIdentifier.java new file mode 100644 index 000000000..ae3ed942d --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/ActionIdentifier.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ActionIdentifier { + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vnfc-name") + private String vnfcName; + + @JsonProperty("vserver-id") + private String vServerId; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfcName() { + return vnfcName; + } + + public void setVnfcName(String vnfcName) { + this.vnfcName = vnfcName; + } + + public String getvServerId() { + return vServerId; + } + + public void setvServerId(String vServerId) { + this.vServerId = vServerId; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Constants.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Constants.java new file mode 100644 index 000000000..354145f02 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Constants.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +public class Constants { + public static final String RETRY_COUNT = "retry-count"; + public static final String WAIT_TIME = "wait-time"; + public static final Integer WAIT_TIME_VALUE = 60; + public static final Integer RETRY_COUNT_VALUE = 4; + public static final String STRATEGY = "strategy"; + public static final String VNFC_TYPE = "vnfc-type"; + + public enum CapabilityLevel{ + VNF("vnf"),VNFC("vnfc"),VM("vm"); + private String level; + CapabilityLevel(String level) { + this.level=level; + } + + public String getLevel() { + return level; + } + } + + public enum Capabilties{ + START_APPLICATION("StartApplication"),HEALTH_CHECK("HealthCheck"),STOP_APPLICATION("StopApplication"); + private String capability; + + Capabilties(String capability) { + this.capability=capability; + } + public String getCapability(){ + return capability; + } + } + + public enum ResponseMessage{ + HEALTHY("healthy"),UNHEALTHY("unhealthy"),SUCCESS("success"),FAILURE("failure"); + + public String getResponse() { + return response; + } + + private String response; + ResponseMessage(String response){ + this.response=response; + } + + } + + public enum ResponseAction{ + STOP("stop"),RETRY("retry"),IGNORE("ignore"),WAIT("wait"),CONTINUE("Continue"); + + ResponseAction(String action) { + this.action=action; + } + + private String action; + + public String getAction() { + return action; + } + + } + + public enum Action{ + START("Start"),START_APPLICATION("StartApplication"),HEALTH_CHECK("HealthCheck"),STOP_APPLICATION("StopApplication"),STOP("Stop"); + + Action(String actionType) { + this.actionType=actionType; + } + + public String getActionType() { + return actionType; + } + + private String actionType; + + } + public enum ActionLevel{ + VM("vm"),VNFC("vnfc"),VNF("vnf"),VF_MODULE("vf-module"); + private String action; + ActionLevel(String action){ + this.action=action; + } + public String getAction() { + return action; + } + } + + public enum PreCheckOperator{ + ANY("any"),ALL("all"); + + PreCheckOperator(String operator){ + this.operator=operator; + } + + public String getOperator() { + return operator; + } + + private String operator; + + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/PreCheckOption.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/PreCheckOption.java new file mode 100644 index 000000000..860fac7e2 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/PreCheckOption.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class PreCheckOption { + + @JsonProperty("pre-transactionID") + private Integer preTransactionId; + + @JsonProperty("param-name") + private String paramName; + + @JsonProperty("param-value") + private String paramValue; + + private String rule; + + + public Integer getPreTransactionId() { + return preTransactionId; + } + + public void setPreTransactionId(Integer preTransactionId) { + this.preTransactionId = preTransactionId; + } + + public String getParamName() { + return paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamValue() { + return paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public String getRule() { + return rule; + } + + public void setRule(String rule) { + this.rule = rule; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfo.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfo.java new file mode 100644 index 000000000..697e13e3b --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfo.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RequestInfo { + + private String action; + + @JsonProperty("action-level") + private String actionLevel; + + @JsonProperty("action-identifier") + private ActionIdentifier actionIdentifier; + + private String payload; + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getActionLevel() { + return actionLevel; + } + + public void setActionLevel(String actionLevel) { + this.actionLevel = actionLevel; + } + + public ActionIdentifier getActionIdentifier() { + return actionIdentifier; + } + + public void setActionIdentifier(ActionIdentifier actionIdentifier) { + this.actionIdentifier = actionIdentifier; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfoBuilder.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfoBuilder.java new file mode 100644 index 000000000..70d4e9a0c --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfoBuilder.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +public class RequestInfoBuilder { + + private String action; + + private String actionLevel; + + private ActionIdentifier actionIdentifier; + + private String payload; + + public RequestInfoBuilder actionIdentifier(){ + this.actionIdentifier = new ActionIdentifier(); + return this; + } + + public RequestInfoBuilder vnfId(String vnfId){ + this.actionIdentifier.setVnfId(vnfId); + return this; + } + + public RequestInfoBuilder vnfcName(String vnfcName){ + this.actionIdentifier.setVnfcName(vnfcName); + return this; + } + + public RequestInfoBuilder vServerId(String vServerId){ + this.actionIdentifier.setvServerId(vServerId); + return this; + } + + public RequestInfoBuilder action(String action){ + this.action = action; + return this; + } + + public RequestInfoBuilder actionLevel(String actionLevel){ + this.actionLevel = actionLevel; + return this; + } + + public RequestInfoBuilder payload(String payload){ + this.payload = payload; + return this; + } + + public RequestInfo build(){ + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setAction(this.action); + requestInfo.setActionIdentifier(this.actionIdentifier); + requestInfo.setActionLevel(this.actionLevel); + requestInfo.setPayload(this.payload); + return requestInfo; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Response.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Response.java new file mode 100644 index 000000000..9247e6e7f --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Response.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import java.util.Map; + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Response { + + @JsonProperty("response-code") + private String responseCode; + + @JsonProperty("response-message") + private String responseMessage; + + @JsonProperty("response-action") + private Map responseAction; + + public String getResponseCode() { + return responseCode; + } + + public void setResponseCode(String responseCode) { + this.responseCode = responseCode; + } + + public String getResponseMessage() { + return responseMessage; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + public Map getResponseAction() { + return responseAction; + } + + public void setResponseAction(Map responseAction) { + this.responseAction = responseAction; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInput.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInput.java new file mode 100644 index 000000000..851a07582 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInput.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.openecomp.appc.dg.objects.InventoryModel; +import org.openecomp.appc.dg.objects.VnfcDependencyModel; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SequenceGeneratorInput { + + @NotNull + @JsonProperty("request-info") + private RequestInfo requestInfo; + + @JsonIgnore + private InventoryModel inventoryModel; + + @JsonIgnore + private VnfcDependencyModel dependencyModel; + + @JsonProperty("tunable-parameters") + private Map tunableParams; + + @JsonProperty("capabilities") + private Map> capability; + + public RequestInfo getRequestInfo() { + return requestInfo; + } + + public void setRequestInfo(RequestInfo requestInfo) { + this.requestInfo = requestInfo; + } + + public InventoryModel getInventoryModel() { + return inventoryModel; + } + + public void setInventoryModel(InventoryModel inventoryModel) { + this.inventoryModel = inventoryModel; + } + + public VnfcDependencyModel getDependencyModel() { + return dependencyModel; + } + + public void setDependencyModel(VnfcDependencyModel dependencyModel) { + this.dependencyModel = dependencyModel; + } + + public Map getTunableParams() { + return tunableParams; + } + + public void setTunableParams(Map tunableParams) { + this.tunableParams = tunableParams; + } + + public Map> getCapability() { + return capability; + } + + public void setCapability(Map> capability) { + this.capability = capability; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInputBuilder.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInputBuilder.java new file mode 100644 index 000000000..b72e46e7e --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInputBuilder.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import org.openecomp.appc.dg.objects.InventoryModel; +import org.openecomp.appc.dg.objects.VnfcDependencyModel; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SequenceGeneratorInputBuilder { + + private RequestInfo requestInfo; + + private InventoryModel inventoryModel; + + private VnfcDependencyModel dependencyModel; + + private Map tunableParams; + + private Map> capability; + + public SequenceGeneratorInputBuilder requestInfo(RequestInfo requestInfo){ + this.requestInfo = requestInfo; + return this; + } + + public SequenceGeneratorInputBuilder capability(String level,List capabilities){ + if(this.capability ==null){ + this.capability = new HashMap<>(); + } + this.capability.put(level,capabilities); + return this; + } + + public SequenceGeneratorInputBuilder tunableParameter(String key,String value){ + if(this.tunableParams ==null){ + this.tunableParams = new HashMap<>(); + } + this.tunableParams.put(key,value); + return this; + } + + public SequenceGeneratorInputBuilder inventoryModel(InventoryModel model){ + this.inventoryModel = model; + return this; + } + + public SequenceGeneratorInputBuilder dependendcyModel(VnfcDependencyModel model){ + this.dependencyModel = model; + return this; + } + + public SequenceGeneratorInput build(){ + SequenceGeneratorInput input = new SequenceGeneratorInput(); + input.setRequestInfo(this.requestInfo); + input.setCapability(this.capability); + input.setInventoryModel(this.inventoryModel); + input.setDependencyModel(this.dependencyModel); + input.setTunableParams(this.tunableParams); + return input; + } + + + +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Transaction.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Transaction.java new file mode 100644 index 000000000..b49d1323a --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Transaction.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.objects; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Transaction { + + @JsonProperty("transactionId") + private Integer transactionId; + + @JsonProperty("action") + private String action; + + @JsonProperty("action-level") + private String actionLevel; + + @JsonProperty("action-identifier") + private ActionIdentifier actionIdentifier; + + @JsonProperty("payload") + private String payload; + + @JsonProperty("parameters") + private Map parameters; + + @JsonProperty("precheck-operator") + private String preCheckOperator; + + + @JsonProperty("precheck-options") + private List precheckOptions; + + @JsonProperty("responses") + private List responses; + + public Transaction(){ + responses = new LinkedList<>(); + } + + public Integer getTransactionId() { + return transactionId; + } + + public void setTransactionId(Integer transactionId) { + this.transactionId = transactionId; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getActionLevel() { + return actionLevel; + } + + public void setActionLevel(String actionLevel) { + this.actionLevel = actionLevel; + } + + public ActionIdentifier getActionIdentifier() { + return actionIdentifier; + } + + public void setActionIdentifier(ActionIdentifier actionIdentifier) { + this.actionIdentifier = actionIdentifier; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } + + public Map getParameters() { + return parameters; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } + + public List getResponses() { + return responses; + } + + public void setResponses(List responses) { + this.responses = responses; + } + + public void addResponse(Response response){ + this.responses.add(response); + } + + public String getPreCheckOperator() { + return preCheckOperator; + } + + public void setPreCheckOperator(String preCheckOperator) { + this.preCheckOperator = preCheckOperator; + } + + public List getPrecheckOptions() { + return precheckOptions; + } + + public void setPrecheckOptions(List precheckOptions) { + this.precheckOptions = precheckOptions; + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/provider/SequenceGeneratorProvider.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/provider/SequenceGeneratorProvider.java new file mode 100644 index 000000000..b3aab54e1 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/provider/SequenceGeneratorProvider.java @@ -0,0 +1,352 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen.provider; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.util.concurrent.Futures; +import org.apache.commons.lang.StringUtils; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.GenerateSequenceInput; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.GenerateSequenceOutput; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.GenerateSequenceOutputBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.SequenceGeneratorService; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.dependency.info.dependency.info.Vnfcs; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.inventory.info.inventory.info.vnf.info.Vm; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.response.StatusBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.response.Transactions; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.response.TransactionsBuilder; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.response.transactions.ActionIdentifier; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.response.transactions.*; +import org.opendaylight.yang.gen.v1.org.openecomp.appc.sequencegenerator.rev170706.response.transactions.responses.ResponseActionBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.openecomp.appc.dg.objects.InventoryModel; +import org.openecomp.appc.dg.objects.Node; +import org.openecomp.appc.dg.objects.VnfcDependencyModel; +import org.openecomp.appc.domainmodel.Vnf; +import org.openecomp.appc.domainmodel.Vserver; +import org.openecomp.appc.domainmodel.lcm.VNFOperation; +import org.openecomp.appc.exceptions.APPCException; +import org.openecomp.appc.seqgen.SequenceGenerator; +import org.openecomp.appc.seqgen.impl.SequenceGeneratorFactory; +import org.openecomp.appc.seqgen.objects.*; + +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + + +public class SequenceGeneratorProvider implements AutoCloseable,SequenceGeneratorService{ + protected DataBroker dataBroker; + protected RpcProviderRegistry rpcRegistry; + protected NotificationProviderService notificationService; + protected BindingAwareBroker.RpcRegistration rpcRegistration; + private final EELFLogger log = EELFManager.getInstance().getLogger(SequenceGeneratorProvider.class); + private final ExecutorService executor; + private final static String APP_NAME = "SequenceGeneratorProvider"; + + public SequenceGeneratorProvider(DataBroker dataBroker2, NotificationProviderService notificationProviderService + , RpcProviderRegistry rpcRegistry2) { + log.info("Creating provider for " + APP_NAME); + executor = Executors.newFixedThreadPool(1); + this.dataBroker = dataBroker2; + this.notificationService = notificationProviderService; + + this.rpcRegistry = rpcRegistry2; + + if (this.rpcRegistry != null) { + rpcRegistration = rpcRegistry.addRpcImplementation(SequenceGeneratorService.class, this); + } + log.info("Initialization complete for " + APP_NAME); + } + + @Override + public void close() throws Exception { + log.info("Closing provider for " + APP_NAME); + if(this.executor != null){ + executor.shutdown(); + } + if(this.rpcRegistration != null){ + rpcRegistration.close(); + } + log.info("Successfully closed provider for " + APP_NAME); + } + + @Override + public Future> generateSequence(GenerateSequenceInput input) { + RpcResult rpcResult=null; + log.debug("Received input = " + input ); + try { + SequenceGenerator seqGenerator = SequenceGeneratorFactory.getInstance() + .createSequenceGenerator(VNFOperation.findByString(input.getRequestInfo().getAction().name())); + SequenceGeneratorInput seqGenInput = buildSeqGenInput(input); + List transactions = seqGenerator.generateSequence(seqGenInput); + rpcResult = buildSuccessResponse(transactions); + } catch (APPCException e) { + log.error("Error Generating Sequence",e); + rpcResult = buildFailureResponse(e.getMessage()); + } + return Futures.immediateFuture(rpcResult); + } + + private RpcResult buildSuccessResponse(List transactions) { + + List transactionList = new LinkedList<>(); + for(Transaction transaction:transactions){ + ActionIdentifier actionIdentifier = null; + if(transaction.getActionIdentifier() != null){ + actionIdentifier = new ActionIdentifierBuilder() + .setVnfId(transaction.getActionIdentifier().getVnfId()) + .setVnfcName(transaction.getActionIdentifier().getVnfcName()) + .setVserverId(transaction.getActionIdentifier().getvServerId()) + .build(); + } + + List precheckOptions = new LinkedList<>(); + if(transaction.getPrecheckOptions()!=null){ + for(PreCheckOption option:transaction.getPrecheckOptions()){ + PrecheckOptions precheckOption = new PrecheckOptionsBuilder() + .setParamName(option.getParamName()) + .setParamValue(option.getParamValue()) + .setPreTransactionId(option.getPreTransactionId()) + .setRule(option.getRule()) + .build(); + precheckOptions.add(precheckOption); + } + } + + List responseList = getResponses(transaction); + + Transactions transactionObj + = new TransactionsBuilder() + .setActionIdentifier(actionIdentifier) + .setAction(transaction.getAction()) + .setActionLevel(transaction.getActionLevel()) + .setPrecheckOperator(transaction.getPreCheckOperator()) + .setPayload(transaction.getPayload()) + .setTransactionId(transaction.getTransactionId()) + .setPrecheckOptions(precheckOptions) + .setResponses(responseList) + .build(); + transactionList.add(transactionObj); + } + + GenerateSequenceOutputBuilder builder = new GenerateSequenceOutputBuilder() + .setTransactions(transactionList); + + return RpcResultBuilder + . status(true) + .withResult(builder.build()).build(); + } + + private List getResponses(Transaction transaction) { + List responseList = new LinkedList<>(); + for(Response resp : transaction.getResponses()){ + Map responseActions = resp.getResponseAction(); + ResponseActionBuilder responseActionBuilder = new ResponseActionBuilder(); + if(responseActions.get(Constants.ResponseAction.WAIT.getAction())!=null){ + responseActionBuilder = responseActionBuilder.setWait(Integer.parseInt(responseActions.get(Constants.ResponseAction.WAIT.getAction()))); + } + if(responseActions.get(Constants.ResponseAction.RETRY.getAction())!=null){ + responseActionBuilder = responseActionBuilder.setRetry(Integer.parseInt(responseActions.get(Constants.ResponseAction.RETRY.getAction()))); + } + if(responseActions.get(Constants.ResponseAction.CONTINUE.getAction().toLowerCase())!=null){ + responseActionBuilder = responseActionBuilder + .setContinue(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.CONTINUE.getAction().toLowerCase()))); + } + if(responseActions.get(Constants.ResponseAction.IGNORE.getAction()) !=null){ + responseActionBuilder = responseActionBuilder.setIgnore(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.IGNORE.getAction()))); + } + if(responseActions.get(Constants.ResponseAction.STOP.getAction()) !=null){ + responseActionBuilder = responseActionBuilder.setStop(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.STOP.getAction()))); + } + Responses response = new ResponsesBuilder() + .setResponseMessage(resp.getResponseMessage()) + .setResponseAction(responseActionBuilder.build()) + .build(); + responseList.add(response); + } + return responseList; + } + + private SequenceGeneratorInput buildSeqGenInput(GenerateSequenceInput input) throws APPCException { + + validateMandatory(input); + + RequestInfoBuilder requestInfobuilder = new RequestInfoBuilder() + .action(input.getRequestInfo().getAction().name()) + .actionLevel(input.getRequestInfo().getActionLevel().getName().toLowerCase()) + .payload(input.getRequestInfo().getPayload()); + + if(input.getRequestInfo().getActionIdentifier() !=null){ + requestInfobuilder = requestInfobuilder + .actionIdentifier() + .vnfId(input.getRequestInfo().getActionIdentifier().getVnfId()) + .vnfcName(input.getRequestInfo().getActionIdentifier().getVnfcName()) + .vServerId(input.getRequestInfo().getActionIdentifier().getVserverId()); + } + + RequestInfo requestInfo = requestInfobuilder.build(); + + InventoryModel inventoryModel = readInventoryModel(input); + + VnfcDependencyModel dependencyModel = readDependencyModel(input); + + SequenceGeneratorInputBuilder builder = new SequenceGeneratorInputBuilder() + .requestInfo(requestInfo) + .inventoryModel(inventoryModel) + .dependendcyModel(dependencyModel); + + if(input.getCapabilities() !=null){ + if(input.getCapabilities().getVnf()!=null){ + builder = builder.capability("vnf",input.getCapabilities().getVnf()); + } + if(input.getCapabilities().getVnfc()!=null){ + builder = builder.capability("vnfc",input.getCapabilities().getVnfc()); + } + if(input.getCapabilities().getVm()!=null){ + builder = builder.capability("vm",input.getCapabilities().getVm()); + } + if(input.getCapabilities().getVfModule()!=null){ + builder = builder.capability("vf-module",input.getCapabilities().getVfModule()); + } + } + + if(input.getTunableParameters() != null){ + builder = builder.tunableParameter(Constants.RETRY_COUNT,String.valueOf(input.getTunableParameters().getRetryCount())) + .tunableParameter(Constants.WAIT_TIME,String.valueOf(input.getTunableParameters().getWaitTime())); + if(input.getTunableParameters().getStrategy() !=null){ + builder = builder.tunableParameter(Constants.STRATEGY,input.getTunableParameters().getStrategy().name()); + } + } + return builder.build(); + } + + + private void validateMandatory(GenerateSequenceInput input) throws APPCException { + if(input.getRequestInfo() ==null){ + throw new APPCException("Request Info is not present in the request"); + } + if(input.getRequestInfo().getAction() ==null){ + throw new APPCException("Action is not present in the request"); + } + if(input.getInventoryInfo() ==null){ + throw new APPCException("inventoryInfo is not provided in the input"); + } + } + + private VnfcDependencyModel readDependencyModel(GenerateSequenceInput input) { + if(input.getDependencyInfo() == null || input.getDependencyInfo().getVnfcs() ==null || input.getDependencyInfo().getVnfcs().isEmpty()){ + return null; + } + List vnfcs = input.getDependencyInfo().getVnfcs(); + Set> dependencies = new HashSet<>(); + for(Vnfcs vnfcObj:vnfcs){ + org.openecomp.appc.domainmodel.Vnfc vnfc; + Node currentNode = readNode(vnfcObj.getVnfcType(),dependencies); + if(currentNode == null){ + vnfc = new org.openecomp.appc.domainmodel.Vnfc(vnfcObj.getVnfcType(),vnfcObj.getResilience()); + currentNode = new Node<>(vnfc); + dependencies.add(currentNode); + } + else{ + currentNode.getChild().setResilienceType(vnfcObj.getResilience()); + currentNode.getChild().setMandatory(vnfcObj.isMandatory()); + } + for(String parentVnfcType:vnfcObj.getParents()){ + Node parentNode = readNode(parentVnfcType,dependencies); + if(parentNode == null){ + org.openecomp.appc.domainmodel.Vnfc parentVnfc = new org.openecomp.appc.domainmodel.Vnfc(parentVnfcType,null); + parentNode = new Node<>(parentVnfc); + currentNode.addParent(parentVnfc); + dependencies.add(parentNode); + } + else{ + currentNode.addParent(parentNode.getChild()); + } + } + } + return new VnfcDependencyModel(dependencies); + } + + private Node readNode(String vnfcType, Set> dependencies) { + for(Node node : dependencies){ + if(node.getChild().getVnfcType().equalsIgnoreCase(vnfcType)){ + return node; + } + } + return null; + } + + private InventoryModel readInventoryModel(GenerateSequenceInput input) throws APPCException { + if (input.getInventoryInfo().getVnfInfo()== null) { + throw new APPCException("vnfInfo is not provided in the input"); + } + + Vnf vnf = new Vnf(input.getInventoryInfo().getVnfInfo().getVnfId(), + input.getInventoryInfo().getVnfInfo().getVnfType(),null); + + Map> map = new HashMap<>(); + for(Vm vm:input.getInventoryInfo().getVnfInfo().getVm()){ + if(StringUtils.isBlank(vm.getVserverId())){ + throw new APPCException("vserver-id not found "); + } + if(StringUtils.isBlank(vm.getVnfc().getVnfcType())){ + throw new APPCException("vnfc-type not found for vserver " + vm.getVserverId()); + } + if(StringUtils.isBlank(vm.getVnfc().getVnfcName())){ + throw new APPCException("vnfc-name not found for vserver " + vm.getVserverId()); + } + + org.openecomp.appc.domainmodel.Vnfc vnfc = new org.openecomp.appc.domainmodel.Vnfc(vm.getVnfc().getVnfcType(),null,vm.getVnfc().getVnfcName()); + List vms = map.get(vnfc); + if(vms ==null){ + vms = new LinkedList<>(); + map.put(vnfc,vms); + } + vms.add(new Vserver(null,null,vm.getVserverId(),null,null)); + } + for(Map.Entry> entry:map.entrySet()){ + org.openecomp.appc.domainmodel.Vnfc vnfc = entry.getKey(); + List vmList = entry.getValue(); + vnfc.addVms(vmList); + vnf.addVnfc(vnfc); + } + return new InventoryModel(vnf); + } + + private RpcResult buildFailureResponse(String errorMessage){ + GenerateSequenceOutputBuilder sequenceGeneratorOutputBuilder=new GenerateSequenceOutputBuilder(); + StatusBuilder statusBuilder =new StatusBuilder(); + statusBuilder.setCode(401); + statusBuilder.setMessage(errorMessage); + sequenceGeneratorOutputBuilder.setStatus(statusBuilder.build()); + return RpcResultBuilder + . status(true) + .withResult(sequenceGeneratorOutputBuilder.build()) + .build(); + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml new file mode 100644 index 000000000..9422bd33a --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/initial/appc-sequence-generator.xml b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/initial/appc-sequence-generator.xml new file mode 100644 index 000000000..fb48c2567 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/initial/appc-sequence-generator.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + prefix:sequence-generator-impl + + sequence-generator-impl + + + + binding:binding-rpc-registry + binding-rpc-broker + + + + binding:binding-async-data-broker + binding-data-broker + + + + + binding:binding-notification-service + + binding-notification-broker + + + + + + + + + + + org:openecomp:appc:sequencegenerator:impl?module=sequence-generator-impl&revision=2017-07-06 + + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/default.properties b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/default.properties new file mode 100644 index 000000000..a3e3f8ac8 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/default.properties @@ -0,0 +1,54 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-C +# ================================================================================ +# 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========================================================= +### + +# +# This property file supplies the configuration defaults for the APP-C controller +# +# Default values are supplied so that all defined properties have well-known values and are +# valid even if a configuration file is not supplied. This is done to ensure that a runnable, +# stable, and defined configuration exists at all times. The reason the defaults are supplied +# via this property file and not in the code is so that the properties can be changed +# easily if needed in the future. Use of the "getProperty(name, default)" method is +# discouraged because if the default value needs to be changed, everywhere in the code it +# is used would have to be changed. By loading the defaults in this property file, all +# values can be defined in one place and support is easier. This does mean that all +# properties that are defined must have a default value supplied here. Which also means +# this file documents all defined properties (not a bad thing either). +# +#-------------------------------------------------------------------------------------------- +# The path and file used to load user-supplied configuration settings, if any +org.openecomp.appc.bootstrap.file=appc.properties +org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},. + +appc.application.name=APPC + +# +# The path to search for logging configuration document, and the name of the document +# +org.openecomp.appc.logging.path=${user.home},etc,../etc,. +org.openecomp.appc.logging.file=logback.xml + +# +# The DG properties +# +appc.service.logic.module.name=APPC +appc.topology.dg.method=topology-operation-all +appc.topology.dg.version=2.0.0 + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/logback.xml b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/logback.xml new file mode 100644 index 000000000..0cefc8cf7 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/logback.xml @@ -0,0 +1,283 @@ + + + + + + + + + + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger - %msg%n + + + + + + + + + + ${logDirectory}/cdp.log + + ${logDirectory}/cdp.%i.log.zip + + 1 + 9 + + + 5MB + + + + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method} + %X{Path}] - %msg%n + + + + 256 + + + + + + ${logDirectory}/cdp-security.log + + ${logDirectory}/cdp-security.%i.log.zip + + 1 + 9 + + + 5MB + + + + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method} + %X{Path}] - %msg%n + + + + 256 + 0 + + + + + + ${logDirectory}/cdp-performance.log + + ${logDirectory}/cdp-performance.%i.log.zip + + 1 + 9 + + + 5MB + + + true + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method} + %X{Path}] - %msg%n + + + + 256 + + + + + + ${logDirectory}/cdp-server.log + + ${logDirectory}/cdp-server.%i.log.zip + + 1 + 9 + + + 5MB + + + + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method} + %X{Path}] - %msg%n + + + + 256 + + + + + + ${logDirectory}/cdp-coordinator.log + + ${logDirectory}/cdp-coordinator.%i.log.zip + + 1 + 9 + + + 5MB + + + + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger - %msg%n + + + + 256 + + + + + + ${logDirectory}/cdp-policy.log + + ${logDirectory}/cdp-policy.%i.log.zip + + 1 + 9 + + + 5MB + + + + %d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level + %-36.36logger - %msg%n + + + + 256 + + + + ${debugLogDirectory}/appc-debug.log + + ${logDirectory}/command-executor.%i.log.zip + + 1 + 9 + + + 5MB + + + + + %d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServiceName} - %X{bundle.id} - %X{bundle.name} - %X{bundle.version}|%X{InstanceUUID}|%-5.5p|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%c{3}]|%m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/yang/sequence-generator.yang b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/yang/sequence-generator.yang new file mode 100644 index 000000000..50c00979b --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/yang/sequence-generator.yang @@ -0,0 +1,62 @@ +module sequence-generator-impl { + + yang-version 1; + namespace "org:openecomp:appc:sequencegenerator:impl"; + prefix "sequence-generator-impl"; + + import config { prefix config; revision-date 2013-04-05; } + import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } + + description + "This module contains the base YANG definitions for + sequence-generator-impl implementation."; + + revision "2017-07-06" { + description + "Initial revision."; + } + + // This is the definition of the service implementation as a module identity. + identity sequence-generator-impl { + base config:module-type; + + // Specifies the prefix for generated java classes. + config:java-name-prefix SequenceGenerator; + } + + // Augments the 'configuration' choice node under modules/module. + // We consume the two main services, RPCs and DataStore + // Notification service is not used + augment "/config:modules/config:module/config:configuration" { + case sequence-generator-impl { + when "/config:modules/config:module/config:type = 'sequence-generator-impl'"; + + container rpc-registry { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity mdsal:binding-rpc-registry; + } + } + } + + container notification-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity mdsal:binding-notification-service; + } + } + } + + container data-broker { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity mdsal:binding-async-data-broker; + } + } + } + } + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/openecomp/appc/seqgen/TestSequenceGeneratorPlugin.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/openecomp/appc/seqgen/TestSequenceGeneratorPlugin.java new file mode 100644 index 000000000..2bb9cd6e2 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/openecomp/appc/seqgen/TestSequenceGeneratorPlugin.java @@ -0,0 +1,256 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * 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.openecomp.appc.seqgen; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.appc.seqgen.dgplugin.SequenceGeneratorPlugin; +import org.openecomp.appc.seqgen.dgplugin.impl.SequenceGeneratorPluginImpl; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.Map; + +public class TestSequenceGeneratorPlugin { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestSequenceGeneratorPlugin.class); + + @Test + public void testGenerateSequenceStart() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/start.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/start.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + + + @Test + public void testGenerateSequenceSingleVM()throws URISyntaxException, IOException { + String inputJSON = readInput("/input/start-single-vm.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/start-single-vm.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceNoStrategy() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/no-strategy.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/start.json"); + + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceStop() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/stop.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/stop.json"); + + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceWrongNumber() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/wrongnumber.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence Invalid Number for Wait Time 6a"); + } + + + @Test + public void testGenerateSequenceCyclic() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/cyclic.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence There seems to be no Root/Independent node for Vnfc dependencies"); + } + + + @Test + public void testGenerateSequenceWrongAction() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/wrongaction.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence Invalid Action start"); + } + + + @Test + public void testGenerateSequenceMissingRequestInfo() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/missingrequestinfo.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence Request info is not provided in the input"); + } + + @Test + public void testGenerateSequenceStopSingleVM() throws URISyntaxException, IOException{ + String inputJSON = readInput("/input/stop-single-vm.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/stop-single-vm.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceStopSingleVmPerVnfc() throws URISyntaxException, IOException{ + String inputJSON = readInput("/input/stop-single-vm-per-vnfc.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/stop-single-vm-per-vnfc.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceStartSingleVmPerVnfc() throws URISyntaxException, IOException{ + String inputJSON = readInput("/input/start-single-vm-per-vnfc.json"); + + Map params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/start-single-vm-per-vnfc.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + private String readInput(String inputFile) throws URISyntaxException, IOException { + File file = new File(this.getClass().getResource(inputFile).toURI()); + + byte[] bFile = new byte[(int) file.length()]; + FileInputStream fileInputStream = new FileInputStream(file); + fileInputStream.read(bFile); + fileInputStream.close(); + return new String(bFile); + } + private String readOutput(String outputFile) throws IOException,URISyntaxException { + File file = new File(this.getClass().getResource(outputFile).toURI()); + + byte[] bFile = new byte[(int) file.length()]; + FileInputStream fileInputStream = new FileInputStream(file); + fileInputStream.read(bFile); + fileInputStream.close(); + + String output=new String(bFile); + int start=output.indexOf("["); + int last=output.length()-1; + return output.substring(start,last); + + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json new file mode 100644 index 000000000..522b99692 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info" : + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : + [ + "VNFC3" + ] + } + ] + }, + "tunable-parameters" : + { + "strategy" : "FORWARD", + "wait-time" : "120", + "retry-count" : "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/mandatory-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/mandatory-vnfc.json new file mode 100644 index 000000000..3e96b5654 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/mandatory-vnfc.json @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json new file mode 100644 index 000000000..c5bc7ead2 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json new file mode 100644 index 000000000..1371d2273 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json @@ -0,0 +1,195 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/optional-vnfc-data.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/optional-vnfc-data.json new file mode 100644 index 000000000..cc5d3a0c4 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/optional-vnfc-data.json @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "false", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/optional-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/optional-vnfc.json new file mode 100644 index 000000000..a3067697d --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/optional-vnfc.json @@ -0,0 +1,176 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "false", + "resilience": "Active-Active", + "parents" : [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm-duplicate.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm-duplicate.json new file mode 100644 index 000000000..3f22fd669 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm-duplicate.json @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vm", + "action-identifier": + { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + } + ] + } + }, + "dependency-info": + { + + }, + "tunable-parameters": + { + + }, + "capabilities" : + { + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm-per-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm-per-vnfc.json new file mode 100644 index 000000000..dac5028b9 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm-per-vnfc.json @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vm", + "action-identifier": + { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + } + ] + } + }, + "dependency-info": + { + + }, + "tunable-parameters": + { + + }, + "capabilities" : + { + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm.json new file mode 100644 index 000000000..ef76ec240 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-single-vm.json @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vm", + "action-identifier": + { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + } + ] + } + }, + "dependency-info": + { + + }, + "tunable-parameters": + { + + }, + "capabilities" : + { + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-without-dependency.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-without-dependency.json new file mode 100644 index 000000000..ec6a2b7ba --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-without-dependency.json @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vm", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + + }, + "tunable-parameters": + { + + }, + "capabilities" : + { + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json new file mode 100644 index 000000000..143b41d23 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info" : + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters" : + { + "strategy" : "FORWARD", + "wait-time" : "120", + "retry-count" : "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-action-level-val.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-action-level-val.json new file mode 100644 index 000000000..f089748f6 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-action-level-val.json @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Stop", + "action-level": "heel ", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-single-vm-per-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-single-vm-per-vnfc.json new file mode 100644 index 000000000..210f9ac0e --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-single-vm-per-vnfc.json @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Stop", + "action-level": "vm", + "action-identifier": + { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + } + ] + }}, + "dependency-info": + { + + }, + "tunable-parameters": + { + + }, + "capabilities" : + { + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-single-vm.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-single-vm.json new file mode 100644 index 000000000..9679c9ba9 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-single-vm.json @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Stop", + "action-level": "vm", + "action-identifier": + { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + } + ] + } + }, + "dependency-info": + { + + }, + "tunable-parameters": + { + + }, + "capabilities" : + { + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-without-dep.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-without-dep.json new file mode 100644 index 000000000..6f70cca23 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-without-dep.json @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Stop", + "action-level": "vm", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": " {\"vnf-host-ip-address\": \"10.147.124.163\" }" + + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json new file mode 100644 index 000000000..9131a652b --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Stop", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": " {\"vnf-host-ip-address\": \"10.147.124.163\" }" + + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json new file mode 100644 index 000000000..72f6ed87f --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json new file mode 100644 index 000000000..958df0379 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + + + + +{ + "request-info": + { + "action": "Start", + "action-level": "vnf", + "action-identifier": + { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": + { + "vnf-info": + { + "vnf-id" : "abc", + "vnf-name": "vVNF", + "vnf-type": "vVNF", + "vnf-version" : "1.0", + "vm": + [ + { + "vserver-id" : "vnfc2_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc3_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC3", + "vnfc-name": "VNFC3 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid3", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid1", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + + }, + { + "vserver-id" : "vnfc1_vserverid2", + "vnfc": + { + "vnfc-type": "VNFC1", + "vnfc-name": "VNFC1 - Name" + } + }, + { + "vserver-id" : "vnfc2_vserverid4", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + }, + { + "vserver-id" : "vnfc2_vserverid5", + "vnfc": + { + "vnfc-type": "VNFC2", + "vnfc-name": "VNFC2 - Name" + } + + } + ] + } + }, + "dependency-info": + { + "vnfcs" : + [ + { + "vnfc-type" : "VNFC2", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC1" + ] + }, + { + "vnfc-type" : "VNFC3", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : + [ + "VNFC2" + ] + }, + { + "vnfc-type" : "VNFC1", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": + { + "strategy" : "FORWARD", + "wait-time": "6a", + "retry-count": "5" + }, + "capabilities" : + { + "vnf": + [ + "Stop", + "Start", + "StartApplication", + "StopApplication" + ], + "vf-module": + [ + "Stop", + "Start" + ], + "vm" : + [ + "Stop", + "Start" + ], + "vnfc": + [ + "StopApplication", + "StartApplication", + "HealthCheck" + ] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/optional-vnfc-with-data.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/optional-vnfc-with-data.json new file mode 100644 index 000000000..15e7faa7e --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/optional-vnfc-with-data.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":1,"param-name":"status","param-value":"success"},{"pre-transactionID":2,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":4,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":5,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid3"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid4"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid5"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":10,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":5,"param-name":"status","param-value":"success"},{"pre-transactionID":6,"param-name":"status","param-value":"success"},{"pre-transactionID":7,"param-name":"status","param-value":"success"},{"pre-transactionID":8,"param-name":"status","param-value":"success"},{"pre-transactionID":9,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":11,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":12,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":13,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":14,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC3 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":12,"param-name":"status","param-value":"success"},{"pre-transactionID":13,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":15,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC3 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/optional-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/optional-vnfc.json new file mode 100644 index 000000000..1981427d3 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/optional-vnfc.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":1,"param-name":"status","param-value":"success"},{"pre-transactionID":2,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":4,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy", "response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":5,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid3"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid4"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid5"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":10,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":5,"param-name":"status","param-value":"success"},{"pre-transactionID":6,"param-name":"status","param-value":"success"},{"pre-transactionID":7,"param-name":"status","param-value":"success"},{"pre-transactionID":8,"param-name":"status","param-value":"success"},{"pre-transactionID":9,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":11,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-single-vm-per-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-single-vm-per-vnfc.json new file mode 100644 index 000000000..600e315b2 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-single-vm-per-vnfc.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-single-vm.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-single-vm.json new file mode 100644 index 000000000..be4dc57b8 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-single-vm.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-without-dependency.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-without-dependency.json new file mode 100644 index 000000000..2bb344598 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-without-dependency.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":4,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":5,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid3"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid4"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid5"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start.json new file mode 100644 index 000000000..15e7faa7e --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":1,"param-name":"status","param-value":"success"},{"pre-transactionID":2,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":4,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":5,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid3"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid4"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid5"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":10,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":5,"param-name":"status","param-value":"success"},{"pre-transactionID":6,"param-name":"status","param-value":"success"},{"pre-transactionID":7,"param-name":"status","param-value":"success"},{"pre-transactionID":8,"param-name":"status","param-value":"success"},{"pre-transactionID":9,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":11,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":12,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":13,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":14,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC3 - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":12,"param-name":"status","param-value":"success"},{"pre-transactionID":13,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":15,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC3 - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-single-vm-per-vnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-single-vm-per-vnfc.json new file mode 100644 index 000000000..97d2d1be5 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-single-vm-per-vnfc.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-single-vm.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-single-vm.json new file mode 100644 index 000000000..b237fe6f7 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-single-vm.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":"ABC","responses":[]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-without-dep.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-without-dep.json new file mode 100644 index 000000000..85f3b9650 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-without-dep.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":4,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":5,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid3"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid4"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid5"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop.json new file mode 100644 index 000000000..c401ed6a2 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"StopApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC1 - Name"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc1_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":4,"action":"StopApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC2 - Name"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":5,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid3"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid4"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc2_vserverid5"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":10,"action":"StopApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"VNFC3 - Name"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":11,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":12,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"vnfc3_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-features/pom.xml b/appc-sequence-generator/appc-sequence-generator-features/pom.xml new file mode 100644 index 000000000..5f4fbe6ea --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-features/pom.xml @@ -0,0 +1,129 @@ + + + 4.0.0 + + org.openecomp.appc + appc-sequence-generator + 1.1.0-SNAPSHOT + + appc-sequence-generator-features + Application Controller Sequence Generator Features + + + + org.openecomp.appc + appc-sequence-generator-bundle + ${project.version} + + + org.openecomp.appc + appc-sequence-generator-model + ${project.version} + + + org.opendaylight.mdsal + features-mdsal + features + xml + + runtime + + + org.opendaylight.yangtools + features-yangtools + features + xml + runtime + + + org.openecomp.appc + appc-dg-domain-model-lib + ${project.version} + + + org.openecomp.appc + appc-dg-dependency-model + ${project.version} + + + org.openecomp.appc + appc-common + ${project.version} + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/appc-sequence-generator/appc-sequence-generator-features/src/main/resources/features.xml b/appc-sequence-generator/appc-sequence-generator-features/src/main/resources/features.xml new file mode 100644 index 000000000..4a3e46938 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-features/src/main/resources/features.xml @@ -0,0 +1,43 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + + mvn:org.openecomp.appc/domain-model-lib/${project.version} + mvn:org.openecomp.appc/appc-common/${project.version} + mvn:org.openecomp.appc/appc-sequence-generator-model/${project.version} + mvn:org.openecomp.appc/appc-sequence-generator-bundle/${project.version} + wrap:mvn:org.openecomp.appc/appc-dg-domain-model-lib/${project.version} + wrap:mvn:org.openecomp.appc/appc-dg-dependency-model/${project.version} + + mvn:org.openecomp.appc/appc-sequence-generator-bundle/${project.version}/xml/config + + + diff --git a/appc-sequence-generator/appc-sequence-generator-installer/pom.xml b/appc-sequence-generator/appc-sequence-generator-installer/pom.xml new file mode 100644 index 000000000..c7b7428e9 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-installer/pom.xml @@ -0,0 +1,149 @@ + + + 4.0.0 + + org.openecomp.appc + appc-sequence-generator + 1.1.0-SNAPSHOT + + appc-sequence-generator-installer + Appc Sequence Generator : Karaf Installer + pom + + + appc-sequence-generator + appc-sequence-generator + mvn:com.att.appc/appc-sequence-generator-features/${project.version}/xml/features + false + + + + + + org.openecomp.appc + appc-sequence-generator-features + ${project.version} + features + xml + + + * + * + + + + + + org.openecomp.appc + appc-sequence-generator-bundle + ${project.version} + + + + org.openecomp.appc + appc-sequence-generator-bundle + config + ${project.version} + xml + + + + org.openecomp.appc + appc-sequence-generator-model + ${project.version} + + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + + + + installer-zip + + single + + package + + false + true + ${application.name}-${project.version} + + src/assembly/assemble_installer_zip.xml + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.opendaylight + provided + + + + + + maven-resources-plugin + + + copy-version + + copy-resources + + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + \ No newline at end of file diff --git a/appc-sequence-generator/appc-sequence-generator-installer/src/assembly/assemble_installer_zip.xml b/appc-sequence-generator/appc-sequence-generator-installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..cfa3f8f63 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,58 @@ + + + + + + controller + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/appc-sequence-generator/appc-sequence-generator-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-sequence-generator/appc-sequence-generator-installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..7510c1be3 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,53 @@ + + + + + + controller + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + ../${feature-name}-bundle/src/main/resources/initial/${feature-name}.xml + ./etc/opendaylight/karaf/201-${feature-name}.xml + + + + diff --git a/appc-sequence-generator/appc-sequence-generator-installer/src/main/resources/scripts/install-feature.sh b/appc-sequence-generator/appc-sequence-generator-installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..c5a39bf9a --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,39 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-C +# ================================================================================ +# 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========================================================= +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-sequence-generator/appc-sequence-generator-model/pom.xml b/appc-sequence-generator/appc-sequence-generator-model/pom.xml new file mode 100644 index 000000000..8c492b046 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-model/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + org.openecomp.appc + appc-sequence-generator + 1.1.0-SNAPSHOT + + appc-sequence-generator-model + appc-sequence-generator-model + bundle + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + + ${odl.sal.api.gen.plugin.version} + jar + + + + + + generate-sources + + + ${yang.file.directory} + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + + + + + junit + junit + test + + + org.opendaylight.mdsal + yang-binding + + + org.opendaylight.yangtools + yang-common + + + org.opendaylight.mdsal.model + ietf-inet-types + ${odl.ietf-inet-types.version} + + + org.opendaylight.mdsal.model + ietf-yang-types + ${odl.ietf-yang-types.version} + + + diff --git a/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang b/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang new file mode 100644 index 000000000..6777dad63 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang @@ -0,0 +1,223 @@ +module sequence-generator { + yang-version 1; + + namespace "org:openecomp:appc:sequencegenerator"; + prefix sequencegenerator; + + description + "Defines sequence generator api interface for App-C services"; + + revision "2017-07-06" { + description + "Initial draft"; + } + + grouping request-info { + container request-info{ + leaf action { + type enumeration { + enum "Start"; + enum "Stop"; + } + } + leaf action-level { + type enumeration { + enum "vm"; + enum "vnfc"; + enum "vnf"; + enum "vf-module"; + } + } + container action-identifier { + leaf vnf-id { + description "identifies the VNF to which this action is to be applied(vnf-id uniquely identifies the service-instance referred to)."; + type string; + } + leaf vnfc-name { + type string; + } + leaf vserver-id { + type string; + } + } + leaf payload { + description "An action-specific value opaque to the APPC handler. + The value can be any valid JSON type (primitive, object, collection of those two). + APPC will pass the value as raw JSON string"; + type string; + } + } + } + + grouping inventory-info { + container inventory-info { + container vnf-info { + leaf vnf-id { + type string; + } + leaf vnf-name { + type string; + } + leaf vnf-type { + type string; + } + list vm { + key "vserver-id"; + leaf vserver-id { + type string; + } + container vnfc { + leaf vnfc-type { + type string; + } + leaf vnfc-name { + type string; + } + } + } + } + } + } + + grouping dependency-info { + container dependency-info { + list vnfcs { + leaf vnfc-type { + type string; + } + leaf mandatory { + type boolean; + } + leaf resilience { + type string; + } + leaf-list parents { + type string; + } + } + } + } + + grouping tunable-parameters { + container tunable-parameters { + leaf strategy { + type enumeration { + enum "FORWARD"; + enum "REVERSE"; + } + } + leaf wait-time { + type uint16; + } + leaf retry-count { + type uint16; + } + } + } + + grouping capabilities { + container capabilities { + leaf-list vnf { + type string; + } + leaf-list vf-module { + type string; + } + leaf-list vm { + type string; + } + leaf-list vnfc { + type string; + } + } + } + + grouping response { + container status { + leaf code { + type uint16; + } + leaf message { + type string; + } + } + list transactions{ + key "transaction-id"; + leaf transaction-id{ + type uint16; + } + leaf action{ + type string; + } + leaf action-level{ + type string; + } + container action-identifier{ + leaf vserver-id { + type string; + } + leaf vnfc-name { + type string; + } + leaf vnf-id { + type string; + } + } + leaf payload{ + type string; + } + leaf precheck-operator{ + type string; + } + list precheck-options{ + leaf pre-transaction-id{ + type uint16; + } + leaf param-name{ + type string; + } + leaf param-value{ + type string; + } + leaf rule{ + type string; + } + } + list responses{ + leaf response-message{ + type string; + } + container response-action{ + leaf wait{ + type uint16; + } + leaf retry{ + type uint16; + } + leaf continue{ + type boolean; + } + leaf stop{ + type boolean; + } + leaf ignore{ + type boolean; + } + } + } + } + } + + rpc generate-sequence { + input{ + uses request-info; + uses inventory-info; + uses dependency-info; + uses tunable-parameters; + uses capabilities; + } + output{ + uses response; + } + } + } \ No newline at end of file diff --git a/appc-sequence-generator/pom.xml b/appc-sequence-generator/pom.xml new file mode 100644 index 000000000..55b4c14ee --- /dev/null +++ b/appc-sequence-generator/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + org.openecomp.appc + appc + 1.1.0-SNAPSHOT + + + org.openecomp.appc + appc-sequence-generator + appc-sequence-generator + pom + + + + 2.5.0 + appc-sequence-generator + + + + + org.openecomp.appc + appc-sequence-generator-model + ${project.version} + + + org.openecomp.appc + appc-sequence-generator-features + ${project.version} + + + org.openecomp.appc + appc-sequence-generator-bundle + ${project.version} + + + + + + appc-sequence-generator-model + appc-sequence-generator-bundle + appc-sequence-generator-features + appc-sequence-generator-installer + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 638a50de0..e0914db2c 100644 --- a/pom.xml +++ b/pom.xml @@ -555,6 +555,11 @@ update-file-header process-sources + + + *.json + + @@ -641,6 +646,7 @@ appc-directed-graph appc-outbound appc-inbound + appc-sequence-generator