From 485559b57a49a449c6fc3baeda1b0ffd8b05cf6b Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 10 Jan 2019 09:57:51 -0500 Subject: Remove model-impl/vfc checkstyle suppressions Entails renaming VFCxxx classes and updated drl files, as well. Change-Id: Ib31c61a35536df22772de6090761b22beb1b561b Issue-ID: POLICY-1145 Signed-off-by: Jim Hahn --- .../actor/vfc/VfcActorServiceProvider.java | 22 +-- .../actor/vfc/VfcActorServiceProviderTest.java | 8 +- .../eventmanager/ControlLoopOperationManager.java | 10 +- .../ControlLoopOperationManagerTest.java | 10 +- .../model-impl/vfc/checkstyle-suppressions.xml | 30 ---- controlloop/common/model-impl/vfc/pom.xml | 1 - .../org/onap/policy/vfc/VFCHealActionVmInfo.java | 55 ------ .../onap/policy/vfc/VFCHealAdditionalParams.java | 55 ------ .../java/org/onap/policy/vfc/VFCHealRequest.java | 66 ------- .../main/java/org/onap/policy/vfc/VFCManager.java | 189 --------------------- .../main/java/org/onap/policy/vfc/VFCRequest.java | 64 ------- .../main/java/org/onap/policy/vfc/VFCResponse.java | 65 ------- .../org/onap/policy/vfc/VFCResponseDescriptor.java | 100 ----------- .../org/onap/policy/vfc/VfcHealActionVmInfo.java | 55 ++++++ .../onap/policy/vfc/VfcHealAdditionalParams.java | 55 ++++++ .../java/org/onap/policy/vfc/VfcHealRequest.java | 66 +++++++ .../main/java/org/onap/policy/vfc/VfcManager.java | 189 +++++++++++++++++++++ .../main/java/org/onap/policy/vfc/VfcRequest.java | 64 +++++++ .../main/java/org/onap/policy/vfc/VfcResponse.java | 65 +++++++ .../org/onap/policy/vfc/VfcResponseDescriptor.java | 100 +++++++++++ .../test/java/org/onap/policy/vfc/DemoTest.java | 20 +-- .../onap/policy/vfc/VfcHealActionVmInfoTest.java | 4 +- .../policy/vfc/VfcHealAdditionalParamsTest.java | 6 +- .../org/onap/policy/vfc/VfcHealRequestTest.java | 6 +- .../java/org/onap/policy/vfc/VfcManagerTest.java | 46 ++--- .../java/org/onap/policy/vfc/VfcRequestTest.java | 10 +- .../onap/policy/vfc/VfcResponseDescriptorTest.java | 6 +- .../java/org/onap/policy/vfc/VfcResponseTest.java | 6 +- .../onap/policy/simulators/VfcSimulatorTest.java | 8 +- .../main/resources/__closedLoopControlName__.drl | 14 +- .../main/resources/__closedLoopControlName__.drl | 14 +- .../main/resources/__closedLoopControlName__.drl | 14 +- .../policy/template/demo/VfcControlLoopTest.java | 6 +- 33 files changed, 699 insertions(+), 730 deletions(-) delete mode 100644 controlloop/common/model-impl/vfc/checkstyle-suppressions.xml delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java delete mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java create mode 100644 controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java 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 index 8660aa3e2..323b54d9c 100644 --- 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 @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018-2019 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. @@ -34,10 +34,10 @@ import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.rest.RESTManager; -import org.onap.policy.vfc.VFCHealActionVmInfo; -import org.onap.policy.vfc.VFCHealAdditionalParams; -import org.onap.policy.vfc.VFCHealRequest; -import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VfcHealActionVmInfo; +import org.onap.policy.vfc.VfcHealAdditionalParams; +import org.onap.policy.vfc.VfcHealRequest; +import org.onap.policy.vfc.VfcRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,11 +86,11 @@ public class VfcActorServiceProvider implements Actor { * @param vnfResponse the VNF response * @return the constructed request */ - public static VFCRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, + public static VfcRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy, AaiGetVnfResponse vnfResponse) { // Construct an VFC request - VFCRequest request = new VFCRequest(); + VfcRequest request = new VfcRequest(); String serviceInstance = onset.getAai().get("service-instance.service-instance-id"); if (serviceInstance == null || "".equals(serviceInstance)) { AaiGetVnfResponse tempVnfResp = vnfResponse; @@ -103,16 +103,16 @@ public class VfcActorServiceProvider implements Actor { } serviceInstance = tempVnfResp.getServiceId(); } - request.setNSInstanceId(serviceInstance); + request.setNsInstanceId(serviceInstance); request.setRequestId(onset.getRequestId()); - request.setHealRequest(new VFCHealRequest()); + request.setHealRequest(new VfcHealRequest()); request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id")); request.getHealRequest().setCause(operation.getMessage()); - request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams()); + request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); if (policy.getRecipe().toLowerCase().equalsIgnoreCase(RECIPE_RESTART)) { request.getHealRequest().getAdditionalParams().setAction("restartvm"); - request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo()); + request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); request.getHealRequest().getAdditionalParams().getActionInfo() .setVmid(onset.getAai().get("vserver.vserver-id")); request.getHealRequest().getAdditionalParams().getActionInfo() diff --git a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java index 02387b641..9e6b5b827 100644 --- a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java +++ b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java @@ -1,9 +1,9 @@ /*- * ============LICENSE_START======================================================= - * TestVFCActorServiceProvider + * ONAP - Policy Drools Applications * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T 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. @@ -39,7 +39,7 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.simulators.Util; -import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VfcRequest; public class VfcActorServiceProviderTest { @@ -97,7 +97,7 @@ public class VfcActorServiceProviderTest { policy.setRecipe("Restart"); assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse())); - VFCRequest request = + VfcRequest request = VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse()); assertEquals(requestId, Objects.requireNonNull(request).getRequestId()); 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 5abfca47b..36db9fe53 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * controlloop operation manager * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -54,7 +54,7 @@ import org.onap.policy.guard.Util; import org.onap.policy.sdnc.SdncResponse; import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.so.SOResponseWrapper; -import org.onap.policy.vfc.VFCResponse; +import org.onap.policy.vfc.VfcResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -351,11 +351,11 @@ public class ControlLoopOperationManager implements Serializable { // Cast SO response and handle it // return onResponse((SOResponseWrapper) response); - } else if (response instanceof VFCResponse) { + } else if (response instanceof VfcResponse) { // // Cast VFC response and handle it // - return onResponse((VFCResponse) response); + return onResponse((VfcResponse) response); } else if (response instanceof SdncResponse) { // // Cast SDNC response and handle it @@ -563,7 +563,7 @@ public class ControlLoopOperationManager implements Serializable { * @param vfcResponse the VFC response * @return The result of the response handling */ - private PolicyResult onResponse(VFCResponse vfcResponse) { + private PolicyResult onResponse(VfcResponse vfcResponse) { if ("finished".equalsIgnoreCase(vfcResponse.getResponseDescriptor().getStatus())) { // // Consider it as success diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java index 0afe9d2d3..f761d69b7 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * unit test * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -73,8 +73,8 @@ import org.onap.policy.controlloop.processor.ControlLoopProcessor; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.so.SOResponse; import org.onap.policy.so.SOResponseWrapper; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCResponseDescriptor; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcResponseDescriptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -753,8 +753,8 @@ public class ControlLoopOperationManagerTest { soResponse.setHttpResponseCode(500); assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw)); - VFCResponse vfcResponse = new VFCResponse(); - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponse vfcResponse = new VfcResponse(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); vfcResponse.setResponseDescriptor(responseDescriptor); responseDescriptor.setStatus("finished"); diff --git a/controlloop/common/model-impl/vfc/checkstyle-suppressions.xml b/controlloop/common/model-impl/vfc/checkstyle-suppressions.xml deleted file mode 100644 index ea04e03f1..000000000 --- a/controlloop/common/model-impl/vfc/checkstyle-suppressions.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml index d5de89f6e..1df42831b 100644 --- a/controlloop/common/model-impl/vfc/pom.xml +++ b/controlloop/common/model-impl/vfc/pom.xml @@ -92,7 +92,6 @@ true - ${project.basedir}/checkstyle-suppressions.xml true true warning 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 deleted file mode 100644 index 0286a7d8b..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealActionVmInfo.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VFCHealActionVmInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("vmid") - private String vmid; - - @SerializedName("vmname") - private String vmname; - - public VFCHealActionVmInfo() { - // Default constructor for VFCHealActionVmInfo - } - - public String getVmid() { - return vmid; - } - - public void setVmid(String vmid) { - this.vmid = vmid; - } - - public String getVmname() { - return vmname; - } - - public void setVmname(String vmname) { - this.vmname = vmname; - } -} 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 deleted file mode 100644 index 393e3761f..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealAdditionalParams.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VFCHealAdditionalParams implements Serializable { - - private static final long serialVersionUID = 2656694137285096191L; - - @SerializedName("action") - private String action; - - @SerializedName("actionvminfo") - private VFCHealActionVmInfo actionInfo; - - public VFCHealAdditionalParams() { - // Default constructor for VFCHealAdditionalParams - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public VFCHealActionVmInfo getActionInfo() { - return actionInfo; - } - - public void setActionInfo(VFCHealActionVmInfo actionInfo) { - this.actionInfo = actionInfo; - } -} 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 deleted file mode 100644 index 75b9566b1..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCHealRequest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VFCHealRequest implements Serializable { - - private static final long serialVersionUID = -7341931593089709247L; - - @SerializedName("vnfInstanceId") - private String vnfInstanceId; - - @SerializedName("cause") - private String cause; - - @SerializedName("additionalParams") - private VFCHealAdditionalParams additionalParams; - - public VFCHealRequest() { - // Default constructor for VFCHealRequest - } - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public String getCause() { - return cause; - } - - public void setCause(String cause) { - this.cause = cause; - } - - public VFCHealAdditionalParams getAdditionalParams() { - return additionalParams; - } - - public void setAdditionalParams(VFCHealAdditionalParams additionalParams) { - this.additionalParams = additionalParams; - } -} 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 deleted file mode 100644 index d84d0403f..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017-2018 Intel Corp, AT&T. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.JsonSyntaxException; - -import java.util.HashMap; -import java.util.Map; - -import org.drools.core.WorkingMemory; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RESTManager; -import org.onap.policy.rest.RESTManager.Pair; -import org.onap.policy.vfc.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class VFCManager implements Runnable { - private static final String SYSTEM_LS = System.lineSeparator(); - - private String vfcUrlBase; - private String username; - private String password; - private VFCRequest vfcRequest; - private WorkingMemory workingMem; - private static final Logger logger = LoggerFactory.getLogger(VFCManager.class); - private static final Logger netLogger = - LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER); - - // The REST manager used for processing REST calls for this VFC manager - private RESTManager restManager; - - /** - * Constructor. - * - * @param wm Drools working memory - * @param request request - */ - public VFCManager(WorkingMemory wm, VFCRequest request) { - if (wm == null || request == null) { - throw new IllegalArgumentException( - "the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null"); - } - workingMem = wm; - vfcRequest = request; - - restManager = new RESTManager(); - - // use getPEManagerEnvProperty() for required properties; others are optional - setVFCParams(getPEManagerEnvProperty("vfc.url"), PolicyEngine.manager.getEnvironmentProperty("vfc.username"), - PolicyEngine.manager.getEnvironmentProperty("vfc.password")); - } - - /** - * Set the parameters. - * - * @param baseUrl base URL - * @param name username - * @param pwd password - */ - public void setVFCParams(String baseUrl, String name, String pwd) { - vfcUrlBase = baseUrl + "/api/nslcm/v1"; - username = name; - password = pwd; - } - - @Override - public void run() { - Map headers = new HashMap<>(); - Pair httpDetails; - - VFCResponse responseError = new VFCResponse(); - responseError.setResponseDescriptor(new VFCResponseDescriptor()); - responseError.getResponseDescriptor().setStatus("error"); - - headers.put("Accept", "application/json"); - String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNSInstanceId() + "/heal"; - try { - String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest); - netLogger.info("[OUT|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, vfcRequestJson); - - httpDetails = restManager.post(vfcUrl, username, password, headers, "application/json", vfcRequestJson); - } catch (Exception e) { - logger.error(e.getMessage(), e); - workingMem.insert(responseError); - return; - } - - if (httpDetails == null) { - workingMem.insert(responseError); - return; - } - - if (httpDetails.first != 202) { - logger.warn("VFC Heal Restcall failed"); - return; - } - - try { - VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VFCResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, httpDetails.second); - String body = Serialization.gsonPretty.toJson(response); - logger.debug("Response to VFC Heal post:"); - logger.debug(body); - - String jobId = response.getJobId(); - int attemptsLeft = 20; - - String urlGet = vfcUrlBase + "/jobs/" + jobId; - VFCResponse responseGet = null; - - while (attemptsLeft-- > 0) { - netLogger.info("[OUT|{}|{}|]", "VFC", urlGet); - Pair httpDetailsGet = restManager.get(urlGet, username, password, headers); - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VFCResponse.class); - netLogger.info("[IN|{}|{}|]{}{}", "VFC", urlGet, SYSTEM_LS, httpDetailsGet.second); - responseGet.setRequestId(vfcRequest.getRequestId().toString()); - body = Serialization.gsonPretty.toJson(responseGet); - logger.debug("Response to VFC Heal get:"); - logger.debug(body); - - String responseStatus = responseGet.getResponseDescriptor().getStatus(); - if (httpDetailsGet.first == 200 - && ("finished".equalsIgnoreCase(responseStatus) || "error".equalsIgnoreCase(responseStatus))) { - logger.debug("VFC Heal Status {}", responseGet.getResponseDescriptor().getStatus()); - workingMem.insert(responseGet); - break; - } - Thread.sleep(20000); - } - if ((attemptsLeft <= 0) && (responseGet != null) && (responseGet.getResponseDescriptor() != null) - && (responseGet.getResponseDescriptor().getStatus() != null) - && (!responseGet.getResponseDescriptor().getStatus().isEmpty())) { - logger.debug("VFC timeout. Status: ({})", responseGet.getResponseDescriptor().getStatus()); - workingMem.insert(responseGet); - } - } catch (JsonSyntaxException e) { - logger.error("Failed to deserialize into VFCResponse {}", e.getLocalizedMessage(), e); - } catch (InterruptedException e) { - logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e); - Thread.currentThread().interrupt(); - } catch (Exception e) { - logger.error("Unknown error deserializing into VFCResponse {}", e.getLocalizedMessage(), e); - } - } - - /** - * Protected setter for rest manager to allow mocked rest manager to be used for testing. - * - * @param restManager the test REST manager - */ - protected void setRestManager(final RESTManager restManager) { - this.restManager = restManager; - } - - /** - * This method reads and validates environmental properties coming from the policy engine. Null - * properties cause an {@link IllegalArgumentException} runtime exception to be thrown - * - * @param string the name of the parameter to retrieve - * @return the property value - */ - - private String getPEManagerEnvProperty(String enginePropertyName) { - String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName); - if (enginePropertyValue == null) { - throw new IllegalArgumentException("The value of policy engine manager environment property \"" - + enginePropertyName + "\" may not be null"); - } - return enginePropertyValue; - } -} 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 deleted file mode 100644 index cfcaf8039..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.UUID; - -public class VFCRequest implements Serializable { - - private static final long serialVersionUID = 3736300970326332512L; - // These fields are not serialized and not part of JSON - private transient String nsInstanceId; - private transient UUID requestId; - - @SerializedName("healVnfData") - private VFCHealRequest healRequest; - - public VFCRequest() { - // Default constructor for VFCRequest - } - - public String getNSInstanceId() { - return nsInstanceId; - } - - public void setNSInstanceId(String nsInstanceId) { - this.nsInstanceId = nsInstanceId; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public VFCHealRequest getHealRequest() { - return healRequest; - } - - public void setHealRequest(VFCHealRequest healRequest) { - this.healRequest = 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 deleted file mode 100644 index 21e9472b7..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VFCResponse implements Serializable { - - private static final long serialVersionUID = 9151443891238218455L; - - @SerializedName("jobId") - private String jobId; - - @SerializedName("responseDescriptor") - private VFCResponseDescriptor responseDescriptor; - - private transient String requestId; - - public VFCResponse() { - // Default constructor for VFCResponse - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public VFCResponseDescriptor getResponseDescriptor() { - return responseDescriptor; - } - - public void setResponseDescriptor(VFCResponseDescriptor responseDescriptor) { - this.responseDescriptor = responseDescriptor; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } -} 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 deleted file mode 100644 index cdd4a39a9..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.List; - -public class VFCResponseDescriptor implements Serializable { - - private static final long serialVersionUID = 6827782899144150158L; - - @SerializedName("progress") - private String progress; - - @SerializedName("status") - private String status; - - @SerializedName("statusDescription") - private String statusDescription; - - @SerializedName("errorCode") - private String errorCode; - - @SerializedName("responseId") - private String responseId; - - @SerializedName("responseHistoryList") - private List responseHistoryList; - - public VFCResponseDescriptor() { - // Default constructor for VFCResponseDescriptor - } - - public String getStatus() { - return status; - } - - public String getProgress() { - return progress; - } - - public void setProgress(String progress) { - this.progress = progress; - } - - public String getStatusDescription() { - return statusDescription; - } - - public void setStatusDescription(String statusDescription) { - this.statusDescription = statusDescription; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getResponseId() { - return responseId; - } - - public void setResponseId(String responseId) { - this.responseId = responseId; - } - - public List getResponseHistoryList() { - return responseHistoryList; - } - - public void setResponseHistoryList(List responseHistoryList) { - this.responseHistoryList = responseHistoryList; - } - - public void setStatus(String status) { - this.status = status; - } -} 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..c154f7226 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class VfcHealActionVmInfo implements Serializable { + + private static final long serialVersionUID = 3208673205100673119L; + + @SerializedName("vmid") + private String vmid; + + @SerializedName("vmname") + private String vmname; + + public VfcHealActionVmInfo() { + // Default constructor + } + + public String getVmid() { + return vmid; + } + + public void setVmid(String vmid) { + this.vmid = vmid; + } + + public String getVmname() { + return vmname; + } + + public void setVmname(String vmname) { + this.vmname = vmname; + } +} 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..2c5de3a22 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class VfcHealAdditionalParams implements Serializable { + + private static final long serialVersionUID = 2656694137285096191L; + + @SerializedName("action") + private String action; + + @SerializedName("actionvminfo") + private VfcHealActionVmInfo actionInfo; + + public VfcHealAdditionalParams() { + // Default constructor + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public VfcHealActionVmInfo getActionInfo() { + return actionInfo; + } + + public void setActionInfo(VfcHealActionVmInfo actionInfo) { + this.actionInfo = actionInfo; + } +} 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..55ca4ac5c --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class VfcHealRequest implements Serializable { + + private static final long serialVersionUID = -7341931593089709247L; + + @SerializedName("vnfInstanceId") + private String vnfInstanceId; + + @SerializedName("cause") + private String cause; + + @SerializedName("additionalParams") + private VfcHealAdditionalParams additionalParams; + + public VfcHealRequest() { + // Default constructor + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getCause() { + return cause; + } + + public void setCause(String cause) { + this.cause = cause; + } + + public VfcHealAdditionalParams getAdditionalParams() { + return additionalParams; + } + + public void setAdditionalParams(VfcHealAdditionalParams additionalParams) { + this.additionalParams = additionalParams; + } +} 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..2a004bd04 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java @@ -0,0 +1,189 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017-2018 Intel Corp, AT&T. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.JsonSyntaxException; + +import java.util.HashMap; +import java.util.Map; + +import org.drools.core.WorkingMemory; +import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; +import org.onap.policy.vfc.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class VfcManager implements Runnable { + private static final String SYSTEM_LS = System.lineSeparator(); + + private String vfcUrlBase; + private String username; + private String password; + private VfcRequest vfcRequest; + private WorkingMemory workingMem; + private static final Logger logger = LoggerFactory.getLogger(VfcManager.class); + private static final Logger netLogger = + LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER); + + // The REST manager used for processing REST calls for this VFC manager + private RESTManager restManager; + + /** + * Constructor. + * + * @param wm Drools working memory + * @param request request + */ + public VfcManager(WorkingMemory wm, VfcRequest request) { + if (wm == null || request == null) { + throw new IllegalArgumentException( + "the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null"); + } + workingMem = wm; + vfcRequest = request; + + restManager = new RESTManager(); + + // use getPEManagerEnvProperty() for required properties; others are optional + setVfcParams(getPeManagerEnvProperty("vfc.url"), PolicyEngine.manager.getEnvironmentProperty("vfc.username"), + PolicyEngine.manager.getEnvironmentProperty("vfc.password")); + } + + /** + * Set the parameters. + * + * @param baseUrl base URL + * @param name username + * @param pwd password + */ + public void setVfcParams(String baseUrl, String name, String pwd) { + vfcUrlBase = baseUrl + "/api/nslcm/v1"; + username = name; + password = pwd; + } + + @Override + public void run() { + Map headers = new HashMap<>(); + Pair httpDetails; + + VfcResponse responseError = new VfcResponse(); + responseError.setResponseDescriptor(new VfcResponseDescriptor()); + responseError.getResponseDescriptor().setStatus("error"); + + headers.put("Accept", "application/json"); + String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNsInstanceId() + "/heal"; + try { + String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest); + netLogger.info("[OUT|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, vfcRequestJson); + + httpDetails = restManager.post(vfcUrl, username, password, headers, "application/json", vfcRequestJson); + } catch (Exception e) { + logger.error(e.getMessage(), e); + workingMem.insert(responseError); + return; + } + + if (httpDetails == null) { + workingMem.insert(responseError); + return; + } + + if (httpDetails.first != 202) { + logger.warn("VFC Heal Restcall failed"); + return; + } + + try { + VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); + netLogger.info("[IN|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, httpDetails.second); + String body = Serialization.gsonPretty.toJson(response); + logger.debug("Response to VFC Heal post:"); + logger.debug(body); + + String jobId = response.getJobId(); + int attemptsLeft = 20; + + String urlGet = vfcUrlBase + "/jobs/" + jobId; + VfcResponse responseGet = null; + + while (attemptsLeft-- > 0) { + netLogger.info("[OUT|{}|{}|]", "VFC", urlGet); + Pair httpDetailsGet = restManager.get(urlGet, username, password, headers); + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VfcResponse.class); + netLogger.info("[IN|{}|{}|]{}{}", "VFC", urlGet, SYSTEM_LS, httpDetailsGet.second); + responseGet.setRequestId(vfcRequest.getRequestId().toString()); + body = Serialization.gsonPretty.toJson(responseGet); + logger.debug("Response to VFC Heal get:"); + logger.debug(body); + + String responseStatus = responseGet.getResponseDescriptor().getStatus(); + if (httpDetailsGet.first == 200 + && ("finished".equalsIgnoreCase(responseStatus) || "error".equalsIgnoreCase(responseStatus))) { + logger.debug("VFC Heal Status {}", responseGet.getResponseDescriptor().getStatus()); + workingMem.insert(responseGet); + break; + } + Thread.sleep(20000); + } + if ((attemptsLeft <= 0) && (responseGet != null) && (responseGet.getResponseDescriptor() != null) + && (responseGet.getResponseDescriptor().getStatus() != null) + && (!responseGet.getResponseDescriptor().getStatus().isEmpty())) { + logger.debug("VFC timeout. Status: ({})", responseGet.getResponseDescriptor().getStatus()); + workingMem.insert(responseGet); + } + } catch (JsonSyntaxException e) { + logger.error("Failed to deserialize into VfcResponse {}", e.getLocalizedMessage(), e); + } catch (InterruptedException e) { + logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e); + Thread.currentThread().interrupt(); + } catch (Exception e) { + logger.error("Unknown error deserializing into VfcResponse {}", e.getLocalizedMessage(), e); + } + } + + /** + * Protected setter for rest manager to allow mocked rest manager to be used for testing. + * + * @param restManager the test REST manager + */ + protected void setRestManager(final RESTManager restManager) { + this.restManager = restManager; + } + + /** + * This method reads and validates environmental properties coming from the policy engine. Null + * properties cause an {@link IllegalArgumentException} runtime exception to be thrown + * + * @param string the name of the parameter to retrieve + * @return the property value + */ + + private String getPeManagerEnvProperty(String enginePropertyName) { + String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName); + if (enginePropertyValue == null) { + throw new IllegalArgumentException("The value of policy engine manager environment property \"" + + enginePropertyName + "\" may not be null"); + } + return enginePropertyValue; + } +} 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..c4473e7f1 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.UUID; + +public class VfcRequest implements Serializable { + + private static final long serialVersionUID = 3736300970326332512L; + // These fields are not serialized and not part of JSON + private transient String nsInstanceId; + private transient UUID requestId; + + @SerializedName("healVnfData") + private VfcHealRequest healRequest; + + public VfcRequest() { + // Default constructor + } + + public String getNsInstanceId() { + return nsInstanceId; + } + + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + + public UUID getRequestId() { + return requestId; + } + + public void setRequestId(UUID requestId) { + this.requestId = requestId; + } + + public VfcHealRequest getHealRequest() { + return healRequest; + } + + public void setHealRequest(VfcHealRequest healRequest) { + this.healRequest = 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 new file mode 100644 index 000000000..2183be71b --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class VfcResponse implements Serializable { + + private static final long serialVersionUID = 9151443891238218455L; + + @SerializedName("jobId") + private String jobId; + + @SerializedName("responseDescriptor") + private VfcResponseDescriptor responseDescriptor; + + private transient String requestId; + + public VfcResponse() { + // Default constructor + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public VfcResponseDescriptor getResponseDescriptor() { + return responseDescriptor; + } + + public void setResponseDescriptor(VfcResponseDescriptor responseDescriptor) { + this.responseDescriptor = responseDescriptor; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } +} 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..147b937dc --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java @@ -0,0 +1,100 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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 com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.List; + +public class VfcResponseDescriptor implements Serializable { + + private static final long serialVersionUID = 6827782899144150158L; + + @SerializedName("progress") + private String progress; + + @SerializedName("status") + private String status; + + @SerializedName("statusDescription") + private String statusDescription; + + @SerializedName("errorCode") + private String errorCode; + + @SerializedName("responseId") + private String responseId; + + @SerializedName("responseHistoryList") + private List responseHistoryList; + + public VfcResponseDescriptor() { + // Default constructor + } + + public String getStatus() { + return status; + } + + public String getProgress() { + return progress; + } + + public void setProgress(String progress) { + this.progress = progress; + } + + public String getStatusDescription() { + return statusDescription; + } + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getResponseId() { + return responseId; + } + + public void setResponseId(String responseId) { + this.responseId = responseId; + } + + public List getResponseHistoryList() { + return responseHistoryList; + } + + public void setResponseHistoryList(List responseHistoryList) { + this.responseHistoryList = responseHistoryList; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java index dae87b6a6..d334d232f 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -28,30 +28,30 @@ public class DemoTest { @Test public void test() { - VFCRequest request = new VFCRequest(); + VfcRequest request = new VfcRequest(); - request.setNSInstanceId("100"); - request.setHealRequest(new VFCHealRequest()); + request.setNsInstanceId("100"); + request.setHealRequest(new VfcHealRequest()); request.getHealRequest().setVnfInstanceId("1"); request.getHealRequest().setCause("vm is down"); - request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams()); + request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); request.getHealRequest().getAdditionalParams().setAction("restartvm"); - request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo()); + request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); request.getHealRequest().getAdditionalParams().getActionInfo().setVmid("33"); request.getHealRequest().getAdditionalParams().getActionInfo().setVmname("xgw-smp11"); String body = Serialization.gsonPretty.toJson(request); System.out.println(body); - VFCResponse response = new VFCResponse(); + VfcResponse response = new VfcResponse(); response.setJobId("1"); body = Serialization.gsonPretty.toJson(response); System.out.println(body); - response.setResponseDescriptor(new VFCResponseDescriptor()); + response.setResponseDescriptor(new VfcResponseDescriptor()); response.getResponseDescriptor().setProgress("40"); response.getResponseDescriptor().setStatus("processing"); response.getResponseDescriptor().setStatusDescription("OMC VMs are decommissioned in VIM"); @@ -60,7 +60,7 @@ public class DemoTest { body = Serialization.gsonPretty.toJson(response); System.out.println(body); - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); responseDescriptor.setProgress("20"); responseDescriptor.setStatus("processing"); responseDescriptor.setStatusDescription("OMC VMs are decommissioned in VIM"); @@ -73,7 +73,7 @@ public class DemoTest { body = Serialization.gsonPretty.toJson(response); System.out.println(body); - response = Serialization.gsonPretty.fromJson(body, VFCResponse.class); + response = Serialization.gsonPretty.fromJson(body, VfcResponse.class); body = Serialization.gsonPretty.toJson(response); System.out.println(body); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java index 10964a909..8b5b118d2 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -31,7 +31,7 @@ public class VfcHealActionVmInfoTest { @Test public void testVfcHealActionVmInfo() { - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); assertNotNull(actionInfo); assertNotEquals(0, actionInfo.hashCode()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java index ca2d844c1..e7cb79fef 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -31,7 +31,7 @@ public class VfcHealAdditionalParamsTest { @Test public void testVfcHealAdditionalParameters() { - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); assertNotNull(additionalParams); assertNotEquals(0, additionalParams.hashCode()); @@ -39,7 +39,7 @@ public class VfcHealAdditionalParamsTest { additionalParams.setAction(action); assertEquals(action, additionalParams.getAction()); - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); additionalParams.setActionInfo(actionInfo ); assertEquals(actionInfo, additionalParams.getActionInfo()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java index 0a256a59b..b67b9ac07 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -31,7 +31,7 @@ public class VfcHealRequestTest { @Test public void testVfcHealRequest() { - VFCHealRequest request = new VFCHealRequest(); + VfcHealRequest request = new VfcHealRequest(); assertNotNull(request); assertNotEquals(0, request.hashCode()); @@ -43,7 +43,7 @@ public class VfcHealRequestTest { request.setCause(cause); assertEquals(cause, request.getCause()); - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); request.setAdditionalParams(additionalParams); assertEquals(additionalParams, request.getAdditionalParams()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java index ab8161164..f5d06de36 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson, AT&T. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -56,8 +56,8 @@ public class VfcManagerTest { private Pair httpResponseBadResponse; private Pair httpResponseErr; - private VFCRequest request; - private VFCResponse response; + private VfcRequest request; + private VfcResponse response; @BeforeClass public static void beforeTestVfcManager() { @@ -82,28 +82,28 @@ public class VfcManagerTest { */ @Before public void createRequestAndResponse() { - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); actionInfo.setVmid("TheWizard"); actionInfo.setVmname("The Wizard of Oz"); - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); additionalParams.setAction("Go Home"); additionalParams.setActionInfo(actionInfo); - VFCHealRequest healRequest = new VFCHealRequest(); + VfcHealRequest healRequest = new VfcHealRequest(); healRequest.setAdditionalParams(additionalParams); healRequest.setCause("WestWitch"); healRequest.setVnfInstanceId("EmeraldCity"); final UUID requestId = UUID.randomUUID(); - request = new VFCRequest(); + request = new VfcRequest(); request.setHealRequest(healRequest); - request.setNSInstanceId("Dorothy"); + request.setNsInstanceId("Dorothy"); request.setRequestId(requestId); - List responseHistoryList = new ArrayList<>();; + List responseHistoryList = new ArrayList<>();; - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); responseDescriptor.setErrorCode("1234"); responseDescriptor.setProgress("Follow The Yellow Brick Road"); responseDescriptor.setResponseHistoryList(responseHistoryList); @@ -111,7 +111,7 @@ public class VfcManagerTest { responseDescriptor.setStatus("finished"); responseDescriptor.setStatusDescription("There's no place like home"); - response = new VFCResponse(); + response = new VfcResponse(); response.setJobId("1234"); response.setRequestId(request.getRequestId().toString()); response.setResponseDescriptor(responseDescriptor); @@ -130,25 +130,25 @@ public class VfcManagerTest { @Test public void testVfcInitiation() { try { - new VFCManager(null, null); + new VfcManager(null, null); fail("test should throw an exception here"); } catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", + assertEquals("the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null", e.getMessage()); } try { - new VFCManager(mockedWorkingMemory, null); + new VfcManager(mockedWorkingMemory, null); fail("test should throw an exception here"); } catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", + assertEquals("the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null", e.getMessage()); } try { - new VFCManager(mockedWorkingMemory, request); + new VfcManager(mockedWorkingMemory, request); fail("test should throw an exception here"); } catch (IllegalArgumentException e) { @@ -158,14 +158,14 @@ public class VfcManagerTest { // add url; username & password are not required PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - new VFCManager(mockedWorkingMemory, request); + new VfcManager(mockedWorkingMemory, request); // url & username, but no password PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); // url, username, and password PolicyEngine.manager.getEnvironment().put("vfc.password", "Toto"); - new VFCManager(mockedWorkingMemory, request); + new VfcManager(mockedWorkingMemory, request); } @Test @@ -174,7 +174,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "Exception"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -202,7 +202,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "Null"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -225,7 +225,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "Error0"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -248,7 +248,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "BadResponse"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); @@ -271,7 +271,7 @@ public class VfcManagerTest { PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); PolicyEngine.manager.getEnvironment().put("vfc.password", "OK"); - VFCManager manager = new VFCManager(mockedWorkingMemory, request); + VfcManager manager = new VfcManager(mockedWorkingMemory, request); manager.setRestManager(mockedRestManager); Thread managerThread = new Thread(manager); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java index 95589154f..7dede1b7b 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -33,19 +33,19 @@ public class VfcRequestTest { @Test public void testVfcRequest() { - VFCRequest request = new VFCRequest(); + VfcRequest request = new VfcRequest(); assertNotNull(request); assertNotEquals(0, request.hashCode()); String nsInstanceId = "Dorothy"; - request.setNSInstanceId(nsInstanceId); - assertEquals(nsInstanceId, request.getNSInstanceId()); + request.setNsInstanceId(nsInstanceId); + assertEquals(nsInstanceId, request.getNsInstanceId()); UUID requestId = UUID.randomUUID(); request.setRequestId(requestId); assertEquals(requestId, request.getRequestId()); - VFCHealRequest healRequest = new VFCHealRequest(); + VfcHealRequest healRequest = new VfcHealRequest(); request.setHealRequest(healRequest); assertEquals(healRequest, request.getHealRequest()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java index 9ab180767..b4dc81b44 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -34,7 +34,7 @@ public class VfcResponseDescriptorTest { @Test public void testVfcResponseDescriptor() { - VFCResponseDescriptor descriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor descriptor = new VfcResponseDescriptor(); assertNotNull(descriptor); assertNotEquals(0, descriptor.hashCode()); @@ -46,7 +46,7 @@ public class VfcResponseDescriptorTest { descriptor.setProgress(progress); assertEquals(progress, descriptor.getProgress()); - List responseHistoryList = new ArrayList<>(); + List responseHistoryList = new ArrayList<>(); descriptor.setResponseHistoryList(responseHistoryList); assertEquals(responseHistoryList, descriptor.getResponseHistoryList()); diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java index f333c4165..15ba6f520 100644 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java @@ -3,7 +3,7 @@ * vfc * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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. @@ -31,7 +31,7 @@ public class VfcResponseTest { @Test public void testVfcResponse() { - VFCResponse response = new VFCResponse(); + VfcResponse response = new VfcResponse(); assertNotNull(response); assertNotEquals(0, response.hashCode()); @@ -43,7 +43,7 @@ public class VfcResponseTest { response.setRequestId(requestId); assertEquals(requestId, response.getRequestId()); - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); response.setResponseDescriptor(responseDescriptor); assertEquals(responseDescriptor, response.getResponseDescriptor()); diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java index 0e083bb6c..6e778d86c 100644 --- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java +++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * simulators * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -33,7 +33,7 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.drools.utils.logging.LoggerUtil; import org.onap.policy.rest.RESTManager; import org.onap.policy.rest.RESTManager.Pair; -import org.onap.policy.vfc.VFCResponse; +import org.onap.policy.vfc.VfcResponse; import org.onap.policy.vfc.util.Serialization; public class VfcSimulatorTest { @@ -64,7 +64,7 @@ public class VfcSimulatorTest { new HashMap(), "application/json", "Some Request Here"); assertNotNull(httpDetails); assertTrue(httpDetails.first == 202); - final VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VFCResponse.class); + final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); assertNotNull(response); } @@ -73,7 +73,7 @@ public class VfcSimulatorTest { final Pair httpDetails = new RESTManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234", "username", "password", new HashMap()); assertNotNull(httpDetails); - final VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VFCResponse.class); + final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); assertNotNull(response); } } diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index be399d9f7..160b75c61 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -45,9 +45,9 @@ import org.onap.policy.sdnr.PciRequestWrapper; import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.sdnr.PciRequest; import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.vfc.VFCRequest; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCManager; +import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; import org.onap.policy.so.SORequestStatus; @@ -594,9 +594,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" } break; case "VFC": - if (request instanceof VFCRequest) { + if (request instanceof VfcRequest) { // Start VFC thread - Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); + Thread t = new Thread(new VfcManager(drools.getWorkingMemory(), (VfcRequest)request)); t.start(); } break; @@ -1252,7 +1252,7 @@ rule "${policyName}.VFC.RESPONSE" $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired ) $lock : TargetLock (requestID == $event.getRequestId()) - $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() ) + $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) then Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl index dc585261c..d8e34313e 100644 --- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -46,9 +46,9 @@ import org.onap.policy.sdnr.PciRequestWrapper; import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.sdnr.PciRequest; import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.vfc.VFCRequest; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCManager; +import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; import org.onap.policy.so.SORequestStatus; @@ -543,9 +543,9 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" } break; case "VFC": - if (request instanceof VFCRequest) { + if (request instanceof VfcRequest) { // Start VFC thread - Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); + Thread t = new Thread(new VfcManager(drools.getWorkingMemory(), (VfcRequest)request)); t.start(); } break; @@ -1093,7 +1093,7 @@ rule "VFC.RESPONSE" $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired ) $lock : TargetLock (requestID == $event.getRequestId()) - $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() ) + $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) then Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); logger.info("{}: {}", $clName, $params.getPolicyName() + "." + drools.getRule().getName()); diff --git a/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl index f7f04af81..feb5bf499 100644 --- a/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl +++ b/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -42,9 +42,9 @@ import org.onap.policy.appclcm.LcmResponseWrapper; import org.onap.policy.appclcm.LcmRequest; import org.onap.policy.appclcm.LcmResponse; import org.onap.policy.appclcm.LcmCommonHeader; -import org.onap.policy.vfc.VFCRequest; -import org.onap.policy.vfc.VFCResponse; -import org.onap.policy.vfc.VFCManager; +import org.onap.policy.vfc.VfcRequest; +import org.onap.policy.vfc.VfcResponse; +import org.onap.policy.vfc.VfcManager; import org.onap.policy.so.SOManager; import org.onap.policy.so.SORequest; import org.onap.policy.so.SORequestStatus; @@ -599,9 +599,9 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" } break; case "VFC": - if (request instanceof VFCRequest) { + if (request instanceof VfcRequest) { // Start VFC thread - Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request)); + Thread t = new Thread(new VfcManager(drools.getWorkingMemory(), (VfcRequest)request)); t.start(); } break; @@ -1103,7 +1103,7 @@ rule "${policyName}.VFC.RESPONSE" $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() ) $opTimer : OperationTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString() ) $lock : TargetLock (requestID == $event.getRequestId()) - $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() ) + $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) then Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java index aa4c108c5..57ed52ad7 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java @@ -3,7 +3,7 @@ * demo * ================================================================================ * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018-2019 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. @@ -57,7 +57,7 @@ import org.onap.policy.drools.protocol.coders.JsonProtocolFilter; import org.onap.policy.drools.system.PolicyController; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.vfc.VFCRequest; +import org.onap.policy.vfc.VfcRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -340,7 +340,7 @@ public class VfcControlLoopTest implements TopicListener { logger.debug("The control loop timed out"); fail("Control Loop Timed Out"); } - } else if (obj instanceof VFCRequest) { + } else if (obj instanceof VfcRequest) { logger.debug("\n============ VFC received the request!!! ===========\n"); } } -- cgit 1.2.3-korg