aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java29
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java5
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java11
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java12
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java234
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java18
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java23
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java17
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java69
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java26
10 files changed, 194 insertions, 250 deletions
diff --git a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java b/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
index 797ea4b9..971077cc 100644
--- a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
+++ b/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
@@ -5,24 +5,25 @@
* 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.distribution.model;
import java.util.Date;
/**
- * An optimization policy
+ * An optimization policy.
*/
public class OptimizationPolicy implements Policy {
@@ -48,7 +49,7 @@ public class OptimizationPolicy implements Policy {
return OPTIMIZATION;
}
- public void setPolicyName(String policyName) {
+ public void setPolicyName(final String policyName) {
this.policyName = policyName;
}
@@ -56,7 +57,7 @@ public class OptimizationPolicy implements Policy {
return policyDescription;
}
- public void setPolicyDescription(String policyDescription) {
+ public void setPolicyDescription(final String policyDescription) {
this.policyDescription = policyDescription;
}
@@ -64,7 +65,7 @@ public class OptimizationPolicy implements Policy {
return policyConfigType;
}
- public void setPolicyConfigType(String policyConfigType) {
+ public void setPolicyConfigType(final String policyConfigType) {
this.policyConfigType = policyConfigType;
}
@@ -72,7 +73,7 @@ public class OptimizationPolicy implements Policy {
return onapName;
}
- public void setOnapName(String onapName) {
+ public void setOnapName(final String onapName) {
this.onapName = onapName;
}
@@ -80,7 +81,7 @@ public class OptimizationPolicy implements Policy {
return configBody;
}
- public void setConfigBody(String configBody) {
+ public void setConfigBody(final String configBody) {
this.configBody = configBody;
}
@@ -88,7 +89,7 @@ public class OptimizationPolicy implements Policy {
return configBodyType;
}
- public void setConfigBodyType(String configBodyType) {
+ public void setConfigBodyType(final String configBodyType) {
this.configBodyType = configBodyType;
}
@@ -96,7 +97,7 @@ public class OptimizationPolicy implements Policy {
return timetolive;
}
- public void setTimetolive(Date timetolive) {
+ public void setTimetolive(final Date timetolive) {
this.timetolive = timetolive;
}
@@ -104,7 +105,7 @@ public class OptimizationPolicy implements Policy {
return guard;
}
- public void setGuard(String guard) {
+ public void setGuard(final String guard) {
this.guard = guard;
}
@@ -112,7 +113,7 @@ public class OptimizationPolicy implements Policy {
return riskLevel;
}
- public void setRiskLevel(String riskLevel) {
+ public void setRiskLevel(final String riskLevel) {
this.riskLevel = riskLevel;
}
@@ -120,7 +121,7 @@ public class OptimizationPolicy implements Policy {
return riskType;
}
- public void setRiskType(String riskType) {
+ public void setRiskType(final String riskType) {
this.riskType = riskType;
}
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java
index c86bae9e..9962894e 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Attribute.java
@@ -33,7 +33,7 @@ class Attribute {
@SerializedName(value = "attribute_value")
private String attributeValue;
- public void setAttributeName(String attributeName) {
+ public void setAttributeName(final String attributeName) {
this.attributeName = attributeName;
}
@@ -41,13 +41,12 @@ class Attribute {
return attributeName;
}
- public void setAttributeValue(String attributeValue) {
+ public void setAttributeValue(final String attributeValue) {
this.attributeValue = attributeValue;
}
public String getAttributeValue() {
return attributeValue;
}
-
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java
index 264ba8a6..77d1a9b7 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java
@@ -20,8 +20,8 @@
package org.onap.policy.distribution.reception.decoding.pdpx;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* The content acts the high level abstraction which to be used by OOF to do Optimization.
@@ -35,15 +35,15 @@ class Content {
private String policyType = "Optimization";
private List<FlavorFeature> flavorFeatures = new ArrayList<>();
- public void setResources(String resources) {
+ public void setResources(final String resources) {
this.resources = resources;
}
public String getResources() {
return resources;
- }
+ }
- public void setIdentity(String identity) {
+ public void setIdentity(final String identity) {
this.identity = identity;
}
@@ -55,7 +55,7 @@ class Content {
return policyScope;
}
- public void setPolicyType(String policyType) {
+ public void setPolicyType(final String policyType) {
this.policyType = policyType;
}
@@ -66,6 +66,5 @@ class Content {
public List<FlavorFeature> getFlavorFeatures() {
return flavorFeatures;
}
-
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java
index c04fc91d..6df5bc38 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Directive.java
@@ -20,22 +20,21 @@
package org.onap.policy.distribution.reception.decoding.pdpx;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
- * The attribute acts an abstraction to indicate OOF which supports two different Models
- * (Heat and TOSCA), two areas are wrapped: in the VNFC level to indicate the flavor,
- * in the hpa_feature level to contains specified information.
+ * The attribute acts an abstraction to indicate OOF which supports two different Models (Heat and TOSCA), two areas are
+ * wrapped: in the VNFC level to indicate the flavor, in the hpa_feature level to contains specified information.
*
* @author Libo Zhu (libo.zhu@intel.com)
*/
-class Directive{
+class Directive {
private String type;
private List<Attribute> attributes = new ArrayList<>();
- public void setType(String type) {
+ public void setType(final String type) {
this.type = type;
}
@@ -46,6 +45,5 @@ class Directive{
public List<Attribute> getAttributes() {
return attributes;
}
-
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
index 3fba96d4..4e7f9411 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
@@ -5,49 +5,38 @@
* 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.distribution.reception.decoding.pdpx;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import java.io.FileWriter;
import java.io.Writer;
-
+import java.util.ArrayList;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.annotations.SerializedName;
-
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
-
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcCsarHelperImpl;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-
-import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
import org.onap.sdc.toscaparser.api.CapabilityAssignments;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
/**
* Extract concerned info from NodeTemplate, currently ONLY HPA Feature.
@@ -57,167 +46,156 @@ import org.onap.sdc.toscaparser.api.elements.Metadata;
public class ExtractFromNode {
private static final Logger LOGGER = FlexLogger.getLogger(ExtractFromNode.class);
- private static final String CONTENT_RESOURCES = "name";
private static final String VDU_TYPE = "tosca.nodes.nfv.Vdu.Compute";
private static final String VDU_CP_TYPE = "tosca.nodes.nfv.VduCp";
private static final String VIRTUAL_MEM_SIZE_PATH = "virtual_memory#virtual_mem_size";
private static final String NUM_VIRTUAL_CPU_PATH = "virtual_cpu#num_virtual_cpu";
private static final String CPU_ARCHITECTURE_PATH = "virtual_cpu#cpu_architecture";
- private static final String NUMBER_OF_PAGES_PATH = "virtual_memory#vdu_memory_requirements#numberOfPages";
private static final String BASIC_CAPABILITIES = "BasicCapabilities";
-
ISdcCsarHelper sdcCsarHelper;
- final Gson gson = new GsonBuilder()
- .serializeNulls()
- .setPrettyPrinting()
- .disableHtmlEscaping()
- .create();
-
+ final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();
- public void setSdcCsarHelper(ISdcCsarHelper sdcCsarHelper) {
+ public void setSdcCsarHelper(final ISdcCsarHelper sdcCsarHelper) {
this.sdcCsarHelper = sdcCsarHelper;
}
- /*
- * ExtractInfo from VNF , each VNF may includes more than one VDUs and CPs return new generated PdpxPolicy
- * if it has got Hpa feature info or else return null.
- *
+ /**
+ * ExtractInfo from VNF , each VNF may includes more than one VDUs and CPs return new generated PdpxPolicy if it has
+ * got Hpa feature info or else return null.
+ *
* @param node the NodeTemplate
* @return the extracted info from input node
* @throws PolicyDecodingException if extract fails
*/
- public PdpxPolicy extractInfo(NodeTemplate node) throws PolicyDecodingException {
- PdpxPolicy pdpxPolicy = new PdpxPolicy();
- Content content = pdpxPolicy.getContent();
+ public PdpxPolicy extractInfo(final NodeTemplate node) throws PolicyDecodingException {
- String outputFile = sdcCsarHelper.getNodeTemplateMetadata(node).getValue("name");
- outputFile += ".json";
LOGGER.debug("the meta data of this nodetemplate = " + sdcCsarHelper.getNodeTemplateMetadata(node));
- LOGGER.debug("outputFile = " + outputFile);
-
- List<NodeTemplate> lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node);
+ final List<NodeTemplate> lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node);
LOGGER.debug("the size of lnodeChild = " + lnodeChild.size());
- //Store all the VDUs under one VNF
- List<NodeTemplate> lnodeVdu = new ArrayList<>();
- //Store all the Cps under one VNF
- List<NodeTemplate> lnodeVduCp = new ArrayList<>();
- for ( NodeTemplate nodeChild : lnodeChild) {
- String type = sdcCsarHelper.getTypeOfNodeTemplate(nodeChild);
+ // Store all the VDUs under one VNF
+ final List<NodeTemplate> lnodeVdu = new ArrayList<>();
+ // Store all the Cps under one VNF
+ final List<NodeTemplate> lnodeVduCp = new ArrayList<>();
+ for (final NodeTemplate nodeChild : lnodeChild) {
+ final String type = sdcCsarHelper.getTypeOfNodeTemplate(nodeChild);
LOGGER.debug("the type of this nodeChild = " + type);
LOGGER.debug("the meta data of this nodetemplate = " + sdcCsarHelper.getNodeTemplateMetadata(nodeChild));
- if ( type.equalsIgnoreCase(VDU_TYPE)) {
+ if (type.equalsIgnoreCase(VDU_TYPE)) {
lnodeVdu.add(nodeChild);
- } else if ( type.equalsIgnoreCase(VDU_CP_TYPE)) {
+ } else if (type.equalsIgnoreCase(VDU_CP_TYPE)) {
lnodeVduCp.add(nodeChild);
}
}
-
LOGGER.debug("the size of vdu is =" + lnodeVdu.size());
LOGGER.debug("the size of cp is =" + lnodeVduCp.size());
+ final PdpxPolicy pdpxPolicy = new PdpxPolicy();
+ final Content content = pdpxPolicy.getContent();
extractInfoVdu(lnodeVdu, content);
extractInfoVduCp(lnodeVduCp, content);
-
- if (content.getFlavorFeatures().isEmpty() ){
+ if (content.getFlavorFeatures().isEmpty()) {
return null;
- }
-
+ }
+ String outputFile = sdcCsarHelper.getNodeTemplateMetadata(node).getValue("name");
+ outputFile += ".json";
+ LOGGER.debug("outputFile = " + outputFile);
try (Writer writer = new FileWriter(outputFile)) {
gson.toJson(pdpxPolicy, writer);
- } catch (Exception e) {
- LOGGER.error("can't write generated policies to file " , e);
- throw new PolicyDecodingException ("Exception caught when writing generated policies to file ", e);
+ } catch (final Exception exp) {
+ final String message = "Failed writing generated policies to file";
+ LOGGER.error(message, exp);
+ throw new PolicyDecodingException(message, exp);
}
return pdpxPolicy;
}
- /*
+ /**
* ExtractInfofromVdu, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute.
- *
+ *
* @param lnodeVdu the list of Vdu node
* @param content to be change based on lnodeVdu
*/
- public void extractInfoVdu(final List<NodeTemplate> lnodeVdu, Content content) {
- //each VDU <=> FlavorFeature
- for ( NodeTemplate node : lnodeVdu) {
- String id = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, "name");
- FlavorFeature flavorFeature = new FlavorFeature();
- flavorFeature.setId(id);
- Attribute flavorAttribute = new Attribute();
+ public void extractInfoVdu(final List<NodeTemplate> lnodeVdu, final Content content) {
+ // each VDU <=> FlavorFeature
+ for (final NodeTemplate node : lnodeVdu) {
+ final Attribute flavorAttribute = new Attribute();
flavorAttribute.setAttributeName("flavorName");
flavorAttribute.setAttributeValue("");
- Directive flavorDirective = new Directive();
+ final Directive flavorDirective = new Directive();
flavorDirective.setType("flavor_directive");
flavorDirective.getAttributes().add(flavorAttribute);
+ final FlavorFeature flavorFeature = new FlavorFeature();
+ flavorFeature.setId(sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, "name"));
flavorFeature.getDirectives().add(flavorDirective);
-
- CapabilityAssignments capabilityAssignments = sdcCsarHelper.getCapabilitiesOf(node);
- CapabilityAssignment capabilityAssignment = capabilityAssignments.getCapabilityByName("virtual_compute");
+
+ final CapabilityAssignments capabilityAssignments = sdcCsarHelper.getCapabilitiesOf(node);
+ final CapabilityAssignment capabilityAssignment =
+ capabilityAssignments.getCapabilityByName("virtual_compute");
if (capabilityAssignment != null) {
generateBasicCapability(capabilityAssignment, flavorFeature);
- generateHugePages(capabilityAssignment, flavorFeature);
+ generateHugePages(capabilityAssignment);
}
-
- content.getFlavorFeatures().add(flavorFeature);
+ content.getFlavorFeatures().add(flavorFeature);
}
}
- /*
+ /**
* GenerateBasicCapability, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute.
*
* @param capabilityAssignment represents the capability of node
* @param flavorFeature represents all the features of specified flavor
*/
- private void generateBasicCapability(final CapabilityAssignment capabilityAssignment, FlavorFeature flavorFeature){
- //the format is xxx MB/GB like 4096 MB
- String virtualMemSize = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
- VIRTUAL_MEM_SIZE_PATH);
- if (virtualMemSize != null) {
- LOGGER.debug("the virtualMemSize = " + virtualMemSize);
- HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
- FlavorProperty flavorProperty = new FlavorProperty();
- flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
- flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
- flavorFeature.getFlavorProperties().add(flavorProperty);
- }
-
- //the format is int like 2
- String numVirtualCpu = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
- NUM_VIRTUAL_CPU_PATH);
- if (numVirtualCpu != null) {
- LOGGER.debug("the numVirtualCpu = " + numVirtualCpu);
- HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
- String cpuArchitecture = sdcCsarHelper.getCapabilityPropertyLeafValue
- (capabilityAssignment,CPU_ARCHITECTURE_PATH);
- FlavorProperty flavorProperty = new FlavorProperty();
- flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
- if (cpuArchitecture != null) {
- flavorProperty.setArchitecture(cpuArchitecture);
- }
- flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
- flavorFeature.getFlavorProperties().add(flavorProperty);
+ private void generateBasicCapability(final CapabilityAssignment capabilityAssignment,
+ final FlavorFeature flavorFeature) {
+ // the format is xxx MB/GB like 4096 MB
+ final String virtualMemSize =
+ sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, VIRTUAL_MEM_SIZE_PATH);
+ if (virtualMemSize != null) {
+ LOGGER.debug("the virtualMemSize = " + virtualMemSize);
+ final HpaFeatureAttribute hpaFeatureAttribute =
+ generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
+ final FlavorProperty flavorProperty = new FlavorProperty();
+ flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
+ flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
+ flavorFeature.getFlavorProperties().add(flavorProperty);
+ }
+
+ // the format is int like 2
+ final String numVirtualCpu =
+ sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH);
+ if (numVirtualCpu != null) {
+ LOGGER.debug("the numVirtualCpu = " + numVirtualCpu);
+ final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
+ final String cpuArchitecture =
+ sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, CPU_ARCHITECTURE_PATH);
+ final FlavorProperty flavorProperty = new FlavorProperty();
+ flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
+ if (cpuArchitecture != null) {
+ flavorProperty.setArchitecture(cpuArchitecture);
}
+ flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
+ flavorFeature.getFlavorProperties().add(flavorProperty);
+ }
}
- /*
- * GenerateHpaFeatureAttribute based on the value of featureValue.
- * the format: "hpa-attribute-key": "pciVendorId", "hpa-attribute-value": "1234", "operator": "=", "unit": "xxx".
+ /**
+ * GenerateHpaFeatureAttribute based on the value of featureValue. the format: "hpa-attribute-key": "pciVendorId",
+ * "hpa-attribute-value": "1234", "operator": "=", "unit": "xxx".
*
* @param hpaAttributeKey get from the high layer tosca DM
* @param featureValue get from the high layer tosca DM
- * @return the format used in underlayer component
*/
- private HpaFeatureAttribute generateHpaFeatureAttribute(final String hpaAttributeKey, final String featureValue){
+ private HpaFeatureAttribute generateHpaFeatureAttribute(final String hpaAttributeKey, final String featureValue) {
- HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute();
+ final HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute();
hpaFeatureAttribute.setHpaAttributeKey(hpaAttributeKey);
- String tmp = featureValue.replace(" ","");
- String pattern = "(\\D*)(\\d+)(\\D*)";
- Pattern r = Pattern.compile(pattern);
- Matcher m = r.matcher(tmp);
+ final String tmp = featureValue.replace(" ", "");
+ final String pattern = "(\\D*)(\\d+)(\\D*)";
+ final Pattern r = Pattern.compile(pattern);
+ final Matcher m = r.matcher(tmp);
if (m.find()) {
LOGGER.debug("operator = " + m.group(1));
LOGGER.debug("value = " + m.group(2));
@@ -229,35 +207,27 @@ public class ExtractFromNode {
return hpaFeatureAttribute;
}
- /*
- * GenerateHugePages, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute.
+ /**
+ * GenerateHugePages, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute. The format is
+ * a map like: {"schema-version": "0", "schema-location": "", "platform-id": "generic", "mandatory": true,
+ * "configuration-value": "2 MB"}
*
* @param capabilityAssignment represents the capability of node
* @param flavorFeature represents all the features of specified flavor
*/
- private void generateHugePages(final CapabilityAssignment capabilityAssignment, FlavorFeature flavorFeature){
- //the format is a map like: {"schema-version": "0", "schema-location": "", "platform-id": "generic",
- // "mandatory": true, "configuration-value": "2 MB"}
- String numberOfPages = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
- NUMBER_OF_PAGES_PATH);
- if (numberOfPages != null) {
- LOGGER.debug("the virtualMemSize = " + numberOfPages);
- //TODO add HugePages support
- }
+ private void generateHugePages(final CapabilityAssignment capabilityAssignment) {
+ // add HugePages support
}
- /*
- * ExtractInfoVduCp, supposted hpa features, under the virtual_network_interface_requirements of
- * tosca.nodes.nfv.VduCp.
- *
+ /**
+ * ExtractInfoVduCp, supported hpa features, under the virtual_network_interface_requirements of
+ * tosca.nodes.nfv.VduCp.
+ *
* @param lnodeVduCp the list of VduCp node
* @param content to be change based on lnodeVduCp
*/
- @SuppressWarnings("unchecked")
- public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, Content content) {
- for ( NodeTemplate node : lnodeVduCp) {
- //TODO to add VDU cp Hpa feature extract
- }
+ public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, final Content content) {
+ // to add VDU cp Hpa feature extract
}
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java
index 551fbdee..b8f4b6ac 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java
@@ -20,8 +20,8 @@
package org.onap.policy.distribution.reception.decoding.pdpx;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* The FlavorFeature includes all the specified flavor infos used in multicloud, it represents one VDU of TOSCA.
@@ -29,12 +29,12 @@ import java.util.ArrayList;
* @author Libo Zhu (libo.zhu@intel.com)
*/
class FlavorFeature {
- private String id ;
+ private String id;
private String type = "tosca.node.nfv.Vdu.Compute";
private List<Directive> directives = new ArrayList<>();
private List<FlavorProperty> flavorProperties = new ArrayList<>();
-
- public void setId(String id) {
+
+ public void setId(final String id) {
this.id = id;
}
@@ -42,7 +42,7 @@ class FlavorFeature {
return id;
}
- public void setType(String type) {
+ public void setType(final String type) {
this.type = type;
}
@@ -50,18 +50,12 @@ class FlavorFeature {
return type;
}
- public List<FlavorProperty> getFlavorProperties() {
+ public List<FlavorProperty> getFlavorProperties() {
return flavorProperties;
}
public List<Directive> getDirectives() {
return directives;
}
-
- @Override
- public String toString() {
- return "{ id = " + id + ", type = " + type + ", \n" + "directivies:["+directives + ",\n"
- + flavorProperties + "}";
- }
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java
index 552164c5..b800f355 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java
@@ -20,17 +20,17 @@
package org.onap.policy.distribution.reception.decoding.pdpx;
-import java.util.List;
-import java.util.ArrayList;
-
import com.google.gson.annotations.SerializedName;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* The FlavorProperty includes all the properties of Flavor.
*
* @author Libo Zhu (libo.zhu@intel.com)
*/
-class FlavorProperty{
+class FlavorProperty {
@SerializedName(value = "hpa-feature")
private String hpaFeature;
private String mandatory = "true";
@@ -41,7 +41,7 @@ class FlavorProperty{
@SerializedName(value = "hpa-feature-attributes")
private List<HpaFeatureAttribute> hpaFeatureAttributes = new ArrayList<>();
- public void setHpaFeature(String hpaFeature) {
+ public void setHpaFeature(final String hpaFeature) {
this.hpaFeature = hpaFeature;
}
@@ -49,7 +49,7 @@ class FlavorProperty{
return hpaFeature;
}
- public void setMandatory(String mandatory) {
+ public void setMandatory(final String mandatory) {
this.mandatory = mandatory;
}
@@ -57,7 +57,7 @@ class FlavorProperty{
return mandatory;
}
- public void setArchitecture(String architecture) {
+ public void setArchitecture(final String architecture) {
this.architecture = architecture;
}
@@ -65,7 +65,7 @@ class FlavorProperty{
return architecture;
}
- public void setHpaVersion(String hpaVersion) {
+ public void setHpaVersion(final String hpaVersion) {
this.hpaVersion = hpaVersion;
}
@@ -80,12 +80,5 @@ class FlavorProperty{
public List<HpaFeatureAttribute> getHpaFeatureAttributes() {
return hpaFeatureAttributes;
}
-
- @Override
- public String toString() {
- return "{ hpaFeature:" + hpaFeature + ", mandatory = " + mandatory + ",architecture:" + architecture
- + ", hpaFeatureAttributes : [" + hpaFeatureAttributes + "]";
- }
-
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java
index 7574ee87..1617956f 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java
@@ -27,7 +27,7 @@ import com.google.gson.annotations.SerializedName;
*
* @author Libo Zhu (libo.zhu@intel.com)
*/
-class HpaFeatureAttribute{
+class HpaFeatureAttribute {
@SerializedName(value = "hpa-attribute-key")
private String hpaAttributeKey;
@SerializedName(value = "hap-attribute-value")
@@ -35,17 +35,15 @@ class HpaFeatureAttribute{
private String operator;
private String unit;
- public HpaFeatureAttribute(){}
-
- public void setHpaAttributeKey(String hpaAttributeKey) {
+ public void setHpaAttributeKey(final String hpaAttributeKey) {
this.hpaAttributeKey = hpaAttributeKey;
}
-
+
public String getHpaAttributeKey() {
return hpaAttributeKey;
}
- public void setHpaAttributeValue(String hpaAttributeValue) {
+ public void setHpaAttributeValue(final String hpaAttributeValue) {
this.hpaAttributeValue = hpaAttributeValue;
}
@@ -53,15 +51,15 @@ class HpaFeatureAttribute{
return hpaAttributeValue;
}
- public void setOperator(String operator) {
+ public void setOperator(final String operator) {
this.operator = operator;
}
public String getOperator() {
return operator;
}
-
- public void setUnit(String unit) {
+
+ public void setUnit(final String unit) {
this.unit = unit;
}
@@ -70,5 +68,4 @@ class HpaFeatureAttribute{
}
}
-
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java
index 179024a8..e7a0e8ab 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PdpxPolicy.java
@@ -28,15 +28,15 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
*/
public class PdpxPolicy implements Policy {
+ private String guard;
private String service;
private String policyName;
private String description;
private String templateVersion;
private String version;
- private String priority;
private String riskType;
+ private String priority;
private String riskLevel;
- private String guard;
private Content content = new Content();
@Override
@@ -49,30 +49,18 @@ public class PdpxPolicy implements Policy {
return content.getPolicyType();
}
- public void setService(String service) {
- this.service = service;
+ public String getGuard() {
+ return guard;
}
public String getService() {
return service;
- }
-
- public void setPolicyName(String policyName) {
- this.policyName = policyName;
- }
-
- public void setDescription(String description) {
- this.description = description;
}
public String getDescription() {
return description;
}
- public void setTemplateVersion(String templateVersion) {
- this.templateVersion = templateVersion;
- }
-
public String getTemplateVersion() {
return templateVersion;
}
@@ -81,48 +69,59 @@ public class PdpxPolicy implements Policy {
return version;
}
- public void setVersion(String version) {
- this.version = version;
+ public String getRiskType() {
+ return riskType;
}
public String getPriority() {
return priority;
}
- public void setPriority(String priority) {
- this.priority = priority;
+ public String getRiskLevel() {
+ return riskLevel;
}
- public String getGuard() {
- return guard;
+ public Content getContent() {
+ return content;
}
- public void setGuard(String guard) {
+ public void setGuard(final String guard) {
this.guard = guard;
}
- public String getRiskLevel() {
- return riskLevel;
+ public void setService(final String service) {
+ this.service = service;
}
- public void setRiskLevel(String riskLevel) {
- this.riskLevel = riskLevel;
+ public void setPolicyName(final String policyName) {
+ this.policyName = policyName;
}
- public String getRiskType() {
- return riskType;
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public void setTemplateVersion(final String templateVersion) {
+ this.templateVersion = templateVersion;
+ }
+
+ public void setVersion(final String version) {
+ this.version = version;
}
- public void setRiskType(String riskType) {
+ public void setRiskType(final String riskType) {
this.riskType = riskType;
}
- public Content getContent(){
- return content;
+ public void setPriority(final String priority) {
+ this.priority = priority;
}
- public void setContent(Content content) {
- this.content = content;
- }
+ public void setRiskLevel(final String riskLevel) {
+ this.riskLevel = riskLevel;
+ }
+ public void setContent(final Content content) {
+ this.content = content;
+ }
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
index 6c4f285a..4585ce73 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
@@ -36,7 +36,7 @@ import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.NodeTemplate;
/**
- * Decodes PDP-X policies from a TOSCA file.
+ * Decodes PDP-X policies from a CSAR file.
*/
public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, PdpxPolicy> {
@@ -44,7 +44,6 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, PdpxPolicy> {
@Override
public Collection<PdpxPolicy> decode(final Csar csar) throws PolicyDecodingException {
- // logic for generating the policies from the CSAR.
final List<PdpxPolicy> lPdpxPolicy = new ArrayList<>();
final ISdcCsarHelper sdcCsarHelper = parseCsar(csar);
final List<NodeTemplate> lnodeVf = sdcCsarHelper.getServiceVfList();
@@ -66,7 +65,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, PdpxPolicy> {
}
/**
- * Parse the input Csar by SDC tosca tool.
+ * Parse the input Csar using SDC TOSCA parser.
*
* @param csar represents the service TOSCA Csar
* @return the object to represents the content of input csar
@@ -75,23 +74,18 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, PdpxPolicy> {
public ISdcCsarHelper parseCsar(final Csar csar) throws PolicyDecodingException {
ISdcCsarHelper sdcCsarHelper;
try {
-
- final SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();// Autoclosable
-
- LOGGER.debug("tosca File Path = " + csar.getCsarPath());
-
- final File spoolFile = new File(csar.getCsarPath());
-
- sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath());
-
- } catch (final Exception e) {
- LOGGER.error("Exception got in parseTosca", e);
- throw new PolicyDecodingException("Exception caught when passing the csar file to the parser ", e);
+ final SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ LOGGER.debug("Csar File Path = " + csar.getCsarPath());
+ final File csarFile = new File(csar.getCsarPath());
+ sdcCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath());
+ } catch (final Exception exp) {
+ final String message = "Failed passing the csar file";
+ LOGGER.error(message, exp);
+ throw new PolicyDecodingException(message, exp);
}
return sdcCsarHelper;
}
@Override
public void configure(final String parameterGroupName) {}
-
}