summaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/main/java
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2018-10-31 10:03:49 +0800
committerliboNet <libo.zhu@intel.com>2018-11-01 01:44:30 +0800
commit46b926fdacf597c1afc7136230d72562444008f6 (patch)
tree99c3100bedcbf8ddc567455844bfcfa7441d6fe4 /plugins/reception-plugins/src/main/java
parenta64169b24ab24101719c1a926ab1d3c9d25c219c (diff)
Add more logics about fields value for OOF model
To align with OOF/Policy/SO, need add below: . resource should be set as name field of SDC resource. . identity should be set as a concatenation of PolicyType + "_" + Resource . value of flavorDirective's type, expected from OOF, is "flavor_directives" . policyScope should add the name of service from SDC to align with that from SO. . Update the Testcase Change-Id: I57f461ef51e0f50e6096c9c9ba84c5832cb13656 Issue-ID: POLICY-1227 Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'plugins/reception-plugins/src/main/java')
-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
2 files changed, 9 insertions, 3 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);