Fix in CreateSnapshot 37/29637/2
authorburdziak <olaf.burdziakowski@nokia.com>
Tue, 30 Jan 2018 11:47:50 +0000 (12:47 +0100)
committerPatrick Brady <pb071s@att.com>
Wed, 31 Jan 2018 20:49:54 +0000 (20:49 +0000)
Change-Id: I05fa53bd4573aa4179fd488c617b338d9188f7ad
Issue-ID: APPC-552
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java

index 5165b0c..4513352 100644 (file)
@@ -166,11 +166,14 @@ public class CreateSnapshot extends ProviderServerOperation {
             String identStr = (ident == null) ? null : ident.toString();
 
             Context context = null;
+            String tenantName = "Unknown";//this variable is also used in catch
             try {
                 context = getContext(rc, vm_url, identStr);
                 if (context != null) {
+                    tenantName = context.getTenantName();
                     Server server = lookupServer(rc, context, vm.getServerId());
-                    logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+
+                    logger.debug(Msg.SERVER_FOUND, vm_url, tenantName, server.getStatus().toString());
 
                     if (hasImageAccess(rc, context)) {
                         snapshot = createSnapshot(rc, server);
@@ -192,7 +195,7 @@ public class CreateSnapshot extends ProviderServerOperation {
             } catch (Exception e1) {
                 msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
                         Operation.SNAPSHOT_SERVICE.toString(), vm_url,
-                        context == null ? "Unknown" : context.getTenantName());
+                        tenantName);
                 logger.error(msg, e1);
                 doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
             }