コード例 #1
0
ファイル: manager_test.go プロジェクト: kjplatz/vic
// utility function to mock a vsphere event
//
// size is the number of events to create
// lifeCycle is true when we want to generate state events
// lifeCycle events == poweredOn, poweredOff, etc..
func eventPage(size int, lifeCycle bool) []types.BaseEvent {
	page := make([]types.BaseEvent, 0, size)
	moid := 100
	for i := 0; i < size; i++ {
		var eve types.BaseEvent
		moid++
		vm := types.ManagedObjectReference{Value: strconv.Itoa(moid), Type: "vm"}
		if lifeCycle {
			eve = types.BaseEvent(&types.VmPoweredOnEvent{VmEvent: types.VmEvent{Event: types.Event{Vm: &types.VmEventArgument{Vm: vm}}}})
		} else {
			eve = types.BaseEvent(&types.VmReconfiguredEvent{VmEvent: types.VmEvent{Event: types.Event{Vm: &types.VmEventArgument{Vm: vm}}}})
		}

		page = append(page, eve)
	}

	return page
}
コード例 #2
0
ファイル: manager_test.go プロジェクト: vmware/vic
func newBaseEvent() types.BaseEvent {
	vm := newVMMO()
	return types.BaseEvent(&types.VmPoweredOnEvent{VmEvent: types.VmEvent{Event: types.Event{Vm: &types.VmEventArgument{Vm: *vm}}}})
}