Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emlin committed Nov 4, 2016
1 parent 8733dbe commit 339697d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pkg/vsphere/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ import (
"github.com/vmware/vic/pkg/vsphere/tasks"
)

const (
summary = "summary"
connectionStatus = "summary.runtime.connectionState"
)

type InvalidState struct {
r types.ManagedObjectReference
}
Expand Down Expand Up @@ -479,7 +474,7 @@ func (vm *VirtualMachine) fixVM(ctx context.Context) error {
return err
}

properties := []string{"summary.config", "summary.runtime", "resourcePool", "parentVApp"}
properties := []string{"summary.config", "summary.runtime.host", "resourcePool", "parentVApp"}
log.Debugf("Get vm properties %s", properties)
var mvm mo.VirtualMachine
if err = vm.VirtualMachine.Properties(ctx, vm.Reference(), properties, &mvm); err != nil {
Expand Down Expand Up @@ -536,7 +531,7 @@ func (vm *VirtualMachine) needsFix(ctx context.Context, err error) bool {

func (vm *VirtualMachine) IsInvalidState(ctx context.Context) bool {
var o mo.VirtualMachine
if err := vm.VirtualMachine.Properties(ctx, vm.Reference(), []string{connectionStatus}, &o); err != nil {
if err := vm.VirtualMachine.Properties(ctx, vm.Reference(), []string{"summary.runtime.connectionState"}, &o); err != nil {
log.Debugf("Failed to get vm properties: %s", err)
return false
}
Expand Down Expand Up @@ -566,14 +561,14 @@ func (vm *VirtualMachine) Properties(ctx context.Context, r types.ManagedObjectR
log.Debugf("get vm properties %s of vm %s", ps, r)
contains := false
for i := range ps {
if ps[i] == summary {
if ps[i] == "summary" || ps[i] == "summary.runtime" {
contains = true
break
}
}
var newps []string
if !contains {
newps = append(ps, connectionStatus)
newps = append(ps, "summary.runtime.connectionState")
} else {
newps = append(newps, ps...)
}
Expand Down

0 comments on commit 339697d

Please sign in to comment.