View Javadoc
1   package org.metricshub.ipmi.core.coding.commands.chassis;
2   
3   /*-
4    * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5    * IPMI Java Client
6    * ჻჻჻჻჻჻
7    * Copyright 2023 Verax Systems, MetricsHub
8    * ჻჻჻჻჻჻
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   *
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
23   */
24  
25  /**
26   * Specifies types of commands that can be sent to BMC via
27   * {@link ChassisControl} command.
28   */
29  public enum PowerCommand {
30      /**
31       * Force system into soft off (S4/S45) state. This is for 'emergency'
32       * management power down actions. The command does not initiate a clean
33       * shut-down of the operating system prior to powering down the system.
34       */
35      PowerDown(PowerCommand.POWERDOWN), PowerUp(PowerCommand.POWERUP),
36      /**
37       * Hard reset. In some implementations, the BMC may not know whether a reset
38       * will cause any particular effect and will pulse the system reset signal
39       * regardless of power state. If the implementation can tell that no action
40       * will occur if a reset is delivered in a given power state, then it is
41       * recommended (but still optional) that a D5h 'Request parameter(s) not
42       * supported in present state.' error completion code be returned.
43       */
44      HardReset(PowerCommand.HARDRESET), ;
45      private static final int POWERDOWN = 0;
46      private static final int POWERUP = 1;
47      private static final int HARDRESET = 3;
48  
49      private int code;
50  
51      PowerCommand(int code) {
52          this.code = code;
53      }
54  
55      public int getCode() {
56          return code;
57      }
58  
59      public static PowerCommand parseInt(int value) {
60          switch (value) {
61          case POWERDOWN:
62              return PowerDown;
63          case POWERUP:
64              return PowerUp;
65          case HARDRESET:
66              return HardReset;
67          default:
68              throw new IllegalArgumentException("Invalid value: " + value);
69          }
70      }
71  }