diff options
author | Liang Ding <liang.ding@intel.com> | 2019-10-22 21:56:25 -0700 |
---|---|---|
committer | Liang Ding <liang.ding@intel.com> | 2019-10-30 08:43:18 -0700 |
commit | 0f7c0e57f391e1c9e25c174ffb0b7bda370b713e (patch) | |
tree | d9d2a2211a38d61e8917c33b559cbb90e525725f /plugins/reception-plugins/src/main/java/org | |
parent | 6df52982d9e22fc1ff7a56eea8714a2598a51639 (diff) |
changes in decoder as per new infra APIs
Change-Id: Ie2ebfa16bc6b08dc54d60ef276f52e9ea2c91b1f
Issue-ID: POLICY-1869
Signed-off-by: Liang Ding <liang.ding@intel.com>
Diffstat (limited to 'plugins/reception-plugins/src/main/java/org')
-rw-r--r-- | plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java index eadca94d..8cfc6857 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java @@ -23,7 +23,9 @@ package org.onap.policy.distribution.reception.decoding.pdpx; import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.coder.StandardCoder; @@ -31,7 +33,12 @@ import org.onap.policy.distribution.model.Csar; import org.onap.policy.distribution.model.PolicyInput; import org.onap.policy.distribution.reception.decoding.PolicyDecoder; import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.onap.sdc.toscaparser.api.NodeTemplate; @@ -47,6 +54,14 @@ public class PolicyDecoderCsarPdpxLifecycleApi implements PolicyDecoder<Csar, To private final StandardCoder coder = new StandardCoder(); private PolicyDecoderCsarPdpxLifecycleApiParameters decoderParameters; + public static final String TOSCA_POLICY_SCOPE = "scope"; + public static final String TOSCA_POLICY_SERVICES = "services"; + public static final String TOSCA_POLICY_RESOURCES = "resources"; + public static final String TOSCA_POLICY_IDENTITY = "identity"; + public static final String TOSCA_POLICY_FLAVORFEATURES = "flavorfeatures"; + + public static final String TOSCA_POLICY_HPA_OOF = "Optimization"; + @Override public Collection<ToscaServiceTemplate> decode(final Csar csar) throws PolicyDecodingException { final List<ToscaServiceTemplate> entities = new ArrayList<>(); @@ -61,7 +76,22 @@ public class PolicyDecoderCsarPdpxLifecycleApi implements PolicyDecoder<Csar, To final Content content = extractFromNode.extractInfo(node); if (content != null) { final ToscaServiceTemplate entity = new ToscaServiceTemplate(); - // TODO: add the logic for creating ToscaServiceTemplate for HPA policy + Map<String, Object> props = new LinkedHashMap<>(); + props.put(TOSCA_POLICY_SCOPE, content.getScope()); + props.put(TOSCA_POLICY_SERVICES, content.getServices()); + props.put(TOSCA_POLICY_RESOURCES, content.getResources()); + props.put(TOSCA_POLICY_IDENTITY, content.getIdentity()); + props.put(TOSCA_POLICY_FLAVORFEATURES, content.getFlavorFeatures()); + ToscaPolicy policy = new ToscaPolicy(); + policy.setProperties(props); + Map<String, ToscaPolicy> map = new LinkedHashMap<>(); + String type = content.getPolicyType(); + map.put(type, policy); + List<Map<String, ToscaPolicy>> policies = new ArrayList<>(); + policies.add(map); + ToscaTopologyTemplate topologyTemplate = new ToscaTopologyTemplate(); + topologyTemplate.setPolicies(policies); + entity.setToscaTopologyTemplate(topologyTemplate); entities.add(entity); } } |