aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@est.tech>2019-09-04 09:26:53 +0000
committerramverma <ram.krishna.verma@est.tech>2019-09-04 09:26:53 +0000
commit53d14240b684df3d4f2fa8f02355effba722e514 (patch)
tree2e6a5cd13f27a1fca909ede4060a537c4dc8d362
parenta790e5194cd246b286265589ed598270dd5c96fe (diff)
Bring back the old HPA decoder & model
Bringing back the old HPA policy decoder and its related classes and tests. The distribution framework will support both the new PAP/API and the old policy engine in El Alto release. Issue-ID: POLICY-1871 Change-Id: Iab911b793207a09b02e906ed6913c54bc252f64c Signed-off-by: ramverma <ram.krishna.verma@est.tech>
-rw-r--r--model/pom.xml5
-rw-r--r--model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java95
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java14
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java290
4 files changed, 180 insertions, 224 deletions
diff --git a/model/pom.xml b/model/pom.xml
index 9cd53650..9e7e9f63 100644
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -35,5 +35,10 @@
<artifactId>utils</artifactId>
<version>${policy.common.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.models</groupId>
+ <artifactId>policy-models-tosca</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java b/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
index 2ca3c945..9a889eed 100644
--- a/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
+++ b/model/src/main/java/org/onap/policy/distribution/model/OptimizationPolicy.java
@@ -22,10 +22,22 @@ package org.onap.policy.distribution.model;
import java.util.Date;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
+
/**
* An optimization policy.
*/
-public class OptimizationPolicy implements Policy {
+@Getter
+@Setter
+@ToString
+@EqualsAndHashCode(callSuper = true)
+public class OptimizationPolicy extends ToscaEntity {
private static final String OPTIMIZATION = "Optimization";
private String policyName;
@@ -39,84 +51,23 @@ public class OptimizationPolicy implements Policy {
private String riskType;
@Override
- public String getPolicyName() {
+ public String getName() {
return policyName;
}
@Override
- public String getPolicyType() {
- return OPTIMIZATION;
- }
-
- public void setPolicyName(final String policyName) {
- this.policyName = policyName;
- }
-
- public String getPolicyDescription() {
- return policyDescription;
- }
-
- public void setPolicyDescription(final String policyDescription) {
- this.policyDescription = policyDescription;
- }
-
- public String getPolicyConfigType() {
- return getPolicyType();
- }
-
- public String getOnapName() {
- return onapName;
- }
-
- public void setOnapName(final String onapName) {
- this.onapName = onapName;
- }
-
- public String getConfigBody() {
- return configBody;
- }
-
- public void setConfigBody(final String configBody) {
- this.configBody = configBody;
+ public void setName(final String name) {
+ this.policyName = name;
}
- public String getConfigBodyType() {
- return configBodyType;
- }
-
- public void setConfigBodyType(final String configBodyType) {
- this.configBodyType = configBodyType;
- }
-
- public Date getTimetolive() {
- return timetolive;
- }
-
- public void setTimetolive(final Date timetolive) {
- this.timetolive = timetolive;
- }
-
- public String getGuard() {
- return guard;
- }
-
- public void setGuard(final String guard) {
- this.guard = guard;
- }
-
- public String getRiskLevel() {
- return riskLevel;
- }
-
- public void setRiskLevel(final String riskLevel) {
- this.riskLevel = riskLevel;
- }
-
- public String getRiskType() {
- return riskType;
+ @Override
+ public String getVersion() {
+ // Utilizing this method to return the policy type instead of version for the old model.
+ return OPTIMIZATION;
}
- public void setRiskType(final String riskType) {
- this.riskType = riskType;
+ @Override
+ public void setVersion(final String version) {
+ throw new NotImplementedException("Not supported");
}
}
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 8bbdaffe..842245c0 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
@@ -31,10 +31,10 @@ import java.util.List;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
+import org.onap.policy.distribution.model.OptimizationPolicy;
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.ToscaServiceTemplate;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.NodeTemplate;
@@ -44,15 +44,15 @@ import org.slf4j.LoggerFactory;
/**
* Decodes PDP-X policies from a CSAR file.
*/
-public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, ToscaServiceTemplate> {
+public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPolicy> {
private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarPdpx.class);
private final Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().create();
private PolicyDecoderCsarPdpxConfigurationParameterGroup decoderParameters;
@Override
- public Collection<ToscaServiceTemplate> decode(final Csar csar) throws PolicyDecodingException {
- final List<ToscaServiceTemplate> policies = new ArrayList<>();
+ public Collection<OptimizationPolicy> decode(final Csar csar) throws PolicyDecodingException {
+ final List<OptimizationPolicy> policies = new ArrayList<>();
final ISdcCsarHelper sdcCsarHelper = parseCsar(csar);
final List<NodeTemplate> lnodeVf = sdcCsarHelper.getServiceVfList();
LOGGER.debug("the size of Vf = {}", lnodeVf.size());
@@ -63,9 +63,9 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, ToscaServiceTe
for (final NodeTemplate node : lnodeVf) {
final Content content = extractFromNode.extractInfo(node);
if (content != null) {
- final ToscaServiceTemplate policy = new ToscaServiceTemplate();
+ final OptimizationPolicy policy = new OptimizationPolicy();
final String policyName = decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity();
- // policy.setOnapName(decoderParameters.getOnapName());
+ policy.setOnapName(decoderParameters.getOnapName());
policy.setName(policyName);
final ConfigBody configBody = new ConfigBody();
configBody.setService("hpaPolicy");
@@ -81,7 +81,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, ToscaServiceTe
content.getPolicyScope().add("HPA");
content.getPolicyScope().add(serviceName);
configBody.setContent(content);
- // policy.setConfigBody(gson.toJson(configBody));
+ policy.setConfigBody(gson.toJson(configBody));
policies.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 9cfbaf80..0eac8bf6 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
@@ -33,8 +33,8 @@ import org.junit.Test;
import org.onap.policy.common.parameters.ParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
+import org.onap.policy.distribution.model.OptimizationPolicy;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* Class to perform unit test of {@link PolicyDecoderCsarPdpx}.
@@ -68,29 +68,29 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
- final Collection<ToscaServiceTemplate> ret = policyDecoderCsarPdpx.decode(csar);
+ final Collection<OptimizationPolicy> ret = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, ret.size());
- final ToscaServiceTemplate policy = (ToscaServiceTemplate) ret.toArray()[0];
+ final OptimizationPolicy policy = (OptimizationPolicy) ret.toArray()[0];
- // assertEquals("onapName", policy.getOnapName());
+ assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().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\":\"hpa\""));
- //
- // assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
- // assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
- // 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\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"virtualMemSize\""));
- // assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
- // assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
+ 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\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.nfv.Vdu.Compute\""));
+ 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\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-version\":\"v1\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"virtualMemSize\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
}
@Test
@@ -99,38 +99,38 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
- final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
- final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
+ final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0];
- // assertEquals("onapName", policy.getOnapName());
+ assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().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\":\"hpa\""));
- //
- // assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
- // assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"sriovNICNetwork\""));
- // 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\":\"\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\""));
- // assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
- // assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\""));
- // assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
- // assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
+ 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\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"sriovNICNetwork\""));
+ 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\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
}
@Test
@@ -139,39 +139,39 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
- final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, policies.size());
- final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
+ final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0];
- // assertEquals("onapName", policy.getOnapName());
+ assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().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\":\"hpa\""));
- //
- // assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
- // assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\""));
- // assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
- // assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\""));
- // assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
- // assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
+ 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\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciDeviceId\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"5678\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-key\":\"pciNumDevices\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"1\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"\""));
}
@@ -182,31 +182,31 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
- final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, policies.size());
- final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
+ final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0];
- // assertEquals("onapName", policy.getOnapName());
+ assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().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\":\"hpa\""));
- //
- // assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
- // assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"hugePages\""));
- // 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\":\"memoryPageSize\""));
- // assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"2\""));
- // assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
- // assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
+ 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\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"hugePages\""));
+ 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\":\"memoryPageSize\""));
+ assertTrue(policy.getConfigBody().contains("\"hpa-attribute-value\":\"2\""));
+ assertTrue(policy.getConfigBody().contains("\"operator\":\"=\""));
+ assertTrue(policy.getConfigBody().contains("\"unit\":\"MB\""));
}
@Test
@@ -215,31 +215,31 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
- final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(1, policies.size());
- final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
+ final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0];
- // assertEquals("onapName", policy.getOnapName());
+ assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().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\":\"hpa\""));
- //
- // assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
- // assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"\""));
+ 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\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"id\":\"VDU_vgw_0\""));
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"\""));
}
@@ -249,30 +249,30 @@ public class TestPolicyDecoderCsarPdpx {
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
- final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
+ final Collection<OptimizationPolicy> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(5, policies.size());
- final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
+ final OptimizationPolicy policy = (OptimizationPolicy) policies.toArray()[0];
- // assertEquals("onapName", policy.getOnapName());
+ assertEquals("onapName", policy.getOnapName());
assertTrue(policy.getName().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\":\"hpa\""));
- //
- // assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"sriovNICNetwork\""));
- // 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\":\"\""));
+ 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\":\"hpa\""));
+
+ assertTrue(policy.getConfigBody().contains("\"type\":\"tosca.nodes.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\":\"sriovNICNetwork\""));
+ 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\":\"\""));
}
}