summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java9
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java3
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java8
3 files changed, 13 insertions, 7 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 4f822b20..02b57552 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.policy.distribution.reception.decoding.PolicyDecodingException;
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.elements.Metadata;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
@@ -82,8 +83,8 @@ public class ExtractFromNode {
* @throws PolicyDecodingException if extract fails
*/
public Content extractInfo(final NodeTemplate node) throws PolicyDecodingException {
-
- LOGGER.debug("the meta data of this nodetemplate = " + sdcCsarHelper.getNodeTemplateMetadata(node));
+ Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node);
+ LOGGER.debug("the meta data of this nodetemplate = " + metaData);
final List<NodeTemplate> lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node);
LOGGER.debug("the size of lnodeChild = " + lnodeChild.size());
@@ -105,6 +106,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());
extractInfoVdu(lnodeVdu, content);
extractInfoVduCp(lnodeVduCp, content);
if (content.getFlavorFeatures().isEmpty()) {
@@ -128,7 +131,7 @@ public class ExtractFromNode {
flavorAttribute.setAttributeName("flavorName");
flavorAttribute.setAttributeValue("");
final Directive flavorDirective = new Directive();
- flavorDirective.setType("flavor_directive");
+ flavorDirective.setType("flavor_directives");
flavorDirective.getAttributes().add(flavorAttribute);
final FlavorFeature flavorFeature = new FlavorFeature();
flavorFeature.setId(sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, "name"));
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 97ca3f5e..14519757 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
@@ -55,6 +55,8 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
LOGGER.debug("the size of Vf = " + lnodeVf.size());
final ExtractFromNode extractFromNode = new ExtractFromNode();
extractFromNode.setSdcCsarHelper(sdcCsarHelper);
+ final String serviceName = sdcCsarHelper.getServiceMetadata().getValue("name");
+ LOGGER.debug("the name of the service = " + serviceName);
for (final NodeTemplate node : lnodeVf) {
final Content content = extractFromNode.extractInfo(node);
if (content != null) {
@@ -70,6 +72,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
configBody.setRiskType(decoderParameters.getRiskType());
configBody.setGuard("false");
content.getPolicyScope().add("HPA");
+ content.getPolicyScope().add(serviceName);
configBody.setContent(content);
policy.setConfigBody(gson.toJson(configBody));
policys.add(policy);
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 21593868..de148520 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
@@ -84,7 +84,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directive\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directives\""));
assertTrue(policy.getConfigBody().contains("\"hpa-feature\":\"BasicCapabilities\""));
assertTrue(policy.getConfigBody().contains("\"mandatory\":\"true\""));
assertTrue(policy.getConfigBody().contains("\"architecture\":\"generic\""));
@@ -113,7 +113,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directive\""));
+ 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\""));
@@ -154,7 +154,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directive\""));
+ 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\""));
@@ -197,7 +197,7 @@ public class TestPolicyDecoderCsarPdpx {
assertTrue(policy.getConfigBody().contains("\"id\":\"vdu_vnf_1\""));
assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.node.nfv.Vdu.Compute\""));
- assertTrue(policy.getConfigBody().contains("\"type\":\"flavor_directive\""));
+ 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\":\"hugePages\""));