當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.ClusterNetwork方法代碼示例

本文整理匯總了Golang中github.com/openshift/origin/pkg/client.Client.ClusterNetwork方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.ClusterNetwork方法的具體用法?Golang Client.ClusterNetwork怎麽用?Golang Client.ClusterNetwork使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/openshift/origin/pkg/client.Client的用法示例。


在下文中一共展示了Client.ClusterNetwork方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: validateAndGetNetworkPluginName

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
}
開發者ID:rhamilto,項目名稱:origin,代碼行數:28,代碼來源:node_config.go

示例2: getNetworkInfo

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)
}
開發者ID:pweil-,項目名稱:origin,代碼行數:8,代碼來源:common.go

示例3: GetOpenShiftNetworkPlugin

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
}
開發者ID:juanluisvaladas,項目名稱:origin,代碼行數:10,代碼來源:util.go

示例4: NewOsdnRegistryInterface

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),
	}
}
開發者ID:kimsh92,項目名稱:origin,代碼行數:17,代碼來源:osdn.go


注:本文中的github.com/openshift/origin/pkg/client.Client.ClusterNetwork方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。