コード例 #1
0
ファイル: container_cache.go プロジェクト: kjplatz/vic
// callback for the event stream
func callback(ie event.Event, session *session.Session) {
	// grab the container from the cache
	container := containers.Container(ie.Reference())
	if container != nil {

		newState := eventedState(ie.String(), container.State)
		// do we have a state change
		if newState != container.State {
			switch newState {
			case StateStopping:
				// set state only in cache -- allow tether / tools to update vmx
				log.Debugf("Container(%s) Shutdown via OOB activity", container.ExecConfig.ID)
				container.State = StateStopped
			case StateRunning:
				// set state only in cache -- allow tether / tools to update vmx
				log.Debugf("Container(%s) started via OOB activity", container.ExecConfig.ID)
				container.State = newState
			case StateStopped:
				log.Debugf("Container(%s) stopped via OOB activity", container.ExecConfig.ID)
				container.State = newState
			case StateSuspended:
				//set state only in cache
				log.Debugf("Container(%s) suspened via OOB activity", container.ExecConfig.ID)
				container.State = newState
			case StateRemoved:
				log.Debugf("Container(%s) removed via OOB activity", container.ExecConfig.ID)
				// remove from cache
				containers.Remove(container.ExecConfig.ID)

			}
		}
	}

	return
}
コード例 #2
0
ファイル: manager.go プロジェクト: kjplatz/vic
// action will execute the callbacks
func action(mgr *vSphereManager, vmwEve event.Event) {
	for caller, callback := range mgr.callbacks {
		log.Debugf("EventManager callling back to %s on %s for Event(%s)", caller, vmwEve.Reference(), vmwEve.String())
		callback(vmwEve, mgr.session)
	}
}