Updated Branches:
  refs/heads/4.3 fd5b9a278 -> 48a439156

[UCS] increate ipmi command retry


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

Branch: refs/heads/4.3
Commit: 48a43915681b9b4ce89f4b78129b38827a095c04
Parents: fd5b9a2
Author: Frank.Zhang <frank.zh...@citrix.com>
Authored: Tue Oct 29 17:49:39 2013 -0700
Committer: Frank.Zhang <frank.zh...@citrix.com>
Committed: Thu Dec 5 17:29:08 2013 -0800

----------------------------------------------------------------------
 .../networkservice/BareMetalResourceBase.java   | 33 ++++++++++++++++----
 1 file changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48a43915/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
 
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
index 1ac4eed..0daafd0 100755
--- 
a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
+++ 
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
@@ -281,8 +281,15 @@ public class BareMetalResourceBase extends ManagerBase 
implements ServerResource
                return doScript(cmd, null);
        }
 
-       protected boolean doScript(Script cmd, OutputInterpreter interpreter) {
-               int retry = 5;
+    protected boolean doScript(Script cmd, int retry) {
+        return doScript(cmd, null, retry);
+    }
+
+    protected boolean doScript(Script cmd, OutputInterpreter interpreter) {
+        return doScript(cmd, interpreter, 5);
+    }
+
+       protected boolean doScript(Script cmd, OutputInterpreter interpreter, 
int retry) {
                String res = null;
                while (retry-- > 0) {
                        if (interpreter == null) {
@@ -292,7 +299,11 @@ public class BareMetalResourceBase extends ManagerBase 
implements ServerResource
                        }
                        if (res != null && res.startsWith("Error: Unable to 
establish LAN")) {
                                s_logger.warn("IPMI script timeout(" + 
cmd.toString() + "), will retry " + retry + " times");
-                               continue;
+                try {
+                    TimeUnit.SECONDS.sleep(1);
+                } catch (InterruptedException e) {
+                }
+                continue;
                        } else if (res == null) {
                                return true;
                        } else {
@@ -540,8 +551,17 @@ public class BareMetalResourceBase extends ManagerBase 
implements ServerResource
        }
 
        protected RebootAnswer execute(final RebootCommand cmd) {
-               if (!doScript(_rebootCommand)) {
-                       return new RebootAnswer(cmd, "IPMI reboot failed", 
false);
+        String infoStr = "Command not supported in present state";
+        OutputInterpreter.AllLinesParser interpreter = new 
OutputInterpreter.AllLinesParser();
+               if (!doScript(_rebootCommand, interpreter, 10)) {
+            if (interpreter.getLines().contains(infoStr)) {
+                // try again, this error should be temporary
+                if (!doScript(_rebootCommand, interpreter, 10)) {
+                    return new RebootAnswer(cmd, "IPMI reboot failed", false);
+                }
+            } else {
+                           return new RebootAnswer(cmd, "IPMI reboot failed", 
false);
+            }
                }
 
                return new RebootAnswer(cmd, "reboot succeeded", true);
@@ -565,7 +585,8 @@ public class BareMetalResourceBase extends ManagerBase 
implements ServerResource
 
                        OutputInterpreter.AllLinesParser interpreter = new 
OutputInterpreter.AllLinesParser();
                        if (!doScript(_getStatusCommand, interpreter)) {
-                               s_logger.warn("Cannot get power status of " + 
_name + ", assume VM state was not changed");
+                success = true;
+                               s_logger.warn("Cannot get power status of " + 
_name + ", assume VM state changed successfully");
                                break;
                        }
 

Reply via email to