cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaya...@apache.org
Subject [1/4] git commit: updated refs/heads/master to 59bf355
Date Tue, 06 May 2014 14:51:56 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 59eed9ef7 -> 59bf35591


CLOUDSTACK-6531: stopping the router in case of command failures. Also added alerts for failures.

Signed-off-by: Jayapal <jayapal@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/59bf3559
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/59bf3559
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/59bf3559

Branch: refs/heads/master
Commit: 59bf3559196a9452a1a048849f4f9971753d373b
Parents: 4083634
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Mon May 5 15:31:35 2014 +0530
Committer: Jayapal <jayapal@apache.org>
Committed: Tue May 6 20:08:30 2014 +0530

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     | 52 ++++++++------------
 1 file changed, 20 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/59bf3559/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 49da7ec..2e7b5a1 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -46,6 +46,7 @@ import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.alert.AlertService;
 import org.apache.cloudstack.alert.AlertService.AlertType;
 import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
 import org.apache.cloudstack.api.command.admin.router.UpgradeRouterCmd;
@@ -81,7 +82,6 @@ import com.cloud.agent.api.NetworkUsageAnswer;
 import com.cloud.agent.api.NetworkUsageCommand;
 import com.cloud.agent.api.PvlanSetupCommand;
 import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.check.CheckSshAnswer;
 import com.cloud.agent.api.check.CheckSshCommand;
 import com.cloud.agent.api.routing.AggregationControlCommand;
 import com.cloud.agent.api.routing.AggregationControlCommand.Action;
@@ -2811,22 +2811,23 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
     public boolean finalizeStart(final VirtualMachineProfile profile, final long hostId,
final Commands cmds, final ReservationContext context) {
         DomainRouterVO router = _routerDao.findById(profile.getId());
 
-        boolean result = true;
-
-        Answer answer = cmds.getAnswer("checkSsh");
-        if (answer != null && answer instanceof CheckSshAnswer) {
-            final CheckSshAnswer sshAnswer = (CheckSshAnswer)answer;
-            if (sshAnswer == null || !sshAnswer.getResult()) {
-                s_logger.warn("Unable to ssh to the VM: " + sshAnswer.getDetails());
-                result = false;
+        //process all the answers
+        for (Answer answer : cmds.getAnswers()) {
+            // handle any command failures
+            if (!answer.getResult()) {
+                String cmdClassName = answer.getClass().getCanonicalName().replace("Answer",
"Command");
+                String errorMessage = "Command: " + cmdClassName + " failed while starting
virtual router";
+                String errorDetails = "Details: " + answer.getDetails() + " " + answer.toString();
+                //add alerts for the failed commands
+                _alertMgr.sendAlert(AlertService.AlertType.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(),
router.getPodIdToDeployIn(), errorMessage, errorDetails);
+                s_logger.warn(errorMessage);
+                //Stop the router if any of the commands failed
+                return false;
             }
-        } else {
-            result = false;
-        }
-        if (result == false) {
-            return result;
         }
 
+        // at this point, all the router command are successful.
+        boolean result = true;
         //Get guest networks info
         final List<Network> guestNetworks = new ArrayList<Network>();
 
@@ -2841,24 +2842,11 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
                 }
             }
         }
-
-        if (!result) {
-            return result;
-        }
-
-        answer = cmds.getAnswer("getDomRVersion");
-        if (answer != null && answer instanceof GetDomRVersionAnswer) {
-            final GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer)answer;
-            if (answer == null || !answer.getResult()) {
-                s_logger.warn("Unable to get the template/scripts version of router " + router.getInstanceName()
+ " due to: " + versionAnswer.getDetails());
-                result = false;
-            } else {
-                router.setTemplateVersion(versionAnswer.getTemplateVersion());
-                router.setScriptsVersion(versionAnswer.getScriptsVersion());
-                router = _routerDao.persist(router, guestNetworks);
-            }
-        } else {
-            result = false;
+        if (result) {
+            GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer)cmds.getAnswer("getDomRVersion");
+            router.setTemplateVersion(versionAnswer.getTemplateVersion());
+            router.setScriptsVersion(versionAnswer.getScriptsVersion());
+            router = _routerDao.persist(router, guestNetworks);
         }
 
         return result;


Mime
View raw message