This repository has been archived by the owner on Jul 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
multitenant.go
55 lines (47 loc) · 1.76 KB
/
multitenant.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package multitenant
import (
"github.com/golang/glog"
"strings"
kclient "k8s.io/kubernetes/pkg/client"
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/util/exec"
"github.com/openshift/openshift-sdn/ovssubnet"
osclient "github.com/openshift/origin/pkg/client"
"github.com/openshift/origin/plugins/osdn"
)
func NetworkPluginName() string {
return "redhat/openshift-ovs-multitenant"
}
func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork string, clusterNetworkLength uint, serviceNetwork string) {
osdnInterface := osdn.NewOsdnRegistryInterface(osClient, kClient)
// get hostname from the gateway
output, err := exec.New().Command("hostname", "-f").CombinedOutput()
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
host := strings.TrimSpace(string(output))
kc, err := ovssubnet.NewMultitenantController(&osdnInterface, host, "", nil)
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
err = kc.StartMaster(false, clusterNetwork, clusterNetworkLength, serviceNetwork)
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
}
func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, plugin knetwork.NetworkPlugin, mtu uint) {
mp, ok := plugin.(*MultitenantPlugin)
if !ok {
glog.Fatalf("Failed to type cast provided plugin to a multitenant type plugin")
}
osdnInterface := osdn.NewOsdnRegistryInterface(osClient, kClient)
kc, err := ovssubnet.NewMultitenantController(&osdnInterface, hostname, publicIP, ready)
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
mp.OvsController = kc
err = kc.StartNode(false, false, mtu)
if err != nil {
glog.Fatalf("SDN Node failed: %v", err)
}
}