Fixed error message for rebuild 89/64489/1
authorBalaji, Ramya (rb111y) <rb111y@att.com>
Tue, 4 Sep 2018 17:17:17 +0000 (13:17 -0400)
committerBalaji, Ramya (rb111y) <rb111y@att.com>
Tue, 4 Sep 2018 17:31:13 +0000 (13:31 -0400)
Corrected code to ensure that all errors
in retrieving images do not result in a misleading
error message attributed to bootable volumes.
Instead, a generic error message processing has
been added.

Issue-ID: APPC-1189
Change-Id: Ic4dc917e86429a3ab7bce4432796083f0741c637
Signed-off-by: Balaji, Ramya (rb111y) <rb111y@att.com>
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebuildServer.java

index fa8b22b..c320f49 100644 (file)
@@ -9,15 +9,15 @@
 * 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=========================================================
 */
 
@@ -77,7 +77,7 @@ public class RebuildServer extends ProviderServerOperation {
     // processing the request"
     private long rebuildSleepTime = 10L * 1000L;
 
-    /**
+    /*
      * Rebuild the indicated server with the indicated image. This method assumes
      * the server has been determined to be in the correct state to do the rebuild.
      *
@@ -176,6 +176,16 @@ public class RebuildServer extends ProviderServerOperation {
          */
         setTimeForMetricsLogger();
         String msg;
+        //Throw error if boot source is unknown
+        if (ServerBootSource.UNKNOWN.equals(builtFrom)) {
+            logger.debug("Boot Source Unknown" );
+            msg = String.format("Error occured when retrieving server boot source [%s]!!!", server.getId());
+            logger.error(msg);
+            generateEvent(rc, false,msg);
+            metricsLogger.error(msg);
+            throw new RequestFailedException("Rebuild Server", msg, HttpStatus.INTERNAL_SERVER_ERROR_500, server);
+        }
+
         // Throw exception for non image/snap boot source
         if (ServerBootSource.VOLUME.equals(builtFrom)) {
             msg = String.format("Rebuilding is currently not supported for servers built from bootable volumes [%s]",