summaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2017-08-23 07:52:20 -0700
committerRitu Sood <ritu.sood@intel.com>2017-08-24 06:33:57 -0700
commit1c4fcf40b4cd33454bb57bde1e82a3819cb6ccff (patch)
tree1e0ea36076cf9249c2a66ef9eb3d331b10cb9493 /controlloop
parent945627aef4645a9a696aeb2150669e43aae9f98a (diff)
Add VFC integration code
This patch adds VFC Actor code and updates drool template for VFC. This is WIP patch. There are two opens for this patch that are still in discussion 1) AA&I fields in onset event 2) VFC URL, username and password Issue-ID: POLICY-57 Change-Id: Idc1d1fada295fa1c2e563ba37dd359f7b5c59f87 Signed-off-by: Ritu Sood <ritu.sood@intel.com>
Diffstat (limited to 'controlloop')
-rw-r--r--controlloop/common/actors/actor.vfc/pom.xml32
-rw-r--r--controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java94
-rw-r--r--controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor1
-rw-r--r--controlloop/common/actors/pom.xml1
-rw-r--r--controlloop/common/eventmanager/pom.xml12
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java8
-rw-r--r--controlloop/common/model-impl/pom.xml1
-rw-r--r--controlloop/common/model-impl/vfc/pom.xml49
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java40
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java39
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java42
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java107
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java38
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java38
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java50
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java36
-rw-r--r--controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java30
-rw-r--r--controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java84
-rw-r--r--controlloop/packages/artifacts/pom.xml6
-rw-r--r--controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl14
20 files changed, 717 insertions, 5 deletions
diff --git a/controlloop/common/actors/actor.vfc/pom.xml b/controlloop/common/actors/actor.vfc/pom.xml
new file mode 100644
index 000000000..de6f05841
--- /dev/null
+++ b/controlloop/common/actors/actor.vfc/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actors</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>actor.vfc</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actorServiceProvider</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>vfc</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>events</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
new file mode 100644
index 000000000..ffada0a81
--- /dev/null
+++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.actor.vfc;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.vfc.VFCRequest;
+import org.onap.policy.vfc.VFCHealRequest;
+import org.onap.policy.vfc.VFCHealAdditionalParams;
+import org.onap.policy.vfc.VFCHealActionVmInfo;
+import org.onap.policy.controlloop.ControlLoopOperation;
+import org.onap.policy.controlloop.policy.Policy;
+
+import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+
+public class VFCActorServiceProvider implements Actor {
+
+ private static final ImmutableList<String> recipes = ImmutableList.of("Restart");
+ private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
+ .put("Restart", ImmutableList.of("VM"))
+ .build();
+
+ @Override
+ public String actor() {
+ return "VFC";
+ }
+
+ @Override
+ public List<String> recipes() {
+ return ImmutableList.copyOf(recipes);
+ }
+
+ @Override
+ public List<String> recipeTargets(String recipe) {
+ return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList()));
+ }
+
+ @Override
+ public List<String> recipePayloads(String recipe) {
+ return Collections.emptyList();
+ }
+
+ public static VFCRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
+
+ // Construct an VFC request
+ VFCRequest request = new VFCRequest();
+ // TODO: Verify service-instance-id is part of onset event
+ request.nsInstanceId = onset.AAI.get("service-instance.service-instance-id");
+ request.healRequest = new VFCHealRequest();
+ request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id");
+ request.healRequest.cause = operation.message;
+
+ request.healRequest.additionalParams = new VFCHealAdditionalParams();
+ switch (policy.getRecipe()) {
+ case "Restart":
+ // TODO: check target??
+ request.healRequest.additionalParams.action = "restartvm";
+ request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
+ // TODO: Verify vserver-id and vserver-name is part of onset event
+ request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id");
+ request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name");
+ break;
+ default:
+ //TODO: default
+ break;
+ }
+ return request;
+ }
+
+
+}
diff --git a/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor
new file mode 100644
index 000000000..3ccac9949
--- /dev/null
+++ b/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor
@@ -0,0 +1 @@
+org.onap.policy.controlloop.actor.vfc.APPCActorServiceProvider
diff --git a/controlloop/common/actors/pom.xml b/controlloop/common/actors/pom.xml
index a00a3af52..e99fbb09f 100644
--- a/controlloop/common/actors/pom.xml
+++ b/controlloop/common/actors/pom.xml
@@ -14,6 +14,7 @@
<modules>
<module>actorServiceProvider</module>
<module>actor.appc</module>
+ <module>actor.vfc</module>
<module>actor.mso</module>
<module>actor.test</module>
</modules>
diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml
index efe7b3487..b33763b12 100644
--- a/controlloop/common/eventmanager/pom.xml
+++ b/controlloop/common/eventmanager/pom.xml
@@ -40,6 +40,12 @@
<version>1.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>actor.vfc</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>guard</artifactId>
@@ -58,6 +64,12 @@
<version>1.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>vfc</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index f552cc549..0df58be06 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -37,6 +37,7 @@ import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.actor.appc.APPCActorServiceProvider;
+import org.onap.policy.controlloop.actor.vfc.VFCActorServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -132,7 +133,7 @@ public class ControlLoopOperationManager implements Serializable {
break;
case "SDNO":
break;
- case "SDNR":
+ case "VFC":
break;
default:
throw new ControlLoopException("ControlLoopEventManager: policy has an unknown actor.");
@@ -212,6 +213,11 @@ public class ControlLoopOperationManager implements Serializable {
//
System.out.println("We are not supporting MSO actor in the latest release.");
return null;
+ case "VFC":
+ this.operationRequest = VFCActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy);
+ this.currentOperation = operation;
+ return operationRequest;
+
}
return null;
}
diff --git a/controlloop/common/model-impl/pom.xml b/controlloop/common/model-impl/pom.xml
index 94c3f345a..5d18e4916 100644
--- a/controlloop/common/model-impl/pom.xml
+++ b/controlloop/common/model-impl/pom.xml
@@ -40,6 +40,7 @@
<module>rest</module>
<module>sdc</module>
<module>trafficgenerator</module>
+ <module>vfc</module>
</modules>
diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml
new file mode 100644
index 000000000..db86345e8
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/pom.xml
@@ -0,0 +1,49 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2017 Intel Corp. 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=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>vfc</artifactId>
+
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>model-impl</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java
new file mode 100644
index 000000000..b2535e3af
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.google.gson.annotations.SerializedName;
+
+public class VFCHealActionVmInfo implements Serializable {
+
+ private static final long serialVersionUID = 3208673205100673119L;
+
+ @SerializedName("vmid")
+ public String vmid;
+
+ @SerializedName("vmname")
+ public String vmname;
+
+
+ public VFCHealActionVmInfo() {
+ }
+
+}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java
new file mode 100644
index 000000000..a65ad8aac
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.google.gson.annotations.SerializedName;
+
+public class VFCHealAdditionalParams implements Serializable {
+
+ private static final long serialVersionUID = 2656694137285096191L;
+
+ @SerializedName("action")
+ public String action;
+
+ @SerializedName("actionvminfo")
+ public VFCHealActionVmInfo actionInfo;
+
+ public VFCHealAdditionalParams() {
+ }
+
+}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java
new file mode 100644
index 000000000..f7fc891c0
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.google.gson.annotations.SerializedName;
+
+public class VFCHealRequest implements Serializable {
+
+ private static final long serialVersionUID = -7341931593089709247L;
+
+ @SerializedName("vnfInstanceId")
+ public String vnfInstanceId;
+
+ @SerializedName("cause")
+ public String cause;
+
+ @SerializedName("additionalParams")
+ public VFCHealAdditionalParams additionalParams;
+
+ public VFCHealRequest() {
+ }
+
+}
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
new file mode 100644
index 000000000..44f9905b2
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.policy.vfc.util.Serialization;
+import org.onap.policy.rest.RESTManager;
+import org.onap.policy.rest.RESTManager.Pair;
+
+import com.google.gson.JsonSyntaxException;
+
+public final class VFCManager implements Runnable {
+
+ private String vfcUrlBase;
+ private String username;
+ private String password;
+ private VFCRequest vfcRequest;
+
+ public VFCManager(VFCRequest request) {
+ vfcRequest = request;
+ // TODO: Get base URL, username and password from MSB?
+ // TODO: Following code is a placeholder, needs to be updated
+ setVFCParams("https://", "vfc", "vfc");
+
+ }
+
+ public void setVFCParams(String baseUrl, String name, String pwd) {
+ vfcUrlBase = baseUrl + "/api/nslcm/v1";
+ username = name;
+ password = pwd;
+ }
+
+ @Override
+ public void run() {
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("Accept", "application/json");
+
+ String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.nsInstanceId + "/heal";
+ Pair<Integer, String> httpDetails = RESTManager.post(vfcUrl, username, password, headers,
+ "application/json", Serialization.gsonPretty.toJson(vfcRequest));
+
+ if (httpDetails == null) {
+ return;
+ }
+
+ if (httpDetails.a == 202) {
+ try {
+ VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
+
+ String body = Serialization.gsonPretty.toJson(response);
+ System.out.println("Response to VFC Heal post:");
+ System.out.println(body);
+
+ String jobId = response.jobId;
+ int attemptsLeft = 20;
+
+ String urlGet = vfcUrlBase + "/jobs/" + jobId;
+ VFCResponse responseGet = null;
+
+ while (attemptsLeft-- > 0) {
+
+ Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
+ responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
+ body = Serialization.gsonPretty.toJson(responseGet);
+ System.out.println("Response to VFC Heal get:");
+ System.out.println(body);
+
+ if (httpDetailsGet.a == 200) {
+ if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") ||
+ responseGet.responseDescriptor.status.equalsIgnoreCase("error")) {
+ System.out.println("VFC Heal Status " + responseGet.responseDescriptor.status);
+ break;
+ }
+ }
+ Thread.sleep(20000);
+ }
+ if (attemptsLeft <= 0)
+ System.out.println("VFC timeout. Status: (" + responseGet.responseDescriptor.status + ")");
+ } catch (JsonSyntaxException e) {
+ System.err.println("Failed to deserialize into VFCResponse" + e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ System.err.println("Interrupted exception: " + e.getLocalizedMessage());
+ }
+ } else {
+ System.out.println("VFC Heal Restcall failed");
+ }
+ }
+}
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
new file mode 100644
index 000000000..a45a62dfa
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+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
+ public transient String nsInstanceId;
+
+ @SerializedName("healVnfData")
+ public VFCHealRequest healRequest;
+
+ public VFCRequest() {
+ }
+
+}
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
new file mode 100644
index 000000000..775d78f1d
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class VFCResponse implements Serializable {
+
+ private static final long serialVersionUID = 9151443891238218455L;
+
+ @SerializedName("jobId")
+ public String jobId;
+
+ @SerializedName("responseDescriptor")
+ VFCResponseDescriptor responseDescriptor;
+
+ 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
new file mode 100644
index 000000000..f156fa0d0
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class VFCResponseDescriptor implements Serializable {
+
+ private static final long serialVersionUID = 6827782899144150158L;
+
+ @SerializedName("progress")
+ public String progress;
+
+ @SerializedName("status")
+ String status;
+
+ @SerializedName("statusDescription")
+ String statusDescription;
+
+ @SerializedName("errorCode")
+ String errorCode;
+
+ @SerializedName("responseId")
+ String responseId;
+
+ @SerializedName("responseHistoryList")
+ VFCResponseHistoryList responseHistoryList;
+
+ public VFCResponseDescriptor() {
+ }
+
+}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java
new file mode 100644
index 000000000..3fe62ea25
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseHistoryList.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+
+public class VFCResponseHistoryList implements Serializable {
+
+ private static final long serialVersionUID = 3340914325806649762L;
+
+ public List<VFCResponseDescriptor> responseDescriptorList= new LinkedList<>();
+
+ public VFCResponseHistoryList() {
+ }
+
+}
diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java
new file mode 100644
index 000000000..655085288
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public final class Serialization {
+
+ final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
+ .setPrettyPrinting()
+ .create();
+
+}
diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java
new file mode 100644
index 000000000..7e8c212e1
--- /dev/null
+++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2017 Intel Corp. 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.vfc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.policy.vfc.VFCRequest;
+import org.onap.policy.vfc.VFCHealRequest;
+import org.onap.policy.vfc.VFCHealAdditionalParams;
+import org.onap.policy.vfc.VFCHealActionVmInfo;
+import org.onap.policy.vfc.VFCResponse;
+import org.onap.policy.vfc.VFCResponseDescriptor;
+import org.onap.policy.vfc.VFCResponseHistoryList;
+import org.junit.Test;
+import org.onap.policy.vfc.util.Serialization;
+
+public class TestDemo {
+
+ @Test
+ public void test() {
+ VFCRequest request = new VFCRequest();
+
+ request.nsInstanceId = "100";
+ request.healRequest = new VFCHealRequest();
+ request.healRequest.vnfInstanceId = "1";
+ request.healRequest.cause = "vm is down";
+
+ request.healRequest.additionalParams = new VFCHealAdditionalParams();
+ request.healRequest.additionalParams.action = "restartvm";
+
+ request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
+ request.healRequest.additionalParams.actionInfo.vmid = "33";
+ request.healRequest.additionalParams.actionInfo.vmname = "xgw-smp11";
+
+ String body = Serialization.gsonPretty.toJson(request);
+ System.out.println(body);
+
+ VFCResponse response = new VFCResponse();
+ response.jobId = "1";
+
+ body = Serialization.gsonPretty.toJson(response);
+ System.out.println(body);
+
+ response.responseDescriptor = new VFCResponseDescriptor();
+ response.responseDescriptor.progress = "40";
+ response.responseDescriptor.status = "processing";
+ response.responseDescriptor.statusDescription = "OMC VMs are decommissioned in VIM";
+ response.responseDescriptor.errorCode = null;
+ response.responseDescriptor.responseId = "42";
+ body = Serialization.gsonPretty.toJson(response);
+ System.out.println(body);
+
+ VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor();
+ responseDescriptor.progress = "20";
+ responseDescriptor.status = "processing";
+ responseDescriptor.statusDescription = "OMC VMs are decommissioned in VIM";
+ responseDescriptor.errorCode = null;
+ responseDescriptor.responseId = "11";
+
+ response.responseDescriptor.responseHistoryList = new VFCResponseHistoryList();
+ response.responseDescriptor.responseHistoryList.responseDescriptorList.add(responseDescriptor);
+
+ body = Serialization.gsonPretty.toJson(response);
+ System.out.println(body);
+
+ }
+}
diff --git a/controlloop/packages/artifacts/pom.xml b/controlloop/packages/artifacts/pom.xml
index 27ec28a84..f47f2b75d 100644
--- a/controlloop/packages/artifacts/pom.xml
+++ b/controlloop/packages/artifacts/pom.xml
@@ -96,6 +96,12 @@
<version>${project.version}</version>
<type>jar</type>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>vfc</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
<dependency>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>aai</artifactId>
diff --git a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
index a141f4956..8eab47885 100644
--- a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
+++ b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
@@ -32,6 +32,8 @@ import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
import org.onap.policy.appc.CommonHeader;
+import org.onap.policy.vfc.VFCRequest;
+import org.onap.policy.vfc.VFCManager;
import org.onap.policy.guard.PolicyGuard;
import org.onap.policy.guard.PolicyGuard.LockResult;
import org.onap.policy.guard.TargetLock;
@@ -491,11 +493,15 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if (request instanceof Request) {
Engine.deliver("UEB", "APPC-CL", request);
}
- case "SDNR":
- default:
+ break;
+ case "VFC":
+ if (request instanceof VFCRequest) {
+ // Start VFC thread
+ Thread t = new Thread(new VFCManager(request));
+ t.start();
+ }
+ break;
}
-
-
} else {
//
// What happens if its null?