本文整理匯總了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
}
示例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)
}
示例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
}
示例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),
}
}