Пример #1
0
func validateAndGetNetworkPluginName(originClient *osclient.Client, pluginName string) (string, error) {
	if sdnplugin.IsOpenShiftNetworkPlugin(pluginName) {
		// Detect any plugin mismatches between node and master
		clusterNetwork, err := originClient.ClusterNetwork().Get(sdnapi.ClusterNetworkDefault)
		if kerrs.IsNotFound(err) {
			return "", fmt.Errorf("master has not created a default cluster network, network plugin %q can not start", pluginName)
		} else if err != nil {
			return "", fmt.Errorf("cannot fetch %q cluster network: %v", sdnapi.ClusterNetworkDefault, err)
		}

		if clusterNetwork.PluginName != strings.ToLower(pluginName) {
			if len(clusterNetwork.PluginName) != 0 {
				return "", fmt.Errorf("detected network plugin mismatch between OpenShift node(%q) and master(%q)", pluginName, clusterNetwork.PluginName)
			} else {
				// Do not return error in this case
				glog.Warningf(`either there is network plugin mismatch between OpenShift node(%q) and master or OpenShift master is running an older version where we did not persist plugin name`, pluginName)
			}
		}
	} else if pluginName == "" {
		// Auto detect network plugin configured by master
		clusterNetwork, err := originClient.ClusterNetwork().Get(sdnapi.ClusterNetworkDefault)
		if err == nil {
			return clusterNetwork.PluginName, nil
		}
	}

	return pluginName, nil
}
Пример #2
0
func getNetworkInfo(osClient *osclient.Client) (*NetworkInfo, error) {
	cn, err := osClient.ClusterNetwork().Get(osapi.ClusterNetworkDefault)
	if err != nil {
		return nil, err
	}

	return parseNetworkInfo(cn.Network, cn.ServiceNetwork)
}
Пример #3
0
func GetOpenShiftNetworkPlugin(osClient *osclient.Client) (string, bool, error) {
	cn, err := osClient.ClusterNetwork().Get(api.ClusterNetworkDefault)
	if err != nil {
		if kerrors.IsNotFound(err) {
			return "", false, nil
		}
		return "", false, err
	}
	return cn.PluginName, sdnapi.IsOpenShiftNetworkPlugin(cn.PluginName), nil
}
Пример #4
0
func NewOsdnRegistryInterface(osClient *osclient.Client, kClient *kclient.Client) *OsdnRegistryInterface {
	var clusterNetwork, serviceNetwork *net.IPNet
	cn, err := osClient.ClusterNetwork().Get("default")
	if err == nil {
		_, clusterNetwork, _ = net.ParseCIDR(cn.Network)
		_, serviceNetwork, _ = net.ParseCIDR(cn.ServiceNetwork)
	}
	// else the same error will occur again later and be reported

	return &OsdnRegistryInterface{
		oClient:          osClient,
		kClient:          kClient,
		serviceNetwork:   serviceNetwork,
		clusterNetwork:   clusterNetwork,
		namespaceOfPodIP: make(map[string]string),
	}
}