From 5b7590935559fe9e286a703dc662a60b47b7ed1a Mon Sep 17 00:00:00 2001 From: Kalpesh Chaniyara Date: Tue, 15 Aug 2017 23:40:34 +0530 Subject: 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 --- .../impl/rev170706/SequenceGeneratorModule.java | 51 +++ .../rev170706/SequenceGeneratorModuleFactory.java | 33 ++ .../openecomp/appc/seqgen/SequenceGenerator.java | 43 +++ .../seqgen/dgplugin/SequenceGeneratorPlugin.java | 31 ++ .../dgplugin/impl/SequenceGeneratorPluginImpl.java | 243 ++++++++++++++ .../appc/seqgen/impl/SequenceGeneratorFactory.java | 54 ++++ .../appc/seqgen/impl/StartSequenceGenerator.java | 291 +++++++++++++++++ .../appc/seqgen/impl/StopSequenceGenerator.java | 183 +++++++++++ .../appc/seqgen/objects/ActionIdentifier.java | 63 ++++ .../openecomp/appc/seqgen/objects/Constants.java | 123 +++++++ .../appc/seqgen/objects/PreCheckOption.java | 74 +++++ .../openecomp/appc/seqgen/objects/RequestInfo.java | 72 +++++ .../appc/seqgen/objects/RequestInfoBuilder.java | 76 +++++ .../openecomp/appc/seqgen/objects/Response.java | 65 ++++ .../seqgen/objects/SequenceGeneratorInput.java | 93 ++++++ .../objects/SequenceGeneratorInputBuilder.java | 85 +++++ .../openecomp/appc/seqgen/objects/Transaction.java | 142 +++++++++ .../seqgen/provider/SequenceGeneratorProvider.java | 352 +++++++++++++++++++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 29 ++ .../resources/initial/appc-sequence-generator.xml | 71 +++++ .../org.openecomp.appc/default.properties | 54 ++++ .../main/resources/org.openecomp.appc/logback.xml | 283 +++++++++++++++++ .../src/main/yang/sequence-generator.yang | 62 ++++ 23 files changed, 2573 insertions(+) create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModule.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/sequencegenerator/impl/rev170706/SequenceGeneratorModuleFactory.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/SequenceGenerator.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/SequenceGeneratorPlugin.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/SequenceGeneratorFactory.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/ActionIdentifier.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Constants.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/PreCheckOption.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfo.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/RequestInfoBuilder.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Response.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInput.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/SequenceGeneratorInputBuilder.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/objects/Transaction.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/provider/SequenceGeneratorProvider.java create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/initial/appc-sequence-generator.xml create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/default.properties create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/resources/org.openecomp.appc/logback.xml create mode 100644 appc-sequence-generator/appc-sequence-generator-bundle/src/main/yang/sequence-generator.yang (limited to 'appc-sequence-generator/appc-sequence-generator-bundle/src/main') 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; + } + } + } + } + } +} -- cgit 1.2.3-korg