diff options
Diffstat (limited to 'src')
39 files changed, 2739 insertions, 637 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/SSLConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/SSLConfiguration.java new file mode 100644 index 00000000..ac5849b8 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/spring/SSLConfiguration.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.config.spring; + +import java.net.URL; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; + +@Configuration +public class SSLConfiguration { + @Autowired + private Environment env; + + @PostConstruct + private void configureSSL() { + if (env.getProperty("server.ssl.trust-store") != null) { + URL storeResource = SSLConfiguration.class + .getResource(env.getProperty("server.ssl.trust-store").replaceAll("classpath:", "")); + System.setProperty("javax.net.ssl.trustStore", storeResource.getPath()); + System.setProperty("javax.net.ssl.trustStorePassword", env.getProperty("server.ssl.trust-store-password")); + System.setProperty("javax.net.ssl.trustStoreType", env.getProperty("server.ssl.key-store-type")); + + storeResource = SSLConfiguration.class + .getResource(env.getProperty("server.ssl.key-store").replaceAll("classpath:", "")); + System.setProperty("javax.net.ssl.keyStore", storeResource.getPath()); + System.setProperty("javax.net.ssl.keyStorePassword", env.getProperty("server.ssl.key-store-password")); + System.setProperty("javax.net.ssl.keyStoreType", env.getProperty("server.ssl.key-store-type")); + } + } +}
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java index a93b09cf..a56c57d1 100644 --- a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java +++ b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java @@ -26,11 +26,11 @@ package org.onap.clamp.clds.model.properties; import com.google.gson.JsonObject; + import org.onap.clamp.clds.util.JsonUtils; /** - * Parse Holmes bpmn parameters json properties. - * Example json: + * Parse Holmes bpmn parameters json properties. Example json: * [{"name":"correlationalLogic","value":"vcwx"},{"name":"configPolicyName","value":"cccc"}] */ public class Holmes extends AbstractModelElement { @@ -43,14 +43,18 @@ public class Holmes extends AbstractModelElement { /** * Default constructor for Holmes Element. * - * @param modelBpmn The model bpmn - * @param modelJson The model json + * @param modelBpmn + * The model bpmn + * @param modelJson + * The model json */ public Holmes(ModelBpmn modelBpmn, JsonObject modelJson) { super(TYPE_HOLMES, modelBpmn, modelJson); - correlationLogic = JsonUtils.getStringValueByName(modelElementJsonNode, "correlationalLogic"); - configPolicyName = JsonUtils.getStringValueByName(modelElementJsonNode, "configPolicyName"); + if (modelElementJsonNode != null) { + correlationLogic = JsonUtils.getStringValueByName(modelElementJsonNode, "correlationalLogic"); + configPolicyName = JsonUtils.getStringValueByName(modelElementJsonNode, "configPolicyName"); + } } public static final String getType() { diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java index 809904f2..aca2ed01 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java @@ -29,6 +29,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import java.util.AbstractMap; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -61,12 +62,12 @@ public class BlueprintParser { public Set<MicroService> getMicroServices(String blueprintString) { Set<MicroService> microServices = new HashSet<>(); JsonObject jsonObject = BlueprintParser.convertToJson(blueprintString); - JsonObject results = jsonObject.get(NODE_TEMPLATES).getAsJsonObject(); + JsonObject nodeTemplateList = jsonObject.get(NODE_TEMPLATES).getAsJsonObject(); - for (Entry<String, JsonElement> entry : results.entrySet()) { + for (Entry<String, JsonElement> entry : nodeTemplateList.entrySet()) { JsonObject nodeTemplate = entry.getValue().getAsJsonObject(); if (nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) { - MicroService microService = getNodeRepresentation(entry); + MicroService microService = getNodeRepresentation(entry, nodeTemplateList); microServices.add(microService); } } @@ -89,7 +90,7 @@ public class BlueprintParser { } String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA; return Collections - .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "", "")); + .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "")); } String getName(Entry<String, JsonElement> entry) { @@ -118,8 +119,22 @@ public class BlueprintParser { return ""; } - String getModelType(Entry<String, JsonElement> entry) { + String findModelTypeInTargetArray(JsonArray jsonArray, JsonObject nodeTemplateList) { + for (JsonElement elem : jsonArray) { + String modelType = getModelType( + new AbstractMap.SimpleEntry<String, JsonElement>(elem.getAsJsonObject().get(TARGET).getAsString(), + nodeTemplateList.get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()), + nodeTemplateList); + if (!modelType.isEmpty()) { + return modelType; + } + } + return ""; + } + + String getModelType(Entry<String, JsonElement> entry, JsonObject nodeTemplateList) { JsonObject ob = entry.getValue().getAsJsonObject(); + // Search first in this node template if (ob.has(PROPERTIES)) { JsonObject properties = ob.get(PROPERTIES).getAsJsonObject(); if (properties.has(POLICYID)) { @@ -129,19 +144,18 @@ public class BlueprintParser { } } } + // Then it's may be a relationship + if (ob.has(RELATIONSHIPS)) { + return findModelTypeInTargetArray(ob.get(RELATIONSHIPS).getAsJsonArray(), nodeTemplateList); + } return ""; } - String getBlueprintName(Entry<String, JsonElement> entry) { - return entry.getKey(); - } - - MicroService getNodeRepresentation(Entry<String, JsonElement> entry) { + MicroService getNodeRepresentation(Entry<String, JsonElement> entry, JsonObject nodeTemplateList) { String name = getName(entry); String getInputFrom = getInput(entry); - String modelType = getModelType(entry); - String blueprintName = getBlueprintName(entry); - return new MicroService(name, modelType, getInputFrom, "", blueprintName); + String modelType = getModelType(entry, nodeTemplateList); + return new MicroService(name, modelType, getInputFrom, ""); } private String getTarget(JsonObject elementObject) { diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java index ac4daeff..9bc7a022 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java @@ -29,16 +29,14 @@ import java.util.Objects; public class MicroService { private final String name; private final String modelType; - private final String blueprintName; private final String inputFrom; private String mappedNameJpa; - public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa, String blueprintName) { + public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa) { this.name = name; this.inputFrom = inputFrom; this.mappedNameJpa = mappedNameJpa; - this.modelType = modelType; - this.blueprintName = blueprintName; + this.modelType = modelType; } public String getName() { @@ -53,15 +51,10 @@ public class MicroService { return inputFrom; } - public String getBlueprintName() { - return blueprintName; - } - @Override public String toString() { return "MicroService{" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='" - + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + ", blueprintName='" - + blueprintName + '\'' + '}'; + + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + '}'; } public String getMappedNameJpa() { @@ -81,11 +74,12 @@ public class MicroService { return false; } MicroService that = (MicroService) o; - return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom) && mappedNameJpa.equals(that.mappedNameJpa) && blueprintName.equals(that.blueprintName); + return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom) + && mappedNameJpa.equals(that.mappedNameJpa); } @Override public int hashCode() { - return Objects.hash(name, modelType, inputFrom, mappedNameJpa, blueprintName); + return Objects.hash(name, modelType, inputFrom, mappedNameJpa); } } diff --git a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java index 0124aa70..ad13ad34 100644 --- a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java @@ -25,7 +25,6 @@ package org.onap.clamp.loop; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.google.gson.Gson; import com.google.gson.JsonObject; import java.io.IOException; @@ -51,9 +50,13 @@ import org.onap.clamp.clds.util.drawing.SvgFacade; import org.onap.clamp.policy.Policy; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.api.IEntityDetails; +import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; +import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; +import org.onap.sdc.tosca.parser.enums.EntityTemplateType; import org.onap.sdc.tosca.parser.enums.SdcTypes; import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.Property; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -183,22 +186,49 @@ public class LoopCsarInstaller implements CsarInstaller { return globalProperties; } - private JsonObject createModelPropertiesJson(CsarHandler csar) { - JsonObject modelProperties = new JsonObject(); - Gson gson = new Gson(); - ISdcCsarHelper csarHelper = csar.getSdcCsarHelper(); - modelProperties.add("serviceDetails", - gson.fromJson(gson.toJson(csarHelper.getServiceMetadataAllProperties()), JsonObject.class)); + private static JsonObject createVfModuleProperties(CsarHandler csar) { + JsonObject vfModuleProps = new JsonObject(); + // Loop on all Groups defined in the service (VFModule entries type: + // org.openecomp.groups.VfModule) + for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity( + EntityQuery.newBuilder(EntityTemplateType.GROUP).build(), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(), false)) { + // Get all metadata info + JsonObject allVfProps = (JsonObject) JsonUtils.GSON.toJsonTree(entity.getMetadata().getAllProperties()); + vfModuleProps.add(entity.getMetadata().getAllProperties().get("vfModuleModelName"), allVfProps); + // now append the properties section so that we can also have isBase, + // volume_group, etc ... fields under the VFmodule name + for (Entry<String, Property> additionalProp : entity.getProperties().entrySet()) { + allVfProps.add(additionalProp.getValue().getName(), + JsonUtils.GSON.toJsonTree(additionalProp.getValue().getValue())); + } + } + return vfModuleProps; + } + private static JsonObject createServicePropertiesByType(CsarHandler csar) { JsonObject resourcesProp = new JsonObject(); + // Iterate on all types defined in the tosca lib for (SdcTypes type : SdcTypes.values()) { JsonObject resourcesPropByType = new JsonObject(); - for (NodeTemplate nodeTemplate : csarHelper.getServiceNodeTemplateBySdcType(type)) { - resourcesPropByType.add(nodeTemplate.getName(), JsonUtils.GSON_JPA_MODEL - .fromJson(new Gson().toJson(nodeTemplate.getMetaData().getAllProperties()), JsonObject.class)); + // For each type, get the metadata of each nodetemplate + for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) { + resourcesPropByType.add(nodeTemplate.getName(), + JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties())); } resourcesProp.add(type.getValue(), resourcesPropByType); } + return resourcesProp; + } + + private static JsonObject createModelPropertiesJson(CsarHandler csar) { + JsonObject modelProperties = new JsonObject(); + // Add service details + modelProperties.add("serviceDetails", JsonUtils.GSON.fromJson( + JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class)); + // Add properties details for each type, VfModule, VF, VFC, .... + JsonObject resourcesProp = createServicePropertiesByType(csar); + resourcesProp.add("VFModule", createVfModuleProperties(csar)); modelProperties.add("resourceDetails", resourcesProp); return modelProperties; } diff --git a/src/main/java/org/onap/clamp/loop/LoopOperation.java b/src/main/java/org/onap/clamp/loop/LoopOperation.java index 3f4c5293..c3eb08be 100644 --- a/src/main/java/org/onap/clamp/loop/LoopOperation.java +++ b/src/main/java/org/onap/clamp/loop/LoopOperation.java @@ -31,23 +31,21 @@ import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import java.io.IOException; import java.lang.reflect.Array; import java.util.Collection; -import java.util.Date; +import java.util.Iterator; import java.util.Map; - -import javax.servlet.http.HttpServletRequest; +import java.util.Set; import org.apache.camel.Exchange; -import org.onap.clamp.clds.client.DcaeDispatcherServices; +import org.apache.camel.Message; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; import org.onap.clamp.clds.config.ClampProperties; -import org.onap.clamp.clds.util.LoggingUtils; -import org.onap.clamp.clds.util.ONAPLogConstants; -import org.onap.clamp.exception.OperationException; -import org.onap.clamp.util.HttpConnectionManager; -import org.slf4j.event.Level; +import org.onap.clamp.policy.operational.OperationalPolicy; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; @@ -59,117 +57,198 @@ public class LoopOperation { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LoopOperation.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getMetricsLogger(); - private final DcaeDispatcherServices dcaeDispatcherServices; + private static final String DCAE_LINK_FIELD = "links"; + private static final String DCAE_STATUS_FIELD = "status"; + private static final String DCAE_DEPLOYMENT_TEMPLATE = "dcae.deployment.template"; + private static final String DCAE_SERVICETYPE_ID = "serviceTypeId"; + private static final String DCAE_INPUTS = "inputs"; + private static final String DCAE_DEPLOYMENT_PREFIX = "closedLoop_"; + private static final String DCAE_DEPLOYMENT_SUFIX = "_deploymentId"; private final LoopService loopService; - private LoggingUtils util = new LoggingUtils(logger); + private final ClampProperties refProp; - @Autowired - private HttpServletRequest request; + public enum TempLoopState { + NOT_SUBMITTED, SUBMITTED, DEPLOYED, NOT_DEPLOYED, PROCESSING, IN_ERROR; + } + /** + * The constructor. + * @param loopService The loop service + * @param refProp The clamp properties + */ @Autowired - public LoopOperation(LoopService loopService, DcaeDispatcherServices dcaeDispatcherServices, - ClampProperties refProp, HttpConnectionManager httpConnectionManager) { + public LoopOperation(LoopService loopService, ClampProperties refProp) { this.loopService = loopService; - this.dcaeDispatcherServices = dcaeDispatcherServices; + this.refProp = refProp; } - + /** - * Deploy the closed loop. + * Get the payload used to send the deploy closed loop request. * - * @param loopName - * the loop name - * @return the updated loop - * @throws OperationException - * Exception during the operation + * @param loop The loop + * @return The payload used to send deploy closed loop request + * @throws IOException IOException */ - public Loop deployLoop(Exchange camelExchange, String loopName) throws OperationException { - util.entering(request, "CldsService: Deploy model"); - Date startTime = new Date(); - Loop loop = loopService.getLoop(loopName); - - if (loop == null) { - String msg = "Deploy loop exception: Not able to find closed loop:" + loopName; - util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO, - ONAPLogConstants.ResponseStatus.ERROR); - throw new OperationException(msg); - } + public String getDeployPayload(Loop loop) throws IOException { + Yaml yaml = new Yaml(); + Map<String, Object> yamlMap = yaml.load(loop.getBlueprint()); + JsonObject bluePrint = wrapSnakeObject(yamlMap).getAsJsonObject(); + + String serviceTypeId = loop.getDcaeBlueprintId(); - // verify the current closed loop state - if (loop.getLastComputedState() != LoopState.SUBMITTED) { - String msg = "Deploy loop exception: This closed loop is in state:" + loop.getLastComputedState() - + ". It could be deployed only when it is in SUBMITTED state."; - util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO, ONAPLogConstants.ResponseStatus.ERROR); - throw new OperationException(msg); + JsonObject rootObject = refProp.getJsonTemplate(DCAE_DEPLOYMENT_TEMPLATE).getAsJsonObject(); + rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId); + if (bluePrint != null) { + rootObject.add(DCAE_INPUTS, bluePrint); } + String apiBodyString = rootObject.toString(); + logger.info("Dcae api Body String - " + apiBodyString); + return apiBodyString; + } + + /** + * Get the deployment id. + * + * @param loop The loop + * @return The deployment id + * @throws IOException IOException + */ + public String getDeploymentId(Loop loop) { // Set the deploymentId if not present yet String deploymentId = ""; // If model is already deployed then pass same deployment id if (loop.getDcaeDeploymentId() != null && !loop.getDcaeDeploymentId().isEmpty()) { deploymentId = loop.getDcaeDeploymentId(); } else { - loop.setDcaeDeploymentId(deploymentId = "closedLoop_" + loopName + "_deploymentId"); + deploymentId = DCAE_DEPLOYMENT_PREFIX + loop.getName() + DCAE_DEPLOYMENT_SUFIX; } + return deploymentId; + } - Yaml yaml = new Yaml(); - Map<String, Object> yamlMap = yaml.load(loop.getBlueprint()); - JsonObject bluePrint = wrapSnakeObject(yamlMap).getAsJsonObject(); + /** + * Update the loop info. + * + * @param camelExchange The camel exchange + * @param loop The loop + * @param deploymentId The deployment id + * @throws ParseException The parse exception + */ + public void updateLoopInfo(Exchange camelExchange, Loop loop, String deploymentId) throws ParseException { + Message in = camelExchange.getIn(); + String msg = in.getBody(String.class); - loop.setDcaeDeploymentStatusUrl( - dcaeDispatcherServices.createNewDeployment(deploymentId, loop.getDcaeBlueprintId(), bluePrint)); - loop.setLastComputedState(LoopState.DEPLOYED); - // save the updated loop + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(msg); + JSONObject jsonObj = (JSONObject) obj0; + + JSONObject linksObj = (JSONObject) jsonObj.get(DCAE_LINK_FIELD); + String statusUrl = (String) linksObj.get(DCAE_STATUS_FIELD); + + // use http4 instead of http, because camel http4 component is used to do the http call + String newStatusUrl = statusUrl.replaceAll("http:", "http4:"); + + loop.setDcaeDeploymentId(deploymentId); + loop.setDcaeDeploymentStatusUrl(newStatusUrl); loopService.saveOrUpdateLoop(loop); + } - // audit log - LoggingUtils.setTimeContext(startTime, new Date()); - auditLogger.info("Deploy model completed"); - util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED); - return loop; + /** + * Get the Closed Loop status based on the reply from Policy. + * + * @param statusCode The status code + * @return The state based on policy response + * @throws ParseException The parse exception + */ + public String analysePolicyResponse(int statusCode) { + if (statusCode == 200) { + return TempLoopState.SUBMITTED.toString(); + } else if (statusCode == 404) { + return TempLoopState.NOT_SUBMITTED.toString(); + } + return TempLoopState.IN_ERROR.toString(); } /** - * Un deploy closed loop. + * Get the name of the first Operational policy. * - * @param loopName - * the loop name - * @return the updated loop + * @param loop The closed loop + * @return The name of the first operational policy */ - public Loop unDeployLoop(String loopName) throws OperationException { - util.entering(request, "LoopOperation: Undeploy the closed loop"); - Date startTime = new Date(); - Loop loop = loopService.getLoop(loopName); - - if (loop == null) { - String msg = "Undeploy loop exception: Not able to find closed loop:" + loopName; - util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), msg, Level.INFO, - ONAPLogConstants.ResponseStatus.ERROR); - throw new OperationException(msg); + public String getOperationalPolicyName(Loop loop) { + Set<OperationalPolicy> opSet = (Set<OperationalPolicy>)loop.getOperationalPolicies(); + Iterator<OperationalPolicy> iterator = opSet.iterator(); + while (iterator.hasNext()) { + OperationalPolicy policy = iterator.next(); + return policy.getName(); } + return null; + } - // verify the current closed loop state - if (loop.getLastComputedState() != LoopState.DEPLOYED) { - String msg = "Unploy loop exception: This closed loop is in state:" + loop.getLastComputedState() - + ". It could be undeployed only when it is in DEPLOYED state."; - util.exiting(HttpStatus.CONFLICT.toString(), msg, Level.INFO, ONAPLogConstants.ResponseStatus.ERROR); - throw new OperationException(msg); + /** + * Get the Closed Loop status based on the reply from DCAE. + * + * @param camelExchange The camel exchange + * @return The state based on DCAE response + * @throws ParseException The parse exception + */ + public String analyseDcaeResponse(Exchange camelExchange, Integer statusCode) throws ParseException { + if (statusCode == null) { + return TempLoopState.NOT_DEPLOYED.toString(); } + if (statusCode == 200) { + Message in = camelExchange.getIn(); + String msg = in.getBody(String.class); - loop.setDcaeDeploymentStatusUrl( - dcaeDispatcherServices.deleteExistingDeployment(loop.getDcaeDeploymentId(), loop.getDcaeBlueprintId())); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(msg); + JSONObject jsonObj = (JSONObject) obj0; - // clean the deployment ID - loop.setDcaeDeploymentId(null); - loop.setLastComputedState(LoopState.SUBMITTED); + String opType = (String) jsonObj.get("operationType"); + String status = (String) jsonObj.get("status"); - // save the updated loop - loopService.saveOrUpdateLoop(loop); + // status = processing/successded/failed + if (status.equals("succeeded")) { + if (opType.equals("install")) { + return TempLoopState.DEPLOYED.toString(); + } else if (opType.equals("uninstall")) { + return TempLoopState.NOT_DEPLOYED.toString(); + } + } else if (status.equals("processing")) { + return TempLoopState.PROCESSING.toString(); + } + } else if (statusCode == 404) { + return TempLoopState.NOT_DEPLOYED.toString(); + } + return TempLoopState.IN_ERROR.toString(); + } - // audit log - LoggingUtils.setTimeContext(startTime, new Date()); - auditLogger.info("Undeploy model completed"); - util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED); - return loop; + /** + * Update the status of the closed loop based on the response from Policy and DCAE. + * + * @param loop The closed loop + * @param policyState The state get from Policy + * @param dcaeState The state get from DCAE + * @throws ParseException The parse exception + */ + public LoopState updateLoopStatus(Loop loop, TempLoopState policyState, TempLoopState dcaeState) { + LoopState clState = LoopState.IN_ERROR; + if (policyState == TempLoopState.SUBMITTED) { + if (dcaeState == TempLoopState.DEPLOYED) { + clState = LoopState.DEPLOYED; + } else if (dcaeState == TempLoopState.PROCESSING) { + clState = LoopState.WAITING; + } else if (dcaeState == TempLoopState.NOT_DEPLOYED) { + clState = LoopState.SUBMITTED; + } + } else if (policyState == TempLoopState.NOT_SUBMITTED) { + if (dcaeState == TempLoopState.NOT_DEPLOYED) { + clState = LoopState.DESIGN; + } + } + loop.setLastComputedState(clState); + loopService.saveOrUpdateLoop(loop); + return clState; } private JsonElement wrapSnakeObject(Object obj) { diff --git a/src/main/java/org/onap/clamp/loop/log/LoopLog.java b/src/main/java/org/onap/clamp/loop/log/LoopLog.java index 3edb2ee5..cea49571 100644 --- a/src/main/java/org/onap/clamp/loop/log/LoopLog.java +++ b/src/main/java/org/onap/clamp/loop/log/LoopLog.java @@ -69,7 +69,7 @@ public class LoopLog implements Serializable { private LogType logType; @Expose - @Column(name = "message", nullable = false) + @Column(name = "message", columnDefinition = "MEDIUMTEXT", nullable = false) private String message; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index b2f6109f..906c3cfa 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -206,7 +206,7 @@ public class OperationalPolicy implements Serializable, Policy { for (Entry<String, JsonElement> guardElem : guardsList.getAsJsonObject().entrySet()) { JsonObject guard = new JsonObject(); guard.addProperty("policy-id", guardElem.getKey()); - guard.add("contents", guardElem.getValue()); + guard.add("content", guardElem.getValue()); result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard)); } } diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html index b7864eca..db81e476 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP CLAMP ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -291,7 +291,7 @@ label { Type</label> <div class="col-sm-8"> <select class="form-control" name="type" id="type" - ng-click="initTargetResourceId()" ng-model="type"> + ng-click="initTargetResourceId($event)" ng-model="type"> <option value="">-- choose an option --</option> <option value="VFModule">VFModule</option> <option value="VM">VM</option> @@ -304,10 +304,9 @@ label { Target ResourceId</label> <div class="col-sm-8"> <select class="form-control" name="resourceId" id="resourceId" - enableFilter="true" ng-click="changeTargetResourceId()" + enableFilter="true" ng-click="changeTargetResourceId($event)" ng-model="resourceId"> <option value="">-- choose an option --</option> - <option value="Other:">Other:</option> </select> </div> </div> @@ -404,34 +403,34 @@ label { </div> <div class="form-group clearfix"> - <label for="guardTargets" class="col-sm-4 control-label">Guard + <label for="targets" class="col-sm-4 control-label">Guard targets</label> <div class="col-sm-8"> - <input class="form-control" name="guardTargets" id="guardTargets" /> + <input class="form-control" name="targets" id="targets" /> </div> </div> <div class="form-group clearfix" id="minMaxGuardPolicyDiv"> - <label for="minGuard" class="col-sm-4 control-label"> Min + <label for="min" class="col-sm-4 control-label"> Min Guard</label> <div class="col-sm-8"> - <input class="form-control" name="minGuard" id="minGuard" /> + <input class="form-control" name="min" id="min" /> </div> - <label for="maxGuard" class="col-sm-4 control-label"> Max + <label for="max" class="col-sm-4 control-label"> Max Guard</label> <div class="col-sm-8"> - <input class="form-control" name="maxGuard" id="maxGuard" /> + <input class="form-control" name="max" id="max" /> </div> </div> <div class="form-group clearfix" id="frequencyLimiterGuardPolicyDiv" style="display: none"> - <label for="limitGuard" class="col-sm-4 control-label">Limit</label> + <label for="limit" class="col-sm-4 control-label">Limit</label> <div class="col-sm-8"> - <input class="form-control" name="limitGuard" id="limitGuard" /> + <input class="form-control" name="limit" id="limit" /> </div> <div class="col-sm-8"> - <select class="form-control" name="timeUnitsGuard" - id="timeUnitsGuard"> + <select class="form-control" name="timeUnits" + id="timeUnits"> <option value=""></option> <option value="minute">minute</option> <option value="hour">hour</option> @@ -440,12 +439,12 @@ label { <option value="month">month</option> <option value="year">year</option> - </select> <label for="timeWindowGuard" class="col-sm-4 control-label">Time + </select> <label for="timeWindow" class="col-sm-4 control-label">Time Window</label> </div> <div class="col-sm-8"> - <input class="form-control" name="timeWindowGuard" - id="timeWindowGuard" /> + <input class="form-control" name="timeWindow" + id="timeWindow" /> </div> </div> <div class="form-group clearfix"> diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js index 2c3f83e4..0cf4c2e3 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,7 +55,6 @@ app } console.log("No active formId found !"); } - function add_one_more() { console.log("add one more"); @@ -154,10 +153,9 @@ app policiesArray.push(policyProperties); // Now get the Guard if ($("#" + this.id + " #enableGuardPolicy").is(':checked')) { - var guardPolicyBody = serializeElement($("#" + this.id + " .guardProperties")); - var guardPolicyId = guardPolicyBody['id']; - delete guardPolicyBody['id']; - + var guardPolicyBody = serializeElement($("#" + this.id + " .guardProperties")); + var guardPolicyId = guardPolicyBody['id']; + delete guardPolicyBody['id']; allPolicies['guard_policies'][guardPolicyId] = guardPolicyBody; $scope.guard_ids.push(guardPolicyId); } @@ -190,9 +188,14 @@ app var formNum = add_one_more(); $.each($('.policyProperties').find('.form-control'), function(opPolicyPropIndex, opPolicyPropValue) { - $("#formId"+formNum+" .policyProperties").find("#"+opPolicyPropValue.id).val( + $("#formId" + formNum + " .policyProperties").find("#" + opPolicyPropValue.id).val( allPolicies['operational_policy']['policies'][opPolicyElemIndex][opPolicyPropValue.id]); }); + $.each($('.policyTarget').find('.form-control'), function(opPolicyTargetPropIndex, opPolicyTargetPropValue) { + + $("#formId" + formNum + " .policyTarget").find("#" + opPolicyTargetPropValue.id).val( + allPolicies['operational_policy']['policies'][opPolicyElemIndex]['target'][opPolicyTargetPropValue.id]); + }); // update the current tab label $("#go_properties_tab" + formNum).text( allPolicies['operational_policy']['policies'][opPolicyElemIndex]['id']); @@ -201,9 +204,11 @@ app if (guardElemValue.recipe === $($("#formId" + formNum + " #recipe")[0]).val()) { // Found one, set all guard prop - $.each($('.guardProperties').find('.form-control'), function(guardPropElemIndex,guardPropElemValue) { - guardElemValue['id'] = guardElemId; - $("#formId"+formNum+" .guardProperties").find("#"+guardPropElemValue.id).val( + $.each($('.guardProperties').find('.form-control'), function(guardPropElemIndex, + guardPropElemValue) { + + guardElemValue['id'] = guardElemId; + $("#formId" + formNum + " .guardProperties").find("#" + guardPropElemValue.id).val( guardElemValue[guardPropElemValue.id]); }); // And finally enable the flag @@ -212,108 +217,69 @@ app }); }); } - - $scope.initTargetResourceId = function() { - - var recipe = $(event.target).val(); - - var type = $(event.target).val(); - - $("#modelName").val(""); - $("#modelInvariantId").val(""); - $("#modelVersionId").val(""); - $("#modelVersion").val(""); - $("#modelCustomizationId").val(""); - $('#resourceId').empty(); - $("#resourceId") - .append( - $('<option></option>').val("") - .html("-- choose an option --")); - $("#resourceId").append( - $('<option></option>').val("Other:") - .html("Other:")); - if (type == "VM" || type == "" || type == "VNF" ) { - $("#metadata *").prop('disabled',true); - } - - var resourceVnf = getResourceDetailsProperty(); - if (type == "VNF" - && (null !== resourceVnf || undefined !== resourceVnf)) { - for ( var prop in resourceVnf) { - var name = resourceVnf[prop]["name"]; - $("#resourceId").append( - $('<option></option>') - .val(name).html(name)); - } - - } - var resourceVFModule = getResourceDetailsVfModuleProperty(); - if (type == "VFModule" - && (null !== resourceVFModule || undefined !== resourceVFModule)) { - if (recipe == 'VF Module Create' - || recipe == 'VF Module Delete') { - for ( var prop in resourceVFModule) { - if (resourceVFModule[prop]["isBase"] == false) { - var name = resourceVFModule[prop]["name"]; - $("#resourceId").append( - $('<option></option>') - .val(name) - .html(name)); - } - } - } - else - { - for ( var prop in resourceVFModule) { - var name = resourceVFModule[prop]["name"]; - $("#resourceId").append( - $('<option></option>') - .val(name).html(name)); - } - } - } - } - - $scope.changeTargetResourceId = function() { - $("#modelName").val(""); - $("#modelInvariantId").val(""); - $("#modelVersionId").val(""); - $("#modelVersion").val(""); - $("#modelCustomizationId").val(""); - var resourceVFModule = getResourceDetailsVfModuleProperty(); - var type = $("#type").val(); - var recipe = $("#recipe").val(); - vfBaseName = $(event.target).val(); - if (type == "VFModule" - && (null !== resourceVFModule || undefined !== resourceVFModule) - && (recipe == 'VF Module Create' || recipe == 'VF Module Delete')) { - for ( var prop in resourceVFModule) { - var name = resourceVFModule[prop]["name"]; - if (name == vfBaseName) { - var vfModuleModelName = resourceVFModule[prop]["name"]; - $("#modelName").val( - vfModuleModelName); - var vfModuleModelInvariantUUID = resourceVFModule[prop]["invariantUUID"]; - $("#modelInvariantId").val( - vfModuleModelInvariantUUID); - var vfModuleModelUUID = resourceVFModule[prop]["UUID"]; - $("#modelVersionId").val( - vfModuleModelUUID); - var vfModuleModelVersion = resourceVFModule[prop]["version"]; - $("#modelVersion").val( - vfModuleModelVersion); - var vfModuleModelCustomizationUUID = resourceVFModule[prop]["customizationUUID"]; - $("#modelCustomizationId") - .val( - vfModuleModelCustomizationUUID); - } - } - } - else { - $("#metadata *").prop('disabled',true); - } - } - + $scope.initTargetResourceId = function(event) { + var formNum = $(event.target).closest('.formId').attr('id').substring(6); + + var type = $(event.target).val(); + var recipe = $("#formId" + formNum + "#recipe").val(); + $("#formId" + formNum + " #modelName").val(""); + $("#formId" + formNum + " #modelInvariantId").val(""); + $("#formId" + formNum + " #modelVersionId").val(""); + $("#formId" + formNum + " #modelVersion").val(""); + $("#formId" + formNum + " #modelCustomizationId").val(""); + $("#formId" + formNum + " #resourceId").empty(); + $("#formId" + formNum + " #resourceId").append($('<option></option>').val("").html("-- choose an option --")); + if (type == "VM" || type == "" || type == "VNF") { + $("#formId" + formNum + " #metadata *").prop('disabled', true); + } + var resourceVnf = getResourceDetailsVfProperty(); + if (type == "VNF" && (null !== resourceVnf || undefined !== resourceVnf)) { + for ( var prop in resourceVnf) { + var name = resourceVnf[prop]["name"]; + $("#formId" + formNum + " #resourceId").append($('<option></option>').val(name).html(name)); + } + } + var resourceVFModule = getResourceDetailsVfModuleProperty(); + if (type == "VFModule" && (null !== resourceVFModule || undefined !== resourceVFModule)) { + if (recipe == 'VF Module Create' || recipe == 'VF Module Delete') { + for ( var prop in resourceVFModule) { + if (resourceVFModule[prop]["isBase"] == false) { + $("#formId" + formNum + " #resourceId").append($('<option></option>').val(resourceVFModule[prop]["vfModuleModelName"]).html(resourceVFModule[prop]["vfModuleModelName"])); + } + } + } else { + for ( var prop in resourceVFModule) { + $("#formId" + formNum + " #resourceId").append($('<option></option>').val(resourceVFModule[prop]["vfModuleModelName"]).html(resourceVFModule[prop]["vfModuleModelName"])); + } + } + } + } + $scope.changeTargetResourceId = function(event) { + var formNum = $(event.target).closest('.formId').attr('id').substring(6); + $("#formId" + formNum +" #modelName").val(""); + $("#formId" + formNum +" #modelInvariantId").val(""); + $("#formId" + formNum +" #modelVersionId").val(""); + $("#formId" + formNum +" #modelVersion").val(""); + $("#formId" + formNum +" #modelCustomizationId").val(""); + var resourceVFModule = getResourceDetailsVfModuleProperty(); + var type = $("#formId" + formNum +" #type").val(); + var recipe = $("#formId" + formNum +" #recipe").val(); + if (type == "VFModule" && (null !== resourceVFModule || undefined !== resourceVFModule) + && (recipe == 'VF Module Create' || recipe == 'VF Module Delete')) { + for ( var prop in resourceVFModule) { + if (prop == $(event.target).val()) { + $("#formId" + formNum +" #modelName").val(resourceVFModule[prop]["vfModuleModelName"]); + $("#formId" + formNum +" #modelInvariantId").val(resourceVFModule[prop]["vfModuleModelInvariantUUID"]); + $("#formId" + formNum +" #modelVersionId").val(resourceVFModule[prop]["vfModuleModelUUID"]); + $("#formId" + formNum +" #modelVersion").val(resourceVFModule[prop]["vfModuleModelVersion"]); + $("#formId" + formNum +" #modelCustomizationId").val(resourceVFModule[prop]["vfModuleModelCustomizationUUID"]); + $("#formId" + formNum +" #metadata *").prop('disabled', false); + } + } + } else { + $("#formId" + formNum +" #metadata *").prop('disabled', true); + } + } $scope.changeGuardPolicyType = function() { var formItemActive = searchActiveFormId(); @@ -343,7 +309,8 @@ app $scope.init = function() { $(function() { - $scope.clname=getLoopName(); + + $scope.clname = getLoopName(); $("#add_one_more").click(function(event) { console.log("add one more"); @@ -359,17 +326,18 @@ app add_new_policy(); } $("#savePropsBtn").click(function(event) { + console.log("save properties triggered"); savePolicyLocally(); - for(var i = 0; i <= $scope.guard_ids.length; i++) { - for(var j = i; j <= $scope.guard_ids.length; j++) { - if(i != j && $scope.guard_ids[i] == $scope.guard_ids[j]) { - // duplacated guard policy id exist - alert("The guard policy ID should be unique."); - return; - } - } - } + for (var i = 0; i <= $scope.guard_ids.length; i++) { + for (var j = i; j <= $scope.guard_ids.length; j++) { + if (i != j && $scope.guard_ids[i] == $scope.guard_ids[j]) { + // duplacated guard policy id exist + alert("The guard policy ID should be unique."); + return; + } + } + } angular.element(document.getElementById('formSpan')).scope().submitForm(allPolicies); $("#close_button").click(); }); diff --git a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js index 3902cf41..ee602b99 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js +++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js @@ -114,7 +114,7 @@ function setDeploymentStatusURL(deploymentStatusURL) { cl_props["dcaeDeploymentStatusUrl"] = deploymentStatusURL; } -function getResourceDetailsProperty() { +function getResourceDetailsVfProperty() { return cl_props["modelPropertiesJson"]["resourceDetails"]["VF"]; } @@ -126,4 +126,4 @@ function getLoopLogsArray() { return cl_props.loopLogs; } -module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL,getResourceDetailsProperty,getResourceDetailsVfModuleProperty };
\ No newline at end of file +module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL,getResourceDetailsVfProperty,getResourceDetailsVfModuleProperty };
\ No newline at end of file diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index de3f7c07..52f79bef 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -210,6 +210,11 @@ clamp.config.dcae.dispatcher.url=http://dcae.api.simpledemo.onap.org:8188 clamp.config.dcae.dispatcher.retry.interval=20000 clamp.config.dcae.dispatcher.retry.limit=30 +#DCAE Deployment Url Properties +clamp.config.dcae.deployment.url=http4://dcae.api.simpledemo.onap.org:8188 +clamp.config.dcae.deployment.userName=test +clamp.config.dcae.deployment.password=test + #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f59b8ac6..534dc481 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -228,6 +228,11 @@ clamp.config.dcae.dispatcher.url=http://dcae.api.simpledemo.onap.org:8188 clamp.config.dcae.dispatcher.retry.interval=20000 clamp.config.dcae.dispatcher.retry.limit=30 +#DCAE Deployment Url Properties +clamp.config.dcae.deployment.url=http4://dcae.api.simpledemo.onap.org:8188 +clamp.config.dcae.deployment.userName=test +clamp.config.dcae.deployment.password=test + #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 5c5f122c..1883145d 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -202,11 +202,35 @@ excludePattern="loopName" /> <doTry> <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Deploy the closed loop')" /> + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'DEPLOY the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> + <to uri="direct:load-loop" /> + <to uri="direct:get-status-from-policy" /> + <to uri="direct:get-status-from-dcae" /> + <log + loggingLevel="INFO" + message="Policy deployment status: ${exchangeProperty[policyStatus]}"></log> + <choice> + <when> + <simple> ${exchangeProperty[policyStatus]} == 'SUBMITTED' and + ${exchangeProperty[dcaeStatus]} == 'NOT_DEPLOYED' + </simple> + <to uri="direct:deploy-closedloop" /> + </when> + <otherwise> + <log + loggingLevel="INFO" + message="Closed Loop is in state ${exchangeProperty[policyStatus]}, it can only be deployed when in state SUBMIT" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Closed Loop is in state ${exchangeProperty[policyStatus]}, it can only be deployed when in state SUBMIT','ERROR',${exchangeProperty[loopObject]})" /> + </otherwise> + </choice> + <log + loggingLevel="INFO" + message="DEPLOY request successfully executed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.operation.LoopOperation?method=deployLoop(*,${header.loopName})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DEPLOY request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> <doCatch> @@ -216,6 +240,11 @@ </handled> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="DEPLOY request failed for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DEPLOY request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" /> </doCatch> </doTry> </route> @@ -233,8 +262,27 @@ uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Undeploy the closed loop')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> + <to uri="direct:load-loop" /> + <to uri="direct:get-status-from-dcae" /> + <choice> + <when> + <simple> ${exchangeProperty[dcaeStatus]} == 'DEPLOYED' + </simple> + <to uri="direct:undeploy-closedloop" /> + </when> + <otherwise> + <log + loggingLevel="INFO" + message="Closed Loop is in state ${exchangeProperty[dcaeStatus]}, it can only be undeployed when in state DEPLOYED" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Closed Loop is in state ${exchangeProperty[dcaeStatus]}, it can only be deployed when in state DEPLOYED','ERROR',${exchangeProperty[loopObject]})" /> + </otherwise> + </choice> + <log + loggingLevel="INFO" + message="UNDEPLOY request successfully executed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.operation.LoopOperation?method=unDeployLoop(${header.loopName})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('UNDEPLOY request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> <doCatch> @@ -244,6 +292,11 @@ </handled> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="UNDEPLOY request failed for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('UNDEPLOY request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" /> </doCatch> </doTry> </route> @@ -268,12 +321,10 @@ <to uri="direct:remove-all-policy-from-active-pdp-group" /> <log loggingLevel="INFO" - message="STOP request successfully executed for loop: ${body}" /> + message="STOP request successfully executed for loop: ${header.loopName}" /> <to uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to - uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> <doCatch> <exception>java.lang.Exception</exception> @@ -286,7 +337,7 @@ loggingLevel="ERROR" message="STOP request failed for loop: $${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request failed','ERROR',${exchangeProperty[loopObject]})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" /> </doCatch> </doTry> </route> @@ -317,8 +368,6 @@ <to uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('START request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to - uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> <doCatch> <exception>java.lang.Exception</exception> @@ -331,7 +380,7 @@ loggingLevel="ERROR" message="START request failed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('START request failed','INFO',${exchangeProperty[loopObject]})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('START request failed, Error reported: ${exception}','INFO',${exchangeProperty[loopObject]})" /> </doCatch> </doTry> </route> @@ -425,8 +474,6 @@ <to uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request successfully executed','INFO',${exchangeProperty[loopObject]})" /> <to - uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> <doCatch> <exception>java.lang.Exception</exception> @@ -439,7 +486,7 @@ loggingLevel="ERROR" message="SUBMIT request failed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request failed','ERROR',${exchangeProperty[loopObject]})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" /> </doCatch> </doTry> </route> @@ -521,10 +568,61 @@ loggingLevel="ERROR" message="DELETE request failed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request failed','ERROR',${exchangeProperty[loopObject]})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" /> </doCatch> </doTry> </route> </put> + <get + uri="/v2/loop/getstatus/{loopName}" + outType="org.onap.clamp.loop.Loop" + produces="application/json"> + <route> + <removeHeaders + pattern="*" + excludePattern="loopName" /> + <doTry> + <log + loggingLevel="INFO" + message="Get current status for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Get the closed loop status')" /> + <to + uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')" /> + <to uri="direct:load-loop" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Receive GET STATUS request','INFO',${exchangeProperty[loopObject]})" /> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:get-status-from-policy" /> + <to uri="direct:get-status-from-dcae" /> + <to + uri="bean:org.onap.clamp.loop.LoopOperation?method=updateLoopStatus(${exchangeProperty[loopObject]},${exchangeProperty[policyStatus]}, ${exchangeProperty[dcaeStatus]})" /> + <log + loggingLevel="INFO" + message="Get Status request successfully executed. The new state is: ${body}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Get Status request successfully executed','INFO',${exchangeProperty[loopObject]})" /> + <to + uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" /> + <log + loggingLevel="ERROR" + message="Get Status request failed for loop: ${header.loopName}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Get Status request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> + </doTry> + </route> + </get> </rest> </rests> diff --git a/src/main/resources/clds/camel/routes/flexible-flow.xml b/src/main/resources/clds/camel/routes/flexible-flow.xml index 75341de9..920e1e54 100644 --- a/src/main/resources/clds/camel/routes/flexible-flow.xml +++ b/src/main/resources/clds/camel/routes/flexible-flow.xml @@ -133,7 +133,7 @@ loggingLevel="INFO" message="Endpoint to create microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> <to @@ -178,7 +178,7 @@ loggingLevel="INFO" message="Endpoint to delete microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> @@ -226,9 +226,9 @@ </setHeader> <log loggingLevel="INFO" - message="Endpoint to create operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies"></log> + message="Endpoint to create operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> <to @@ -271,9 +271,9 @@ </setHeader> <log loggingLevel="INFO" - message="Endpoint to delete operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1.0.0"></log> + message="Endpoint to delete operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1.0.0"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> <to @@ -320,9 +320,9 @@ </setHeader> <log loggingLevel="INFO" - message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.guard/versions/1.0.0/policies"></log> + message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.guard/versions/1.0.0/policies?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> <to @@ -364,9 +364,9 @@ </setHeader> <log loggingLevel="INFO" - message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1.0.0"></log> + message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1.0.0"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policy.controlloop.guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1.0.0?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> @@ -413,9 +413,9 @@ </setHeader> <log loggingLevel="INFO" - message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log> + message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies"></log> <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}" /> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}" /> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> @@ -465,7 +465,7 @@ loggingLevel="INFO" message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0"></log> <toD - uri="{{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}" /> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}" /> <setProperty propertyName="logMessage"> <simple>${exchangeProperty[policyName]} PDP Group removal status </simple> @@ -478,8 +478,7 @@ <constant>false</constant> </handled> <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[policyName]} PDP Group removal status - </simple> + <simple>PDP Group removal, Error reported: ${exception}</simple> </setProperty> <to uri="direct:dump-loop-log-http-response" /> </doCatch> @@ -490,7 +489,217 @@ </doFinally> </doTry> </route> + <route id="deploy-closedloop"> + <from uri="direct:deploy-closedloop" /> + <doTry> + <log + loggingLevel="INFO" + message="Deploy the closed loop: ${exchangeProperty[loopObject].getName()}" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Deploy closed loop')" /> + <setBody> + <method ref="org.onap.clamp.loop.LoopOperation" + method="getDeployPayload(${exchangeProperty[loopObject]})" /> + </setBody> + <setProperty propertyName="deploymentId"> + <method ref="org.onap.clamp.loop.LoopOperation" + method="getDeploymentId(${exchangeProperty[loopObject]})" /> + </setProperty> + <setHeader headerName="CamelHttpMethod"> + <constant>PUT</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log + loggingLevel="INFO" + message="Endpoint to deploy closed loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[deploymentId]}"></log> + <toD + uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[deploymentId]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[RaiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}" /> + <to + uri="bean:org.onap.clamp.loop.LoopOperation?method=updateLoopInfo(*,${exchangeProperty[loopObject]},${exchangeProperty[deploymentId]})" /> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <setProperty propertyName="logMessage"> + <simple>Deploy closed loop status</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> + </route> + <route id="undeploy-closedloop"> + <from uri="direct:undeploy-closedloop" /> + <doTry> + <log + loggingLevel="INFO" + message="UNdeploy the closed loop: ${exchangeProperty[loopObject].getName()} : ${exchangeProperty[loopObject].getDcaeDeploymentId()}" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Undeploy closed loop')" /> + + <setBody> + <simple>{\"serviceTypeId\": \"${exchangeProperty[loopObject].getDcaeBlueprintId()}\"} + </simple> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>DELETE</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log + loggingLevel="INFO" + message="Endpoint to undeploy closed loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}"></log> + <toD + uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[RaiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}" /> + <to + uri="bean:org.onap.clamp.loop.LoopOperation?method=updateLoopInfo(*,${exchangeProperty[loopObject]},null)" /> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <setProperty propertyName="logMessage"> + <simple>Undeploy closed loop status</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> + </route> + <route id="get-status-from-policy"> + <from uri="direct:get-status-from-policy" /> + <doTry> + <log + loggingLevel="INFO" + message="Query Closed Loop status from policy PDP: ${exchangeProperty[loopObject].getName()}" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Query operational policies to PDP group')" /> + <setProperty propertyName="operationalPolicyName"> + <method ref="org.onap.clamp.loop.LoopOperation" + method="getOperationalPolicyName(${exchangeProperty[loopObject]})" /> + </setProperty> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log + loggingLevel="INFO" + message="Endpoint to query from Policy PDP: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicyName]}/versions/deployed"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicyName]}/versions/deployed?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authMethod=Basic&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}" /> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <setProperty propertyName="logMessage"> + <simple>Query closed loop from Policy status</simple> + </setProperty> + <setProperty propertyName="policyStatus"> + <method ref="org.onap.clamp.loop.LoopOperation" + method="analysePolicyResponse(${header.CamelHttpResponseCode})" /> + </setProperty> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> + </route> + <route id="get-status-from-dcae"> + <from uri="direct:get-status-from-dcae" /> + <log + loggingLevel="INFO" + message="Query Closed Loop status from DCAE ${exchangeProperty[loopObject].getName()}" /> + <choice> + <when> + <simple>${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()} == null + </simple> + <setProperty propertyName="dcaeStatus"> + <method ref="org.onap.clamp.loop.LoopOperation" + method="analyseDcaeResponse(*,null)" /> + </setProperty> + <log + loggingLevel="INFO" + message="dcae status: ${exchangeProperty[dcaeStatus]}"></log> + </when> + <otherwise> + <doTry> + <log + loggingLevel="INFO" + message="Query Closed Loop status from Dcae" /> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log + loggingLevel="INFO" + message="Endpoint to query Closed Loop status: ${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}"></log> + <toD + uri="${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&httpClient.connectTimeout=10000&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}" /> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag" /> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" /> + <setProperty propertyName="logMessage"> + <simple>Query closed loop from DCAE status</simple> + </setProperty> + <setProperty propertyName="dcaeStatus"> + <method ref="org.onap.clamp.loop.LoopOperation" + method="analyseDcaeResponse(*,${header.CamelHttpResponseCode})" /> + </setProperty> + <log + loggingLevel="INFO" + message="dcae status: ${exchangeProperty[dcaeStatus]}"></log> + <to uri="direct:dump-loop-log-http-response" /> + </doFinally> + </doTry> + </otherwise> + </choice> + </route> <route id="reset-raise-http-exception-flag"> <from uri="direct:reset-raise-http-exception-flag" /> <setProperty propertyName="raiseHttpExceptionFlag"> @@ -500,7 +709,8 @@ <route id="dump-loop-log-http-response"> <from uri="direct:dump-loop-log-http-response" /> + <log loggingLevel="INFO" message="${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog(${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText},'INFO',${exchangeProperty[loopObject]})" /> + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}','INFO',${exchangeProperty[loopObject]})" /> </route> </routes>
\ No newline at end of file diff --git a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java new file mode 100644 index 00000000..75be799b --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 Samsung. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.client; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.UnsupportedEncodingException; + +import org.apache.camel.Exchange; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.clamp.clds.client.req.policy.PolicyClient; +import org.onap.clamp.clds.config.ClampProperties; +import org.onap.clamp.clds.exception.ModelBpmnException; +import org.onap.policy.controlloop.policy.builder.BuilderException; + +@RunWith(MockitoJUnitRunner.class) +public class OperationalPolicyDelegateTest { + + private static final String TEST_KEY = "isTest"; + private static final String MODEL_BPMN_KEY = "modelBpmnProp"; + private static final String MODEL_PROP_KEY = "modelProp"; + private static final String RECIPE_TOPIC_KEY = "op.recipeTopic"; + private static final String MESSAGE_KEY = "operationalPolicyResponseMessage"; + private static final String SERVICE_NAME = "service.name"; + private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Oper12,from:''}]}"; + private static final String ID_WITH_CHAIN_JSON = "{Oper12:{ab:[" + + "{name:timeout,value:500}," + + "{policyConfigurations:[" + + "[{name:maxRetries,value:5}," + + "{name:retryTimeLimit,value:1000}," + + "{name:recipe,value:go}," + + "{name:targetResourceId," + + "value:resid234}]]}]}," + + "global:[{name:service,value:" + SERVICE_NAME + "}]}"; + private static final String SIMPLE_JSON = "{}"; + private static final String NOT_JSON = "not json"; + private static final String MESSAGE_VALUE = "message"; + private static final String RECIPE_TOPIC_VALUE = "recipe.topic"; + + @Mock + private Exchange exchange; + + @Mock + private PolicyClient policyClient; + + @Mock + private ClampProperties refProp; + + @InjectMocks + private OperationalPolicyDelegate operationalPolicyDelegate; + + @Test + public void shouldExecuteSuccessfully() throws BuilderException, UnsupportedEncodingException { + // given + when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true); + when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON); + when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON); + when(policyClient.sendBrmsPolicy(any(), any(), any())).thenReturn(MESSAGE_VALUE); + when(refProp.getStringValue(eq(RECIPE_TOPIC_KEY), eq(SERVICE_NAME))).thenReturn(RECIPE_TOPIC_VALUE); + + // when + operationalPolicyDelegate.execute(exchange); + + // then + verify(exchange).setProperty(eq(MESSAGE_KEY), eq(MESSAGE_VALUE.getBytes())); + } + + @Test + public void shouldExecutePolicyNotFound() throws BuilderException, UnsupportedEncodingException { + // given + when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false); + when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(SIMPLE_JSON); + when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(SIMPLE_JSON); + + // when + operationalPolicyDelegate.execute(exchange); + + // then + verify(policyClient, never()).sendBrmsPolicy(any(), any(), any()); + } + + @Test(expected = ModelBpmnException.class) + public void shouldThrowModelBpmnException() throws BuilderException, UnsupportedEncodingException { + // given + when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true); + when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON); + + // when + operationalPolicyDelegate.execute(exchange); + } + + @Test(expected = NullPointerException.class) + public void shouldThrowNullPointerException() throws BuilderException, UnsupportedEncodingException { + // when + operationalPolicyDelegate.execute(exchange); + } +} diff --git a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java new file mode 100644 index 00000000..9d87e7e9 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 Samsung. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.client; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.apache.camel.Exchange; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.clamp.clds.client.req.policy.PolicyClient; +import org.onap.clamp.clds.exception.ModelBpmnException; +import org.onap.clamp.clds.model.properties.ModelProperties; + +@RunWith(MockitoJUnitRunner.class) +public class OperationalPolicyDeleteDelegateTest { + + private static final String TEST_KEY = "isTest"; + private static final String MODEL_BPMN_KEY = "modelBpmnProp"; + private static final String MODEL_PROP_KEY = "modelProp"; + private static final String EVENT_ACTION_KEY = "eventAction"; + private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Poli2,from:''}]}"; + private static final String ID_WITH_CHAIN_JSON = "{Poli2:{ab:c,xy:z}}"; + private static final String ID_NO_CHAIN_JSON = "{Poli2:{}}"; + private static final String EVENT_ACTION_VALUE = "still"; + private static final String NOT_JSON = "23e"; + + @Mock + private Exchange exchange; + + @Mock + private PolicyClient policyClient; + + @InjectMocks + private OperationalPolicyDeleteDelegate operationalPolicyDeleteDelegate; + + @Test + public void shouldExecuteSuccessfully() { + // given + when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false); + when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON); + when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON); + when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE); + + // when + operationalPolicyDeleteDelegate.execute(exchange); + + // then + verify(policyClient, times(2)).deleteBrms(any(ModelProperties.class)); + } + + @Test + public void shouldExecuteTcaNotFound() { + // given + when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true); + when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON); + when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_NO_CHAIN_JSON); + + // when + operationalPolicyDeleteDelegate.execute(exchange); + + // then + verify(policyClient, never()).deleteBrms(any(ModelProperties.class)); + } + + @Test(expected = ModelBpmnException.class) + public void shouldThrowModelBpmnException() { + // given + when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false); + when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON); + + // when + operationalPolicyDeleteDelegate.execute(exchange); + } + + @Test(expected = NullPointerException.class) + public void shouldThrowNullPointerException() { + // when + operationalPolicyDeleteDelegate.execute(exchange); + } +} diff --git a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java index a32a6035..549c9132 100644 --- a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java +++ b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -25,10 +27,11 @@ package org.onap.clamp.clds.config; import static org.assertj.core.api.Assertions.assertThat; - import org.junit.Test; +import org.onap.clamp.clds.exception.CldsUsersException; import org.onap.clamp.clds.service.CldsUser; + public class CldsUserJsonDecoderTest { private String user1 = "admin1"; @@ -92,4 +95,12 @@ public class CldsUserJsonDecoderTest { assertThat(user.getPassword()).isEqualTo(password); assertThat(user.getPermissionsString()).isEqualTo(incompletePermissionsArray); } + + @Test(expected = CldsUsersException.class) + public void shouldThrowCldsUsersException() { + //when + CldsUserJsonDecoder + .decodeJson(this.getClass().getResourceAsStream("/clds/clds-parse-exception.json")); + } + } diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java index 36d4eb82..e1b963cc 100644 --- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java @@ -179,10 +179,9 @@ public class CsarInstallerItCase { ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-2.json"), StandardCharsets.UTF_8), cldsModel2.getPropText(), true); CldsModel cldsModel3 = verifyClosedLoopModelLoadedInDb(csar, "tca_3.yaml"); - JSONAssert.assertEquals( - IOUtils.toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca.json"), - StandardCharsets.UTF_8), - cldsModel3.getPropText(), true); + JSONAssert.assertEquals(IOUtils.toString( + ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-3.json"), + StandardCharsets.UTF_8), cldsModel3.getPropText(), true); } private CldsModel verifyClosedLoopModelLoadedInDb(CsarHandler csar, String artifactName) diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index 211bb390..7a1f9f0a 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -142,18 +142,18 @@ public class BlueprintParserTest { public void getNodeRepresentationFromCompleteYaml() { final JsonObject jsonObject = jsonObjectBlueprintValid; - MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, "", SECOND_APPP); + MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, ""); Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next(); - MicroService actual = new BlueprintParser().getNodeRepresentation(entry); + MicroService actual = new BlueprintParser().getNodeRepresentation(entry, jsonObject); Assert.assertEquals(expected, actual); } @Test public void getMicroServicesFromBlueprintTest() { - MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", "", THIRD_APPP); - MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, "", FIRST_APPP); - MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, "", SECOND_APPP); + MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", ""); + MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, ""); + MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, ""); Set<MicroService> expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp)); Set<MicroService> actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid); @@ -164,7 +164,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceTCATest() { MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", - "", ""); + ""); List<MicroService> expected = Collections.singletonList(tcaMS); List<MicroService> actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); @@ -175,7 +175,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceHolmesTest() { MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app", - "", "", ""); + "", ""); List<MicroService> expected = Collections.singletonList(holmesMS); List<MicroService> actual = new BlueprintParser() diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java index 1eb66ead..4b41ee81 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java @@ -38,10 +38,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, "", ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, ""); List<MicroService> expectedList = Arrays.asList(ms1, ms2, ms3, ms4); Set<MicroService> inputSet = new HashSet<>(expectedList); @@ -52,10 +52,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesTwiceNoInputTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", "", "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", "", ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, ""); Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet); @@ -64,10 +64,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesBranchingTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, "", ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, ""); Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet); diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java index 5eb664fe..ff6e1b5d 100644 --- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java +++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java @@ -56,8 +56,8 @@ public class ClampGraphBuilderTest { @Test public void clampGraphBuilderCompleteChainTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", ""); - MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", ""); + MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id"); + MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id"); String policy = "OperationalPolicy"; List<MicroService> microServices = Arrays.asList(ms1, ms2); @@ -76,8 +76,8 @@ public class ClampGraphBuilderTest { @Test(expected = InvalidStateException.class) public void clampGraphBuilderNoPolicyGivenTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", ""); - MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", ""); + MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id"); + MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id"); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build(); diff --git a/src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java b/src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java new file mode 100644 index 00000000..1abeb104 --- /dev/null +++ b/src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java @@ -0,0 +1,41 @@ +package org.onap.clamp.flow; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.impl.DefaultExchange; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.clamp.clds.util.LoggingUtils; +import org.onap.clamp.clds.util.ONAPLogConstants; +import org.onap.clamp.flow.log.FlowLogOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.util.ReflectionTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + + +public class FlowLogOperationTestItCase { + + @Autowired + CamelContext camelContext; + + @Test + public void testStratLog() { + //given + FlowLogOperation flowLogOperation = new FlowLogOperation(); + Exchange exchange = new DefaultExchange(camelContext); + LoggingUtils loggingUtils = mock(LoggingUtils.class); + ReflectionTestUtils.setField(flowLogOperation, "util", loggingUtils); + + //when + Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)).thenReturn("MockRequestId"); + Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID)).thenReturn("MockInvocationId"); + Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME)).thenReturn("MockPartnerName"); + flowLogOperation.startLog(exchange, "serviceName"); + + //then + assertThat(exchange.getProperty(ONAPLogConstants.Headers.REQUEST_ID)).isEqualTo("MockRequestId"); + assertThat(exchange.getProperty(ONAPLogConstants.Headers.INVOCATION_ID)).isEqualTo("MockInvocationId"); + assertThat(exchange.getProperty(ONAPLogConstants.Headers.PARTNER_NAME)).isEqualTo("MockPartnerName"); + } +}
\ No newline at end of file diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index 883945eb..cd6db68d 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -49,7 +49,9 @@ import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerExceptio import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller; +import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; @@ -57,6 +59,7 @@ import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.onap.sdc.toscaparser.api.elements.Metadata; +import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -69,7 +72,7 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller-new") public class CsarInstallerItCase { - private static final String CSAR_ARTIFACT_NAME = "example/sdc/service-Vloadbalancerms-csar.csar"; + private static final String CSAR_ARTIFACT_NAME = "example/sdc/service_Vloadbalancerms_csar.csar"; private static final String INVARIANT_SERVICE_UUID = "4cc5b45a-1f63-4194-8100-cd8e14248c92"; private static final String INVARIANT_RESOURCE1_UUID = "07e266fc-49ab-4cd7-8378-ca4676f1b9ec"; private static final String INVARIANT_RESOURCE2_UUID = "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad"; @@ -137,8 +140,7 @@ public class CsarInstallerItCase { // set SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); String path = Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME).getFile(); - ISdcCsarHelper sdcHelper = factory - .getSdcCsarHelper(path); + ISdcCsarHelper sdcHelper = factory.getSdcCsarHelper(path); Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(sdcHelper); // Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(csarHelper); @@ -158,11 +160,11 @@ public class CsarInstallerItCase { Mockito.when(notificationData.getServiceArtifacts()).thenReturn(serviceArtifactsList); CsarHandler csarHandler = new CsarHandler(notificationData, "", ""); - csarHandler.setFilePath(Thread.currentThread().getContextClassLoader() - .getResource(CSAR_ARTIFACT_NAME).getFile()); + csarHandler + .setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME).getFile()); Optional<String> testyaml = csarHandler.getPolicyModelYaml(); - Assert.assertEquals(testyaml, Optional.ofNullable(ResourceFileUtil - .getResourceAsString("example/sdc/expected-result/policy-data.yaml"))); + Assert.assertEquals(testyaml, + Optional.ofNullable(ResourceFileUtil.getResourceAsString("example/sdc/expected-result/policy-data.yaml"))); } @Test @@ -178,6 +180,7 @@ public class CsarInstallerItCase { @Test @Transactional + @Rollback(value = false) public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException, JSONException, InterruptedException, PolicyModelException { String generatedName = RandomStringUtils.randomAlphanumeric(5); @@ -202,6 +205,19 @@ public class CsarInstallerItCase { assertThat(loop.getOperationalPolicies()).hasSize(1); assertThat(loop.getModelPropertiesJson().get("serviceDetails")).isNotNull(); assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull(); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), + JsonUtils.GSON.toJson(loop.getModelPropertiesJson()), true); + assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); + + loop = loopsRepo + .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml")) + .get(); + assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); + + loop = loopsRepo + .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml")) + .get(); + assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); } } diff --git a/src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java new file mode 100644 index 00000000..e71b4982 --- /dev/null +++ b/src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java @@ -0,0 +1,250 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 Nokia Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; + +import java.io.IOException; +import java.util.HashSet; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.json.simple.parser.ParseException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.clamp.clds.Application; +import org.onap.clamp.clds.config.ClampProperties; +import org.onap.clamp.loop.LoopOperation.TempLoopState; +import org.onap.clamp.policy.microservice.MicroServicePolicy; +import org.onap.clamp.policy.operational.OperationalPolicy; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +public class LoopOperationTestItCase { + + private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + @Autowired + LoopService loopService; + + @Autowired + ClampProperties property; + + private Loop createTestLoop() { + String yaml = "imports:\n" + + " - \"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"\n" + + "node_templates:\n" + + " docker_service_host:\n" + + " type: dcae.nodes.SelectedDockerHost"; + + Loop loopTest = new Loop("ControlLoopTest", yaml, "<xml></xml>"); + loopTest.setGlobalPropertiesJson(new Gson().fromJson("{\"testname\":\"testvalue\"}", JsonObject.class)); + loopTest.setLastComputedState(LoopState.DESIGN); + loopTest.setDcaeDeploymentId("123456789"); + loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085"); + loopTest.setDcaeBlueprintId("UUID-blueprint"); + + MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", "", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", true, + gson.fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>()); + microServicePolicy.setProperties(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class)); + + loopTest.addMicroServicePolicy(microServicePolicy); + return loopTest; + } + + + @Test + public void testAnalysePolicyResponse() { + LoopOperation loopOp = new LoopOperation(loopService, property); + String status1 = loopOp.analysePolicyResponse(200); + String status2 = loopOp.analysePolicyResponse(404); + String status3 = loopOp.analysePolicyResponse(500); + String status4 = loopOp.analysePolicyResponse(503); + + // then + assertThat(status1).isEqualTo("SUBMITTED"); + assertThat(status2).isEqualTo("NOT_SUBMITTED"); + assertThat(status3).isEqualTo("IN_ERROR"); + assertThat(status4).isEqualTo("IN_ERROR"); + } + + @Test + public void testGetOperationalPolicyName() { + LoopOperation loopOp = new LoopOperation(loopService, property); + Loop loop = this.createTestLoop(); + String opName1 = loopOp.getOperationalPolicyName(loop); + assertThat(opName1).isNull(); + + OperationalPolicy opPolicy1 = new OperationalPolicy("OperationalPolicyTest1", null, + gson.fromJson("{\"type\":\"Operational\"}", JsonObject.class)); + loop.addOperationalPolicy(opPolicy1); + String opName2 = loopOp.getOperationalPolicyName(loop); + assertThat(opName2).isEqualTo("OperationalPolicyTest1"); + } + + @Test + public void testAnalyseDcaeResponse() throws ParseException { + LoopOperation loopOp = new LoopOperation(loopService, property); + String dcaeStatus1 = loopOp.analyseDcaeResponse(null, null); + assertThat(dcaeStatus1).isEqualTo("NOT_DEPLOYED"); + + String dcaeStatus2 = loopOp.analyseDcaeResponse(null, 500); + assertThat(dcaeStatus2).isEqualTo("IN_ERROR"); + + String dcaeStatus3 = loopOp.analyseDcaeResponse(null, 404); + assertThat(dcaeStatus3).isEqualTo("NOT_DEPLOYED"); + + Exchange camelExchange = Mockito.mock(Exchange.class); + Message mockMessage = Mockito.mock(Message.class); + Mockito.when(camelExchange.getIn()).thenReturn(mockMessage); + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"operationType\":\"install\",\"status\":\"succeeded\"}"); + String dcaeStatus4 = loopOp.analyseDcaeResponse(camelExchange, 200); + assertThat(dcaeStatus4).isEqualTo("DEPLOYED"); + + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"operationType\":\"install\",\"status\":\"processing\"}"); + String dcaeStatus5 = loopOp.analyseDcaeResponse(camelExchange, 200); + assertThat(dcaeStatus5).isEqualTo("PROCESSING"); + + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"operationType\":\"install\",\"status\":\"failed\"}"); + String dcaeStatus6 = loopOp.analyseDcaeResponse(camelExchange, 200); + assertThat(dcaeStatus6).isEqualTo("IN_ERROR"); + + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"operationType\":\"uninstall\",\"status\":\"succeeded\"}"); + String dcaeStatus7 = loopOp.analyseDcaeResponse(camelExchange, 200); + assertThat(dcaeStatus7).isEqualTo("NOT_DEPLOYED"); + + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"operationType\":\"uninstall\",\"status\":\"processing\"}"); + String dcaeStatus8 = loopOp.analyseDcaeResponse(camelExchange, 200); + assertThat(dcaeStatus8).isEqualTo("PROCESSING"); + + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"operationType\":\"uninstall\",\"status\":\"failed\"}"); + String dcaeStatus9 = loopOp.analyseDcaeResponse(camelExchange, 200); + assertThat(dcaeStatus9).isEqualTo("IN_ERROR"); + } + + @Test + public void testUpdateLoopStatus() { + LoopOperation loopOp = new LoopOperation(loopService, property); + Loop loop = this.createTestLoop(); + loopService.saveOrUpdateLoop(loop); + LoopState newState1 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.DEPLOYED); + LoopState dbState1 = loopService.getLoop(loop.getName()).getLastComputedState(); + assertThat(newState1).isEqualTo(LoopState.DEPLOYED); + assertThat(dbState1).isEqualTo(LoopState.DEPLOYED); + + LoopState newState2 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.NOT_DEPLOYED); + LoopState dbState2 = loopService.getLoop(loop.getName()).getLastComputedState(); + assertThat(newState2).isEqualTo(LoopState.SUBMITTED); + assertThat(dbState2).isEqualTo(LoopState.SUBMITTED); + + LoopState newState3 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.PROCESSING); + assertThat(newState3).isEqualTo(LoopState.WAITING); + + LoopState newState4 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.IN_ERROR); + assertThat(newState4).isEqualTo(LoopState.IN_ERROR); + + LoopState newState5 = loopOp.updateLoopStatus(loop, TempLoopState.NOT_SUBMITTED, TempLoopState.DEPLOYED); + assertThat(newState5).isEqualTo(LoopState.IN_ERROR); + + LoopState newState6 = loopOp.updateLoopStatus(loop, TempLoopState.NOT_SUBMITTED, TempLoopState.PROCESSING); + assertThat(newState6).isEqualTo(LoopState.IN_ERROR); + + LoopState newState7 = loopOp.updateLoopStatus(loop, TempLoopState.NOT_SUBMITTED, TempLoopState.NOT_DEPLOYED); + assertThat(newState7).isEqualTo(LoopState.DESIGN); + + LoopState newState8 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.DEPLOYED); + assertThat(newState8).isEqualTo(LoopState.IN_ERROR); + + LoopState newState9 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.NOT_DEPLOYED); + assertThat(newState9).isEqualTo(LoopState.IN_ERROR); + + LoopState newState10 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.PROCESSING); + assertThat(newState10).isEqualTo(LoopState.IN_ERROR); + + LoopState newState11 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.IN_ERROR); + assertThat(newState11).isEqualTo(LoopState.IN_ERROR); + } + + @Test + public void testUpdateLoopInfo() throws ParseException { + Loop loop = this.createTestLoop(); + loopService.saveOrUpdateLoop(loop); + + Exchange camelExchange = Mockito.mock(Exchange.class); + Message mockMessage = Mockito.mock(Message.class); + Mockito.when(camelExchange.getIn()).thenReturn(mockMessage); + Mockito.when(mockMessage.getBody(String.class)) + .thenReturn("{\"links\":{\"status\":\"http://testhost/dcae-operationstatus\",\"test2\":\"test2\"}}"); + + LoopOperation loopOp = new LoopOperation(loopService, property); + loopOp.updateLoopInfo(camelExchange, loop, "testNewId"); + + Loop newLoop = loopService.getLoop(loop.getName()); + String newDeployId = newLoop.getDcaeDeploymentId(); + String newDeploymentStatusUrl = newLoop.getDcaeDeploymentStatusUrl(); + + assertThat(newDeployId).isEqualTo("testNewId"); + assertThat(newDeploymentStatusUrl).isEqualTo("http4://testhost/dcae-operationstatus"); + } + + @Test + public void testGetDeploymentId() { + Loop loop = this.createTestLoop(); + LoopOperation loopOp = new LoopOperation(loopService, property); + String deploymentId1 = loopOp.getDeploymentId(loop); + assertThat(deploymentId1).isEqualTo("123456789"); + + loop.setDcaeDeploymentId(null); + String deploymentId2 = loopOp.getDeploymentId(loop); + assertThat(deploymentId2).isEqualTo("closedLoop_ControlLoopTest_deploymentId"); + + loop.setDcaeDeploymentId(""); + String deploymentId3 = loopOp.getDeploymentId(loop); + assertThat(deploymentId3).isEqualTo("closedLoop_ControlLoopTest_deploymentId"); + } + + @Test + public void testGetDeployPayload() throws IOException { + Loop loop = this.createTestLoop(); + LoopOperation loopOp = new LoopOperation(loopService, property); + String deploymentPayload = loopOp.getDeployPayload(loop); + + String expectedPayload = "{\"serviceTypeId\":\"UUID-blueprint\",\"inputs\":{\"imports\":[\"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"],\"node_templates\":{\"docker_service_host\":{\"type\":\"dcae.nodes.SelectedDockerHost\"}}}}"; + assertThat(deploymentPayload).isEqualTo(expectedPayload); + } +}
\ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index ecc40331..061505a1 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -217,6 +217,11 @@ clamp.config.dcae.dispatcher.url=http://localhost:${docker.http-cache.port.host} clamp.config.dcae.dispatcher.retry.interval=100
clamp.config.dcae.dispatcher.retry.limit=1
+#DCAE Deployment Url Properties
+clamp.config.dcae.deployment.url=http4://localhost:${docker.http-cache.port.host}
+clamp.config.dcae.deployment.userName=test
+clamp.config.dcae.deployment.password=test
+
#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !
clamp.config.security.permission.type.cl=permission-type-cl
clamp.config.security.permission.type.cl.manage=permission-type-cl-manage
diff --git a/src/test/resources/clds/clds-parse-exception.json b/src/test/resources/clds/clds-parse-exception.json new file mode 100644 index 00000000..1c06a394 --- /dev/null +++ b/src/test/resources/clds/clds-parse-exception.json @@ -0,0 +1 @@ +This is not json
\ No newline at end of file diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json index 41ca2de2..d7a54162 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json +++ b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json @@ -27,23 +27,22 @@ { "name": "deployParameters", "value": { - "dh_override": "component_dockerhost", - "dh_location_id": "zone1", - "aaiEnrichmentHost": "none", - "aaiEnrichmentPort": 8443, - "enableAAIEnrichment": false, - "dmaap_host": "dmaap.onap-message-router", - "dmaap_port": 3904, + "aaiEnrichmentHost": "aai.onap.svc.cluster.local", + "aaiEnrichmentPort": "8443", + "enableAAIEnrichment": true, + "dmaap_host": "message-router.onap", + "dmaap_port": "3904", "enableRedisCaching": false, - "redisHosts": "", - "tag_version": "nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0", - "consul_host": "consul-server.onap-consul", + "redisHosts": "dcae-redis.onap.svc.cluster.local:6379", + "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1", + "consul_host": "consul-server.onap", "consul_port": "8500", - "cbs_host": "config-binding-service.dcae", + "cbs_host": "config-binding-servicel", "cbs_port": "10000", - "external_port": "32010", + "external_port": "32012", + "policy_model_id": "onap.policies.monitoring.cdap.tca.hi.lo.app", "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT" } } ] -} +}
\ No newline at end of file diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json new file mode 100644 index 00000000..f8f53165 --- /dev/null +++ b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json @@ -0,0 +1,47 @@ +{ + "global": [ + { + "name": "service", + "value": [ + "4cc5b45a-1f63-4194-8100-cd8e14248c92" + ] + }, + { + "name": "vf", + "value": [ + "07e266fc-49ab-4cd7-8378-ca4676f1b9ec" + ] + }, + { + "name": "actionSet", + "value": [ + "vnfRecipe" + ] + }, + { + "name": "location", + "value": [ + "DC1" + ] + }, + { + "name": "deployParameters", + "value": { + "aaiEnrichmentHost": "aai.onap.svc.cluster.local", + "aaiEnrichmentPort": "8443", + "enableAAIEnrichment": true, + "dmaap_host": "message-router.onap.svc.cluster.local", + "dmaap_port": "3904", + "enableRedisCaching": false, + "redisHosts": "dcae-redis.onap.svc.cluster.local:6379", + "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest", + "consul_host": "consul-server.onap.svc.cluster.local", + "consul_port": "8500", + "cbs_host": "config-binding-service.dcae.svc.cluster.local", + "cbs_port": "10000", + "external_port": "32012", + "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT" + } + } + ] +}
\ No newline at end of file diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml index c834b1b9..56ae32a7 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml @@ -1,76 +1,92 @@ +# +# ============LICENSE_START==================================================== +# ============================================================================= +# Copyright (c) 2019 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====================================================== + tosca_definitions_version: cloudify_dsl_1_3 -imports: - - "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml" - - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dockerplugin/3.2.0/dockerplugin_types.yaml - - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/relationshipplugin/1.0.0/relationshipplugin_types.yaml - - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml +description: > + This blueprint deploys/manages the TCA module as a Docker container + +imports: + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml +# - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/clamppolicyplugin/1.0.0/clamppolicyplugin_types.yaml inputs: - dh_override: - type: string - default: "component_dockerhost" - dh_location_id: - type: string - default: "zone1" aaiEnrichmentHost: type: string - default: "none" + default: "aai.onap.svc.cluster.local" aaiEnrichmentPort: - type: string - default: 8443 + type: string + default: "8443" enableAAIEnrichment: type: string - default: false + default: true dmaap_host: type: string - default: dmaap.onap-message-router + default: message-router.onap dmaap_port: type: string - default: 3904 + default: "3904" enableRedisCaching: type: string - default: false + default: false redisHosts: - type: string + type: string + default: dcae-redis.onap.svc.cluster.local:6379 tag_version: type: string - default: "nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0" + default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1" consul_host: type: string - default: consul-server.onap-consul + default: consul-server.onap consul_port: type: string default: "8500" cbs_host: type: string - default: "config-binding-service.dcae" + default: "config-binding-servicel" cbs_port: type: string default: "10000" policy_id: type: string - default: "none" + default: "onap.restart.tca" external_port: type: string - description: "Port for CDAPgui to be exposed" - default: "32010" - + description: Kubernetes node port on which CDAPgui is exposed + default: "32012" + policy_model_id: + type: string + default: "onap.policies.monitoring.cdap.tca.hi.lo.app" node_templates: - docker_service_host: - properties: - docker_host_override: - get_input: dh_override - location_id: - get_input: dh_location_id - type: dcae.nodes.SelectedDockerHost - tca_docker: + tca_k8s: + type: dcae.nodes.ContainerizedServiceComponent relationships: - - type: dcae.relationships.component_contained_in - target: docker_service_host - - target: tca_policy - type: cloudify.relationships.depends_on - type: dcae.nodes.DockerContainerForComponentsUsingDmaap + - target: tca_policy + type: cloudify.relationships.depends_on properties: + service_component_type: 'dcaegen2-analytics-tca' + application_config: {} + docker_config: {} + image: + get_input: tag_version + log_info: + log_directory: "/opt/app/TCAnalytics/logs" application_config: app_config: appDescription: DCAE Analytics Threshold Crossing Alert Application @@ -84,87 +100,75 @@ node_templates: tcaVESMessageStatusTableTTLSeconds: '86400' thresholdCalculatorFlowletInstances: '2' app_preferences: - aaiEnrichmentHost: + aaiEnrichmentHost: get_input: aaiEnrichmentHost aaiEnrichmentIgnoreSSLCertificateErrors: 'true' aaiEnrichmentPortNumber: '8443' aaiEnrichmentProtocol: https - aaiEnrichmentUserName: DCAE - aaiEnrichmentUserPassword: DCAE + aaiEnrichmentUserName: dcae@dcae.onap.org + aaiEnrichmentUserPassword: demo123456! aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf - enableAAIEnrichment: + enableAAIEnrichment: get_input: enableAAIEnrichment - enableRedisCaching: + enableRedisCaching: get_input: enableRedisCaching - redisHosts: + redisHosts: get_input: redisHosts enableAlertCEFFormat: 'false' publisherContentType: application/json - publisherHostName: + publisherHostName: get_input: dmaap_host - publisherHostPort: - get_input: dmaap_port + publisherHostPort: + get_input: dmaap_port publisherMaxBatchSize: '1' publisherMaxRecoveryQueueSize: '100000' publisherPollingInterval: '20000' publisherProtocol: http publisherTopicName: unauthenticated.DCAE_CL_OUTPUT - subscriberConsumerGroup: OpenDCAE-c12 + subscriberConsumerGroup: OpenDCAE-clamp subscriberConsumerId: c12 subscriberContentType: application/json - subscriberHostName: + subscriberHostName: get_input: dmaap_host subscriberHostPort: - get_input: dmaap_port + get_input: dmaap_port subscriberMessageLimit: '-1' subscriberPollingInterval: '30000' subscriberProtocol: http subscriberTimeoutMS: '-1' - subscriberTopicName: unauthenticated.SEC_MEASUREMENT_OUTPUT - tca_policy_default: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}' - service_component_type: dcaegen2-analytics_tca - docker_config: - healthcheck: - endpoint: /healthcheck - interval: 15s - timeout: 1s - type: http - image: - get_input: tag_version + subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT +# tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}' + service_component_type: dcaegen2-analytics_tca interfaces: cloudify.interfaces.lifecycle: start: inputs: envs: - DMAAPHOST: + DMAAPHOST: { get_input: dmaap_host } DMAAPPORT: { get_input: dmaap_port } DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT" - DMAAPSUBTOPIC: "unauthenticated.SEC_MEASUREMENT_OUTPUT" - AAIHOST: + DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT" + AAIHOST: { get_input: aaiEnrichmentHost } - AAIPORT: + AAIPORT: { get_input: aaiEnrichmentPort } - CONSUL_HOST: + CONSUL_HOST: { get_input: consul_host } - CONSUL_PORT: + CONSUL_PORT: { get_input: consul_port } - CBS_HOST: + CBS_HOST: { get_input: cbs_host } - CBS_PORT: + CBS_PORT: { get_input: cbs_port } - CONFIG_BINDING_SERVICE: "config_binding_service" + CONFIG_BINDING_SERVICE: "config_binding_service" ports: - - concat: ["11011:", { get_input: external_port }] - stop: - inputs: - cleanup_image: true + - concat: ["11011:", { get_input: external_port }] tca_policy: - type: dcae.nodes.policy + type: clamp.nodes.policy properties: policy_id: get_input: policy_id policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app - diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml index edaa0be2..53cfc4f7 100644 --- a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml +++ b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml @@ -1,105 +1,153 @@ tosca_definitions_version: cloudify_dsl_1_3 + +description: > + This blueprint deploys/manages the TCA module as a Docker container + imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/docker/2.2.0/node-type.yaml -- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml -- http://onap.org:8081/repository/solutioning01-mte2-raw/type_files/dmaap/dmaap_mr.yaml + - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml inputs: - location_id: + aaiEnrichmentHost: type: string - service_id: + default: "aai.onap.svc.cluster.local" + aaiEnrichmentPort: type: string + default: "8443" + enableAAIEnrichment: + type: string + default: true + dmaap_host: + type: string + default: message-router.onap.svc.cluster.local + dmaap_port: + type: string + default: "3904" + enableRedisCaching: + type: string + default: false + redisHosts: + type: string + default: dcae-redis.onap.svc.cluster.local:6379 + tag_version: + type: string + default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest" + consul_host: + type: string + default: consul-server.onap.svc.cluster.local + consul_port: + type: string + default: "8500" + cbs_host: + type: string + default: "config-binding-service.dcae.svc.cluster.local" + cbs_port: + type: string + default: "10000" policy_id: type: string + default: "none" + external_port: + type: string + description: Kubernetes node port on which CDAPgui is exposed + default: "32012" + node_templates: - policy_0: - type: dcae.nodes.policy - properties: - policy_id: - get_input: policy_id - policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app - cdap_host_host: - type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure - properties: - location_id: - get_input: location_id - scn_override: cdap_broker.solutioning-central.dcae.onap.org - interfaces: - cloudify.interfaces.lifecycle: { - } - tca_tca: - type: dcae.nodes.MicroService.cdap - properties: - app_config: - appDescription: DCAE Analytics Threshold Crossing Alert Application - appName: dcae-tca - tcaSubscriberOutputStreamName: TCASubscriberOutputStream - tcaVESAlertsTableName: TCAVESAlertsTable - tcaVESAlertsTableTTLSeconds: '1728000' - tcaVESMessageStatusTableName: TCAVESMessageStatusTable - tcaVESMessageStatusTableTTLSeconds: '86400' - thresholdCalculatorFlowletInstances: '2' - app_preferences: - publisherContentType: application/json - publisherHostName: mrlocal-mtnjftle01.onap.org - publisherHostPort: '3905' - publisherMaxBatchSize: '10' - publisherMaxRecoveryQueueSize: '100000' - publisherPollingInterval: '20000' - publisherProtocol: https - publisherTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESPub - publisherUserName: test@tca.af.dcae.onap.org - publisherUserPassword: password - subscriberConsumerGroup: OpenDCAE-c12 - subscriberConsumerId: c12 - subscriberContentType: application/json - subscriberHostName: mrlocal-mtnjftle01.onap.org - subscriberHostPort: '3905' - subscriberMessageLimit: '-1' - subscriberPollingInterval: '20000' - subscriberProtocol: https - subscriberTimeoutMS: '-1' - subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub - subscriberUserName: test@tca.af.dcae.onap.org - subscriberUserPassword: password - tca_policy: null - artifact_name: dcae-analytics-tca - artifact_version: 1.0.0 - connections: - streams_publishes: [ - ] - streams_subscribes: [ - ] - jar_url: http://somejar - location_id: - get_input: location_id - namespace: cdap_tca_hi_lo - programs: - - program_id: TCAVESCollectorFlow - program_type: flows - - program_id: TCADMaaPMRSubscriberWorker - program_type: workers - - program_id: TCADMaaPMRPublisherWorker - program_type: workers - service_component_type: cdap_app_tca - service_id: - get_input: service_id - streamname: TCASubscriberOutputStream + tca_k8s: + type: dcae.nodes.ContainerizedServiceComponent relationships: - - target: topic0 - type: dcae.relationships.subscribe_to_events - - target: topic1 - type: dcae.relationships.publish_events - - target: cdap_host_host - type: dcae.relationships.component_contained_in - - target: policy_0 - type: dcae.relationships.depends_on - topic0: - type: dcae.nodes.Topic + - target: tca_policy + type: cloudify.relationships.depends_on properties: - topic_name: '' - topic1: - type: dcae.nodes.Topic + service_component_type: 'dcaegen2-analytics-tca' + application_config: {} + docker_config: {} + image: + get_input: tag_version + log_info: + log_directory: "/opt/app/TCAnalytics/logs" + application_config: + app_config: + appDescription: DCAE Analytics Threshold Crossing Alert Application + appName: dcae-tca + tcaAlertsAbatementTableName: TCAAlertsAbatementTable + tcaAlertsAbatementTableTTLSeconds: '1728000' + tcaSubscriberOutputStreamName: TCASubscriberOutputStream + tcaVESAlertsTableName: TCAVESAlertsTable + tcaVESAlertsTableTTLSeconds: '1728000' + tcaVESMessageStatusTableName: TCAVESMessageStatusTable + tcaVESMessageStatusTableTTLSeconds: '86400' + thresholdCalculatorFlowletInstances: '2' + app_preferences: + aaiEnrichmentHost: + get_input: aaiEnrichmentHost + aaiEnrichmentIgnoreSSLCertificateErrors: 'true' + aaiEnrichmentPortNumber: '8443' + aaiEnrichmentProtocol: https + aaiEnrichmentUserName: dcae@dcae.onap.org + aaiEnrichmentUserPassword: demo123456! + aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query + aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf + enableAAIEnrichment: + get_input: enableAAIEnrichment + enableRedisCaching: + get_input: enableRedisCaching + redisHosts: + get_input: redisHosts + enableAlertCEFFormat: 'false' + publisherContentType: application/json + publisherHostName: + get_input: dmaap_host + publisherHostPort: + get_input: dmaap_port + publisherMaxBatchSize: '1' + publisherMaxRecoveryQueueSize: '100000' + publisherPollingInterval: '20000' + publisherProtocol: http + publisherTopicName: unauthenticated.DCAE_CL_OUTPUT + subscriberConsumerGroup: OpenDCAE-c12 + subscriberConsumerId: c12 + subscriberContentType: application/json + subscriberHostName: + get_input: dmaap_host + subscriberHostPort: + get_input: dmaap_port + subscriberMessageLimit: '-1' + subscriberPollingInterval: '30000' + subscriberProtocol: http + subscriberTimeoutMS: '-1' + subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT + tca_policy: '' + service_component_type: dcaegen2-analytics_tca + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + envs: + DMAAPHOST: + { get_input: dmaap_host } + DMAAPPORT: + { get_input: dmaap_port } + DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT" + DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT" + AAIHOST: + { get_input: aaiEnrichmentHost } + AAIPORT: + { get_input: aaiEnrichmentPort } + CONSUL_HOST: + { get_input: consul_host } + CONSUL_PORT: + { get_input: consul_port } + CBS_HOST: + { get_input: cbs_host } + CBS_PORT: + { get_input: cbs_port } + CONFIG_BINDING_SERVICE: "config_binding_service" + ports: + - concat: ["11011:", { get_input: external_port }] + tca_policy: + type: dcae.nodes.policy properties: - topic_name: '' - + policy_id: + get_input: policy_id + policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app diff --git a/src/test/resources/example/sdc/expected-result/policy-data.yaml b/src/test/resources/example/sdc/expected-result/policy-data.yaml index 2d315311..3cf5e975 100644 --- a/src/test/resources/example/sdc/expected-result/policy-data.yaml +++ b/src/test/resources/example/sdc/expected-result/policy-data.yaml @@ -132,11 +132,11 @@ policy_types: type: string description: The name of the policy, that related to specific type, same as it is defined in the source. required: false - tosca.policies.Monitoring: + onap.policies.Monitoring: derived_from: tosca.policies.Root description: A base policy type for all policies that governs monitoring provisioning onap.policies.monitoring.cdap.tca.hi.lo.app: - derived_from: tosca.policies.Monitoring + derived_from: onap.policies.Monitoring version: 1.0.0 properties: tca_policy: @@ -144,6 +144,316 @@ policy_types: description: TCA Policy JSON entry_schema: type: onap.datatypes.monitoring.tca_policy + tosca.policies.nfv.InstantiationLevels: + derived_from: tosca.policies.Root + description: The InstantiationLevels type is a policy type representing all the instantiation levels of resources to be instantiated within a deployment flavour and including default instantiation level in term of the number of VNFC instances to be created as defined in ETSI GS NFV-IFA 011 [1]. + properties: + levels: + type: map + description: Describes the various levels of resources that can be used to instantiate the VNF using this flavour. + required: true + entry_schema: + type: tosca.datatypes.nfv.InstantiationLevel + default_level: + type: string + description: The default instantiation level for this flavour. + required: false + tosca.policies.nfv.VduInstantiationLevels: + derived_from: tosca.policies.Root + description: The VduInstantiationLevels type is a policy type representing all the instantiation levels of resources to be instantiated within a deployment flavour in term of the number of VNFC instances to be created from each vdu.Compute. as defined in ETSI GS NFV-IFA 011 [1] + properties: + levels: + type: map + description: Describes the Vdu.Compute levels of resources that can be used to instantiate the VNF using this flavour + required: true + entry_schema: + type: tosca.datatypes.nfv.VduLevel + targets: + - tosca.nodes.nfv.Vdu.Compute + tosca.policies.nfv.VirtualLinkInstantiationLevels: + derived_from: tosca.policies.Root + description: The VirtualLinkInstantiationLevels type is a policy type representing all the instantiation levels of virtual link resources to be instantiated within a deployment flavour as defined in ETSI GS NFV-IFA 011 [1]. + properties: + levels: + type: map + description: Describes the virtual link levels of resources that can be used to instantiate the VNF using this flavour. + required: true + entry_schema: + type: tosca.datatypes.nfv.VirtualLinkBitrateLevel + targets: + - tosca.nodes.nfv.VnfVirtualLink + tosca.policies.nfv.ScalingAspects: + derived_from: tosca.policies.Root + description: The ScalingAspects type is a policy type representing the scaling aspects used for horizontal scaling as defined in ETSI GS NFV-IFA 011 [1]. + properties: + aspects: + type: map + description: Describe maximum scale level for total number of scaling steps that can be applied to a particular aspect + required: true + entry_schema: + type: tosca.datatypes.nfv.ScalingAspect + tosca.policies.nfv.VduScalingAspectDeltas: + derived_from: tosca.policies.Root + description: The VduScalingAspectDeltas type is a policy type representing the Vdu.Compute detail of an aspect deltas used for horizontal scaling, as defined in ETSI GS NFV-IFA 011 [1]. + properties: + aspect: + type: string + description: Represents the scaling aspect to which this policy applies + required: true + deltas: + type: map + description: Describes the Vdu.Compute scaling deltas to be applied for every scaling steps of a particular aspect. + required: true + entry_schema: + type: tosca.datatypes.nfv.VduLevel + targets: + - tosca.nodes.nfv.Vdu.Compute + tosca.policies.nfv.VirtualLinkBitrateScalingAspectDeltas: + derived_from: tosca.policies.Root + description: The VirtualLinkBitrateScalingAspectDeltas type is a policy type representing the VnfVirtualLink detail of an aspect deltas used for horizontal scaling, as defined in ETSI GS NFV-IFA 011 [1]. + properties: + aspect: + type: string + description: Represents the scaling aspect to which this policy applies. + required: true + deltas: + type: map + description: Describes the VnfVirtualLink scaling deltas to be applied for every scaling steps of a particular aspect. + required: true + entry_schema: + type: tosca.datatypes.nfv.VirtualLinkBitrateLevel + targets: + - tosca.nodes.nfv.VnfVirtualLink + tosca.policies.nfv.VduInitialDelta: + derived_from: tosca.policies.Root + description: The VduInitialDelta type is a policy type representing the Vdu.Compute detail of an initial delta used for horizontal scaling, as defined in ETSI GS NFV-IFA 011 [1]. + properties: + initial_delta: + type: tosca.datatypes.nfv.VduLevel + description: Represents the initial minimum size of the VNF. + required: true + targets: + - tosca.nodes.nfv.Vdu.Compute + tosca.policies.nfv.VirtualLinkBitrateInitialDelta: + derived_from: tosca.policies.Root + description: The VirtualLinkBitrateInitialDelta type is a policy type representing the VnfVirtualLink detail of an initial deltas used for horizontal scaling, as defined in ETSI GS NFV-IFA 011 [1]. + properties: + initial_delta: + type: tosca.datatypes.nfv.VirtualLinkBitrateLevel + description: Represents the initial minimum size of the VNF. + required: true + targets: + - tosca.nodes.nfv.VnfVirtualLink + tosca.policies.nfv.SecurityGroupRule: + derived_from: tosca.policies.Root + description: The SecurityGroupRule type is a policy type specified the matching criteria for the ingress and/or egress traffic to/from visited connection points as defined in ETSI GS NFV-IFA 011 [1]. + properties: + description: + type: string + description: Human readable description of the security group rule. + required: false + direction: + type: string + description: The direction in which the security group rule is applied. The direction of 'ingress' or 'egress' is specified against the associated CP. I.e., 'ingress' means the packets entering a CP, while 'egress' means the packets sent out of a CP. + required: false + constraints: + - valid_values: + - ingress + - egress + default: ingress + ether_type: + type: string + description: Indicates the protocol carried over the Ethernet layer. + required: false + constraints: + - valid_values: + - ipv4 + - ipv6 + default: ipv4 + protocol: + type: string + description: Indicates the protocol carried over the IP layer. Permitted values include any protocol defined in the IANA protocol registry, e.g. TCP, UDP, ICMP, etc. + required: false + constraints: + - valid_values: + - hopopt + - icmp + - igmp + - ggp + - ipv4 + - st + - tcp + - cbt + - egp + - igp + - bbn_rcc_mon + - nvp_ii + - pup + - argus + - emcon + - xnet + - chaos + - udp + - mux + - dcn_meas + - hmp + - prm + - xns_idp + - trunk_1 + - trunk_2 + - leaf_1 + - leaf_2 + - rdp + - irtp + - iso_tp4 + - netblt + - mfe_nsp + - merit_inp + - dccp + - 3pc + - idpr + - xtp + - ddp + - idpr_cmtp + - tp++ + - il + - ipv6 + - sdrp + - ipv6_route + - ipv6_frag + - idrp + - rsvp + - gre + - dsr + - bna + - esp + - ah + - i_nlsp + - swipe + - narp + - mobile + - tlsp + - skip + - ipv6_icmp + - ipv6_no_nxt + - ipv6_opts + - cftp + - sat_expak + - kryptolan + - rvd + - ippc + - sat_mon + - visa + - ipcv + - cpnx + - cphb + - wsn + - pvp + - br_sat_mon + - sun_nd + - wb_mon + - wb_expak + - iso_ip + - vmtp + - secure_vmtp + - vines + - ttp + - iptm + - nsfnet_igp + - dgp + - tcf + - eigrp + - ospfigp + - sprite_rpc + - larp + - mtp + - ax.25 + - ipip + - micp + - scc_sp + - etherip + - encap + - gmtp + - ifmp + - pnni + - pim + - aris + - scps + - qnx + - a/n + - ip_comp + - snp + - compaq_peer + - ipx_in_ip + - vrrp + - pgm + - l2tp + - ddx + - iatp + - stp + - srp + - uti + - smp + - sm + - ptp + - isis + - fire + - crtp + - crudp + - sscopmce + - iplt + - sps + - pipe + - sctp + - fc + - rsvp_e2e_ignore + - mobility + - udp_lite + - mpls_in_ip + - manet + - hip + - shim6 + - wesp + - rohc + default: tcp + port_range_min: + type: integer + description: Indicates minimum port number in the range that is matched by the security group rule. If a value is provided at design-time, this value may be overridden at run-time based on other deployment requirements or constraints. + required: false + constraints: + - greater_or_equal: 0 + - less_or_equal: 65535 + default: 0 + port_range_max: + type: integer + description: Indicates maximum port number in the range that is matched by the security group rule. If a value is provided at design-time, this value may be overridden at run-time based on other deployment requirements or constraints. + required: false + constraints: + - greater_or_equal: 0 + - less_or_equal: 65535 + default: 65535 + targets: + - tosca.nodes.nfv.VduCp + - tosca.nodes.nfv.VnfExtCp + tosca.policies.nfv.SupportedVnfInterface: + derived_from: tosca.policies.Root + description: this policy type represents interfaces produced by a VNF, the details to access them and the applicable connection points to use to access these interfaces + properties: + interface_name: + type: string + description: Identifies an interface produced by the VNF. + required: true + constraints: + - valid_values: + - vnf_indicator + - vnf_configuration + details: + type: tosca.datatypes.nfv.InterfaceDetails + description: Provide additional data to access the interface endpoint + required: false + targets: + - tosca.nodes.nfv.VnfExtCp + - tosca.nodes.nfv.VduCp data_types: tosca.datatypes.Root: description: The TOSCA root Data Type all other TOSCA base Data Types derive from @@ -1381,119 +1691,159 @@ data_types: type: string description: The network role of the related network, sharing provider network. required: false + tosca.datatypes.nfv.VnfcAdditionalConfigurableProperties: + derived_from: tosca.datatypes.Root + description: VnfcAdditionalConfigurableProperties type is an empty base type for deriving data types for describing additional configurable properties for a given VNFC. + properties: + description: + type: string + required: false tosca.datatypes.nfv.VnfcConfigurableProperties: derived_from: tosca.datatypes.Root + description: Defines the configurable properties of a VNFC properties: additional_vnfc_configurable_properties: - type: map - entry_schema: - type: string + type: tosca.datatypes.nfv.VnfcAdditionalConfigurableProperties + description: Describes additional configuration for VNFC that can be modified using the ModifyVnfInfo operation required: false tosca.datatypes.nfv.RequestedAdditionalCapability: derived_from: tosca.datatypes.Root + description: describes requested additional capability for a particular VDU properties: + requested_additional_capability_name: + type: string + description: Identifies a requested additional capability for the VDU. + required: true support_mandatory: type: boolean + description: Indicates whether the requested additional capability is mandatory for successful operation. required: true min_requested_additional_capability_version: type: string + description: Identifies the minimum version of the requested additional capability. required: false preferred_requested_additional_capability_version: type: string + description: Identifies the preferred version of the requested additional capability. required: false - requested_additional_capability_name: - type: string - required: true target_performance_parameters: type: map + description: Identifies specific attributes, dependent on the requested additional capability type. + required: true entry_schema: type: string - required: true tosca.datatypes.nfv.VirtualMemory: derived_from: tosca.datatypes.Root + description: supports the specification of requirements related to virtual memory of a virtual compute resource properties: virtual_mem_size: type: scalar-unit.size + description: Amount of virtual memory. required: true virtual_mem_oversubscription_policy: type: string + description: The memory core oversubscription policy in terms of virtual memory to physical memory on the platform. required: false - vdu_memory_requirements: + vdu_mem_requirements: type: map + description: The hardware platform specific VDU memory requirements. A map of strings that contains a set of key-value pairs that describes hardware platform specific VDU memory requirements. + required: false entry_schema: type: string - required: false numa_enabled: type: boolean + description: It specifies the memory allocation to be cognisant of the relevant process/core allocation. required: false + default: false tosca.datatypes.nfv.VirtualCpuPinning: derived_from: tosca.datatypes.Root + description: Supports the specification of requirements related to the virtual CPU pinning configuration of a virtual compute resource properties: - cpu_pinning_policy: + virtual_cpu_pinning_policy: type: string + description: 'Indicates the policy for CPU pinning. The policy can take values + of "static" or "dynamic". In case of "dynamic" the allocation of virtual + CPU cores to logical CPU cores is decided by the VIM. (e.g.: SMT (Simultaneous + Multi-Threading) requirements). In case of "static" the allocation is requested + to be according to the virtual_cpu_pinning_rule.' + required: false constraints: - valid_values: - static - dynamic + virtual_cpu_pinning_rule: + type: list + description: Provides the list of rules for allocating virtual CPU cores to logical CPU cores/threads required: false - cpu_pinning_map: - type: map entry_schema: type: string - required: false tosca.datatypes.nfv.VirtualCpu: derived_from: tosca.datatypes.Root + description: Supports the specification of requirements related to virtual CPU(s) of a virtual compute resource properties: cpu_architecture: type: string + description: CPU architecture type. Examples are x86, ARM required: false num_virtual_cpu: type: integer + description: Number of virtual CPUs required: true + constraints: + - greater_than: 0 virtual_cpu_clock: type: scalar-unit.frequency + description: Minimum virtual CPU clock rate required: false virtual_cpu_oversubscription_policy: type: string + description: CPU core oversubscription policy e.g. the relation of virtual CPU cores to physical CPU cores/threads. required: false vdu_cpu_requirements: type: map + description: The hardware platform specific VDU CPU requirements. A map of strings that contains a set of key-value pairs describing VDU CPU specific hardware platform requirements. + required: false entry_schema: type: string - required: false virtual_cpu_pinning: type: tosca.datatypes.nfv.VirtualCpuPinning + description: The virtual CPU pinning configuration for the virtualised compute resource. required: false tosca.datatypes.nfv.LogicalNodeData: derived_from: tosca.datatypes.Root + description: Describes compute, memory and I/O requirements associated with a particular VDU. properties: logical_node_requirements: type: map + description: The logical node-level compute, memory and I/O requirements. A map of strings that contains a set of key-value pairs that describes hardware platform specific deployment requirements, including the number of CPU cores on this logical node, a memory configuration specific to a logical node or a requirement related to the association of an I/O device with the logical node. + required: false entry_schema: type: string - required: false tosca.datatypes.nfv.VirtualNetworkInterfaceRequirements: derived_from: tosca.datatypes.Root + description: Describes requirements on a virtual network interface properties: name: type: string + description: Provides a human readable name for the requirement. required: false description: type: string + description: Provides a human readable description of the requirement. required: false support_mandatory: type: boolean + description: Indicates whether fulfilling the constraint is mandatory (TRUE) for successful operation or desirable (FALSE). required: true - requirement: - type: string - required: false network_interface_requirements: type: map + description: The network interface requirements. A map of strings that contain a set of key-value pairs that describes the hardware platform specific network interface deployment requirements. + required: true entry_schema: type: string - required: true nic_io_requirements: type: tosca.datatypes.nfv.LogicalNodeData + description: references (couples) the CP with any logical node I/O requirements (for network devices) that may have been created. Linking these attributes is necessary so that so that I/O requirements that need to be articulated at the logical node level can be associated with the network interface requirements associated with the CP. required: false tosca.datatypes.nfv.injectFile: derived_from: tosca.datatypes.Root @@ -1506,24 +1856,27 @@ data_types: required: true tosca.datatypes.nfv.L2AddressData: derived_from: tosca.datatypes.Root + description: Describes the information on the MAC addresses to be assigned to a connection point. properties: mac_address_assignment: type: boolean + description: Specifies if the address assignment is the responsibility of management and orchestration function or not. If it is set to True, it is the management and orchestration function responsibility required: true - address: - type: string - required: false tosca.datatypes.nfv.L3AddressData: derived_from: tosca.datatypes.Root + description: Provides information about Layer 3 level addressing scheme and parameters applicable to a CP properties: ip_address_assignment: type: boolean + description: Specifies if the address assignment is the responsibility of management and orchestration function or not. If it is set to True, it is the management and orchestration function responsibility required: true floating_ip_activated: type: boolean + description: Specifies if the floating IP scheme is activated on the Connection Point or not required: true ip_address_type: type: string + description: Defines address type. The address type should be aligned with the address type supported by the layer_protocols properties of the parent VnfExtCp required: false constraints: - valid_values: @@ -1531,49 +1884,62 @@ data_types: - ipv6 number_of_ip_address: type: integer + description: Minimum number of IP addresses to be assigned required: false + constraints: + - greater_than: 0 fixed_ip_address: type: list entry_schema: type: string required: false tosca.datatypes.nfv.AddressData: + derived_from: tosca.datatypes.Root + description: Describes information about the addressing scheme and parameters applicable to a CP properties: address_type: + type: string + description: Describes the type of the address to be assigned to a connection point. The content type shall be aligned with the address type supported by the layerProtocol property of the connection point + required: true constraints: - valid_values: - mac_address - ip_address - type: string - required: true l2_address_data: - required: false type: tosca.datatypes.nfv.L2AddressData - l3_address_data: + description: Provides the information on the MAC addresses to be assigned to a connection point. required: false + l3_address_data: type: tosca.datatypes.nfv.L3AddressData + description: Provides the information on the IP addresses to be assigned to a connection point + required: false tosca.datatypes.nfv.ConnectivityType: derived_from: tosca.datatypes.Root + description: describes additional connectivity information of a virtualLink properties: - layer_protocol: - type: string + layer_protocols: + type: list + description: Identifies the protocol a virtualLink gives access to (ethernet, mpls, odu2, ipv4, ipv6, pseudo-wire).The top layer protocol of the virtualLink protocol stack shall always be provided. The lower layer protocols may be included when there are specific requirements on these layers. required: true - constraints: - - valid_values: - - ethernet - - mpls - - odu2 - - ipv4 - - ipv6 - - pseudo_wire + entry_schema: + type: string + constraints: + - valid_values: + - ethernet + - mpls + - odu2 + - ipv4 + - ipv6 + - pseudo-wire flow_pattern: type: string + description: Identifies the flow pattern of the connectivity required: false constraints: - valid_values: - - Line - - Tree - - Mesh + - line + - tree + - mesh tosca.datatypes.nfv.VlFlavour: derived_from: tosca.datatypes.Root properties: @@ -1640,108 +2006,223 @@ data_types: required: false tosca.datatypes.nfv.VduProfile: derived_from: tosca.datatypes.Root + description: describes additional instantiation data for a given Vdu.Compute used in a specific deployment flavour. properties: min_number_of_instances: type: integer + description: Minimum number of instances of the VNFC based on this Vdu.Compute that is permitted to exist for a particular VNF deployment flavour. required: true + constraints: + - greater_or_equal: 0 max_number_of_instances: type: integer + description: Maximum number of instances of the VNFC based on this Vdu.Compute that is permitted to exist for a particular VNF deployment flavour. required: true + constraints: + - greater_or_equal: 0 watchdog: type: string required: true vmBootUpTimeOut: type: integer required: false - tosca.datatypes.nfv.LinkBitRateRequirements: + tosca.datatypes.nfv.LinkBitrateRequirements: derived_from: tosca.datatypes.Root + description: describes the requirements in terms of bitrate for a virtual link properties: root: type: integer + description: Specifies the throughput requirement in bits per second of the link (e.g. bitrate of E-Line, root bitrate of E-Tree, aggregate capacity of E-LAN). required: true + constraints: + - greater_or_equal: 0 leaf: type: integer - required: true + description: Specifies the throughput requirement in bits per second of leaf connections to the link when applicable to the connectivity type (e.g. for E-Tree and E LAN branches). + required: false + constraints: + - greater_or_equal: 0 tosca.datatypes.nfv.Qos: derived_from: tosca.datatypes.Root + description: describes QoS data for a given VL used in a VNF deployment flavour properties: latency: - type: integer + type: scalar-unit.time + description: Specifies the maximum latency required: true + constraints: + - greater_than: 0 s packet_delay_variation: - type: integer + type: scalar-unit.time + description: Specifies the maximum jitter required: true + constraints: + - greater_or_equal: 0 s packet_loss_ratio: type: float + description: Specifies the maximum packet loss ratio + required: false constraints: - in_range: - 0.0 - 1.0 - required: false - tosca.datatypes.nfv.VlProfile: + tosca.datatypes.nfv.IpAllocationPool: derived_from: tosca.datatypes.Root + description: Specifies a range of IP addresses properties: - max_bit_rate_requirements: - type: tosca.datatypes.nfv.LinkBitRateRequirements + start_ip_address: + type: string + description: The IP address to be used as the first one in a pool of addresses derived from the cidr block full IP range required: true - min_bit_rate_requirements: - type: tosca.datatypes.nfv.LinkBitRateRequirements + end_ip_address: + type: string + description: The IP address to be used as the last one in a pool of addresses derived from the cidr block full IP range required: true - qos: - type: tosca.datatypes.nfv.Qos - required: false - initiationParameters: - type: map - entry_schema: - type: string + tosca.datatypes.nfv.L2ProtocolData: + derived_from: tosca.datatypes.Root + description: describes L2 protocol data for a given virtual link used in a specific VNF deployment flavour. + properties: + name: + type: string + description: Identifies the network name associated with this L2 protocol. required: false - cidr: + network_type: type: string + description: Specifies the network type for this L2 protocol.The value may be overridden at run-time. required: false - networkName: + constraints: + - valid_values: + - flat + - vlan + - vxlan + - gre + vlan_transparent: + type: boolean + description: Specifies whether to support VLAN transparency for this L2 protocol or not. + required: false + default: false + mtu: + type: integer + description: Specifies the maximum transmission unit (MTU) value for this L2 protocol. + required: false + constraints: + - greater_than: 0 + segmentation_id: + type: integer + required: false + physical_network: type: string required: false - startIp: + tosca.datatypes.nfv.L3ProtocolData: + derived_from: tosca.datatypes.Root + description: describes L3 protocol data for a given virtual link used in a specific VNF deployment flavour. + properties: + name: type: string + description: Identifies the network name associated with this L3 protocol. required: false - endIp: + ip_version: type: string + description: Specifies IP version of this L3 protocol.The value of the ip_version property shall be consistent with the value of the layer_protocol in the connectivity_type property of the virtual link node. + required: true + constraints: + - valid_values: + - ipv4 + - ipv6 + cidr: + type: string + description: Specifies the CIDR (Classless Inter-Domain Routing) of this L3 protocol. The value may be overridden at run-time. + required: true + ip_allocation_pools: + type: list + description: Specifies the allocation pools with start and end IP addresses for this L3 protocol. The value may be overridden at run-time. required: false - gatewayIp: + entry_schema: + type: tosca.datatypes.nfv.IpAllocationPool + gateway_ip: type: string + description: Specifies the gateway IP address for this L3 protocol. The value may be overridden at run-time. required: false - segmentationId: - type: integer + dhcp_enabled: + type: boolean + description: Indicates whether DHCP (Dynamic Host Configuration Protocol) is enabled or disabled for this L3 protocol. The value may be overridden at run-time. required: false - physicalNetwork: + ipv6_address_mode: type: string + description: Specifies IPv6 address mode. May be present when the value of the ipVersion attribute is "ipv6" and shall be absent otherwise. The value may be overridden at run-time. required: false - networkType: + constraints: + - valid_values: + - slaac + - dhcpv6-stateful + - dhcpv6-stateless + tosca.datatypes.nfv.VirtualLinkProtocolData: + derived_from: tosca.datatypes.Root + description: describes one protocol layer and associated protocol data for a given virtual link used in a specific VNF deployment flavour + properties: + associated_layer_protocol: type: string - required: false + description: Identifies one of the protocols a virtualLink gives access to (ethernet, mpls, odu2, ipv4, ipv6, pseudo-wire) as specified by the connectivity_type property. + required: true constraints: - valid_values: - - VLAN - - VXLAN - dhcpEnabled: - type: boolean + - ethernet + - mpls + - odu2 + - ipv4 + - ipv6 + - pseudo-wire + l2_protocol_data: + type: tosca.datatypes.nfv.L2ProtocolData + description: Specifies the L2 protocol data for a virtual link. Shall be present when the associatedLayerProtocol attribute indicates a L2 protocol and shall be absent otherwise. required: false - vlanTransparent: - type: boolean + l3_protocol_data: + type: tosca.datatypes.nfv.L3ProtocolData + description: Specifies the L3 protocol data for this virtual link. Shall be present when the associatedLayerProtocol attribute indicates a L3 protocol and shall be absent otherwise. required: false + tosca.datatypes.nfv.VlProfile: + derived_from: tosca.datatypes.Root + description: Describes additional instantiation data for a given VL used in a specific VNF deployment flavour. + properties: + max_bitrate_requirements: + type: tosca.datatypes.nfv.LinkBitrateRequirements + description: Specifies the maximum bitrate requirements for a VL instantiated according to this profile. + required: true + min_bitrate_requirements: + type: tosca.datatypes.nfv.LinkBitrateRequirements + description: Specifies the minimum bitrate requirements for a VL instantiated according to this profile. + required: true + qos: + type: tosca.datatypes.nfv.Qos + description: Specifies the QoS requirements of a VL instantiated according to this profile. + required: false + virtual_link_protocol_data: + type: list + description: Specifies the protocol data for a virtual link. + required: false + entry_schema: + type: tosca.datatypes.nfv.VirtualLinkProtocolData tosca.datatypes.nfv.VduLevel: derived_from: tosca.datatypes.Root + description: Indicates for a given Vdu.Compute in a given level the number of instances to deploy properties: number_of_instances: type: integer + description: Number of instances of VNFC based on this VDU to deploy for this level. required: true + constraints: + - greater_or_equal: 0 tosca.datatypes.nfv.ScaleInfo: derived_from: tosca.datatypes.Root + description: Indicates for a given scaleAspect the corresponding scaleLevel properties: - scaleLevel: + scale_level: type: integer + description: The scale level for a particular aspect required: true - tosca.datatypes.nfv.ScaleAspect: + constraints: + - greater_or_equal: 0 + tosca.datatypes.nfv.ScalingAspect: derived_from: tosca.datatypes.Root properties: name: @@ -1750,77 +2231,302 @@ data_types: description: type: string required: true - associated_group: - type: string - required: false max_scale_level: type: integer required: true + constraints: + - greater_or_equal: 0 + step_deltas: + type: list + required: false + entry_schema: + type: string tosca.datatypes.nfv.InstantiationLevel: derived_from: tosca.datatypes.Root + description: Describes the scale level for each aspect that corresponds to a given level of resources to be instantiated within a deployment flavour in term of the number VNFC instances properties: description: type: string + description: Human readable description of the level required: true - vdu_levels: - type: map - required: true - entry_schema: - type: tosca.datatypes.nfv.VduLevel scale_info: type: map + description: Represents for each aspect the scale level that corresponds to this instantiation level. scale_info shall be present if the VNF supports scaling. required: false entry_schema: type: tosca.datatypes.nfv.ScaleInfo + tosca.datatypes.nfv.VnfInstantiateOperationConfiguration: + derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the InstantiateVnf operation. + properties: + description: + type: string + required: false tosca.datatypes.nfv.VnfScaleOperationConfiguration: derived_from: tosca.datatypes.Root + description: Represents information that affect the invocation of the ScaleVnf operation properties: scaling_by_more_than_one_step_supported: type: boolean + description: Signals whether passing a value larger than one in the numScalingSteps parameter of the ScaleVnf operation is supported by this VNF. + required: false + default: false tosca.datatypes.nfv.VnfScaleToLevelOperationConfiguration: derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the ScaleVnfToLevel operation properties: arbitrary_target_levels_supported: type: boolean + description: Signals whether scaling according to the parameter "scaleInfo" is supported by this VNF + required: true tosca.datatypes.nfv.VnfHealOperationConfiguration: derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the HealVnf operation properties: causes: type: list + description: Supported "cause" parameter values + required: false entry_schema: type: string tosca.datatypes.nfv.VnfTerminateOperationConfiguration: derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the TerminateVnf properties: min_graceful_termination_timeout: - type: integer + type: scalar-unit.time + description: Minimum timeout value for graceful termination of a VNF instance + required: true max_recommended_graceful_termination_timeout: - type: integer + type: scalar-unit.time + description: Maximum recommended timeout value that can be needed to gracefully terminate a VNF instance of a particular type under certain conditions, such as maximum load condition. This is provided by VNF provider as information for the operator facilitating the selection of optimal timeout value. This value is not used as constraint + required: false tosca.datatypes.nfv.VnfOperateOperationConfiguration: derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the OperateVnf operation properties: - min_graceful_termination_timeout: + min_graceful_stop_timeout: + type: scalar-unit.time + description: Minimum timeout value for graceful stop of a VNF instance + required: true + max_recommended_graceful_stop_timeout: + type: scalar-unit.time + description: Maximum recommended timeout value that can be needed to gracefully stop a VNF instance of a particular type under certain conditions, such as maximum load condition. This is provided by VNF provider as information for the operator facilitating the selection of optimal timeout value. This value is not used as constraint + required: false + tosca.datatypes.nfv.VnfChangeFlavourOperationConfiguration: + derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the ChangeVnfFlavour operation + properties: + description: + type: string + required: false + tosca.datatypes.nfv.VnfProfile: + derived_from: tosca.datatypes.Root + description: describes a profile for instantiating VNFs of a particular NS DF according to a specific VNFD and VNF DF. + properties: + instantiation_level: + type: string + description: Identifier of the instantiation level of the VNF DF to be used for instantiation. If not present, the default instantiation level as declared in the VNFD shall be used. + required: false + min_number_of_instances: type: integer - max_recommended_graceful_termination_timeout: + description: Minimum number of instances of the VNF based on this VNFD that is permitted to exist for this VnfProfile. + required: true + constraints: + - greater_or_equal: 0 + max_number_of_instances: type: integer + description: Maximum number of instances of the VNF based on this VNFD that is permitted to exist for this VnfProfile. + required: true + constraints: + - greater_or_equal: 0 + tosca.datatypes.nfv.UriAuthority: + derived_from: tosca.datatypes.Root + description: information that corresponds to the authority component of a URI as specified in IETF RFC 3986 [8] + properties: + user_info: + type: string + description: user_info field of the authority component of a URI + required: false + host: + type: string + description: host field of the authority component of a URI + required: false + port: + type: string + description: port field of the authority component of a URI + required: false + tosca.datatypes.nfv.UriComponents: + derived_from: tosca.datatypes.Root + description: information used to build a URI that complies with IETF RFC 3986 [8]. + properties: + scheme: + type: string + description: scheme component of a URI. + required: true + authority: + type: tosca.datatypes.nfv.UriAuthority + description: Authority component of a URI + required: false + path: + type: string + description: path component of a URI. + required: false + query: + type: string + description: query component of a URI. + required: false + fragment: + type: string + description: fragment component of a URI. + required: false + tosca.datatypes.nfv.InterfaceDetails: + derived_from: tosca.datatypes.Root + description: information used to access an interface exposed by a VNF + properties: + uri_components: + type: tosca.datatypes.nfv.UriComponents + description: Provides components to build a Uniform Ressource Identifier (URI) where to access the interface end point. + required: false + interface_specific_data: + type: map + description: Provides additional details that are specific to the type of interface considered. + required: false + entry_schema: + type: string + tosca.datatypes.nfv.VirtualLinkMonitoringParameter: + derived_from: tosca.datatypes.Root + description: Represents information on virtualised resource related performance metrics applicable to the VNF. + properties: + name: + type: string + description: Human readable name of the monitoring parameter + required: true + performance_metric: + type: string + description: Identifies a performance metric derived from those defined in ETSI GS NFV-IFA 027.The packetOutgoingVirtualLink and packetIncomingVirtualLink metrics shall be obtained by aggregation the PacketOutgoing and PacketIncoming measurements defined in clause 7.1 of GS NFV-IFA 027 of all virtual link ports attached to the virtual link to which the metrics apply. + required: true + constraints: + - valid_values: + - packet_outgoing_virtual_link + - packet_incoming_virtual_link + collection_period: + type: scalar-unit.time + description: Describes the recommended periodicity at which to collect the performance information. + required: false + constraints: + - greater_than: 0 s + tosca.datatypes.nfv.VnfcMonitoringParameter: + derived_from: tosca.datatypes.Root + description: Represents information on virtualised resource related performance metrics applicable to the VNF. + properties: + name: + type: string + description: Human readable name of the monitoring parameter + required: true + performance_metric: + type: string + description: Identifies the performance metric, according to ETSI GS NFV-IFA 027. + required: true + constraints: + - valid_values: + - v_cpu_usage_mean_vnf + - v_cpu_usage_peak_vnf + - v_memory_usage_mean_vnf + - v_memory_usage_peak_vnf + - v_disk_usage_mean_vnf + - v_disk_usage_peak_vnf + - byte_incoming_vnf_int_cp + - byte_outgoing_vnf_int_cp + - packet_incoming_vnf_int_cp + - packet_outgoing_vnf_int_cp + collection_period: + type: scalar-unit.time + description: Describes the recommended periodicity at which to collect the performance information. + required: false + constraints: + - greater_than: 0 s + tosca.datatypes.nfv.VnfChangeExtConnectivityOperationConfiguration: + derived_from: tosca.datatypes.Root + description: represents information that affect the invocation of the ChangeExtVnfConnectivity operation + properties: + description: + type: string + required: false + tosca.datatypes.nfv.VnfMonitoringParameter: + derived_from: tosca.datatypes.Root + description: Represents information on virtualised resource related performance metrics applicable to the VNF. + properties: + name: + type: string + description: Human readable name of the monitoring parameter + required: true + performance_metric: + type: string + description: Identifies the performance metric, according to ETSI GS NFV-IFA 027. + required: true + constraints: + - valid_values: + - v_cpu_usage_mean_vnf + - v_cpu_usage_peak_vnf + - v_memory_usage_mean_vnf + - v_memory_usage_peak_vnf + - v_disk_usage_mean_vnf + - v_disk_usage_peak_vnf + - byte_incoming_vnf_ext_cp + - byte_outgoing_vnf_ext_cp + - packet_incoming_vnf_ext_cp + - packet_outgoing_vnf_ext_cp + collection_period: + type: scalar-unit.time + description: Describes the recommended periodicity at which to collect the performance information. + required: false + constraints: + - greater_than: 0 s tosca.datatypes.nfv.VnfLcmOperationsConfiguration: derived_from: tosca.datatypes.Root + description: Represents information to configure lifecycle management operations properties: + instantiate: + type: tosca.datatypes.nfv.VnfInstantiateOperationConfiguration + description: Configuration parameters for the InstantiateVnf operation + required: false scale: type: tosca.datatypes.nfv.VnfScaleOperationConfiguration + description: Configuration parameters for the ScaleVnf operation + required: false scale_to_level: type: tosca.datatypes.nfv.VnfScaleToLevelOperationConfiguration + description: Configuration parameters for the ScaleVnfToLevel operation + required: false + change_flavour: + type: tosca.datatypes.nfv.VnfChangeFlavourOperationConfiguration + description: Configuration parameters for the changeVnfFlavourOpConfig operation + required: false heal: type: tosca.datatypes.nfv.VnfHealOperationConfiguration + description: Configuration parameters for the HealVnf operation + required: false terminate: type: tosca.datatypes.nfv.VnfTerminateOperationConfiguration + description: Configuration parameters for the TerminateVnf operation + required: false operate: type: tosca.datatypes.nfv.VnfOperateOperationConfiguration + description: Configuration parameters for the OperateVnf operation + required: false + change_ext_connectivity: + type: tosca.datatypes.nfv.VnfChangeExtConnectivityOperationConfiguration + description: Configuration parameters for the changeExtVnfConnectivityOpConfig operation + required: false tosca.datatypes.nfv.CpProtocolData: derived_from: tosca.datatypes.Root + description: Describes and associates the protocol layer that a CP uses together with other protocol and connection point information properties: - asscociated_layer_protocol: + associated_layer_protocol: type: string + required: true + description: One of the values of the property layer_protocols of the CP constraints: - valid_values: - ethernet @@ -1829,40 +2535,185 @@ data_types: - ipv4 - ipv6 - pseudo-wire - required: true address_data: - type: tosca.datatypes.nfv.AddressData + type: list + description: Provides information on the addresses to be assigned to the CP + entry_schema: + type: tosca.datatypes.nfv.AddressData + required: false + tosca.datatypes.nfv.VnfAdditionalConfigurableProperties: + derived_from: tosca.datatypes.Root + description: is an empty base type for deriving data types for describing additional configurable properties for a given VNF + properties: + description: + type: string required: false tosca.datatypes.nfv.VnfConfigurableProperties: derived_from: tosca.datatypes.Root + description: indicates configuration properties for a given VNF (e.g. related to auto scaling and auto healing). properties: is_autoscale_enabled: type: boolean + description: It permits to enable (TRUE)/disable (FALSE) the auto-scaling functionality. If the properties is not present for configuring, then VNF property is not supported required: false is_autoheal_enabled: type: boolean + description: It permits to enable (TRUE)/disable (FALSE) the auto-healing functionality. If the properties is not present for configuring, then VNF property is not supported + required: false + additional_configurable_properties: + description: It provides VNF specific configurable properties that can be modified using the ModifyVnfInfo operation required: false + type: tosca.datatypes.nfv.VnfAdditionalConfigurableProperties tosca.datatypes.nfv.VnfInfoModifiableAttributesExtensions: derived_from: tosca.datatypes.Root + description: is an empty base type for deriving data types for describing VNF-specific extension properties: description: type: string required: false tosca.datatypes.nfv.VnfInfoModifiableAttributesMetadata: derived_from: tosca.datatypes.Root + description: is an empty base type for deriving data types for describing VNF-specific metadata properties: description: type: string required: false tosca.datatypes.nfv.VnfInfoModifiableAttributes: derived_from: tosca.datatypes.Root + description: Describes VNF-specific extension and metadata for a given VNF properties: extensions: type: tosca.datatypes.nfv.VnfInfoModifiableAttributesExtensions + description: \"Extension\" properties of VnfInfo that are writeable required: false metadata: type: tosca.datatypes.nfv.VnfInfoModifiableAttributesMetadata + description: \"Metadata\" properties of VnfInfo that are writeable required: false + tosca.datatypes.nfv.VirtualLinkBitrateLevel: + derived_from: tosca.datatypes.Root + description: Describes bitrate requirements applicable to the virtual link instantiated from a particicular VnfVirtualLink + properties: + description: + type: string + required: false + bitrate_requirements: + type: tosca.datatypes.nfv.LinkBitrateRequirements + description: Virtual link bitrate requirements for an instantiation level or bitrate delta for a scaling step + required: true + tosca.datatypes.nfv.VnfOperationAdditionalParameters: + derived_from: tosca.datatypes.Root + description: Is an empty base type for deriving data type for describing VNF-specific parameters to be passed when invoking lifecycle management operations + properties: + description: + type: string + required: false + tosca.datatypes.nfv.VirtualFileStorageData: + derived_from: tosca.datatypes.Root + description: VirtualFileStorageData describes file storage requirements associated with compute resources in a particular VDU + properties: + size_of_storage: + type: scalar-unit.size + description: Size of virtualized storage resource + required: true + file_system_protocol: + type: string + description: The shared file system protocol (e.g. NFS, CIFS) + required: true + tosca.datatypes.nfv.VirtualObjectStorageData: + derived_from: tosca.datatypes.Root + description: VirtualObjectStorageData describes object storage requirements associated with compute resources in a particular VDU + properties: + max_size_of_storage: + type: scalar-unit.size + description: Maximum size of virtualized storage resource + required: false + tosca.datatypes.nfv.VirtualBlockStorageData: + derived_from: tosca.datatypes.Root + description: VirtualBlockStorageData describes block storage requirements associated with compute resources in a particular VDU, either as a local disk or as virtual attached storage + properties: + size_of_storage: + type: scalar-unit.size + description: Size of virtualised storage resource + required: true + vdu_storage_requirements: + type: map + description: The hardware platform specific storage requirements. A map of strings that contains a set of key-value pairs that represents the hardware platform specific storage deployment requirements. + required: false + entry_schema: + type: string + rdma_enabled: + type: boolean + description: Indicates if the storage support RDMA + required: false + default: false + tosca.datatypes.nfv.SwImageData: + derived_from: tosca.datatypes.Root + description: describes information related to a software image artifact + properties: + name: + type: string + description: Name of this software image + required: true + version: + type: string + description: Version of this software image + required: true + checksum: + type: string + description: Checksum of the software image file + required: true + container_format: + type: string + description: The container format describes the container file format in which software image is provided + required: true + constraints: + - valid_values: + - aki + - ami + - ari + - bare + - docker + - ova + - ovf + disk_format: + type: string + description: The disk format of a software image is the format of the underlying disk image + required: true + constraints: + - valid_values: + - aki + - ami + - ari + - iso + - qcow2 + - raw + - vdi + - vhd + - vhdx + - vmdk + min_disk: + type: scalar-unit.size + description: The minimal disk size requirement for this software image + required: true + min_ram: + type: scalar-unit.size + description: The minimal RAM requirement for this software image + required: false + size: + type: scalar-unit.size + description: The size of this software image + required: true + operating_system: + type: string + description: Identifies the operating system used in the software image + required: false + supported_virtualisation_environments: + type: list + description: Identifies the virtualisation environments (e.g. hypervisor) compatible with this software image + required: false + entry_schema: + type: string onap.datatypes.monitoring.metricsPerEventName: derived_from: tosca.datatypes.Root properties: diff --git a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar Binary files differdeleted file mode 100755 index 727ef16b..00000000 --- a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar +++ /dev/null diff --git a/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar b/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar Binary files differnew file mode 100644 index 00000000..3330dd1e --- /dev/null +++ b/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py index f19aa0da..0db977bb 100755 --- a/src/test/resources/http-cache/third_party_proxy.py +++ b/src/test/resources/http-cache/third_party_proxy.py @@ -199,6 +199,18 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): with open(cached_file_content, 'w+') as f: f.write(self.data_string) return True + elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "GET": + print "self.path start with /policy/api/v1/policytypes/, generating response json..." + jsonGenerated = "{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}" + print "jsonGenerated: " + jsonGenerated + if not os.path.exists(cached_file_folder): + os.makedirs(cached_file_folder, 0777) + + with open(cached_file_header, 'w') as f: + f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}") + with open(cached_file_content, 'w') as f: + f.write(jsonGenerated) + return True else: return False diff --git a/src/test/resources/tosca/guard1-policy-payload.json b/src/test/resources/tosca/guard1-policy-payload.json index bacf174f..b4e0809c 100644 --- a/src/test/resources/tosca/guard1-policy-payload.json +++ b/src/test/resources/tosca/guard1-policy-payload.json @@ -1,15 +1,15 @@ { "policy-id": "guard1", - "contents": { + "content": { "recipe": "Rebuild", "actor": "SO", "clname": "testloop", - "guardTargets": ".*", - "minGuard": "3", - "maxGuard": "7", - "limitGuard": "", - "timeUnitsGuard": "", - "timeWindowGuard": "", + "targets": ".*", + "min": "3", + "max": "7", + "limit": "", + "timeUnits": "", + "timeWindow": "", "guardActiveStart": "00:00:01-05:00", "guardActiveEnd": "23:59:01-05:00" } diff --git a/src/test/resources/tosca/guard2-policy-payload.json b/src/test/resources/tosca/guard2-policy-payload.json index 89f7ec89..29beb6b9 100644 --- a/src/test/resources/tosca/guard2-policy-payload.json +++ b/src/test/resources/tosca/guard2-policy-payload.json @@ -1,15 +1,15 @@ { "policy-id": "guard2", - "contents": { + "content": { "recipe": "Migrate", "actor": "SO", "clname": "testloop", - "guardTargets": ".*", - "minGuard": "1", - "maxGuard": "2", - "limitGuard": "", - "timeUnitsGuard": "", - "timeWindowGuard": "", + "targets": ".*", + "min": "1", + "max": "2", + "limit": "", + "timeUnits": "", + "timeWindow": "", "guardActiveStart": "00:00:01-05:00", "guardActiveEnd": "23:59:01-05:00" } diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json new file mode 100644 index 00000000..9e7db8eb --- /dev/null +++ b/src/test/resources/tosca/model-properties.json @@ -0,0 +1,123 @@ +{ + "serviceDetails": { + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" + }, + "resourceDetails": { + "CP": { + + }, + "VL": { + + }, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + } + }, + "CR": { + + }, + "VFC": { + + }, + "PNF": { + + }, + "Service": { + + }, + "CVFC": { + + }, + "Service Proxy": { + + }, + "Configuration": { + + }, + "AllottedResource": { + + }, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json index 50361659..52eabb8a 100644 --- a/src/test/resources/tosca/operational-policy-properties.json +++ b/src/test/resources/tosca/operational-policy-properties.json @@ -4,12 +4,12 @@ "recipe": "Rebuild", "actor": "SO", "clname": "testloop", - "guardTargets": ".*", - "minGuard": "3", - "maxGuard": "7", - "limitGuard": "", - "timeUnitsGuard": "", - "timeWindowGuard": "", + "targets": ".*", + "min": "3", + "max": "7", + "limit": "", + "timeUnits": "", + "timeWindow": "", "guardActiveStart": "00:00:01-05:00", "guardActiveEnd": "23:59:01-05:00" }, @@ -17,12 +17,12 @@ "recipe": "Migrate", "actor": "SO", "clname": "testloop", - "guardTargets": ".*", - "minGuard": "1", - "maxGuard": "2", - "limitGuard": "", - "timeUnitsGuard": "", - "timeWindowGuard": "", + "targets": ".*", + "min": "1", + "max": "2", + "limit": "", + "timeUnits": "", + "timeWindow": "", "guardActiveStart": "00:00:01-05:00", "guardActiveEnd": "23:59:01-05:00" } |