* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.pap.concepts.PolicyNotification;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.pap.main.PapConstants;
import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
+import org.onap.policy.pap.main.notification.DeploymentStatus;
+import org.onap.policy.pap.main.notification.PolicyNotifier;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
protected PdpUpdate createPdpUpdateMessage(final String pdpGroupName, final PdpSubGroup subGroup,
- final String pdpInstanceId, final PolicyModelsProvider databaseProvider) throws PfModelException {
+ final String pdpInstanceId, final PolicyModelsProvider databaseProvider)
+ throws PfModelException {
final PdpUpdate update = new PdpUpdate();
update.setName(pdpInstanceId);
LOGGER.debug("Created PdpStateChange message - {}", stateChange);
return stateChange;
}
+
+ /**
+ * If group state=ACTIVE AND updateMsg has policiesToDeploy, then make sure deployment status is updated
+ * If group state=PASSIVE, then delete any deployment information for a PDP.
+ *
+ * @param pdpGroupName the group name
+ * @param pdpType the pdp type
+ * @param pdpInstanceId the pdp instance
+ * @param pdpState the new state as per the PDP_STATE_CHANGE change message
+ * @param databaseProvider the database provider
+ * @param policies list of policies as per the PDP_UPDATE message
+ * @throws PfModelException the exception
+ */
+ protected void updateDeploymentStatus(final String pdpGroupName, final String pdpType, final String pdpInstanceId,
+ PdpState pdpState, final PolicyModelsProvider databaseProvider, List<ToscaPolicy> policies)
+ throws PfModelException {
+ DeploymentStatus deploymentStatus = new DeploymentStatus(databaseProvider);
+ deploymentStatus.loadByGroup(pdpGroupName);
+ if (pdpState.equals(PdpState.PASSIVE)) {
+ deploymentStatus.deleteDeployment(pdpInstanceId);
+ } else if (pdpState.equals(PdpState.ACTIVE)) {
+ for (ToscaPolicy toscaPolicy : policies) {
+ deploymentStatus.deploy(pdpInstanceId, toscaPolicy.getIdentifier(), toscaPolicy.getTypeIdentifier(),
+ pdpGroupName, pdpType, true);
+ }
+ }
+ PolicyNotification notification = new PolicyNotification();
+ deploymentStatus.flush(notification);
+ PolicyNotifier notifier = Registry.get(PapConstants.REG_POLICY_NOTIFIER);
+ notifier.publish(notification);
+ }
}
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
private void sendPdpMessage(final String pdpGroupName, final PdpSubGroup subGroup, final String pdpInstanceId,
final PdpState pdpState, final PolicyModelsProvider databaseProvider) throws PfModelException {
final PdpUpdate pdpUpdatemessage =
- createPdpUpdateMessage(pdpGroupName, subGroup, pdpInstanceId, databaseProvider);
+ createPdpUpdateMessage(pdpGroupName, subGroup, pdpInstanceId, databaseProvider);
final PdpStateChange pdpStateChangeMessage =
- createPdpStateChangeMessage(pdpGroupName, subGroup, pdpInstanceId, pdpState);
+ createPdpStateChangeMessage(pdpGroupName, subGroup, pdpInstanceId, pdpState);
+ updateDeploymentStatus(pdpGroupName, subGroup.getPdpType(), pdpInstanceId, pdpStateChangeMessage.getState(),
+ databaseProvider, pdpUpdatemessage.getPolicies());
+
requestMap.addRequest(pdpUpdatemessage, pdpStateChangeMessage);
LOGGER.debug("Sent PdpUpdate message - {}", pdpUpdatemessage);
LOGGER.debug("Sent PdpStateChange message - {}", pdpStateChangeMessage);
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
}
private void sendPdpMessage(final PdpGroup pdpGroup, final PdpState pdpState,
- final PolicyModelsProvider databaseProvider) throws PfModelException {
-
+ final PolicyModelsProvider databaseProvider) throws PfModelException {
+ String pdpGroupName = pdpGroup.getName();
for (final PdpSubGroup subGroup : pdpGroup.getPdpSubgroups()) {
for (final Pdp pdp : subGroup.getPdpInstances()) {
+ String pdpInstanceId = pdp.getInstanceId();
final PdpUpdate pdpUpdatemessage =
- createPdpUpdateMessage(pdpGroup.getName(), subGroup, pdp.getInstanceId(), databaseProvider);
+ createPdpUpdateMessage(pdpGroupName, subGroup, pdpInstanceId, databaseProvider);
final PdpStateChange pdpStateChangeMessage =
- createPdpStateChangeMessage(pdpGroup.getName(), subGroup, pdp.getInstanceId(), pdpState);
+ createPdpStateChangeMessage(pdpGroupName, subGroup, pdpInstanceId, pdpState);
+ updateDeploymentStatus(pdpGroupName, subGroup.getPdpType(), pdpInstanceId,
+ pdpStateChangeMessage.getState(), databaseProvider, pdpUpdatemessage.getPolicies());
requestMap.addRequest(pdpUpdatemessage, pdpStateChangeMessage);
LOGGER.debug("Sent PdpUpdate message - {}", pdpUpdatemessage);
LOGGER.debug("Sent PdpStateChange message - {}", pdpStateChangeMessage);
{
"info": {
- "_postman_id": "05831254-6fad-419f-b10e-ff21cbbd365a",
+ "_postman_id": "d78b72f0-00b1-44c2-88c4-98a7a51b3932",
"name": "Policy Framework Administration API",
"description": "This collection lists all the Administration API's supported by ONAP Policy Framework. These API's are used to perform administrative operations for managing policies, groups, statistics & health information for all registered PDP engines.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
"response": []
},
{
- "name": "Fetch Policy deployment Status",
+ "name": "Fetch All Policy Status",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"raw": ""
},
"url": {
- "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/policies/deployed/operational.modifyconfig",
+ "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/policies/status",
"host": [
"{{POLICY-PAP-URL}}"
],
"pap",
"v1",
"policies",
- "deployed",
+ "status"
+ ]
+ },
+ "description": "This is a generic API to fetch status of all policies in the registered PDP instances."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch All Policy Status in a Group",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/policies/status/defaultGroup",
+ "host": [
+ "{{POLICY-PAP-URL}}"
+ ],
+ "path": [
+ "policy",
+ "pap",
+ "v1",
+ "policies",
+ "status",
+ "defaultGroup"
+ ]
+ },
+ "description": "This is a generic API to fetch status of all policies in the registered PDP instances in a PDP Group."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch Policy Status in a Group",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/policies/status/defaultGroup/operational.modifyconfig",
+ "host": [
+ "{{POLICY-PAP-URL}}"
+ ],
+ "path": [
+ "policy",
+ "pap",
+ "v1",
+ "policies",
+ "status",
+ "defaultGroup",
"operational.modifyconfig"
]
},
- "description": "This is an API to fetch status of a specific deployed policy in the registered PDP instances."
+ "description": "This is a generic API to fetch status of all versions of a policy in the registered PDP instances in a PDP Group."
},
"response": []
},
},
"response": []
},
+ {
+ "name": "Fetch Policy deployment Status",
+ "protocolProfileBehavior": {
+ "disableBodyPruning": true
+ },
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{POLICY-PAP-URL}}/policy/pap/v1/policies/deployed/operational.modifyconfig",
+ "host": [
+ "{{POLICY-PAP-URL}}"
+ ],
+ "path": [
+ "policy",
+ "pap",
+ "v1",
+ "policies",
+ "deployed",
+ "operational.modifyconfig"
+ ]
+ },
+ "description": "This is an API to fetch status of a specific deployed policy in the registered PDP instances."
+ },
+ "response": []
+ },
{
"name": "Fetch All PDPs Statistics",
"protocolProfileBehavior": {
{
"listen": "prerequest",
"script": {
- "id": "d6987a6d-a224-4288-a7bd-4c1c209a2637",
"type": "text/javascript",
"exec": [
""
{
"listen": "test",
"script": {
- "id": "731a9aab-e8f2-4dc6-941c-ac7e142c5177",
"type": "text/javascript",
"exec": [
""
],
"variable": [
{
- "id": "bc82ca5c-f667-4118-9da1-e78a9b532b91",
"key": "USER",
"value": "healthcheck",
"type": "string"
},
{
- "id": "1c2733ff-2507-49e8-ba07-b0f85ea97914",
"key": "PASSWORD",
"value": "zb!XztG34",
"type": "string"
}
- ],
- "protocolProfileBehavior": {}
+ ]
}
\ No newline at end of file