diff options
Diffstat (limited to 'controlloop/common')
4 files changed, 20 insertions, 9 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 0d4aa938c..7aaac9ead 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -629,7 +629,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { try { if (vserverName != null) { aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url"); - aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user"); + aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username"); aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password"); String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name="; String url = aaiHostURL + aaiGetQueryByVserver; @@ -650,19 +650,17 @@ public class ControlLoopEventManager implements LockCallback, Serializable { String vnfName = event.AAI.get("generic-vnf.vnf-name"); String vnfID = event.AAI.get("generic-vnf.vnf-id"); + aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url"); + aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username"); + aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password"); + try { if (vnfName != null) { - aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url"); - aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user"); - aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password"); String aaiGetQueryByVnfName = "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name="; String url = aaiHostURL + aaiGetQueryByVnfName; logger.info("url: " + url); response = AAIManager.getQueryByVnfName(url, aaiUser, aaiPassword, requestID, vnfName); } else if (vnfID != null) { - aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url"); - aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user"); - aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password"); String aaiGetQueryByVnfID = "/aai/v11/network/generic-vnfs/generic-vnf/"; String url = aaiHostURL + aaiGetQueryByVnfID; logger.info("url: " + url); 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 10cf173fc..add981c65 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 @@ -346,13 +346,16 @@ public class ControlLoopOperationManager implements Serializable { return null; } else if (response instanceof SOResponse) { SOResponse msoResponse = (SOResponse) response; + + Integer operationAttempt = this.attempts; + switch (msoResponse.httpResponseCode) { case 200: case 202: // // Consider it as success // - this.completeOperation(new Integer(1), msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); + this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -361,10 +364,12 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as failure // - this.completeOperation(new Integer(1), msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); + this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } + // increment operation attempts for retries + this.attempts += 1; return PolicyResult.FAILURE; } diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java index 59e97c239..ad106e555 100644 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java @@ -36,6 +36,7 @@ public class AaiSimulatorJaxRs { @GET @Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}") + @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String aaiGetQuery (@PathParam("vnfID") String vnfId) { @@ -63,6 +64,7 @@ public class AaiSimulatorJaxRs { @GET @Path("/v11/network/generic-vnfs/generic-vnf?vnf-name={vnfName}") + @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String getByVnfName (@PathParam("vnfName") String vnfName) { @@ -72,6 +74,7 @@ public class AaiSimulatorJaxRs { @GET @Path("/v11/network/generic-vnfs/generic-vnf/{vnfId}") + @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String getByVnfId (@PathParam("vnfId") String vnfId) { @@ -81,6 +84,7 @@ public class AaiSimulatorJaxRs { @GET @Path("/v11/nodes/vservers?vserver-name={vserverName}") + @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String getByVserverName (@PathParam("vserverName") String vserverName) { diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java index 926536e31..53ae7bc4b 100644 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java @@ -20,6 +20,7 @@ package org.onap.policy.simulators; +import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -27,12 +28,14 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; @Path("/api/nslcm/v1") public class VfcSimulatorJaxRs { @POST @Path("/ns/{nsInstanceId}/heal") + @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId, @Context final HttpServletResponse response) @@ -47,6 +50,7 @@ public class VfcSimulatorJaxRs { @GET @Path("/jobs/{jobId}") + @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String vfcGetQuery(@PathParam("jobId") String jobId) { return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}"; |