示例#1
0
func handleNetworkEvents(netPlugin *plugin.NetPlugin, crt *crt.CRT,
	opts cliOpts, retErr chan error) {
	rsps := make(chan core.WatchState)
	go processStateEvent(netPlugin, crt, opts, rsps)
	cfg := drivers.OvsCfgNetworkState{}
	cfg.StateDriver = netPlugin.StateDriver
	retErr <- cfg.WatchAll(rsps)
	return
}
示例#2
0
文件: main.go 项目: golisai/netplugin
// XXX: This function should be returning logical state instead of driver state
func (d *daemon) networks(id string) ([]core.State, error) {
	var (
		err error
		nw  *drivers.OvsCfgNetworkState
	)

	nw = &drivers.OvsCfgNetworkState{}
	if nw.StateDriver, err = utils.GetStateDriver(); err != nil {
		return nil, err
	}

	if id == "all" {
		return nw.ReadAll()
	} else if err := nw.Read(id); err == nil {
		return []core.State{core.State(nw)}, nil
	}

	return nil, core.Errorf("Unexpected code path")
}