From 875d836aeff308645ce59daf0ca59b77e0f13940 Mon Sep 17 00:00:00 2001 From: "Balaji, Ramya (rb111y)" Date: Tue, 4 Sep 2018 13:17:17 -0400 Subject: Fixed error message for rebuild 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) --- .../iaas/provider/operation/impl/RebuildServer.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src') diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebuildServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebuildServer.java index fa8b22b16..c320f49b4 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebuildServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebuildServer.java @@ -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]", -- cgit 1.2.3-korg