From d95c395499b88834e2f1d767180302512f077a52 Mon Sep 17 00:00:00 2001 From: Chenfei Gao Date: Sun, 7 Apr 2019 21:33:02 -0400 Subject: Modify policy provider to support GET/CREATE Modify policy and policy type providers to better support GET/CREATE policy/policy types. Issue-ID: POLICY-1442 Change-Id: I7a513be4f9dbd5b48b85a948e3bda7b6c6ab7ddb Signed-off-by: Chenfei Gao --- .../api/main/rest/provider/PolicyProvider.java | 166 ++++++++++++++++----- .../api/main/rest/provider/PolicyTypeProvider.java | 70 ++++++--- main/src/main/resources/META-INF/persistence.xml | 9 +- main/src/test/resources/META-INF/persistence.xml | 10 +- .../onap.policies.optimization.AffinityPolicy.yaml | 63 ++++++++ .../onap.policies.optimization.DistancePolicy.yaml | 83 +++++++++++ .../onap.policies.optimization.HpaPolicy.yaml | 136 +++++++++++++++++ ...p.policies.optimization.OptimizationPolicy.yaml | 90 +++++++++++ .../onap.policies.optimization.PciPolicy.yaml | 59 ++++++++ .../onap.policies.optimization.QueryPolicy.yaml | 48 ++++++ ...nap.policies.optimization.SubscriberPolicy.yaml | 52 +++++++ .../onap.policies.optimization.Vim_fit.yaml | 57 +++++++ .../onap.policies.optimization.VnfPolicy.yaml | 74 +++++++++ .../onap.policy.monitoring.cdap.tca.hi.lo.app.json | 2 +- .../onap.policy.monitoring.cdap.tca.hi.lo.app.yaml | 2 +- 15 files changed, 863 insertions(+), 58 deletions(-) create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.PciPolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.Vim_fit.yaml create mode 100644 main/src/test/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml 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, List> 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 policyTypes = new ArrayList<>(); + policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion)); + PdpGroupFilter pdpGroupFilter = PdpGroupFilter.builder().policyTypeList(policyTypes).build(); List 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, List> 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> policies = serviceTemplate.getToscaTopologyTemplate().getPolicies(); for (Map 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 policyTypes = new ArrayList<>(); + policyTypes.add(new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion)); + List 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 pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter); + if (!pdpGroups.isEmpty()) { throw new PfModelException(Response.Status.CONFLICT, "the policy has been deployed in pdp group"); } } + private Map, List> constructDeployedPolicyMap( + List pdpGroups, String policyId) throws PfModelException { + + Map, List> deployedPolicyMap = new HashMap<>(); + for (PdpGroup pdpGroup : pdpGroups) { + List policyIdentifiers = new ArrayList<>(); + for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) { + for (ToscaPolicyIdentifier policyIdentifier : pdpSubGroup.getPolicies()) { + if (policyId.equalsIgnoreCase(policyIdentifier.getName())) { + policyIdentifiers.add(policyIdentifier); + } + } + } + List 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 pdpGroups = modelsProvider.getFilteredPdpGroups(pdpGroupFilter); - if (!pdpGroups.isEmpty()) { + ToscaPolicyFilter policyFilter = ToscaPolicyFilter.builder() + .type(policyTypeId).typeVersion(policyTypeVersion).build(); + List 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 @@ - + 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 @@ - + 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: -- cgit 1.2.3-korg