57
57
// HardwareCharacteristics represents the characteristics of the instance (if known).
58
58
// Attributes that are nil are unknown or not supported.
59
59
type HardwareCharacteristics struct {
60
Arch *string `json:"arch,omitempty" yaml:"arch,omitempty"`
61
Mem *uint64 `json:"mem,omitempty" yaml:"mem,omitempty"`
62
RootDisk *uint64 `json:"root-disk,omitempty" yaml:"rootdisk,omitempty"`
63
CpuCores *uint64 `json:"cpu-cores,omitempty" yaml:"cpucores,omitempty"`
64
CpuPower *uint64 `json:"cpu-power,omitempty" yaml:"cpupower,omitempty"`
65
Tags *[]string `json:"tags,omitempty" yaml:"tags,omitempty"`
60
// Arch is the architecture of the processor.
61
Arch *string `json:"arch,omitempty" yaml:"arch,omitempty"`
63
// Mem is the size of RAM in megabytes.
64
Mem *uint64 `json:"mem,omitempty" yaml:"mem,omitempty"`
66
// RootDisk is the size of the disk in megabytes.
67
RootDisk *uint64 `json:"root-disk,omitempty" yaml:"rootdisk,omitempty"`
69
// CpuCores is the number of logical cores the processor has.
70
CpuCores *uint64 `json:"cpu-cores,omitempty" yaml:"cpucores,omitempty"`
72
// CpuPower is a relative representation of the speed of the processor.
73
CpuPower *uint64 `json:"cpu-power,omitempty" yaml:"cpupower,omitempty"`
75
// Tags is a list of strings that identify the machine.
76
Tags *[]string `json:"tags,omitempty" yaml:"tags,omitempty"`
78
// AvailabilityZone defines the zone in which the machine resides.
67
79
AvailabilityZone *string `json:"availability-zone,omitempty" yaml:"availabilityzone,omitempty"`
73
85
strs = append(strs, fmt.Sprintf("arch=%s", *hc.Arch))
75
87
if hc.CpuCores != nil {
76
strs = append(strs, fmt.Sprintf("cpu-cores=%d", *hc.CpuCores))
88
strs = append(strs, fmt.Sprintf("cores=%d", *hc.CpuCores))
78
90
if hc.CpuPower != nil {
79
91
strs = append(strs, fmt.Sprintf("cpu-power=%d", *hc.CpuPower))
93
105
return strings.Join(strs, " ")
96
// Implement gnuflag.Value
97
func (hc *HardwareCharacteristics) Set(s string) error {
98
parsed, err := ParseHardware(s)
106
108
// MustParseHardware constructs a HardwareCharacteristics from the supplied arguments,
107
109
// as Parse, but panics on failure.
108
110
func MustParseHardware(args ...string) HardwareCharacteristics {