aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2018-11-10 05:32:42 +0800
committerliboNet <libo.zhu@intel.com>2018-11-14 00:07:29 +0800
commita8ceb88ad6f3ce90b00283bd88ff680e6b0a149f (patch)
treec39b28ae6b513549e3daba9c9029329dc27334a0 /plugins
parent6987049afefcf3352143ed6357dc6df49a137e0a (diff)
Fix virtual_binding error under VDU requirements
virtual_binding will bind CP to a VDU but virtual_link use the node name instead of the name of node's propertiy add new test case to cover s3p the picvendorId's path has been changed based on demo repo Change-Id: I0ca400eab4d16284f14cb568fe3da5b409dd9222 Issue-ID: POLICY-1254 Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java13
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java42
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csarbin46645 -> 47214 bytes
-rw-r--r--plugins/reception-plugins/src/test/resources/hpaPolicySriov.csarbin46630 -> 47201 bytes
-rw-r--r--plugins/reception-plugins/src/test/resources/s3p_0_pciVendorId.csarbin0 -> 50534 bytes
5 files changed, 47 insertions, 8 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 f2f27ce8..699ba49e 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
@@ -38,6 +38,7 @@ 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.RequirementAssignments;
import org.onap.sdc.toscaparser.api.elements.Metadata;
/**
@@ -57,7 +58,8 @@ public class ExtractFromNode {
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 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 HUGE_PAGES_HPA_FEATURE = "hugePages";
private static final Map<String, String> NETWORK_HPA_FEATURE_MAP =
@@ -132,7 +134,8 @@ public class ExtractFromNode {
flavorDirective.setType("flavor_directives");
flavorDirective.getAttributes().add(flavorAttribute);
final FlavorFeature flavorFeature = new FlavorFeature();
- flavorFeature.setId(sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, "name"));
+ flavorFeature.setId(node.toString());
+ LOGGER.debug("the name of node =" + node.toString());
flavorFeature.getDirectives().add(flavorDirective);
final CapabilityAssignments capabilityAssignments = sdcCsarHelper.getCapabilitiesOf(node);
@@ -291,8 +294,10 @@ public class ExtractFromNode {
return;
}
- for (final RequirementAssignment requriement : sdcCsarHelper.getRequirementsOf(node).getAll()) {
- final String nodeTemplateName = requriement.getNodeTemplateName().toLowerCase();
+ final RequirementAssignments requriements =
+ sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding");
+ for (final RequirementAssignment requriement : requriements.getAll()) {
+ final String nodeTemplateName = requriement.getNodeTemplateName();
LOGGER.debug("getNodeTemplateName =" + nodeTemplateName);
if (nodeTemplateName == null) {
continue;
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 de148520..3826ec92 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
@@ -82,7 +82,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
- assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"BasicCapabilities\""));
@@ -111,7 +111,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
- assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
@@ -152,7 +152,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
- assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
@@ -195,7 +195,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"version\":\"1.0\""));
assertTrue(policy.getConfigBody().contains("\"policyType\":\"Optimization\""));
- assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"attribute_name\":\"flavorName\""));
@@ -209,4 +209,38 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"operator\":\"\""));
assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
}
+
+ @Test
+ public void testS3p0PciVendorId() throws IOException, PolicyDecodingException {
+ final Csar csar = new Csar("src/test/resources/s3p_0_pciVendorId.csar");
+ final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
+ policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ assertEquals(1, 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\":\"Optimization\""));
+
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.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("\"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/hpaPolicyPciePassthrough.csar b/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar
index 7a9b30b3..a97e76d2 100644
--- a/plugins/reception-plugins/src/test/resources/hpaPolicyPciePassthrough.csar
+++ 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 4eb7458d..29a8ca9b 100644
--- a/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
+++ b/plugins/reception-plugins/src/test/resources/hpaPolicySriov.csar
Binary files differ
diff --git a/plugins/reception-plugins/src/test/resources/s3p_0_pciVendorId.csar b/plugins/reception-plugins/src/test/resources/s3p_0_pciVendorId.csar
new file mode 100644
index 00000000..b1d3cab5
--- /dev/null
+++ b/plugins/reception-plugins/src/test/resources/s3p_0_pciVendorId.csar
Binary files differ