summaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2018-11-27 08:10:33 +0800
committerlibo zhu <libo.zhu@intel.com>2018-12-04 00:41:24 +0000
commit964ac3e2a2e6919a8a20895c286312cd0c8f200f (patch)
treee5bf8458e573d4589104d87278f3d92ff0951faf /plugins/reception-plugins
parentb0d3b4153a48ae0d1f912071f0e012e3582d7bd1 (diff)
Fix policy format with vCPE service
. change the capital and lower-case letter . add missing fields in ConfigBody policyName and templateVersion that are requried by OOF . add '=' into default operator once no such info in the input CSAR . based on the vCPE service, which includes several CPs, some may do NOT connect any VDU. so need deal with such case. . add new test case to cover complicated service includes 5 policies . change the resource's type from String to List as requried by OOF which needs such format to deal with all kind of policies beides hpa . improve the code style Change-Id: Id39b1a0511c362c5ae9dce409af18b032832de80 Issue-ID: POLICY-1282 Signed-off-by: liboNet <libo.zhu@intel.com> (cherry picked from commit 987cb61f269572fec7c0b0fe500f081ca36c2dd9)
Diffstat (limited to 'plugins/reception-plugins')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java18
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/Content.java8
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java54
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorFeature.java2
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/FlavorProperty.java2
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java8
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java12
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java83
-rw-r--r--plugins/reception-plugins/src/test/resources/service-VcpeWithAll-csar.csarbin0 -> 161962 bytes
9 files changed, 119 insertions, 68 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java
index 72d9bd2b..521fcfd6 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ConfigBody.java
@@ -23,7 +23,9 @@ package org.onap.policy.distribution.reception.decoding.pdpx;
public class ConfigBody {
private String service;
+ private String policyName;
private String description;
+ private String templateVersion;
private String version;
private String priority;
private String riskType;
@@ -39,6 +41,14 @@ public class ConfigBody {
this.service = service;
}
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
public String getDescription() {
return description;
}
@@ -47,6 +57,14 @@ public class ConfigBody {
this.description = description;
}
+ public String getTemplateVersion() {
+ return templateVersion;
+ }
+
+ public void setTemplateVersion(String templateVersion) {
+ this.templateVersion = templateVersion;
+ }
+
public String getVersion() {
return version;
}
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 77d1a9b7..6e708977 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
@@ -29,17 +29,13 @@ import java.util.List;
* @author Libo Zhu (libo.zhu@intel.com)
*/
class Content {
- private String resources;
+ private List<String> resources = new ArrayList<>();
private String identity;
private List<String> policyScope = new ArrayList<>();
private String policyType = "Optimization";
private List<FlavorFeature> flavorFeatures = new ArrayList<>();
- public void setResources(final String resources) {
- this.resources = resources;
- }
-
- public String getResources() {
+ public List<String> getResources() {
return resources;
}
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 699ba49e..579454c5 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
@@ -24,12 +24,14 @@ import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
@@ -60,11 +62,11 @@ public class ExtractFromNode {
"virtual_network_interface_requirements#network_interface_requirements#interfaceType";
private static final String NETWORK_PCI_PATH =
"virtual_network_interface_requirements#nic_io_requirements#logical_node_requirements";
- private static final String BASIC_CAPABILITIES_HPA_FEATURE = "BasicCapabilities";
+ private static final String BASIC_CAPABILITIES_HPA_FEATURE = "basicCapabilities";
private static final String HUGE_PAGES_HPA_FEATURE = "hugePages";
private static final Map<String, String> NETWORK_HPA_FEATURE_MAP =
- ImmutableMap.of("SR-IOV", "SriovNICNetwork", "PCI-Passthrough", "pciePassthrough");
-
+ ImmutableMap.of("SR-IOV", "sriovNICNetwork", "PCI-Passthrough", "pciePassthrough");
+ private static final Pattern PATTERN = Pattern.compile("(\\D*)(\\d+)(\\D*)");
private ISdcCsarHelper sdcCsarHelper;
final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();
@@ -106,8 +108,8 @@ public class ExtractFromNode {
LOGGER.debug("the size of cp is =" + lnodeVduCp.size());
final Content content = new Content();
- content.setResources(metaData.getValue("name"));
- content.setIdentity(content.getPolicyType() + "_" + content.getResources());
+ content.getResources().add(metaData.getValue("name"));
+ content.setIdentity(content.getPolicyType() + "_" + metaData.getValue("name"));
extractInfoVdu(lnodeVdu, content);
extractInfoVduCp(lnodeVduCp, content);
if (content.getFlavorFeatures().isEmpty()) {
@@ -202,17 +204,18 @@ public class ExtractFromNode {
// based on input featureValue, return back a suitable hpaFeatureAttribute
final HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute();
hpaFeatureAttribute.setHpaAttributeKey(hpaAttributeKey);
- 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));
- LOGGER.debug("unit = " + m.group(3));
- hpaFeatureAttribute.setOperator(m.group(1));
- hpaFeatureAttribute.setHpaAttributeValue(m.group(2));
- hpaFeatureAttribute.setUnit(m.group(3));
+ final String modifiedValue = featureValue.replace(" ", "");
+ final Matcher matcher = PATTERN.matcher(modifiedValue);
+ if (matcher.find()) {
+ LOGGER.debug("operator " + matcher.group(1) + ", value = " + matcher.group(2)
+ + ", unit = " + matcher.group(3));
+ if ( matcher.group(1).length() == 0 ) {
+ hpaFeatureAttribute.setOperator("=");
+ } else {
+ hpaFeatureAttribute.setOperator(matcher.group(1));
+ }
+ hpaFeatureAttribute.setHpaAttributeValue(matcher.group(2));
+ hpaFeatureAttribute.setUnit(matcher.group(3));
}
return hpaFeatureAttribute;
}
@@ -279,24 +282,19 @@ public class ExtractFromNode {
}
String networkHpaFeature;
- if (retMap.containsKey(CONFIGURATION_VALUE)) {
+ if (retMap.containsKey(CONFIGURATION_VALUE)
+ && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) {
final String interfaceTypeValue = retMap.get(CONFIGURATION_VALUE).toString();
- LOGGER.debug(" the interfacetype value is =" + interfaceTypeValue);
- if (NETWORK_HPA_FEATURE_MAP.containsKey(interfaceTypeValue)) {
- networkHpaFeature = NETWORK_HPA_FEATURE_MAP.get(interfaceTypeValue);
- LOGGER.debug(" the networkHpaFeature is =" + networkHpaFeature);
- } else {
- LOGGER.debug(" unspported network interface ");
- return;
- }
+ networkHpaFeature = NETWORK_HPA_FEATURE_MAP.get(interfaceTypeValue);
+ LOGGER.debug(" the networkHpaFeature is =" + networkHpaFeature);
} else {
- LOGGER.debug(" no configurationValue defined in interfaceType");
- return;
+ LOGGER.debug(" no networkHpaFeature defined in interfaceType");
+ continue;
}
final RequirementAssignments requriements =
sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding");
- for (final RequirementAssignment requriement : requriements.getAll()) {
+ for (final RequirementAssignment requriement: requriements.getAll()) {
final String nodeTemplateName = requriement.getNodeTemplateName();
LOGGER.debug("getNodeTemplateName =" + nodeTemplateName);
if (nodeTemplateName == null) {
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 b8f4b6ac..c29378de 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
@@ -30,7 +30,7 @@ import java.util.List;
*/
class FlavorFeature {
private String id;
- private String type = "tosca.node.nfv.Vdu.Compute";
+ private String type = "tosca.nodes.nfv.Vdu.Compute";
private List<Directive> directives = new ArrayList<>();
private List<FlavorProperty> flavorProperties = new ArrayList<>();
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 b800f355..0453370d 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
@@ -33,7 +33,7 @@ import java.util.List;
class FlavorProperty {
@SerializedName(value = "hpa-feature")
private String hpaFeature;
- private String mandatory = "true";
+ private String mandatory = "True";
private String architecture = "generic";
@SerializedName(value = "hpa-version")
private String hpaVersion = "v1";
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 14519757..7a73c831 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
@@ -61,16 +61,20 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
final Content content = extractFromNode.extractInfo(node);
if (content != null) {
final OptimizationPolicy policy = new OptimizationPolicy();
+ final String policyName = decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity();
policy.setOnapName(decoderParameters.getOnapName());
- policy.setPolicyName(decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity());
+ policy.setPolicyName(policyName);
ConfigBody configBody = new ConfigBody();
configBody.setService("hpaPolicy");
+ configBody.setPolicyName(policyName);
configBody.setDescription("OOF Policy");
+ configBody.setTemplateVersion("OpenSource.version.1");
configBody.setVersion(decoderParameters.getVersion());
configBody.setPriority(decoderParameters.getPriority());
configBody.setRiskLevel(decoderParameters.getRiskLevel());
configBody.setRiskType(decoderParameters.getRiskType());
- configBody.setGuard("false");
+ configBody.setGuard("False");
+ content.setPolicyType("hpa");
content.getPolicyScope().add("HPA");
content.getPolicyScope().add(serviceName);
configBody.setContent(content);
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java
index 56534d8f..d678239f 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestContent.java
@@ -32,21 +32,18 @@ public class TestContent {
@Test
public void testContent() {
- final String resources = "dummyresource";
final String identity = "dummyidentity";
final String policyType = "optimization";
final Content content = new Content();
- content.setResources(resources);
content.setIdentity(identity);
content.setPolicyType(policyType);
- validateReport(resources, identity, policyType, content);
+ validateReport(identity, policyType, content);
}
- private void validateReport(final String resources, final String identity, final String policyType,
+ private void validateReport(final String identity, final String policyType,
final Content content) {
- assertEquals(resources, content.getResources());
assertEquals(identity, content.getIdentity());
assertEquals(policyType, content.getPolicyType());
assertEquals(0, content.getPolicyScope().size());
@@ -60,5 +57,10 @@ public class TestContent {
assertEquals(1, content.getFlavorFeatures().size());
content.getFlavorFeatures().remove(flavorFeature);
assertEquals(0, content.getFlavorFeatures().size());
+ assertEquals(0, content.getResources().size());
+ content.getResources().add("vGW");
+ assertEquals(1, content.getResources().size());
+ content.getResources().remove("vGW");
+ assertEquals(0, content.getResources().size());
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
index 3826ec92..2d91f837 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
@@ -80,17 +80,17 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\""));
assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\""));
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
- assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
+ assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\""));
assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
- assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"BasicCapabilities\""));
- assertTrue(policy.getConfigBody().contains("\"mandatory\":\"true\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"basicCapabilities\""));
+ assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\""));
assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\""));
assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"virtualMemSize\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
}
@@ -109,28 +109,28 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\""));
assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\""));
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
- assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
+ assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\""));
assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\""));
- assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"SriovNICNetwork\""));
- assertTrue(policy.getConfigBody().contains("\"mandatory\":\"true\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"sriovNICNetwork\""));
+ assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\""));
assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\""));
assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
}
@@ -150,28 +150,28 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\""));
assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\""));
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
- assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
+ assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\""));
assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\""));
assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"pciePassthrough\""));
- assertTrue(policy.getConfigBody().contains("\"mandatory\":\"true\""));
+ assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\""));
assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\""));
assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
@@ -193,10 +193,10 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\""));
assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\""));
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
- assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
+ assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\""));
assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\""));
@@ -206,7 +206,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"memoryPageSize\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"2\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
}
@@ -226,20 +226,53 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\""));
assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\""));
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
- assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
+ assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\""));
assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\""));
assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"pciePassthrough\""));
- assertTrue(policy.getConfigBody().contains("\"mandatory\":\"true\""));
+ assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\""));
assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\""));
assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\""));
assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\""));
- assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
+
+ }
+
+ @Test
+ public void testserviceVcpeWithAll() throws IOException, PolicyDecodingException {
+ final Csar csar = new Csar("src/test/resources/service-VcpeWithAll-csar.csar");
+ final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
+ policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ assertEquals(5, policies.size());
+ final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0];
+
+ assertEquals("onapName", policy.getOnapName());
+ assertTrue(policy.getPolicyName().startsWith("OOF."));
+ assertTrue(policy.getConfigBody().contains("\"priority\":\"5\""));
+ assertTrue(policy.getConfigBody().contains("\"riskLevel\":\"2\""));
+ assertTrue(policy.getConfigBody().contains("\"riskType\":\"Test\""));
+ assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
+ assertTrue(policy.getConfigBody().contains("\"policyType\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
+ assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
+ assertTrue(policy.getConfigBody().contains("\"attribute_value\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"sriovNICNetwork\""));
+ assertTrue(policy.getConfigBody().contains("\"mandatory\":\"True\""));
+ assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciVendorId\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1234\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
}
diff --git a/plugins/reception-plugins/src/test/resources/service-VcpeWithAll-csar.csar b/plugins/reception-plugins/src/test/resources/service-VcpeWithAll-csar.csar
new file mode 100644
index 00000000..f9b113f2
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/service-VcpeWithAll-csar.csar
Binary files differ