コード例 #1
0
ファイル: state_event.go プロジェクト: abhinandanpb/netplugin
func processGlobalFwdModeUpdEvent(netPlugin *plugin.NetPlugin, opts core.InstanceInfo, fwdMode string) {

	// parse store URL
	parts := strings.Split(opts.DbURL, "://")
	if len(parts) < 2 {
		log.Fatalf("Invalid cluster-store-url %s", opts.DbURL)
	}
	stateStore := parts[0]
	// initialize the config
	pluginConfig := plugin.Config{
		Drivers: plugin.Drivers{
			Network: "ovs",
			State:   stateStore,
		},
		Instance: opts,
	}
	pluginConfig.Instance.FwdMode = fwdMode
	netPlugin.GlobalFwdModeUpdate(pluginConfig)

	for _, master := range cluster.MasterDB {
		netPlugin.AddMaster(core.ServiceInfo{
			HostAddr: master.HostAddr,
			Port:     9001, //netmasterRPCPort
		})
	}

	serviceList, _ := cluster.ObjdbClient.GetService("netplugin")
	for _, serviceInfo := range serviceList {
		if serviceInfo.HostAddr != opts.VtepIP {
			netPlugin.AddPeerHost(core.ServiceInfo{
				HostAddr: serviceInfo.HostAddr,
				Port:     4789, //vxlanUDPPort
			})
		}
	}

}