aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/reception-plugins/src')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java159
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/HpaFeatureAttribute.java2
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java153
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csarbin0 -> 131275 bytes
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csarbin0 -> 131411 bytes
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar (renamed from plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar)bin131336 -> 131404 bytes
6 files changed, 282 insertions, 32 deletions
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 4e7f9411..1d0f621b 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
@@ -20,16 +20,19 @@
package org.onap.policy.distribution.reception.decoding.pdpx;
-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.Map;
+import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
@@ -37,6 +40,8 @@ import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
import org.onap.sdc.toscaparser.api.CapabilityAssignments;
import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
/**
* Extract concerned info from NodeTemplate, currently ONLY HPA Feature.
@@ -51,7 +56,17 @@ public class ExtractFromNode {
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 BASIC_CAPABILITIES = "BasicCapabilities";
+ private static final String MEMORY_PAGE_SIZE_PATH = "virtual_memory#vdu_memory_requirements#memoryPageSize";
+ private static final String NETWORK_INTERFACE_TYPE_PATH =
+ "virtual_network_interface_requirements#network_interface_requirements#interfaceType";
+ private static final String NETWORK_PCI_PATH =
+ "virtual_network_interface_requirements#nic_io_requirements";
+ 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 = new HashMap() {{
+ put("SR-IOV", "SriovNICNetwork");
+ put("PCI-Passthrough", "pciePassthrough");
+ }};
ISdcCsarHelper sdcCsarHelper;
final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();
@@ -136,7 +151,7 @@ public class ExtractFromNode {
capabilityAssignments.getCapabilityByName("virtual_compute");
if (capabilityAssignment != null) {
generateBasicCapability(capabilityAssignment, flavorFeature);
- generateHugePages(capabilityAssignment);
+ generateHugePages(capabilityAssignment,flavorFeature);
}
content.getFlavorFeatures().add(flavorFeature);
}
@@ -148,31 +163,29 @@ public class ExtractFromNode {
* @param capabilityAssignment represents the capability of node
* @param flavorFeature represents all the features of specified flavor
*/
- 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);
+ 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);
- final HpaFeatureAttribute hpaFeatureAttribute =
- generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
- final FlavorProperty flavorProperty = new FlavorProperty();
- flavorProperty.setHpaFeature(BASIC_CAPABILITIES);
+ HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
+ FlavorProperty flavorProperty = new FlavorProperty();
+ flavorProperty.setHpaFeature(BASIC_CAPABILITIES_HPA_FEATURE);
flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
flavorFeature.getFlavorProperties().add(flavorProperty);
}
-
- // the format is int like 2
- final String numVirtualCpu =
- sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH);
+
+ //the format is int like 2
+ 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);
+ HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
+ String cpuArchitecture = sdcCsarHelper.getCapabilityPropertyLeafValue
+ (capabilityAssignment,CPU_ARCHITECTURE_PATH);
+ FlavorProperty flavorProperty = new FlavorProperty();
+ flavorProperty.setHpaFeature(BASIC_CAPABILITIES_HPA_FEATURE);
if (cpuArchitecture != null) {
flavorProperty.setArchitecture(cpuArchitecture);
}
@@ -189,7 +202,7 @@ public class ExtractFromNode {
* @param featureValue get from the high layer tosca DM
*/
private HpaFeatureAttribute generateHpaFeatureAttribute(final String hpaAttributeKey, final String featureValue) {
-
+ //based on input featureValue, return back a suitable hpaFeatureAttribute
final HpaFeatureAttribute hpaFeatureAttribute = new HpaFeatureAttribute();
hpaFeatureAttribute.setHpaAttributeKey(hpaAttributeKey);
final String tmp = featureValue.replace(" ", "");
@@ -215,8 +228,26 @@ public class ExtractFromNode {
* @param capabilityAssignment represents the capability of node
* @param flavorFeature represents all the features of specified flavor
*/
- private void generateHugePages(final CapabilityAssignment capabilityAssignment) {
- // add HugePages support
+ private void generateHugePages(final CapabilityAssignment capabilityAssignment, FlavorFeature flavorFeature){
+ String memoryPageSize = sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment,
+ MEMORY_PAGE_SIZE_PATH);
+ LOGGER.debug("the memoryPageSize = " + memoryPageSize);
+ if (memoryPageSize != null) {
+ Map<String, Object> retMap = gson.fromJson(memoryPageSize,
+ new TypeToken<HashMap<String, Object>>() {}.getType());
+ LOGGER.debug("the retMap = " + retMap);
+ String memoryPageSizeValue = retMap.get("configuration-value").toString();
+ String mandatory = retMap.get("mandatory").toString();
+ HpaFeatureAttribute hpaFeatureAttribute =
+ generateHpaFeatureAttribute("memoryPageSize",memoryPageSizeValue);
+ FlavorProperty flavorProperty = new FlavorProperty();
+ flavorProperty.setHpaFeature(HUGE_PAGES_HPA_FEATURE);
+ if (mandatory != null) {
+ flavorProperty.setMandatory(mandatory);
+ }
+ flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
+ flavorFeature.getFlavorProperties().add(flavorProperty);
+ }
}
/**
@@ -225,9 +256,79 @@ public class ExtractFromNode {
*
* @param lnodeVduCp the list of VduCp node
* @param content to be change based on lnodeVduCp
+ * @throws PolicyDecodingException if extract CP fails
*/
- public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, final Content content) {
- // to add VDU cp Hpa feature extract
- }
+ public void extractInfoVduCp(final List<NodeTemplate> lnodeVduCp, Content content) throws PolicyDecodingException {
+ // each CP will binds to a VDU so need the vdu flavor map info.
+ Map<String, FlavorFeature> vduFlavorMap = new HashMap<>();
+ for ( FlavorFeature flavorFeature: content.getFlavorFeatures()) {
+ LOGGER.debug("the id = " + flavorFeature.getId());
+ vduFlavorMap.put(flavorFeature.getId(),flavorFeature);
+ }
+ for ( NodeTemplate node : lnodeVduCp) {
+ String interfaceType = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node,NETWORK_INTERFACE_TYPE_PATH);
+ LOGGER.debug("the interfaceType = " + interfaceType);
+ Map<String, Object> retMap = new HashMap<>();
+ if (interfaceType != null) {
+ retMap = gson.fromJson(interfaceType, new TypeToken<HashMap<String, Object>>() {}.getType());
+ LOGGER.debug("the retMap = " + retMap);
+ }
+
+ String networkHpaFeature;
+ if ( retMap.containsKey("configuration-value")) {
+ 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;
+ }
+ }else{
+ LOGGER.debug(" no configuration-value defined in interfaceType");
+ return;
+ }
+
+ for (RequirementAssignment requriement: sdcCsarHelper.getRequirementsOf(node).getAll()) {
+ String nodeTemplateName = requriement.getNodeTemplateName().toLowerCase();
+ LOGGER.debug("getNodeTemplateName =" + nodeTemplateName);
+ if ( nodeTemplateName == null) {
+ continue;
+ }
+ if (!vduFlavorMap.containsKey(nodeTemplateName)) {
+ throw new PolicyDecodingException("vdu Flavor Map should contains the key " + nodeTemplateName);
+ }
+ generateNetworkFeature(networkHpaFeature, node, vduFlavorMap.get(nodeTemplateName));
+ }
+ }
+ }
+ /*
+ * GenerateNetworkFeature, all pci feature are grouped into FlavorFeature together.
+ *
+ * @param networkHpaFeature represents the specified Hpa feature
+ * @param node represents the CP Node
+ * @param flavorFeature represents all the features of specified flavor
+ */
+ private void generateNetworkFeature(final String networkHpaFeature, final NodeTemplate node, FlavorFeature flavorFeature) {
+ //the format is a map like: {"schema-version": "0", "schema-location": "", "platform-id": "generic",
+ // "mandatory": true, "configuration-value": "2 MB"}
+ FlavorProperty flavorProperty = new FlavorProperty();
+ flavorProperty.setHpaFeature(networkHpaFeature);
+ String[] pciKeys = { "pciVendorId", "pciDeviceId", "pciNumDevices", "physicalNetwork"};
+ for (String pciKey: pciKeys) {
+ LOGGER.debug("the pciKey = " + pciKey);
+ String pciKeyPath = NETWORK_PCI_PATH + "#" + pciKey;
+ String pciValue = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node,pciKeyPath);
+ if (pciValue != null) {
+ LOGGER.debug("the pciValue = " + pciValue);
+ Map<String, Object> retMap = gson.fromJson(pciValue, new TypeToken<HashMap<String, Object>>() {}.getType());
+ String pciConfigValue = retMap.get("configuration-value").toString();
+ HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute(pciKey,pciConfigValue);
+ flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute);
+ }
+ }
+ flavorFeature.getFlavorProperties().add(flavorProperty);
+ }
}
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 1617956f..91008aa5 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
@@ -30,7 +30,7 @@ import com.google.gson.annotations.SerializedName;
class HpaFeatureAttribute {
@SerializedName(value = "hpa-attribute-key")
private String hpaAttributeKey;
- @SerializedName(value = "hap-attribute-value")
+ @SerializedName(value = "hpa-attribute-value")
private String hpaAttributeValue;
private String operator;
private String unit;
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 1ce5786c..11bce326 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
@@ -41,24 +41,173 @@ public class TestPolicyDecoderCsarPdpx {
@Test
public void testHpaPolicy2Vnf() throws IOException {
Csar csar = new Csar("src/test/resources/service-TestNs8-csar.csar");
+ PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
+ try {
+ Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
+ assertEquals(2, ret.size());
+ PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+ assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+ assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+ FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+ assertEquals("vdu_vnf_1", flavorFeature.getId());
+ assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+ assertEquals(1, flavorFeature.getDirectives().size());
+ Directive directive = flavorFeature.getDirectives().get(0);
+ assertEquals("flavor_directive", directive.getType());
+ assertEquals(1, directive.getAttributes().size());
+ assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+ assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+ assertEquals(2, flavorFeature.getFlavorProperties().size());
+ FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(0);
+ assertEquals("BasicCapabilities", flavorProperty.getHpaFeature());
+ assertEquals("true", flavorProperty.getMandatory());
+ assertEquals("generic", flavorProperty.getArchitecture());
+ assertEquals("v1", flavorProperty.getHpaVersion());
+ assertEquals(0, flavorProperty.getDirectives().size());
+ assertEquals(1, flavorProperty.getHpaFeatureAttributes().size());
+ HpaFeatureAttribute hpaFeatreAttribute = flavorProperty.getHpaFeatureAttributes().get(0);
+ assertEquals("virtualMemSize",hpaFeatreAttribute.getHpaAttributeKey());
+ assertEquals("4096",hpaFeatreAttribute.getHpaAttributeValue());
+ assertEquals("",hpaFeatreAttribute.getOperator());
+ assertEquals("MB",hpaFeatreAttribute.getUnit());
+
+ } catch (Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ }
+ @Test
+ public void testHpaPolicySriov() throws IOException {
+ Csar csar = new Csar("src/test/resources/hpaPolicySriov.csar");
PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
try {
Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, ret.size());
+ PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+ assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+ assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+ FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+ assertEquals("vdu_vnf_1", flavorFeature.getId());
+ assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+ assertEquals(1, flavorFeature.getDirectives().size());
+ Directive directive = flavorFeature.getDirectives().get(0);
+ assertEquals("flavor_directive", directive.getType());
+ assertEquals(1, directive.getAttributes().size());
+ assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+ assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+ assertEquals(4, flavorFeature.getFlavorProperties().size());
+ FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(3);
+ assertEquals("SriovNICNetwork", flavorProperty.getHpaFeature());
+ assertEquals("true", flavorProperty.getMandatory());
+ assertEquals("generic", flavorProperty.getArchitecture());
+ assertEquals("v1", flavorProperty.getHpaVersion());
+ assertEquals(0, flavorProperty.getDirectives().size());
+ assertEquals(3, flavorProperty.getHpaFeatureAttributes().size());
+
+ HpaFeatureAttribute pciVendorId = flavorProperty.getHpaFeatureAttributes().get(0);
+ assertEquals("pciVendorId",pciVendorId.getHpaAttributeKey());
+ assertEquals("1234",pciVendorId.getHpaAttributeValue());
+ assertEquals("",pciVendorId.getOperator());
+ assertEquals("",pciVendorId.getUnit());
+ HpaFeatureAttribute pciDeviceId = flavorProperty.getHpaFeatureAttributes().get(1);
+ assertEquals("pciDeviceId",pciDeviceId.getHpaAttributeKey());
+ assertEquals("5678",pciDeviceId.getHpaAttributeValue());
+ assertEquals("",pciDeviceId.getOperator());
+ assertEquals("",pciDeviceId.getUnit());
+ HpaFeatureAttribute pciNumDevices = flavorProperty.getHpaFeatureAttributes().get(2);
+ assertEquals("pciNumDevices",pciNumDevices.getHpaAttributeKey());
+ assertEquals("1",pciNumDevices.getHpaAttributeValue());
+ assertEquals("",pciNumDevices.getOperator());
+ assertEquals("",pciNumDevices.getUnit());
} catch (Exception e) {
fail("test should not thrown an exception here: " + e.getMessage());
}
}
@Test
- public void testHpaPolicyFeature() throws IOException {
- Csar csar = new Csar("src/test/resources/hpaPolicySRIOV.csar");
+ public void testHpaPolicyPciePassthrough() throws IOException {
+ Csar csar = new Csar("src/test/resources/hpaPolicyPciePassthrough.csar");
+ PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
+ try {
+ Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
+ assertEquals(2, ret.size());
+ PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+ assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+ assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+ FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+ assertEquals("vdu_vnf_1", flavorFeature.getId());
+ assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+ assertEquals(1, flavorFeature.getDirectives().size());
+ Directive directive = flavorFeature.getDirectives().get(0);
+ assertEquals("flavor_directive", directive.getType());
+ assertEquals(1, directive.getAttributes().size());
+ assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+ assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+ assertEquals(4, flavorFeature.getFlavorProperties().size());
+ FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(3);
+ assertEquals("pciePassthrough", flavorProperty.getHpaFeature());
+ assertEquals("true", flavorProperty.getMandatory());
+ assertEquals("generic", flavorProperty.getArchitecture());
+ assertEquals("v1", flavorProperty.getHpaVersion());
+ assertEquals(0, flavorProperty.getDirectives().size());
+ assertEquals(3, flavorProperty.getHpaFeatureAttributes().size());
+
+ HpaFeatureAttribute pciVendorId = flavorProperty.getHpaFeatureAttributes().get(0);
+ assertEquals("pciVendorId",pciVendorId.getHpaAttributeKey());
+ assertEquals("1234",pciVendorId.getHpaAttributeValue());
+ assertEquals("",pciVendorId.getOperator());
+ assertEquals("",pciVendorId.getUnit());
+ HpaFeatureAttribute pciDeviceId = flavorProperty.getHpaFeatureAttributes().get(1);
+ assertEquals("pciDeviceId",pciDeviceId.getHpaAttributeKey());
+ assertEquals("5678",pciDeviceId.getHpaAttributeValue());
+ assertEquals("",pciDeviceId.getOperator());
+ assertEquals("",pciDeviceId.getUnit());
+ HpaFeatureAttribute pciNumDevices = flavorProperty.getHpaFeatureAttributes().get(2);
+ assertEquals("pciNumDevices",pciNumDevices.getHpaAttributeKey());
+ assertEquals("1",pciNumDevices.getHpaAttributeValue());
+ assertEquals("",pciNumDevices.getOperator());
+ assertEquals("",pciNumDevices.getUnit());
+ } catch (Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ }
+ @Test
+ public void testHpaPolicyHugePage() throws IOException {
+ Csar csar = new Csar("src/test/resources/hpaPolicyHugePage.csar");
PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
try {
Collection<PdpxPolicy> ret = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, ret.size());
+ PdpxPolicy pdpxPolicy = (PdpxPolicy) ret.toArray()[0];
+ assertEquals("Optimization", pdpxPolicy.getContent().getPolicyType());
+ assertEquals(1, pdpxPolicy.getContent().getFlavorFeatures().size());
+
+ FlavorFeature flavorFeature = pdpxPolicy.getContent().getFlavorFeatures().get(0);
+ assertEquals("vdu_vnf_1", flavorFeature.getId());
+ assertEquals("tosca.node.nfv.Vdu.Compute", flavorFeature.getType());
+ assertEquals(1, flavorFeature.getDirectives().size());
+ Directive directive = flavorFeature.getDirectives().get(0);
+ assertEquals("flavor_directive", directive.getType());
+ assertEquals(1, directive.getAttributes().size());
+ assertEquals("flavorName", directive.getAttributes().get(0).getAttributeName());
+ assertEquals("", directive.getAttributes().get(0).getAttributeValue());
+ assertEquals(3, flavorFeature.getFlavorProperties().size());
+ FlavorProperty flavorProperty = flavorFeature.getFlavorProperties().get(2);
+ assertEquals("hugePages", flavorProperty.getHpaFeature());
+ assertEquals("false", flavorProperty.getMandatory());
+ assertEquals("generic", flavorProperty.getArchitecture());
+ assertEquals("v1", flavorProperty.getHpaVersion());
+ assertEquals(0, flavorProperty.getDirectives().size());
+ assertEquals(1, flavorProperty.getHpaFeatureAttributes().size());
+ HpaFeatureAttribute hpaFeatreAttribute = flavorProperty.getHpaFeatureAttributes().get(0);
+ assertEquals("memoryPageSize",hpaFeatreAttribute.getHpaAttributeKey());
+ assertEquals("2",hpaFeatreAttribute.getHpaAttributeValue());
+ assertEquals("",hpaFeatreAttribute.getOperator());
+ assertEquals("MB",hpaFeatreAttribute.getUnit());
} catch (Exception e) {
fail("test should not thrown an exception here: " + e.getMessage());
}
diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar b/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar
new file mode 100644
index 00000000..e1fdc70c
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicyHugePage.csar
Binary files differ
diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar
new file mode 100644
index 00000000..652bc877
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar
Binary files differ
diff --git a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
index f79d2866..ffe996a9 100644
--- a/plugins/reception-plugins/src/test/resources/hpaPolicySRIOV.csar
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
Binary files differ