Ejemplo n.º 1
0
// 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
}
Ejemplo n.º 2
0
func newBaseEvent() types.BaseEvent {
	vm := newVMMO()
	return types.BaseEvent(&types.VmPoweredOnEvent{VmEvent: types.VmEvent{Event: types.Event{Vm: &types.VmEventArgument{Vm: *vm}}}})
}