summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl')
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java14
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java43
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java19
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java16
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java4
-rw-r--r--controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java3
-rw-r--r--controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java109
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java3
-rw-r--r--controlloop/common/model-impl/so/pom.xml6
-rw-r--r--controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java12
-rw-r--r--controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java3
-rw-r--r--controlloop/common/model-impl/vfc/pom.xml6
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java8
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java4
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java4
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java6
16 files changed, 174 insertions, 86 deletions
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java
index d2e2d710f..46a4e5080 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java
@@ -27,10 +27,22 @@ import com.google.gson.annotations.SerializedName;
public class AAIGETResponse implements Serializable {
/**
- *
+ * define common fields for AAIGETVnfResponse and AAIGETVserverResponse
*/
private static final long serialVersionUID = 7311418432051756161L;
+ @SerializedName("in-maint")
+ public String inMaint;
+
+ @SerializedName("is-closed-loop-disabled")
+ public String isClosedLoopDisabled;
+
+ @SerializedName("model-invariant-id")
+ public String modelInvariantId;
+
+ @SerializedName("resource-version")
+ public String resourceVersion;
+
@SerializedName("relationship-list")
public RelationshipList relationshipList;
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java
deleted file mode 100644
index a641383df..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * aai
- * ================================================================================
- * 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.aai;
-
-import java.io.Serializable;
-import java.util.UUID;
-import org.onap.policy.aai.AAIGETResponse;
-
-public class AAIGETResponseWrapper implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 9167822470867043968L;
-
- public UUID requestID;
- public AAIGETResponse aairesponse;
-
- public AAIGETResponseWrapper() {
-
- }
-
- public AAIGETResponseWrapper(UUID requestID, AAIGETResponse aairesponse){
- this.requestID = requestID;
- this.aairesponse = aairesponse;
- }
-} \ No newline at end of file
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java
index 24361c7f6..a95502cca 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java
@@ -24,13 +24,13 @@ import java.io.Serializable;
import com.google.gson.annotations.SerializedName;
-public class AAIGETVnfResponse implements Serializable {
+public class AAIGETVnfResponse extends AAIGETResponse implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6247505944905898870L;
-
+
@SerializedName("vnf-id")
public String vnfID;
@@ -46,21 +46,6 @@ public class AAIGETVnfResponse implements Serializable {
@SerializedName("orchestration-status")
public String orchestrationStatus;
- @SerializedName("in-maint")
- public String inMaint;
-
- @SerializedName("is-closed-loop-disabled")
- public String isClosedLoopDisabled;
-
- @SerializedName("resource-version")
- public String resourceVersion;
-
- @SerializedName("model-invariant-id")
- public String modelInvariantId;
-
- @SerializedName("relationship-list")
- public RelationshipList relationshipList;
-
public AAIGETVnfResponse() {
}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java
index 8ab94e9a4..527bbe528 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java
@@ -24,7 +24,7 @@ import java.io.Serializable;
import com.google.gson.annotations.SerializedName;
-public class AAIGETVserverResponse implements Serializable {
+public class AAIGETVserverResponse extends AAIGETResponse implements Serializable {
/**
*
@@ -43,20 +43,6 @@ public class AAIGETVserverResponse implements Serializable {
@SerializedName("vserver-selflink")
public String vserverSelflink;
- @SerializedName("in-maint")
- public String inMaint;
-
- @SerializedName("is-closed-loop-disabled")
- public String isClosedLoopDisabled;
-
- @SerializedName("resource-version")
- public String resourceVersion;
-
- @SerializedName("model-invariant-id")
- public String modelInvariantId;
-
- public RelationshipList relationshipList;
-
public AAIGETVserverResponse() {
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
index be7a66ada..3afde0a06 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
@@ -42,9 +42,13 @@ public final class Serialization {
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ private Serialization(){
+ }
+
public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
+ @Override
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
throws JsonParseException {
try {
diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java
index 003dc573b..82f374868 100644
--- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java
+++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponse.java
@@ -37,7 +37,7 @@ public class LCMResponse implements Serializable {
private String payload;
public LCMResponse() {
-
+ // EMPTY
}
/**
@@ -51,7 +51,6 @@ public class LCMResponse implements Serializable {
this.commonHeader = new LCMCommonHeader(request.getCommonHeader());
String requestPayload = request.getPayload();
if (requestPayload != null) {
- // this.payload.putAll(request.payload);
this.payload = requestPayload;
}
}
diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java
new file mode 100644
index 000000000..14dee480b
--- /dev/null
+++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LCMResponseTest.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appclcm
+ * ================================================================================
+ * 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.appclcm;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class LCMResponseTest {
+
+ private static final String PAYLOAD = "payload";
+
+ @Test
+ public void testHashCode() {
+ LCMResponse response = new LCMResponse();
+ assertTrue(response.hashCode() != 0);
+ response.setCommonHeader(new LCMCommonHeader());
+ assertTrue(response.hashCode() != 0);
+ response.setPayload(PAYLOAD);
+ assertTrue(response.hashCode() != 0);
+ response.setStatus(null);
+ assertTrue(response.hashCode() != 0);
+ }
+
+ @Test
+ public void testLCMResponse() {
+ LCMResponse response = new LCMResponse();
+ assertNull(response.getCommonHeader());
+ assertNull(response.getPayload());
+ assertNotNull(response.getStatus());
+ }
+
+ @Test
+ public void testToString() {
+ LCMResponse response = new LCMResponse();
+ assertFalse(response.toString().isEmpty());
+ }
+
+ @Test
+ public void testEqualsObject() {
+ LCMResponse response = new LCMResponse();
+ assertTrue(response.equals(response));
+ assertFalse(response.equals(null));
+ assertFalse(response.equals(new Object()));
+
+ LCMResponse response2 = new LCMResponse();
+ assertTrue(response.equals(response2));
+
+ response.setCommonHeader(new LCMCommonHeader());
+ assertFalse(response.equals(response2));
+ response2.setCommonHeader(response.getCommonHeader());
+ assertTrue(response.equals(response2));
+
+ response.setPayload(PAYLOAD);
+ assertFalse(response.equals(response2));
+ response2.setPayload(response.getPayload());
+ assertTrue(response.equals(response2));
+
+ response.setCommonHeader(null);
+ assertFalse(response.equals(response2));
+ response2.setCommonHeader(null);
+ assertTrue(response.equals(response2));
+
+ response.setPayload(null);
+ assertFalse(response.equals(response2));
+ response2.setPayload(response.getPayload());
+ assertTrue(response.equals(response2));
+
+ response.setStatus(null);
+ assertFalse(response.equals(response2));
+ response2.setStatus(response.getStatus());
+ assertTrue(response.equals(response2));
+
+ LCMResponseStatus status = new LCMResponseStatus();
+ status.setCode(5);
+ response.setStatus(status);
+ response2.setStatus(new LCMResponseStatus());
+ assertFalse(response.equals(response2));
+ }
+
+ @Test
+ public void testResponseRequest() {
+ LCMRequest request = new LCMRequest();
+ request.setCommonHeader(new LCMCommonHeader());
+ request.setPayload(PAYLOAD);
+
+ LCMResponse response = new LCMResponse(request);
+
+ assertTrue(response.getPayload().equals(PAYLOAD));
+ }
+
+}
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
index c51fe3980..ed726201a 100644
--- 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
@@ -30,7 +30,8 @@ public enum ControlLoopEventStatus {
private ControlLoopEventStatus(String status) {
this.status = status;
}
-
+
+ @Override
public String toString() {
return this.status;
}
diff --git a/controlloop/common/model-impl/so/pom.xml b/controlloop/common/model-impl/so/pom.xml
index faeb12130..a18030eb7 100644
--- a/controlloop/common/model-impl/so/pom.xml
+++ b/controlloop/common/model-impl/so/pom.xml
@@ -53,5 +53,11 @@
<artifactId>rest</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
index f967414c1..2f5ffdc3e 100644
--- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
+++ b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import org.onap.policy.so.util.Serialization;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
import org.drools.core.WorkingMemory;
@@ -134,9 +135,14 @@ public final class SOManager {
@Override
public void run()
{
- String serverRoot = "http://localhost:6667"; // TODO
- String username = "username"; // TODO
- String password = "password"; // TODO
+
+ /*
+ * TODO: What if these are null?
+ */
+ String serverRoot = PolicyEngine.manager.getEnvironmentProperty("so.url");
+ String username = PolicyEngine.manager.getEnvironmentProperty("so.username");
+ String password = PolicyEngine.manager.getEnvironmentProperty("so.password");
+
String url = serverRoot + "/serviceInstances/v2/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModulesHTTPS/1.1";
String auth = username + ":" + password;
diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java
index e64991d94..9bfe2ffe6 100644
--- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java
+++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java
@@ -25,6 +25,9 @@ import com.google.gson.GsonBuilder;
public final class Serialization {
+ private Serialization(){
+ }
+
final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
.setPrettyPrinting()
// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter())
diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml
index db86345e8..7672b1bc9 100644
--- a/controlloop/common/model-impl/vfc/pom.xml
+++ b/controlloop/common/model-impl/vfc/pom.xml
@@ -45,5 +45,11 @@
<artifactId>rest</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ <version>6.5.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
index 4797ab906..5cb6d6624 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -21,6 +21,7 @@ package org.onap.policy.vfc;
import java.util.HashMap;
import java.util.Map;
+import org.drools.core.WorkingMemory;
import org.onap.policy.vfc.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
@@ -35,9 +36,11 @@ public final class VFCManager implements Runnable {
private String username;
private String password;
private VFCRequest vfcRequest;
+ WorkingMemory workingMem;
private static final Logger logger = LoggerFactory.getLogger(VFCManager.class);
- public VFCManager(VFCRequest request) {
+ public VFCManager(WorkingMemory wm, VFCRequest request) {
+ workingMem = wm;
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
// TODO: Following code is a placeholder, needs to be updated
@@ -83,6 +86,7 @@ public final class VFCManager implements Runnable {
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
+ responseGet.requestId = vfcRequest.requestId.toString();
body = Serialization.gsonPretty.toJson(responseGet);
logger.debug("Response to VFC Heal get:");
logger.debug(body);
@@ -91,6 +95,7 @@ public final class VFCManager implements Runnable {
if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") ||
responseGet.responseDescriptor.status.equalsIgnoreCase("error")) {
logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status);
+ workingMem.insert(responseGet);
break;
}
}
@@ -102,6 +107,7 @@ public final class VFCManager implements Runnable {
&& (responseGet.responseDescriptor.status != null)
&& (!responseGet.responseDescriptor.status.isEmpty())) {
logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
+ workingMem.insert(responseGet);
}
} catch (JsonSyntaxException e) {
logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
index 9e3a77a2b..89c9b08ff 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
@@ -19,14 +19,16 @@
package org.onap.policy.vfc;
import java.io.Serializable;
+import java.util.UUID;
import com.google.gson.annotations.SerializedName;
public class VFCRequest implements Serializable {
private static final long serialVersionUID = 3736300970326332512L;
- // This field is not serialized and not part of JSON
+ // These fields are not serialized and not part of JSON
public transient String nsInstanceId;
+ public transient UUID requestId;
@SerializedName("healVnfData")
public VFCHealRequest healRequest;
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
index 775d78f1d..5d6efa0ce 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
@@ -30,7 +30,9 @@ public class VFCResponse implements Serializable {
public String jobId;
@SerializedName("responseDescriptor")
- VFCResponseDescriptor responseDescriptor;
+ public VFCResponseDescriptor responseDescriptor;
+
+ public transient String requestId;
public VFCResponse() {
}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
index 9bf77c57c..62c61a7f6 100644
--- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
@@ -27,7 +27,7 @@ public class VFCResponseDescriptor implements Serializable {
private static final long serialVersionUID = 6827782899144150158L;
@SerializedName("progress")
- public String progress;
+ String progress;
@SerializedName("status")
String status;
@@ -47,4 +47,8 @@ public class VFCResponseDescriptor implements Serializable {
public VFCResponseDescriptor() {
}
+ public String getStatus() {
+ return status;
+ }
+
}