summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/events/src
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl/events/src')
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java69
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java54
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java62
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java72
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java139
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java38
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java55
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java41
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java40
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java52
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java53
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java124
-rw-r--r--controlloop/common/model-impl/events/src/main/resources/definitions.yaml114
13 files changed, 913 insertions, 0 deletions
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
new file mode 100644
index 000000000..df099ed5e
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+public abstract class ControlLoopEvent implements Serializable {
+
+ private static final long serialVersionUID = 2391252138583119195L;
+
+ public String closedLoopControlName;
+ public String version = "1.0.2";
+ public UUID requestID;
+ public String closedLoopEventClient;
+ public ControlLoopTargetType target_type;
+ public String target;
+ public String from;
+ public String policyScope;
+ public String policyName;
+ public String policyVersion;
+ public ControlLoopEventStatus closedLoopEventStatus;
+
+ public ControlLoopEvent() {
+
+ }
+
+ public ControlLoopEvent(ControlLoopEvent event) {
+ if (event == null) {
+ return;
+ }
+ this.closedLoopControlName = event.closedLoopControlName;
+ this.requestID = event.requestID;
+ this.closedLoopEventClient = event.closedLoopEventClient;
+ this.target_type = event.target_type;
+ this.target = event.target;
+ this.from = event.from;
+ this.policyScope = event.policyScope;
+ this.policyName = event.policyName;
+ this.policyVersion = event.policyVersion;
+ this.closedLoopEventStatus = event.closedLoopEventStatus;
+ }
+
+ public boolean isEventStatusValid() {
+ if (this.closedLoopEventStatus == null) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
new file mode 100644
index 000000000..f74b626cb
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public enum ControlLoopEventStatus {
+ ONSET("ONSET"),
+ ABATED("ABATED")
+ ;
+
+ private String status;
+
+ private ControlLoopEventStatus(String status) {
+ this.status = status;
+ }
+
+ public String toString() {
+ return this.status;
+ }
+
+ public static ControlLoopEventStatus toStatus(String status) {
+ if (ONSET.status.equalsIgnoreCase(status)) {
+ return ONSET;
+ }
+ if (ABATED.status.equalsIgnoreCase(status)) {
+ return ABATED;
+ }
+ //
+ // In case DCAE uses the old abatement
+ //
+ if (status.equalsIgnoreCase("abatement")) {
+ return ABATED;
+ }
+ return null;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
new file mode 100644
index 000000000..8e29b1de3
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.io.Serializable;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+
+public abstract class ControlLoopNotification implements Serializable {
+
+ private static final long serialVersionUID = 7538596984567127915L;
+
+ public String closedLoopControlName;
+ public String version = "1.0.2";
+ public UUID requestID;
+ public String closedLoopEventClient;
+ public ControlLoopTargetType target_type;
+ public String target;
+ public String from;
+ public String policyScope;
+ public String policyName;
+ public String policyVersion;
+ public ControlLoopNotificationType notification;
+ public String message;
+ public ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);;
+ public Integer OPS_CL_timer;
+ public List<ControlLoopOperation> history = new LinkedList<ControlLoopOperation>();
+
+ public ControlLoopNotification() {
+
+ }
+
+ public ControlLoopNotification(ControlLoopEvent event) {
+ this.closedLoopControlName = event.closedLoopControlName;
+ this.requestID = event.requestID;
+ this.closedLoopEventClient = event.closedLoopEventClient;
+ this.target_type = event.target_type;
+ this.target = event.target;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
new file mode 100644
index 000000000..5417baed9
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public enum ControlLoopNotificationType {
+ ACTIVE("ACTIVE"),
+ REJECTED("REJECTED"),
+ OPERATION("OPERATION"),
+ OPERATION_SUCCESS("OPERATION: SUCCESS"),
+ OPERATION_FAILURE("OPERATION: FAILURE"),
+ FINAL_FAILURE("FINAL: FAILURE"),
+ FINAL_SUCCESS("FINAL: SUCCESS"),
+ FINAL_OPENLOOP("FINAL: OPENLOOP")
+ ;
+
+ private String type;
+
+ private ControlLoopNotificationType(String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return this.type;
+ }
+
+ public static ControlLoopNotificationType toType(String type) {
+ if (ACTIVE.toString().equals(type)) {
+ return ACTIVE;
+ }
+ if (REJECTED.toString().equals(type)) {
+ return REJECTED;
+ }
+ if (OPERATION.toString().equals(type)) {
+ return OPERATION;
+ }
+ if (OPERATION_SUCCESS.toString().equals(type)) {
+ return OPERATION_SUCCESS;
+ }
+ if (OPERATION_FAILURE.toString().equals(type)) {
+ return OPERATION_FAILURE;
+ }
+ if (FINAL_FAILURE.toString().equals(type)) {
+ return FINAL_FAILURE;
+ }
+ if (FINAL_SUCCESS.toString().equals(type)) {
+ return FINAL_SUCCESS;
+ }
+ if (FINAL_OPENLOOP.toString().equals(type)) {
+ return FINAL_OPENLOOP;
+ }
+ return null;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
new file mode 100644
index 000000000..ce721b43d
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+public class ControlLoopOperation implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8662706581293017099L;
+
+ public String actor;
+ public String operation;
+ public String target;
+ public Instant start = Instant.now();
+ public Instant end;
+ public String subRequestId;
+ public String outcome;
+ public String message;
+
+ public ControlLoopOperation() {
+
+ }
+
+ public ControlLoopOperation(ControlLoopOperation op) {
+ this.actor = op.actor;
+ this.operation = op.operation;
+ this.target = op.target;
+ this.start = op.start;
+ this.end = op.end;
+ this.subRequestId = op.subRequestId;
+ this.outcome = op.outcome;
+ this.message = op.message;
+ }
+
+ public String toMessage() {
+ return "actor="+actor+",operation="+operation+",target="+target+",subRequestId="+subRequestId;
+ }
+
+ public String toHistory() {
+ return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message;
+ }
+
+ @Override
+ public String toString() {
+ return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
+ + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
+ + message + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((actor == null) ? 0 : actor.hashCode());
+ result = prime * result + ((end == null) ? 0 : end.hashCode());
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((operation == null) ? 0 : operation.hashCode());
+ result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
+ result = prime * result + ((start == null) ? 0 : start.hashCode());
+ result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ControlLoopOperation other = (ControlLoopOperation) obj;
+ if (actor == null) {
+ if (other.actor != null)
+ return false;
+ } else if (!actor.equals(other.actor))
+ return false;
+ if (end == null) {
+ if (other.end != null)
+ return false;
+ } else if (!end.equals(other.end))
+ return false;
+ if (message == null) {
+ if (other.message != null)
+ return false;
+ } else if (!message.equals(other.message))
+ return false;
+ if (operation == null) {
+ if (other.operation != null)
+ return false;
+ } else if (!operation.equals(other.operation))
+ return false;
+ if (outcome == null) {
+ if (other.outcome != null)
+ return false;
+ } else if (!outcome.equals(other.outcome))
+ return false;
+ if (start == null) {
+ if (other.start != null)
+ return false;
+ } else if (!start.equals(other.start))
+ return false;
+ if (subRequestId == null) {
+ if (other.subRequestId != null)
+ return false;
+ } else if (!subRequestId.equals(other.subRequestId))
+ return false;
+ if (target == null) {
+ if (other.target != null)
+ return false;
+ } else if (!target.equals(other.target))
+ return false;
+ return true;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
new file mode 100644
index 000000000..fb3942b63
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.util.UUID;
+
+public class ControlLoopOperationWrapper {
+
+ public UUID requestID;
+ public ControlLoopOperation operation;
+
+ public ControlLoopOperationWrapper() {
+
+ }
+
+ public ControlLoopOperationWrapper(UUID requestID, ControlLoopOperation operation) {
+ this.requestID = requestID;
+ this.operation = operation;
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
new file mode 100644
index 000000000..c8bd1a80c
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public enum ControlLoopTargetType {
+ VM("VM"),
+ VF("VF"),
+ VFC("VFC"),
+ ENODEB("eNodeB")
+ ;
+
+ private String type;
+
+ private ControlLoopTargetType(String type) {
+ this.type = type;
+ }
+
+ public String toString() {
+ return this.type;
+ }
+
+ public static ControlLoopTargetType toType(String type) {
+ if (VM.toString().equals(type)) {
+ return VM;
+ }
+ if (VF.toString().equals(type)) {
+ return VF;
+ }
+ if (VFC.toString().equals(type)) {
+ return VFC;
+ }
+ if (ENODEB.toString().equals(type)) {
+ return ENODEB;
+ }
+ return null;
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
new file mode 100644
index 000000000..aca072eaa
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public class PhysicalControlLoopEvent extends ControlLoopEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7282930271094849487L;
+
+ public PhysicalControlLoopEvent() {
+ }
+
+ public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ }
+
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
new file mode 100644
index 000000000..c904d6740
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+public class PhysicalControlLoopNotification extends ControlLoopNotification {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8105197217140032892L;
+
+ public PhysicalControlLoopNotification() {
+ }
+
+ public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
new file mode 100644
index 000000000..bc3d2beb7
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualControlLoopEvent extends ControlLoopEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5752405682246066226L;
+ public Instant closedLoopAlarmStart;
+ public Instant closedLoopAlarmEnd;
+ public Map<String, String> AAI = new HashMap<String, String>();
+
+ public VirtualControlLoopEvent() {
+ }
+
+ public VirtualControlLoopEvent(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.AAI != null) {
+ this.AAI = new HashMap<String, String>(event.AAI);
+ }
+ this.closedLoopAlarmStart = event.closedLoopAlarmStart;
+ this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
new file mode 100644
index 000000000..f97c609c7
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+
+public class VirtualControlLoopNotification extends ControlLoopNotification {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5354756047932144017L;
+
+ public Map<String, String> AAI = new HashMap<String, String>();
+ public Instant closedLoopAlarmStart;
+ public Instant closedLoopAlarmEnd;
+
+ public VirtualControlLoopNotification() {
+ }
+
+ public VirtualControlLoopNotification(VirtualControlLoopEvent event) {
+ super(event);
+ if (event == null) {
+ return;
+ }
+ if (event.AAI != null) {
+ this.AAI = new HashMap<String, String>(event.AAI);
+ }
+ this.closedLoopAlarmStart = event.closedLoopAlarmStart;
+ this.closedLoopAlarmEnd = event.closedLoopAlarmEnd;
+ }
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
new file mode 100644
index 000000000..a45947733
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.util;
+
+import java.lang.reflect.Type;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import org.onap.policy.controlloop.ControlLoopNotificationType;
+import org.onap.policy.controlloop.ControlLoopTargetType;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+public final class Serialization {
+
+ public static class notificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+
+ @Override
+ public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) throws JsonParseException {
+ return ControlLoopNotificationType.toType(json.getAsString());
+ }
+
+ }
+
+ public static class targetTypeAdapter implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> {
+
+ @Override
+ public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc,
+ JsonSerializationContext context) {
+ return new JsonPrimitive(src.toString());
+ }
+
+ @Override
+ public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT,
+ JsonDeserializationContext context) throws JsonParseException {
+ return ControlLoopTargetType.toType(json.getAsString());
+ }
+
+ }
+
+ public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ return null;
+ }
+
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
+
+ public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+ final static public Gson gson = new GsonBuilder().disableHtmlEscaping()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .create();
+
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter())
+ .create();
+
+}
diff --git a/controlloop/common/model-impl/events/src/main/resources/definitions.yaml b/controlloop/common/model-impl/events/src/main/resources/definitions.yaml
new file mode 100644
index 000000000..cbe422b82
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/main/resources/definitions.yaml
@@ -0,0 +1,114 @@
+AAI:
+ type: object
+ properties:
+ AICVServerSelfLink:
+ type: string
+ VNF_NAME:
+ type: string
+ AICVMID:
+ type: string
+ AICTenantID:
+ type: string
+ LOC_ID:
+ type: string
+ in_maint:
+ type: boolean
+ AICIdentity:
+ type: string
+ Prov_status:
+ type: string
+ OAM_IPV4:
+ type: string
+ is_closed_loop_disabled:
+ type: boolean
+ VM_NAME:
+ type: string
+ OAM_IPV6:
+ type: string
+ required:
+ - AICVServerSelfLink
+ - AICIdentity
+ - is_closed_loop_disabled
+ControlLoop:
+ type: object
+ description: Common fields for control loop events and notifications
+ properties:
+ closedLoopControlName:
+ type: string
+ description: A UNIQUE string identifying the Closed Loop ID this event is for. There are no semantics behind this string.
+ serviceInstance:
+ $ref: '../../../com.att.ecomp.policy.asdc/src/main/resources/definitions.yaml#/serviceInstance'
+ resourceInstance:
+ $ref: '../../../com.att.ecomp.policy.asdc/src/main/resources/definitions.yaml#/resourceInstance'
+ requestID:
+ type: string
+ description: This is required via ECOMP Platform Logging Requirements.
+ pattern: /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/
+ triggerID:
+ type: string
+ description: ID that maps back to Highland Park. Concatenation between eventID and firstEPOCH.
+ triggerSourceName:
+ type: string
+ description: pulled from eventSourceName of trigger H.P. alarm. The contents of this field should also be contained in the AAI Json sub-tag (see below).
+ closedLoopAlarmStart:
+ type: string
+ description: firstEpoch. UTC Timestamp when this event was detected by DCAE. Conform to ECOMP Logging requirements.
+ closedLoopAlarmEnd:
+ type: string
+ description: lastEpoch. UTC Timestamp when this event was detected as cleared by DCAE. Conform to ECOMP Logging requirements.
+ closedLoopEventClient:
+ type: string
+ description: Open DCAE sub-system that detected the event and published this event message.
+ target:
+ type: string
+ description: The target entity that is being administered. This could be VM_NAME, VNF_NAME, etc. This should map to a field name in the AAI sub-tag shown below.
+ AAI:
+ $ref: '#/AAI'
+ from:
+ type: string
+ policyScope:
+ type: string
+ policyName:
+ type: string
+ policyVersion:
+ type: string
+ required:
+ - closedLoopControlName
+ - requestID
+ - triggerID
+ - triggerSourceName
+ - closedLoopAlarmStart
+ - closedLoopEventClient
+ - target
+ - AAI
+ - from
+ - policyScope
+ - policyName
+ - policyVersion
+Event:
+ allOf:
+ - $ref: '#/ControlLoop'
+ - properties:
+ closedLoopEventStatus:
+ type: string
+ description: The status for the event within Open DCAE. A value of “ONSET” indicates the event has been encountered. “ABATED” indicates the event has been abated.
+ valid_values:
+ - ONSET
+ - ABATEMENT
+ - required:
+ - closedLoopEventStatus
+Notification:
+ - $ref: '#/ControlLoop'
+ - properties:
+ notification:
+ type: string
+ notificationTime:
+ type: string
+ message:
+ type: string
+ OPS_CL_timer:
+ type: int
+ - required:
+ - notification
+ - notificationTime
+ - OPS_CL_timer