summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-10-08 13:36:31 +0100
committerliamfallon <liam.fallon@est.tech>2019-03-27 22:35:12 +0000
commitf996ef829249c304550becb0cb57db3efd3baf6a (patch)
treeef2657cd8d44f80b02cfee8db0908a8f9ca7dbf1 /examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
parentcfcffbce70ddc3083e337f18377c0847f7233caa (diff)
Change vCPE example to use POJOs
This review uses POJOs rather than Avro schema to unmarshal and marshal events from and to DMaaP. The POJO classes for interacting with DMaaP have been moved into a common policy module. This review is now ready for full review (finally!). Issue-ID: POLICY-954 Change-Id: Ibb89d8af5b9006821e6a0a756e16bbe3815af15a Signed-off-by: liamfallon <liam.fallon@ericsson.com> Signed-off-by: liamfallon <liam.fallon@est.tech> Signed-off-by: Liam Fallon <liam.fallon@est.tech> Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js')
-rw-r--r--examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js65
1 files changed, 23 insertions, 42 deletions
diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
index 184340288..7d17e25bc 100644
--- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
+++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js
@@ -21,55 +21,36 @@
executor.logger.info(executor.subject.id);
executor.logger.info(executor.inFields);
-var genericDataRecordType = Java.type("org.apache.avro.generic.GenericData.Record");
+var appcRequest = new org.onap.policy.appclcm.LcmRequestWrapper;
+appcRequest.setBody(new org.onap.policy.appclcm.LcmRequest);
+appcRequest.getBody().setCommonHeader(new org.onap.policy.appclcm.LcmCommonHeader);
-var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(
- executor.inFields.get("vnfID").toString());
+appcRequest.setVersion("2.0.0");
+appcRequest.setRpcName("restart");
+appcRequest.setCorrelationId(executor.inFields.get("requestID"));
+appcRequest.setType("request");
-var appcBodyRecord = executor.subject.getOutFieldSchemaHelper("body").createNewInstance();
-var appcBodyRecordSchema = appcBodyRecord.getSchema();
+var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(executor.inFields.get("vnfID").toString());
-var inputRecord = new genericDataRecordType(appcBodyRecordSchema.getField("input").schema());
-var inputRecordRecordSchema = inputRecord.getSchema();
+appcRequest.getBody().getCommonHeader().setTimeStamp(java.time.Instant.now());
+appcRequest.getBody().getCommonHeader().setApiVer("2.00");
+appcRequest.getBody().getCommonHeader().setOriginatorId(executor.inFields.get("requestID").toString());
+appcRequest.getBody().getCommonHeader().setRequestId(executor.inFields.get("requestID"));
+appcRequest.getBody().getCommonHeader().setSubRequestId("1");
+appcRequest.getBody().getCommonHeader().getFlags().put("ttl", "10000");
+appcRequest.getBody().getCommonHeader().getFlags().put("force", "TRUE");
+appcRequest.getBody().getCommonHeader().getFlags().put("mode", "EXCLUSIVE");
-var actionIndentifiersRecord = new genericDataRecordType(inputRecordRecordSchema.getField("action_DasH_identifiers")
- .schema());
+appcRequest.getBody().setAction("Restart");
+appcRequest.getBody().setActionIdentifiers(new java.util.HashMap());
+appcRequest.getBody().getActionIdentifiers().put("vnf-id", executor.inFields.get("vnfID").toString());
-var commonHeaderRecord = new genericDataRecordType(inputRecordRecordSchema.getField("common_DasH_header").schema());
-var commonHeaderRecordSchema = commonHeaderRecord.getSchema();
+executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(), executor.inFields.get("vnfID"));
-var commonHeaderFlagsRecord = new genericDataRecordType(commonHeaderRecordSchema.getField("flags").schema());
+vcpeClosedLoopStatus.put("notification", "OPERATION");
+vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis());
-appcBodyRecord.put("input", inputRecord);
-inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord);
-inputRecord.put("common_DasH_header", commonHeaderRecord);
-commonHeaderRecord.put("flags", commonHeaderFlagsRecord);
-
-inputRecord.put("action", "Restart");
-inputRecord.put("payload", "{}");
-
-actionIndentifiersRecord.put("vnf_DasH_id", executor.inFields.get("vnfID").toString());
-
-commonHeaderRecord.put("timestamp", new Date().toISOString());
-commonHeaderRecord.put("api_DasH_ver", "2.00");
-commonHeaderRecord.put("originator_DasH_id", executor.inFields.get("requestID").toString());
-commonHeaderRecord.put("request_DasH_id", executor.inFields.get("requestID").toString());
-commonHeaderRecord.put("sub_DasH_request_DasH_id", "1");
-
-commonHeaderFlagsRecord.put("ttl", "10000");
-commonHeaderFlagsRecord.put("force", "TRUE");
-commonHeaderFlagsRecord.put("mode", "EXCLUSIVE");
-
-executor.outFields.put("version", "2.0");
-executor.outFields.put("rpc-name", "restart");
-executor.outFields.put("correlation-id", executor.inFields.get("vnfID"));
-executor.outFields.put("type", "request");
-executor.outFields.put("body", appcBodyRecord);
-
-executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(),
- executor.inFields.get("vnfID"));
-
-vcpeClosedLoopStatus.put("notification", "OPERATION: RESTART REQUESTED");
+executor.outFields.put("APPCLCMRequestEvent", appcRequest);
executor.logger.info(executor.outFields);