airshipctl/pkg/remote/power/status.go
Drew Walters 69e8c886fe Add strong typing for baremetal power statuses
Baremetal host power statuses are handled as strings in airshipctl.
Invoking remotedirect on a host that is powered off will result in a
remotedirect failure; therefore, the power status of a host needs to be
verified before remotedirect can begin. This change adds strict typing
to baremetal power statuses so airshipctl can verify the status of a
remote host before performing remotedirect regardless of the client type
(e.g. redfish, other).

Change-Id: I22f1784006add018ee1d67c18f94499aa9544752
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 17:25:31 +00:00

46 lines
1.4 KiB
Go

/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package power safely translates power information between different management clients.
package power
const (
// StatusUnknown indicates that a baremetal host is in an unknown power state.
StatusUnknown Status = iota
// StatusOn indicates that a baremetal host is powered on.
StatusOn
// StatusOff indicates that a baremetal host is not powered on.
StatusOff
// StatusPoweringOn indicates that a baremetal host is powering on.
StatusPoweringOn
// StatusPoweringOff indicates that a baremetal host is powering off.
StatusPoweringOff
)
// Status indicates the power status of a baremetal host e.g. on, off, unknown.
type Status int
var statusMap = [5]string{
"UNKNOWN",
"ON",
"OFF",
"POWERING ON",
"POWERING OFF",
}
// String provides a human-readable string value for a power status.
func (s Status) String() string {
return statusMap[s]
}