add top-level "power" command as shortcut to chassis power commands

This commit is contained in:
Duncan Laurie 2005-09-09 23:19:41 +00:00
parent 6cb97e4327
commit 8a0559a651
3 changed files with 37 additions and 0 deletions

View File

@ -54,5 +54,6 @@
int ipmi_chassis_power_status(struct ipmi_intf * intf);
int ipmi_chassis_power_control(struct ipmi_intf * intf, uint8_t ctl);
int ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv);
int ipmi_power_main(struct ipmi_intf * intf, int argc, char ** argv);
#endif /*IPMI_CHASSIS_H*/

View File

@ -610,6 +610,41 @@ ipmi_chassis_power_policy(struct ipmi_intf * intf, uint8_t policy)
return 0;
}
int
ipmi_power_main(struct ipmi_intf * intf, int argc, char ** argv)
{
int rc = 0;
uint8_t ctl = 0;
if ((argc < 1) || (strncmp(argv[0], "help", 4) == 0)) {
lprintf(LOG_NOTICE, "chassis power Commands: status, on, off, cycle, reset, diag, soft");
return 0;
}
if (strncmp(argv[0], "status", 6) == 0) {
rc = ipmi_chassis_print_power_status(intf);
return rc;
}
if ((strncmp(argv[0], "up", 2) == 0) || (strncmp(argv[0], "on", 2) == 0))
ctl = IPMI_CHASSIS_CTL_POWER_UP;
else if ((strncmp(argv[0], "down", 4) == 0) || (strncmp(argv[0], "off", 3) == 0))
ctl = IPMI_CHASSIS_CTL_POWER_DOWN;
else if (strncmp(argv[0], "cycle", 5) == 0)
ctl = IPMI_CHASSIS_CTL_POWER_CYCLE;
else if (strncmp(argv[0], "reset", 5) == 0)
ctl = IPMI_CHASSIS_CTL_HARD_RESET;
else if (strncmp(argv[0], "diag", 4) == 0)
ctl = IPMI_CHASSIS_CTL_PULSE_DIAG;
else if ((strncmp(argv[0], "acpi", 4) == 0) || (strncmp(argv[0], "soft", 4) == 0))
ctl = IPMI_CHASSIS_CTL_ACPI_SOFT;
else {
lprintf(LOG_ERR, "Invalid chassis power command: %s", argv[0]);
return -1;
}
rc = ipmi_chassis_power_control(intf, ctl);
return rc;
}
int
ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv)
{

View File

@ -82,6 +82,7 @@ struct ipmi_cmd ipmitool_cmd_list[] = {
{ ipmi_rawi2c_main, "i2c", "Send an I2C Master Write-Read command and print response" },
{ ipmi_lanp_main, "lan", "Configure LAN Channels" },
{ ipmi_chassis_main, "chassis", "Get chassis status and set power state" },
{ ipmi_power_main, "power", "Shortcut to chassis power commands" },
{ ipmi_event_main, "event", "Send pre-defined events to MC" },
{ ipmi_mc_main, "mc", "Management Controller status and global enables" },
{ ipmi_mc_main, "bmc", NULL }, /* for backwards compatibility */