import com.nokia.cbam.lcm.v32.api.OperationExecutionsApi;
import com.nokia.cbam.lcm.v32.api.VnfsApi;
import com.nokia.cbam.lcm.v32.model.OperationExecution;
+import com.nokia.cbam.lcm.v32.model.OperationType;
import com.nokia.cbam.lcm.v32.model.VnfInfo;
-import org.apache.http.HttpStatus;
+import java.util.*;
+import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.onap.vnfmdriver.model.JobDetailInfo;
import org.onap.vnfmdriver.model.JobDetailInfoResponseDescriptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.servlet.http.HttpServletResponse;
-import java.util.*;
+import static javax.servlet.http.HttpServletResponse.SC_SERVICE_UNAVAILABLE;
+import static java.util.Optional.empty;
+import static java.util.Optional.of;
import static com.google.common.base.Splitter.on;
import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Lists.newArrayList;
import static com.nokia.cbam.lcm.v32.model.OperationStatus.FAILED;
import static com.nokia.cbam.lcm.v32.model.OperationStatus.STARTED;
-import static java.util.Optional.empty;
-import static java.util.Optional.of;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
return jobId.getAsString();
}
+ /**
+ * @return is the component preparing for shutdown
+ */
+ public boolean isPreparingForShutDown(){
+ return preparingForShutDown;
+ }
+
/**
* Throws an exception in case the service is not ready to serve requests due to
* not being able to register to MSB or to subscribe to CBAM LCNs
String jobId = vnfId + SEPARATOR + UUID.randomUUID().toString();
synchronized (this) {
if (preparingForShutDown) {
- response.setStatus(HttpStatus.SC_SERVICE_UNAVAILABLE);
+ response.setStatus(SC_SERVICE_UNAVAILABLE);
throw buildFatalFailure(logger, "The service is preparing to shut down");
}
if (!selfRegistrationManager.isReady()) {
- response.setStatus(HttpStatus.SC_SERVICE_UNAVAILABLE);
+ response.setStatus(SC_SERVICE_UNAVAILABLE);
throw buildFatalFailure(logger, "The service is not yet ready");
}
}
}
private boolean isCurrentOperationTriggeredByJob(String jobId, OperationExecutionsApi cbamOperationExecutionApi, OperationExecution operationExecution) {
-
+ if (OperationType.MODIFY_INFO.equals(operationExecution.getOperationType())) {
+ //the modify info is never triggered by an external job
+ return false;
+ }
try {
Object operationParams = cbamOperationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet(operationExecution.getId(), NOKIA_LCM_API_VERSION).blockingFirst();
if (extractOnapJobId(operationParams).equals(jobId)) {
return true;
}
} catch (Exception e) {
- throw buildFatalFailure(logger, "Unable to retrieve operation parameters", e);
+ throw buildFatalFailure(logger, "Unable to retrieve operation parameters of operation with " + operationExecution.getId() + " identifier", e);
}
return false;
}
return of(cbamLcmApi.vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION).blockingFirst());
}
} catch (Exception e) {
- throw buildFatalFailure(logger, "Unable to retrieve VNF", e);
+ throw buildFatalFailure(logger, "Unable to retrieve VNF with " + vnfId + " identifier", e);
}
}
}