You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by fr...@apache.org on 2013/10/28 22:48:28 UTC
git commit: updated refs/heads/4.2 to 16a51ee
Updated Branches:
refs/heads/4.2 1a3f39473 -> 16a51ee47
CLOUDSTACK-4674
[baremetal] /usr/share/cloudstack-common/scripts/util/ipmi.py script
need to recognize various ipmi version and BMC type of server
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/16a51ee4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/16a51ee4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/16a51ee4
Branch: refs/heads/4.2
Commit: 16a51ee47925eeaafb27bee5f0610800b79f93fc
Parents: 1a3f394
Author: Frank.Zhang <fr...@citrix.com>
Authored: Mon Oct 28 14:48:01 2013 -0700
Committer: Frank.Zhang <fr...@citrix.com>
Committed: Mon Oct 28 14:48:01 2013 -0700
----------------------------------------------------------------------
.../networkservice/BareMetalResourceBase.java | 19 ++++++++++++++++
scripts/util/ipmi.py | 23 ++++++++++++++------
server/src/com/cloud/configuration/Config.java | 1 +
3 files changed, 36 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16a51ee4/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 d84096e..abe1d4d 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
@@ -30,6 +30,8 @@ import javax.ejb.Local;
import javax.naming.ConfigurationException;
import com.cloud.agent.api.*;
+import com.cloud.configuration.Config;
+import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.utils.Pair;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.log4j.Logger;
@@ -155,6 +157,14 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_isEchoScAgent = Boolean.valueOf(echoScAgent);
}
+ String ipmiIface = "default";
+ try {
+ ConfigurationDao configDao = ComponentContext.getComponent(ConfigurationDao.class);
+ ipmiIface = configDao.getValue(Config.BaremetalIpmiLanInterface.key());
+ } catch (Exception e) {
+ s_logger.debug(e.getMessage(), e);
+ }
+
String injectScript = "scripts/util/ipmi.py";
String scriptPath = Script.findScript("", injectScript);
if (scriptPath == null) {
@@ -164,6 +174,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_pingCommand = new Script2(pythonPath, s_logger);
_pingCommand.add(scriptPath);
_pingCommand.add("ping");
+ _pingCommand.add("interface=" + ipmiIface);
_pingCommand.add("hostname=" + _ip);
_pingCommand.add("usrname=" + _username);
_pingCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -171,6 +182,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_setPxeBootCommand = new Script2(pythonPath, s_logger);
_setPxeBootCommand.add(scriptPath);
_setPxeBootCommand.add("boot_dev");
+ _setPxeBootCommand.add("interface=" + ipmiIface);
_setPxeBootCommand.add("hostname=" + _ip);
_setPxeBootCommand.add("usrname=" + _username);
_setPxeBootCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -179,6 +191,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_setDiskBootCommand = new Script2(pythonPath, s_logger);
_setDiskBootCommand.add(scriptPath);
_setDiskBootCommand.add("boot_dev");
+ _setDiskBootCommand.add("interface=" + ipmiIface);
_setDiskBootCommand.add("hostname=" + _ip);
_setDiskBootCommand.add("usrname=" + _username);
_setDiskBootCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -187,6 +200,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_rebootCommand = new Script2(pythonPath, s_logger);
_rebootCommand.add(scriptPath);
_rebootCommand.add("reboot");
+ _rebootCommand.add("interface=" + ipmiIface);
_rebootCommand.add("hostname=" + _ip);
_rebootCommand.add("usrname=" + _username);
_rebootCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -194,6 +208,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_getStatusCommand = new Script2(pythonPath, s_logger);
_getStatusCommand.add(scriptPath);
_getStatusCommand.add("ping");
+ _getStatusCommand.add("interface=" + ipmiIface);
_getStatusCommand.add("hostname=" + _ip);
_getStatusCommand.add("usrname=" + _username);
_getStatusCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -201,6 +216,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_powerOnCommand = new Script2(pythonPath, s_logger);
_powerOnCommand.add(scriptPath);
_powerOnCommand.add("power");
+ _powerOnCommand.add("interface=" + ipmiIface);
_powerOnCommand.add("hostname=" + _ip);
_powerOnCommand.add("usrname=" + _username);
_powerOnCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -209,6 +225,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_powerOffCommand = new Script2(pythonPath, s_logger);
_powerOffCommand.add(scriptPath);
_powerOffCommand.add("power");
+ _powerOffCommand.add("interface=" + ipmiIface);
_powerOffCommand.add("hostname=" + _ip);
_powerOffCommand.add("usrname=" + _username);
_powerOffCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -217,6 +234,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_forcePowerOffCommand = new Script2(pythonPath, s_logger);
_forcePowerOffCommand.add(scriptPath);
_forcePowerOffCommand.add("power");
+ _forcePowerOffCommand.add("interface=" + ipmiIface);
_forcePowerOffCommand.add("hostname=" + _ip);
_forcePowerOffCommand.add("usrname=" + _username);
_forcePowerOffCommand.add("password=" + _password, ParamType.PASSWORD);
@@ -225,6 +243,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
_bootOrRebootCommand = new Script2(pythonPath, s_logger);
_bootOrRebootCommand.add(scriptPath);
_bootOrRebootCommand.add("boot_or_reboot");
+ _bootOrRebootCommand.add("interface=" + ipmiIface);
_bootOrRebootCommand.add("hostname=" + _ip);
_bootOrRebootCommand.add("usrname=" + _username);
_bootOrRebootCommand.add("password=" + _password, ParamType.PASSWORD);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16a51ee4/scripts/util/ipmi.py
----------------------------------------------------------------------
diff --git a/scripts/util/ipmi.py b/scripts/util/ipmi.py
index c9e9a66..0cd6fc0 100755
--- a/scripts/util/ipmi.py
+++ b/scripts/util/ipmi.py
@@ -83,6 +83,15 @@ def check_tool():
print "Can not find ipmitool"
return False
+def addInterfaceOption(cmd, args):
+ iface = args.get("interface")
+ if not iface or iface == "default":
+ return cmd
+
+ cmd.insert(0, iface)
+ cmd.insert(0, "-I")
+ return cmd
+
def ping(args):
hostname = args.get("hostname")
usrname = args.get("usrname")
@@ -92,7 +101,7 @@ def ping(args):
print "No hostname"
return 1
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status")
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status"], args))
if o.ret:
print o.stderr
return 1
@@ -114,7 +123,7 @@ def boot_dev(args):
print "No boot device specified"
return 1
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "bootdev", dev)
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "bootdev", dev], args))
if o.ret:
print o.stderr
return 1
@@ -130,16 +139,16 @@ def reboot(args):
print "No hostname"
return 1
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status")
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status"], args))
if o.ret:
print o.stderr
return 1
if "is on" in o.stdout:
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "cycle")
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "cycle"], args))
else:
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "reset")
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "reset"], args))
if o.ret:
print o.stderr
@@ -157,7 +166,7 @@ def power(args):
print "No hostname"
return 1
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", action)
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "power", action], args))
if o.ret:
print o.stderr
return 1
@@ -168,7 +177,7 @@ def boot_or_reboot(args):
hostname = args.get("hostname")
usrname = args.get("usrname")
password = args.get("password")
- o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status")
+ o = ipmitool(*addInterfaceOption(["-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status"], args))
if o.ret:
print o.stderr
return 1
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16a51ee4/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 0c78c53..f3cb919 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -423,6 +423,7 @@ public enum Config {
EnableBaremetalSecurityGroupAgentEcho("Advanced", ManagementServer.class, Boolean.class, "enable.baremetal.securitygroup.agent.echo", "false", "After starting provision process, periodcially echo security agent installed in the template. Treat provisioning as success only if echo successfully", null),
IntervalToEchoBaremetalSecurityGroupAgent("Advanced", ManagementServer.class, Integer.class, "interval.baremetal.securitygroup.agent.echo", "10", "Interval to echo baremetal security group agent, in seconds", null),
TimeoutToEchoBaremetalSecurityGroupAgent("Advanced", ManagementServer.class, Integer.class, "timeout.baremetal.securitygroup.agent.echo", "3600", "Timeout to echo baremetal security group agent, in seconds, the provisioning process will be treated as a failure", null),
+ BaremetalIpmiLanInterface("Advanced", ManagementServer.class, String.class, "baremetal.ipmi.lan.interface", "default", "option specified in -I option of impitool. candidates are: open/bmc/lipmi/lan/lanplus/free/imb, see ipmitool man page for details. default valule 'default' means using default option of ipmitool", null),
ApiLimitEnabled("Advanced", ManagementServer.class, Boolean.class, "api.throttling.enabled", "false", "Enable/disable Api rate limit", null),
ApiLimitInterval("Advanced", ManagementServer.class, Integer.class, "api.throttling.interval", "1", "Time interval (in seconds) to reset API count", null),