properly support cases where only min is passed

release/release-0.2.0
parent edf1530816
commit 6372875ead

@ -58,8 +58,14 @@ func (x *ServersStatusCommand) Execute(args []string) error {
Unknown(fmt.Sprintf("%s: %s", "Error retrieving server", err))
}
if vm.Server.Cores >= x.Min && vm.Server.Cores <= x.Max {
Ok(fmt.Sprintf("Expected amount (%d <= %d <= %d) of cores assigned: %d", x.Min, vm.Server.Cores, x.Max, vm.Server.Cores))
if x.Max == 0 {
if vm.Server.Cores >= x.Min {
Ok(fmt.Sprintf("Expected amount (%d <= %d) of cores assigned: %d", x.Min, vm.Server.Cores, vm.Server.Cores))
}
} else {
if vm.Server.Cores >= x.Min && vm.Server.Cores <= x.Max {
Ok(fmt.Sprintf("Expected amount (%d <= %d <= %d) of cores assigned: %d", x.Min, vm.Server.Cores, x.Max, vm.Server.Cores))
}
}
Critical(fmt.Sprintf("Expect amount (%d <= %d <= %d) of cores NOT assigned: %d", x.Min, vm.Server.Cores, x.Max, vm.Server.Cores))
@ -72,8 +78,14 @@ func (x *ServersStatusCommand) Execute(args []string) error {
Unknown(fmt.Sprintf("%s: %s", "Error retrieving server", err))
}
if vm.Server.Memory >= x.Min && vm.Server.Memory <= x.Max {
Ok(fmt.Sprintf("Expected amount (%d <= %d <= %d) of memory assigned: %d", x.Min, vm.Server.Memory, x.Max, vm.Server.Memory))
if x.Max == 0 {
if vm.Server.Memory >= x.Min {
Ok(fmt.Sprintf("Expected amount (%d <= %d) of memory assigned: %d", x.Min, vm.Server.Memory, vm.Server.Memory))
}
} else {
if vm.Server.Memory >= x.Min && vm.Server.Memory <= x.Max {
Ok(fmt.Sprintf("Expected amount (%d <= %d <= %d) of memory assigned: %d", x.Min, vm.Server.Memory, x.Max, vm.Server.Memory))
}
}
Critical(fmt.Sprintf("Expect amount (%d <= %d <= %d) of memory NOT assigned: %d", x.Min, vm.Server.Memory, x.Max, vm.Server.Memory))

Loading…
Cancel
Save