aboutsummaryrefslogtreecommitdiffstats
path: root/vfwsim/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:49:32 -0500
committerPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:52:21 -0500
commita6557b0429dbe94a3806be237d9ba5aa7c4b183c (patch)
treee84136dc5aeb5b1c4ec1065e99c45a5084f295c6 /vfwsim/src/main/java
parenta91087731b18dab019621d99827cf1f4bcb95d10 (diff)
Initial OpenECOMP policy/drools-applications commt
Change-Id: I21c0edbf9b7f18dccd6bd4fe2a3287f3a68e6de0 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'vfwsim/src/main/java')
-rw-r--r--vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java97
-rw-r--r--vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java257
2 files changed, 354 insertions, 0 deletions
diff --git a/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java
new file mode 100644
index 000000000..d135e79bc
--- /dev/null
+++ b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/AppcResponseEvent.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * vFW simulator
+ * ================================================================================
+ * 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.openecomp.policy.sim.vfw;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+import org.openecomp.policy.appc.CommonHeader;
+import org.openecomp.policy.appc.Response;
+import org.openecomp.policy.appc.ResponseStatus;
+
+public class AppcResponseEvent implements Serializable {
+
+ private static final long serialVersionUID = 6661836261200950007L;
+
+ public final String requestID;
+ public final String appcTopic;
+ public final int code;
+
+ public AppcResponseEvent(String requestID, String appcTopic, int code) {
+ this.requestID = requestID;
+ this.appcTopic = appcTopic;
+ this.code = code;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((appcTopic == null) ? 0 : appcTopic.hashCode());
+ result = prime * result + code;
+ result = prime * result + ((requestID == null) ? 0 : requestID.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;
+ AppcResponseEvent other = (AppcResponseEvent) obj;
+ if (appcTopic == null) {
+ if (other.appcTopic != null)
+ return false;
+ } else if (!appcTopic.equals(other.appcTopic))
+ return false;
+ if (code != other.code)
+ return false;
+ if (requestID == null) {
+ if (other.requestID != null)
+ return false;
+ } else if (!requestID.equals(other.requestID))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "AppcResponseEvent [requestID=" + requestID + ", appcTopic=" + appcTopic + ", code=" + code + "]";
+ }
+
+ public static Response toResponse(String requestId, int code) {
+ Response response = new Response();
+
+ CommonHeader commonHeader = new CommonHeader();
+ commonHeader.RequestID = UUID.fromString(requestId);
+ response.CommonHeader = commonHeader;
+
+ ResponseStatus responseStatus = new ResponseStatus();
+ responseStatus.Code = responseStatus.Code = code;
+ response.Status = responseStatus;
+
+ return response;
+ }
+
+}
diff --git a/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java
new file mode 100644
index 000000000..5c371316e
--- /dev/null
+++ b/vfwsim/src/main/java/org/openecomp/policy/sim/vfw/OnsetEvent.java
@@ -0,0 +1,257 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * vFW simulator
+ * ================================================================================
+ * 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.openecomp.policy.sim.vfw;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.UUID;
+
+import org.openecomp.policy.controlloop.ControlLoopEventStatus;
+import org.openecomp.policy.controlloop.ControlLoopTargetType;
+import org.openecomp.policy.controlloop.VirtualControlLoopEvent;
+
+public class OnsetEvent implements Serializable {
+
+ private static final long serialVersionUID = -7904064194557621526L;
+
+ public static String DEFAULT_CLOSEDLOOP_CONTROL_NAME = "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8";
+ public static String DEFAULT_CLOSEDLOOP_EVENT_CLIENT = "tca.instance00001";
+ public static String DEFAULT_REQUEST_ID = "664be3d2-6c12-4f4b-a3e7-c349acced200";
+ public static String DEFAULT_TARGET = "generic-vnf.vnf-id";
+ public static String DEFAULT_TARGET_TYPE = "VF";
+ public static String DEFAULT_FROM = "DCAE";
+
+ public static String DEFAULT_AAI_VNF_ID_NAME = DEFAULT_TARGET;
+ public static String DEFAULT_AAI_VNF_ID_VALUE = "fw0001vm001fw001";
+
+ public static String DEFAULT_AAI_VSERVER_NAME = "vserver.vserver-name";
+ public static String DEFAULT_AAI_VSERVER_VALUE = "vserver-name-16102016-aai3255-data-11-1";
+
+ public String closedLoopControlName = DEFAULT_CLOSEDLOOP_CONTROL_NAME;
+ public String closedLoopEventClient = DEFAULT_CLOSEDLOOP_EVENT_CLIENT;
+ public String requestID = UUID.randomUUID().toString();
+ public String target = DEFAULT_TARGET;
+ public String targetType = DEFAULT_TARGET_TYPE;
+ public String aaIVnfId = DEFAULT_AAI_VNF_ID_VALUE;
+ public String aaIServerName = DEFAULT_AAI_VSERVER_VALUE;
+ public String from = "DCAE";
+
+ public String dcaeTopic = "DCAE-CL-EVENT";
+ public String appcTopic = "APPC-CL";
+ public int appcResponseCode = 100;
+
+ public OnsetEvent() {
+ super();
+ }
+
+ public OnsetEvent(String closedLoopControlName) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+ }
+
+ public OnsetEvent(String closedLoopControlName, String dcaeTopic, String appcTopic, int code) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+
+ if (dcaeTopic != null && !dcaeTopic.isEmpty())
+ this.dcaeTopic = dcaeTopic;
+
+ if (appcTopic != null && !appcTopic.isEmpty())
+ this.appcTopic = appcTopic;
+
+ this.appcResponseCode = code;
+ }
+
+ public OnsetEvent(String closedLoopControlName, String requestID, String dcaeTopic, String appcTopic, int code) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+
+ if (requestID != null)
+ this.requestID = requestID;
+
+ if (dcaeTopic != null && !dcaeTopic.isEmpty())
+ this.dcaeTopic = dcaeTopic;
+
+ if (appcTopic != null && !appcTopic.isEmpty())
+ this.appcTopic = appcTopic;
+
+ this.appcResponseCode = code;
+ }
+
+ public OnsetEvent(String closedLoopControlName, String closedLoopEventClient,
+ String requestID, String target,
+ String targetType, String aaIVnfId,
+ String aaIServerName, String from,
+ String dcaeTopic, String appcTopic,
+ int code) {
+ super();
+
+ if (closedLoopControlName != null && !closedLoopControlName.isEmpty())
+ this.closedLoopControlName = closedLoopControlName;
+
+ if (closedLoopEventClient != null && !closedLoopEventClient.isEmpty())
+ this.closedLoopEventClient = closedLoopEventClient;
+
+ if (requestID != null)
+ this.requestID = requestID;
+
+ if (target != null && !target.isEmpty())
+ this.target = target;
+
+ if (targetType != null && !targetType.isEmpty())
+ this.targetType = targetType;
+
+ if (aaIVnfId != null && !aaIVnfId.isEmpty())
+ this.aaIVnfId = aaIVnfId;
+
+ if (aaIServerName != null && !aaIServerName.isEmpty())
+ this.aaIServerName = aaIServerName;
+
+ if (from != null && !from.isEmpty())
+ this.from = from;
+
+ if (dcaeTopic != null && !dcaeTopic.isEmpty())
+ this.dcaeTopic = dcaeTopic;
+
+ if (appcTopic != null && !appcTopic.isEmpty())
+ this.appcTopic = appcTopic;
+
+ this.appcResponseCode = code;
+ }
+
+ public VirtualControlLoopEvent toDcaeOnset() {
+
+ VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
+
+ onsetEvent.closedLoopControlName = this.closedLoopControlName;
+ onsetEvent.requestID = UUID.fromString(this.requestID);
+ onsetEvent.closedLoopEventClient = this.closedLoopEventClient;
+ onsetEvent.target_type = ControlLoopTargetType.valueOf(this.targetType);
+ onsetEvent.target = this.target;
+ onsetEvent.from = this.from;
+ onsetEvent.closedLoopAlarmStart = Instant.now();
+ onsetEvent.AAI = new HashMap<String, String>();
+ onsetEvent.AAI.put(this.target, this.aaIVnfId);
+ onsetEvent.AAI.put(DEFAULT_AAI_VSERVER_NAME, "vserver-name-16102016-aai3255-data-11-1");
+ onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ return onsetEvent;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((aaIServerName == null) ? 0 : aaIServerName.hashCode());
+ result = prime * result + ((aaIVnfId == null) ? 0 : aaIVnfId.hashCode());
+ result = prime * result + appcResponseCode;
+ result = prime * result + ((appcTopic == null) ? 0 : appcTopic.hashCode());
+ result = prime * result + ((closedLoopControlName == null) ? 0 : closedLoopControlName.hashCode());
+ result = prime * result + ((closedLoopEventClient == null) ? 0 : closedLoopEventClient.hashCode());
+ result = prime * result + ((dcaeTopic == null) ? 0 : dcaeTopic.hashCode());
+ result = prime * result + ((from == null) ? 0 : from.hashCode());
+ result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ result = prime * result + ((targetType == null) ? 0 : targetType.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;
+ OnsetEvent other = (OnsetEvent) obj;
+ if (aaIServerName == null) {
+ if (other.aaIServerName != null)
+ return false;
+ } else if (!aaIServerName.equals(other.aaIServerName))
+ return false;
+ if (aaIVnfId == null) {
+ if (other.aaIVnfId != null)
+ return false;
+ } else if (!aaIVnfId.equals(other.aaIVnfId))
+ return false;
+ if (appcResponseCode != other.appcResponseCode)
+ return false;
+ if (appcTopic == null) {
+ if (other.appcTopic != null)
+ return false;
+ } else if (!appcTopic.equals(other.appcTopic))
+ return false;
+ if (closedLoopControlName == null) {
+ if (other.closedLoopControlName != null)
+ return false;
+ } else if (!closedLoopControlName.equals(other.closedLoopControlName))
+ return false;
+ if (closedLoopEventClient == null) {
+ if (other.closedLoopEventClient != null)
+ return false;
+ } else if (!closedLoopEventClient.equals(other.closedLoopEventClient))
+ return false;
+ if (dcaeTopic == null) {
+ if (other.dcaeTopic != null)
+ return false;
+ } else if (!dcaeTopic.equals(other.dcaeTopic))
+ return false;
+ if (from == null) {
+ if (other.from != null)
+ return false;
+ } else if (!from.equals(other.from))
+ return false;
+ if (requestID == null) {
+ if (other.requestID != null)
+ return false;
+ } else if (!requestID.equals(other.requestID))
+ return false;
+ if (target == null) {
+ if (other.target != null)
+ return false;
+ } else if (!target.equals(other.target))
+ return false;
+ if (targetType == null) {
+ if (other.targetType != null)
+ return false;
+ } else if (!targetType.equals(other.targetType))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "OnsetEvent [closedLoopControlName=" + closedLoopControlName + ", closedLoopEventClient="
+ + closedLoopEventClient + ", requestID=" + requestID + ", target=" + target + ", targetType="
+ + targetType + ", aaIVnfId=" + aaIVnfId + ", aaIServerName=" + aaIServerName + ", from=" + from
+ + ", dcaeTopic=" + dcaeTopic + ", appcTopic=" + appcTopic + ", appcResponseCode=" + appcResponseCode
+ + "]";
+ }
+
+}