summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenes Nemeth <denes.nemeth@nokia.com>2018-05-17 10:54:28 +0200
committerDenes Nemeth <denes.nemeth@nokia.com>2018-05-17 10:55:09 +0200
commitb884556a9c083ffe9450e55fd67ae0574e475959 (patch)
tree42dfd29eb65163c8d888b75dfcc78166913f4082
parent65de5e8a56100c0c44b8fce128d4b8c8e67a2a0c (diff)
Fix LCN handling during healing
Change-Id: I561d65b5861dee410aeb4b71d4037afd44cafe17 Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com> Issue-ID: VFC-728
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java27
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java1
3 files changed, 19 insertions, 11 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
index b4e59151..116420d6 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
@@ -81,7 +81,7 @@ public class CbamUtils {
return new OperationMustBeAborted(msg);
}
- private static class OperationMustBeAborted extends RuntimeException {
+ public static class OperationMustBeAborted extends RuntimeException {
OperationMustBeAborted(String msg) {
super(msg);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
index 9b497343..88c1e007 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
@@ -28,6 +28,8 @@ import java.util.Optional;
import java.util.Set;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.OperationMustBeAborted;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager;
@@ -210,15 +212,19 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
JsonObject operationResult = root.getAsJsonObject().get("operationResult").getAsJsonObject();
if (isAbsent(operationResult, "cbam_pre") ||
isAbsent(operationResult, "cbam_post")) {
- return handleFailure(operationExecution, null);
+ return handleFailure(operationExecution);
} else {
return of(new Gson().fromJson(operationResult, ReportedAffectedConnectionPoints.class));
}
} else {
- return handleFailure(operationExecution, null);
+ return handleFailure(operationExecution);
}
- } catch (Exception e) {
- return handleFailure(operationExecution, e);
+ }
+ catch(OperationMustBeAborted handledFailuire){
+ throw handledFailuire;
+ }
+ catch (Exception e) {
+ return toleratedFailure();
}
}
@@ -226,15 +232,16 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
return !operationResult.has(key) || !operationResult.get(key).isJsonArray();
}
- private Optional<ReportedAffectedConnectionPoints> handleFailure(OperationExecution operationExecution, Exception e) {
+ private Optional<ReportedAffectedConnectionPoints> handleFailure(OperationExecution operationExecution) {
if (operationExecution.getStatus() == OperationStatus.FAILED) {
- logger.warn("The operation failed and the affected connection points were not reported");
- return empty();
+ return toleratedFailure();
} else {
- if (e != null) {
- throw buildFatalFailure(logger, PROBLEM, e);
- }
throw buildFatalFailure(logger, PROBLEM);
}
}
+
+ private Optional<ReportedAffectedConnectionPoints> toleratedFailure() {
+ logger.warn("The operation failed and the affected connection points were not reported");
+ return empty();
+ }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
index bfb30abd..d0657852 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
@@ -23,6 +23,7 @@ import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.concurrent.*;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;