summaryrefslogtreecommitdiffstats
path: root/sdnr/northbound/a1Adapter
diff options
context:
space:
mode:
authorSandeep Shah <sandeeplinux1068@gmail.com>2019-12-17 00:32:01 -0600
committerSandeep Shah <sandeeplinux1068@gmail.com>2019-12-17 00:32:01 -0600
commit1194cb075b95b7cabe40b7114c2dd0df22ecb777 (patch)
tree7478651152f16daf57072c72e0ad1bc96be1a448 /sdnr/northbound/a1Adapter
parent6795925af9187658c44d5b8ced752a917813c4f7 (diff)
YANG Model update for A1 Adapter
YANG model update to address policy type and poliy instance creation as well as notification for policy enforcement update Issue-ID: CCSDK-1996 Signed-off-by: SandeepLinux <Sandeep.Shah@ibm.com> Change-Id: I4dc4fdf1fadd996d7f32ff370b2b1edd853823df
Diffstat (limited to 'sdnr/northbound/a1Adapter')
-rw-r--r--sdnr/northbound/a1Adapter/model/src/main/yang/A1-ADAPTER-API.yang102
-rw-r--r--sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java51
-rw-r--r--sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java79
3 files changed, 229 insertions, 3 deletions
diff --git a/sdnr/northbound/a1Adapter/model/src/main/yang/A1-ADAPTER-API.yang b/sdnr/northbound/a1Adapter/model/src/main/yang/A1-ADAPTER-API.yang
index 297787b32..68eb3be6a 100644
--- a/sdnr/northbound/a1Adapter/model/src/main/yang/A1-ADAPTER-API.yang
+++ b/sdnr/northbound/a1Adapter/model/src/main/yang/A1-ADAPTER-API.yang
@@ -14,8 +14,6 @@ module A1-ADAPTER-API {
"A1 adapter for Frankfurt";
}
-
-
grouping a1-adapter-response {
leaf response-code {
type string;
@@ -27,12 +25,59 @@ module A1-ADAPTER-API {
"Response payload for A1 Adapter RPC's";
}
+ grouping a1-policy-instance-property {
+
+ description
+ "Properties as specified in the create_schema field of policy type in PUT payload";
+
+ leaf property-name {
+ type string {
+ length "1..64";
+ }
+ description
+ "Individual property name";
+ }
+ leaf property-value {
+ type string {
+ length "1..64";
+ }
+ description
+ "Value of the property";
+ }
+ }
+
+
+ grouping a1-policy-type-create-schema-property-statement {
+
+ leaf policy-statement {
+ type string {
+ length "1..64";
+ }
+ description
+ "Individual policy statement name";
+ }
+ leaf policy-statement-value {
+ type string {
+ length "1..64";
+ }
+ description
+ "Value of the policy statement";
+ }
+ }
+
///Flattend interface using RPC
//Get a comma separated list of near-rt rics, e.g. domain-name1:port1,domainname2:port2
//Each item in the returned list will be regarded as one near-rt-ric-id.
rpc getNearRT-RICs {
+ // OpenDaylight Fluorine version of restconf cannot handle RPCs with no input
+ input {
+ leaf dummy {
+ type string;
+ }
+ }
+
output {
uses a1-adapter-response;
leaf-list near-rt-ric-id-list {
@@ -91,7 +136,21 @@ module A1-ADAPTER-API {
leaf policy-type {
type string;
}
- }
+ list properties {
+ key "property-name";
+ leaf property-name {
+ type string {
+ length "1..64";
+ }
+ description
+ "Individual property name";
+ }
+ list policy-statements {
+ key "policy-statement";
+ uses a1-policy-type-create-schema-property-statement;
+ }
+ }
+ }
output {
uses a1-adapter-response;
leaf status {
@@ -177,6 +236,10 @@ module A1-ADAPTER-API {
leaf policy-instance {
type string;
}
+ list properties {
+ key "property-name";
+ uses a1-policy-instance-property;
+ }
}
output {
uses a1-adapter-response;
@@ -242,4 +305,37 @@ module A1-ADAPTER-API {
}
}
}
+
+ //Policy feedback Notification to provide policy enforcement update
+ rpc notifyPolicyEnforcementUpdate {
+ input {
+ leaf near-rt-ric-id {
+ type string;
+ }
+ leaf policy-type-id {
+ type uint32;
+ }
+ leaf policy-instance-id {
+ type string;
+ }
+
+ }
+ output {
+ uses a1-adapter-response;
+ leaf policy_enforcement_status {
+ type string;
+ description
+ "Policy enforcement status - IN_EFFECT or NON_IN_EFFECT";
+ }
+ leaf policy_enforcement_reason {
+ type string;
+ description
+ "Indicates the reason why policy is no longer being enforced";
+ }
+ }
+ }
+
+
+
+
}
diff --git a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java
index 216f9bd38..429c57f92 100644
--- a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java
+++ b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java
@@ -617,6 +617,57 @@ public Properties execute(String module, String rpc, String version, String mode
}
+ // Client for notifyPolicyEnforcementUpdate
+
+
+ public Properties execute(String module, String rpc, String version, String mode, NotifyPolicyEnforcementUpdateOutputBuilder serviceData)
+ throws SvcLogicException {
+
+ Properties parms = new Properties();
+
+ return execute(module,rpc,version, mode,serviceData,parms);
+ }
+
+ public Properties execute(String module, String rpc, String version, String mode, NotifyPolicyEnforcementUpdateOutputBuilder serviceData, Properties parms)
+ throws SvcLogicException {
+ Properties localProp;
+ localProp = MdsalHelper.toProperties(parms, serviceData);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Parameters passed to SLI");
+
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
+
+ LOG.debug(parmName+" = "+parmValue);
+
+ }
+ }
+
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Parameters returned by SLI");
+
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
+
+ LOG.debug(parmName+" = "+parmValue);
+
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
+
+ MdsalHelper.toBuilder(respProps, serviceData);
+
+ return respProps;
+ }
diff --git a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java
index 5e06118f9..986ebb33d 100644
--- a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java
+++ b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java
@@ -963,6 +963,85 @@ public ListenableFuture<RpcResult<GetStatusOutput>> getStatus(
}
+// RPC notifyPolicyEnforcementUpdate
+
+@Override
+public ListenableFuture<RpcResult<NotifyPolicyEnforcementUpdateOutput>> notifyPolicyEnforcementUpdate(
+ NotifyPolicyEnforcementUpdateInput input) {
+ final String svcOperation = "notifyPolicyEnforcementUpdate";
+
+ Properties parms = new Properties();
+ NotifyPolicyEnforcementUpdateOutputBuilder serviceDataBuilder = new NotifyPolicyEnforcementUpdateOutputBuilder();
+
+ LOG.info( "Reached RPC notifyPolicyEnforcementUpdate");
+
+ LOG.info( svcOperation +" called." );
+
+ if(input == null ) {
+ LOG.debug("exiting " +svcOperation+ " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult =
+ RpcResultBuilder.<NotifyPolicyEnforcementUpdateOutput> status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
+ NotifyPolicyEnforcementUpdateInputBuilder inputBuilder = new NotifyPolicyEnforcementUpdateInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try
+ {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
+ {
+ LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try
+ {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ }
+ catch (Exception e)
+ {
+ LOG.error("Caught exception executing service logic for "+ svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ }
+ catch (Exception e)
+ {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for "+svcOperation+" ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for notifyPolicyEnforcementUpdate. " );
+ }
+
+ RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult =
+ RpcResultBuilder.<NotifyPolicyEnforcementUpdateOutput> status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from notifyPolicyEnforcementUpdate ");
+
+ return Futures.immediateFuture(rpcResult);
+}
+
+
}