diff options
Diffstat (limited to 'main')
15 files changed, 863 insertions, 58 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java index d7f152ea..1cb3af5d 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java @@ -22,6 +22,8 @@ package org.onap.policy.api.main.rest.provider;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
@@ -31,6 +33,7 @@ import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
@@ -74,20 +77,16 @@ public class PolicyProvider { public ToscaServiceTemplate fetchPolicies(String policyTypeId, String policyTypeVersion,
String policyId, String policyVersion) throws PfModelException {
- validatePolicyTypeExist(policyTypeId, policyTypeVersion);
+ ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder()
+ .name(policyId).version(policyVersion)
+ .type(policyTypeId).typeVersion(policyTypeVersion).build();
+ ToscaServiceTemplate serviceTemplate = modelsProvider.getFilteredPolicies(policyFilter);
- ToscaServiceTemplate serviceTemplate;
- if (policyId == null || policyVersion == null) {
- ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder()
- .name(policyId).version(policyVersion)
- .type(policyTypeId).typeVersion(policyTypeVersion).build();
- serviceTemplate = modelsProvider.getFilteredPolicies(policyFilter);
- } else {
- serviceTemplate = modelsProvider.getPolicies(policyId, policyVersion);
+ if (!hasPolicy(serviceTemplate)) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructResourceNotFoundMessage(policyTypeId, policyTypeVersion, policyId, policyVersion));
}
- validatePolicyTypeMatch(policyTypeId, policyTypeVersion, serviceTemplate);
-
close();
return serviceTemplate;
}
@@ -106,14 +105,15 @@ public class PolicyProvider { public ToscaServiceTemplate fetchLatestPolicies(String policyTypeId, String policyTypeVersion,
String policyId) throws PfModelException {
- validatePolicyTypeExist(policyTypeId, policyTypeVersion);
-
ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder()
.name(policyId).version(ToscaPolicyFilter.LATEST_VERSION)
.type(policyTypeId).typeVersion(policyTypeVersion).build();
ToscaServiceTemplate serviceTemplate = modelsProvider.getFilteredPolicies(policyFilter);
- validatePolicyTypeMatch(policyTypeId, policyTypeVersion, serviceTemplate);
+ if (!hasPolicy(serviceTemplate)) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructResourceNotFoundMessage(policyTypeId, policyTypeVersion, policyId, null));
+ }
close();
return serviceTemplate;
@@ -133,19 +133,25 @@ public class PolicyProvider { public Map<Pair<String, String>, List<ToscaPolicy>> fetchDeployedPolicies(
String policyTypeId, String policyTypeVersion, String policyId) throws PfModelException {
- validatePolicyTypeExist(policyTypeId, policyTypeVersion);
-
- ToscaPolicyIdentifier policyIdentifier = new ToscaPolicyIdentifier();
- policyIdentifier.setName(policyId);
- PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder()
- .policyType(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion))
- .policy(policyIdentifier).build();
+ List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>();
+ policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion));
+ PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyTypeList(policyTypes).build();
List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
- //TODO: I don't know how to get policies matching policyId that are deployed in those PDP groups
+ if (pdpGroups.isEmpty()) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructDeploymentNotFoundMessage(policyTypeId, policyTypeVersion, policyId));
+ }
+
+ Map<Pair<String, String>, List<ToscaPolicy>> deployedPolicyMap = constructDeployedPolicyMap(
+ pdpGroups, policyId);
+ if (deployedPolicyMap.isEmpty()) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructDeploymentNotFoundMessage(policyTypeId, policyTypeVersion, policyId));
+ }
close();
- return null;
+ return deployedPolicyMap;
}
/**
@@ -186,17 +192,17 @@ public class PolicyProvider { public ToscaServiceTemplate deletePolicy(String policyTypeId, String policyTypeVersion,
String policyId, String policyVersion) throws PfModelException {
- validatePolicyTypeExist(policyTypeId, policyTypeVersion);
-
- ToscaServiceTemplate serviceTemplate = modelsProvider.getPolicies(policyId, policyVersion);
-
- validatePolicyTypeMatch(policyTypeId, policyTypeVersion, serviceTemplate);
validateDeleteEligibility(policyTypeId, policyTypeVersion, policyId, policyVersion);
- ToscaServiceTemplate deletedServiceTemplate = modelsProvider.deletePolicy(policyId, policyVersion);
+ ToscaServiceTemplate serviceTemplate = modelsProvider.deletePolicy(policyId, policyVersion);
+
+ if (!hasPolicy(serviceTemplate)) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructResourceNotFoundMessage(policyTypeId, policyTypeVersion, policyId, policyVersion));
+ }
close();
- return deletedServiceTemplate;
+ return serviceTemplate;
}
/**
@@ -230,14 +236,17 @@ public class PolicyProvider { List<Map<String, ToscaPolicy>> policies = serviceTemplate.getToscaTopologyTemplate().getPolicies();
for (Map<String, ToscaPolicy> policy : policies) {
- if (policy.size() != 1) {
+ if (policy.size() > 1) {
throw new PfModelException(Response.Status.BAD_REQUEST,
"one policy block contains more than one policies");
}
ToscaPolicy policyContent = policy.values().iterator().next();
- if (!policyTypeId.equalsIgnoreCase(policyContent.getType())
- || !policyTypeVersion.equalsIgnoreCase(policyContent.getTypeVersion())) {
- throw new PfModelException(Response.Status.BAD_REQUEST, "policy type does not match");
+ if (!policyTypeId.equalsIgnoreCase(policyContent.getType())) {
+ throw new PfModelException(Response.Status.BAD_REQUEST, "policy type id does not match");
+ }
+ if (policyContent.getTypeVersion() != null
+ && !policyTypeVersion.equalsIgnoreCase(policyContent.getTypeVersion())) {
+ throw new PfModelException(Response.Status.BAD_REQUEST, "policy type version does not match");
}
}
}
@@ -255,16 +264,101 @@ public class PolicyProvider { private void validateDeleteEligibility(String policyTypeId, String policyTypeVersion,
String policyId, String policyVersion) throws PfModelException {
+ List<ToscaPolicyTypeIdentifier> policyTypes = new ArrayList<>();
+ policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion));
+ List<ToscaPolicyIdentifier> policies = new ArrayList<>();
+ policies.add(new ToscaPolicyIdentifier(policyId, policyVersion));
PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder()
- .policyType(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion))
- .policy(new ToscaPolicyIdentifier(policyId, policyVersion)).build();
+ .policyTypeList(policyTypes).policyList(policies).build();
List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
+
if (!pdpGroups.isEmpty()) {
throw new PfModelException(Response.Status.CONFLICT, "the policy has been deployed in pdp group");
}
}
+ private Map<Pair<String, String>, List<ToscaPolicy>> constructDeployedPolicyMap(
+ List<PdpGroup> pdpGroups, String policyId) throws PfModelException {
+
+ Map<Pair<String, String>, List<ToscaPolicy>> deployedPolicyMap = new HashMap<>();
+ for (PdpGroup pdpGroup : pdpGroups) {
+ List<ToscaPolicyIdentifier> policyIdentifiers = new ArrayList<>();
+ for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) {
+ for (ToscaPolicyIdentifier policyIdentifier : pdpSubGroup.getPolicies()) {
+ if (policyId.equalsIgnoreCase(policyIdentifier.getName())) {
+ policyIdentifiers.add(policyIdentifier);
+ }
+ }
+ }
+ List<ToscaPolicy> deployedPolicies = new ArrayList<>();
+ if (!policyIdentifiers.isEmpty()) {
+ for (ToscaPolicyIdentifier policyIdentifier : policyIdentifiers) {
+ deployedPolicies.addAll(
+ modelsProvider.getPolicyList(policyIdentifier.getName(), policyIdentifier.getVersion()));
+ }
+ }
+ if (!deployedPolicies.isEmpty()) {
+ deployedPolicyMap.put(Pair.of(pdpGroup.getName(), pdpGroup.getVersion()), deployedPolicies);
+ }
+ }
+ return deployedPolicyMap;
+ }
+
+ /**
+ * Constructs returned message for not found resource.
+ *
+ * @param policyTypeId the ID of policy type
+ * @param policyTypeVersion the version of policy type
+ * @param policyId the ID of policy
+ * @param policyVersion the version of policy
+ *
+ * @return constructed message
+ */
+ private String constructResourceNotFoundMessage(String policyTypeId, String policyTypeVersion,
+ String policyId, String policyVersion) {
+
+ return "policy with ID " + policyId + ":" + policyVersion
+ + " and type " + policyTypeId + ":" + policyTypeVersion + " does not exist";
+ }
+
+ /**
+ * Constructs returned message for not found policy deployment.
+ *
+ * @param policyTypeId the ID of policy type
+ * @param policyTypeVersion the version of policy type
+ * @param policyId the ID of policy
+ * @param policyVersion the version of policy
+ *
+ * @return constructed message
+ */
+ private String constructDeploymentNotFoundMessage(String policyTypeId, String policyTypeVersion,
+ String policyId) {
+
+ return "could not find policy with ID " + policyId + " and type "
+ + policyTypeId + ":" + policyTypeVersion + " deployed in any pdp group";
+ }
+
+ /**
+ * Checks if service template contains any policy.
+ *
+ * @param serviceTemplate the service template to check against
+ *
+ * @return boolean whether service template contains any policy
+ */
+ private boolean hasPolicy(ToscaServiceTemplate serviceTemplate) {
+
+ if (serviceTemplate.getToscaTopologyTemplate().getPolicies() == null) {
+ return false;
+ } else if (serviceTemplate.getToscaTopologyTemplate().getPolicies().isEmpty()) {
+ return false;
+ } else if (serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
/**
* Closes the connection to database.
*
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyTypeProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyTypeProvider.java index 8fab2bdb..19f3a750 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyTypeProvider.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyTypeProvider.java @@ -27,13 +27,12 @@ import javax.ws.rs.core.Response; import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
@@ -68,13 +67,13 @@ public class PolicyTypeProvider { public ToscaServiceTemplate fetchPolicyTypes(String policyTypeId, String policyTypeVersion)
throws PfModelException {
- ToscaServiceTemplate serviceTemplate;
- if (policyTypeId == null || policyTypeVersion == null) {
- ToscaPolicyTypeFilter policyTypeFilter = ToscaPolicyTypeFilter.builder()
- .name(policyTypeId).version(policyTypeVersion).build();
- serviceTemplate = modelsProvider.getFilteredPolicyTypes(policyTypeFilter);
- } else {
- serviceTemplate = modelsProvider.getPolicyTypes(policyTypeId, policyTypeVersion);
+ ToscaPolicyTypeFilter policyTypeFilter = ToscaPolicyTypeFilter.builder()
+ .name(policyTypeId).version(policyTypeVersion).build();
+ ToscaServiceTemplate serviceTemplate = modelsProvider.getFilteredPolicyTypes(policyTypeFilter);
+
+ if (policyTypeId != null && !hasPolicyType(serviceTemplate)) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructResourceNotFoundMessage(policyTypeId, policyTypeVersion));
}
close();
@@ -95,6 +94,10 @@ public class PolicyTypeProvider { ToscaPolicyTypeFilter policyTypeFilter = ToscaPolicyTypeFilter.builder()
.name(policyTypeId).version(ToscaPolicyTypeFilter.LATEST_VERSION).build();
ToscaServiceTemplate serviceTemplate = modelsProvider.getFilteredPolicyTypes(policyTypeFilter);
+ if (serviceTemplate.getPolicyTypes().isEmpty()) {
+ throw new PfModelException(Response.Status.NOT_FOUND,
+ constructResourceNotFoundMessage(policyTypeId, null));
+ }
close();
return serviceTemplate;
@@ -143,20 +146,50 @@ public class PolicyTypeProvider { *
* @param policyTypeId the ID of policy type
* @param policyTypeVersion the version of policy type
- * @param policyId the ID of policy
- * @param policyVersion the version of policy
*
* @throws PfModelException the PfModel parsing exception
*/
private void validateDeleteEligibility(String policyTypeId, String policyTypeVersion) throws PfModelException {
- PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder()
- .policyType(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion)).build();
-
- List<PdpGroup> pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter);
- if (!pdpGroups.isEmpty()) {
+ ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder()
+ .type(policyTypeId).typeVersion(policyTypeVersion).build();
+ List<ToscaPolicy> policies = modelsProvider.getFilteredPolicyList(policyFilter);
+ if (!policies.isEmpty()) {
throw new PfModelException(Response.Status.CONFLICT,
- "the policy type is parameterized by at least one policies that have been deployed in pdp group");
+ "the policy type has been parameterized by at least one policies");
+ }
+ }
+
+ /**
+ * Constructs returned message for not found resource.
+ *
+ * @param policyTypeId the ID of policy type
+ * @param policyTypeVersion the version of policy type
+ *
+ * @return constructed message
+ */
+ private String constructResourceNotFoundMessage(String policyTypeId, String policyTypeVersion) {
+
+ return "policy type with ID " + policyTypeId + ":" + policyTypeVersion + " does not exist";
+ }
+
+ /**
+ * Checks if service template contains any policy type.
+ *
+ * @param serviceTemplate the service template to check against
+ *
+ * @return boolean whether service template contains any policy type
+ */
+ private boolean hasPolicyType(ToscaServiceTemplate serviceTemplate) {
+
+ if (serviceTemplate.getPolicyTypes() == null) {
+ return false;
+ } else if (serviceTemplate.getPolicyTypes().isEmpty()) {
+ return false;
+ } else if (serviceTemplate.getPolicyTypes().get(0).isEmpty()) {
+ return false;
+ } else {
+ return true;
}
}
@@ -166,6 +199,7 @@ public class PolicyTypeProvider { * @throws PfModelException the PfModel parsing exception
*/
private void close() throws PfModelException {
+
try {
modelsProvider.close();
} catch (Exception e) {
diff --git a/main/src/main/resources/META-INF/persistence.xml b/main/src/main/resources/META-INF/persistence.xml index 81be3db9..8812ebf6 100644 --- a/main/src/main/resources/META-INF/persistence.xml +++ b/main/src/main/resources/META-INF/persistence.xml @@ -2,6 +2,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2019 Nordix Foundation. + Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28,6 +29,9 @@ <class>org.onap.policy.models.base.PfConceptKey</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class> <properties> <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> @@ -48,6 +52,9 @@ <class>org.onap.policy.models.base.PfConceptKey</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class> <properties> <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" /> @@ -67,7 +74,7 @@ <property name="eclipselink.logging.level.query" value="ALL" /> <property name="eclipselink.logging.level.properties" value="ALL" /--> - <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> + <property name="eclipselink.ddl-generation" value="create-or-extend-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> <property name="eclipselink.logging.level" value="INFO" /> </properties> diff --git a/main/src/test/resources/META-INF/persistence.xml b/main/src/test/resources/META-INF/persistence.xml index 23e8567f..8812ebf6 100644 --- a/main/src/test/resources/META-INF/persistence.xml +++ b/main/src/test/resources/META-INF/persistence.xml @@ -2,6 +2,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2019 Nordix Foundation. + Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28,6 +29,9 @@ <class>org.onap.policy.models.base.PfConceptKey</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class> <properties> <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> @@ -46,7 +50,11 @@ <class>org.onap.policy.models.dao.converters.CDataConditioner</class> <class>org.onap.policy.models.dao.converters.Uuid2String</class> <class>org.onap.policy.models.base.PfConceptKey</class> + <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class> + <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class> <properties> <property name="javax.persistence.jdbc.driver" value="org.mariadb.jdbc.Driver" /> @@ -66,7 +74,7 @@ <property name="eclipselink.logging.level.query" value="ALL" /> <property name="eclipselink.logging.level.properties" value="ALL" /--> - <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> + <property name="eclipselink.ddl-generation" value="create-or-extend-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> <property name="eclipselink.logging.level" value="INFO" /> </properties> diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml new file mode 100644 index 00000000..415e05e2 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml @@ -0,0 +1,63 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.AffinityPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - zone + identity: + type: string + required: true + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + affinityProperties: + type: policy.data.affinityProperties_properties + required: true + resources: + type: list + required: true + entry_schema: + type: string +data_types: + - + policy.data.affinityProperties_properties: + derived_from: tosca.nodes.Root + properties: + qualifier: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - same + - different + category: + type: string + required: true diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml new file mode 100644 index 00000000..a0571bc1 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml @@ -0,0 +1,83 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.DistancePolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - distance_to_location + identity: + type: string + required: true + resources: + type: list + required: true + entry_schema: + type: string + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + distanceProperties: + type: policy.data.distanceProperties_properties + required: true +data_types: + - + policy.data.distanceProperties_properties: + derived_from: tosca.nodes.Root + properties: + locationInfo: + type: string + required: true + distance: + type: policy.data.distance_properties + required: true + policy.data.distance_properties: + derived_from: tosca.nodes.Root + properties: + value: + type: string + required: true + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - < + - <= + - '>' + - '>=' + - '=' + unit: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - km diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml new file mode 100644 index 00000000..e9e5436f --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml @@ -0,0 +1,136 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.HpaPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - hpa + resources: + type: list + required: true + entry_schema: + type: string + identity: + type: string + required: true + flavorFeatures: + type: list + required: true + entry_schema: + type: policy.data.flavorFeatures_properties +data_types: + - + policy.data.flavorFeatures_properties: + derived_from: tosca.nodes.Root + properties: + id: + type: string + required: true + type: + type: string + required: true + directives: + type: list + required: true + entry_schema: + type: policy.data.directives_properties + flavorProperties: + type: list + required: true + entry_schema: + type: policy.data.flavorProperties_properties + - + policy.data.directives_properties: + derived_from: tosca.nodes.Root + properties: + type: + type: string + attributes: + type: list + entry_schema: + type: policy.data.directives_attributes_properties + - + policy.data.directives_attributes_properties: + derived_from: tosca.nodes.Root + properties: + attribute_name: + type: string + attribute_value: + type: string + - + policy.data.flavorProperties_properties: + derived_from: tosca.nodes.Root + properties: + hpa-feature: + type: string + required: true + mandatory: + type: string + required: true + score: + type: string + required: false + architecture: + type: string + required: true + hpa-version: + type: string + required: true + directives: + type: list + required: true + entry_schema: + type: policy.data.directives_properties + hpa-feature-attributes: + type: list + required: true + entry_schema: + type: policy.data.hpa-feature-attributes_properties + - + policy.data.hpa-feature-attributes_properties: + derived_from: tosca.nodes.Root + properties: + hpa-attribute-key: + type: string + required: true + hpa-attribute-value: + type: string + required: true + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - < + - <= + - '>' + - '>=' + - '=' + - '!=' + - any + - all + - subset + unit: + type: string + required: false diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml new file mode 100644 index 00000000..cccd0b50 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml @@ -0,0 +1,90 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.OptimizationPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - placement_optimization + identity: + type: string + required: true + objective: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - minimize + - maximize + objectiveParameter: + type: policy.data.objectiveParameter_properties + required: true +data_types: + - + policy.data.objectiveParameter_properties: + derived_from: tosca.nodes.Root + properties: + parameterAttributes: + type: list + required: true + entry_schema: + type: policy.data.parameterAttributes_properties + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - '*' + - + + - '-' + - / + - '%' + policy.data.parameterAttributes_properties: + derived_from: tosca.nodes.Root + properties: + resources: + type: string + required: true + customerLocationInfo: + type: string + required: true + parameter: + type: string + required: true + weight: + type: string + required: true + operator: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - '*' + - + + - '-' + - / + - '%' diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.PciPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.PciPolicy.yaml new file mode 100644 index 00000000..2cc6d418 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.PciPolicy.yaml @@ -0,0 +1,59 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.PciPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - pciPolicy + identity: + type: string + required: true + resources: + type: list + required: true + entry_schema: + type: string + pciProperties: + type: list + required: false + entry_schema: + type: policy.data.pciProperties_properties +data_types: + - + policy.data.pciProperties_properties: + derived_from: tosca.nodes.Root + properties: + algoCategory: + type: string + required: false + pciOptmizationAlgoName: + type: string + required: false + pciOptimizationNwConstraint: + type: string + required: false + pciOptimizationPriority: + type: string + required: false + pciOptimizationTimeConstraint: + type: string + required: false diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml new file mode 100644 index 00000000..7c54a8d0 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml @@ -0,0 +1,48 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.QueryPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - request_param_query + identity: + type: string + required: true + queryProperties: + type: list + required: true + entry_schema: + type: policy.data.queryProperties_properties +data_types: + - + policy.data.queryProperties_properties: + derived_from: tosca.nodes.Root + properties: + attribute: + type: string + required: true + value: + type: string + required: true + attribute_location: + type: string + required: true diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml new file mode 100644 index 00000000..294dcdf4 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml @@ -0,0 +1,52 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.SubscriberPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - subscriberPolicy + identity: + type: string + required: true + properties: + type: policy.data.properties_properties + required: true +data_types: + - + policy.data.properties_properties: + derived_from: tosca.nodes.Root + properties: + subscriberName: + type: list + required: true + entry_schema: + type: string + subscriberRole: + type: list + required: true + entry_schema: + type: string + provStatus: + type: list + required: true + entry_schema: + type: string diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.Vim_fit.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.Vim_fit.yaml new file mode 100644 index 00000000..e4dc5009 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.Vim_fit.yaml @@ -0,0 +1,57 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.Vim_fit: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - vim_fit + identity: + type: string + required: true + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + resources: + type: list + required: true + entry_schema: + type: string + capacityProperties: + type: policy.data.capacityProperties_properties + required: true +data_types: + - + policy.data.capacityProperties_properties: + derived_from: tosca.nodes.Root + properties: + controller: + type: string + required: true + request: + type: string + required: true diff --git a/main/src/test/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml b/main/src/test/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml new file mode 100644 index 00000000..009df412 --- /dev/null +++ b/main/src/test/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml @@ -0,0 +1,74 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + - onap.policies.Optimization: + derived_from: tosca.policies.Root + version: 1.0.0 + description: a base policy type for all policies that govern optimization + - onap.policies.optimization.VnfPolicy: + derived_from: onap.policies.Optimization + properties: + policyScope: + type: list + description: scope where the policy is applicable + required: true + matchable: true + entry_schema: + type: string + policyType: + type: list + description: type of a policy + required: true + matchable: true + entry_schema: + type: string + constraints: + - valid_values: + - vnfPolicy + identity: + type: string + required: true + resources: + type: list + required: true + entry_schema: + type: string + applicableResources: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - any + - all + vnfProperties: + type: list + required: true + entry_schema: + type: policy.data.vnfProperties_properties +data_types: + - + policy.data.vnfProperties_properties: + derived_from: tosca.nodes.Root + properties: + inventoryProvider: + type: string + required: true + serviceType: + type: string + required: true + inventoryType: + type: list + required: true + entry_schema: + type: string + constraints: + - valid_values: + - serviceInstanceId + - vnfName + - cloudRegionId + - vimId + customerId: + type: string + required: true + diff --git a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json index 95d7a53b..292c632c 100644 --- a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json +++ b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json @@ -8,7 +8,7 @@ } }, { - "onap.policy.monitoring.cdap.tca.hi.lo.app": { + "onap.policies.monitoring.cdap.tca.hi.lo.app": { "derived_from": "onap.policies.Monitoring", "version": "1.0.0", "properties": { diff --git a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml index f8e9b752..2985603a 100644 --- a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml +++ b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml @@ -5,7 +5,7 @@ policy_types: derived_from: tosca.policies.Root description: a base policy type for all policies that governs monitoring provisioning - - onap.policy.monitoring.cdap.tca.hi.lo.app: + onap.policies.monitoring.cdap.tca.hi.lo.app: derived_from: onap.policies.Monitoring version: 1.0.0 properties: |