func (d *Dispatcher) isVCH(vm *vm.VirtualMachine) (bool, error) { if vm == nil { return false, errors.New("nil parameter") } defer trace.End(trace.Begin(vm.InventoryPath)) info, err := vm.FetchExtraConfig(d.ctx) if err != nil { err = errors.Errorf("Failed to fetch guest info of appliance vm: %s", err) return false, err } var remoteConf config.VirtualContainerHostConfigSpec extraconfig.Decode(extraconfig.MapSource(info), &remoteConf) // if the moref of the target matches where we expect to find it for a VCH, run with it if remoteConf.ExecutorConfig.ID == vm.Reference().String() { return true, nil } return false, nil }
func (d *Dispatcher) GetVCHConfig(vm *vm.VirtualMachine) (*metadata.VirtualContainerHostConfigSpec, error) { defer trace.End(trace.Begin("")) //this is the appliance vm mapConfig, err := vm.FetchExtraConfig(d.ctx) if err != nil { err = errors.Errorf("Failed to get VM extra config of %s, %s", vm.Reference(), err) log.Errorf("%s", err) return nil, err } data := extraconfig.MapSource(mapConfig) vchConfig := &metadata.VirtualContainerHostConfigSpec{} result := extraconfig.Decode(data, vchConfig) if result == nil { err = errors.Errorf("Failed to decode VM configuration %s, %s", vm.Reference(), err) log.Errorf("%s", err) return nil, err } // vchConfig.ID return vchConfig, nil }