-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathflatsdn.go
More file actions
49 lines (41 loc) · 1.45 KB
/
flatsdn.go
File metadata and controls
49 lines (41 loc) · 1.45 KB
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
package flatsdn
import (
"github.com/golang/glog"
"strings"
kclient "k8s.io/kubernetes/pkg/client"
"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-subnet"
}
func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork string, clusterNetworkLength uint) {
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.NewKubeController(&osdnInterface, host, "", nil)
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
err = kc.StartMaster(false, clusterNetwork, clusterNetworkLength)
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{}) {
osdnInterface := osdn.NewOsdnRegistryInterface(osClient, kClient)
kc, err := ovssubnet.NewKubeController(&osdnInterface, hostname, publicIP, ready)
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
err = kc.StartNode(false, false)
if err != nil {
glog.Fatalf("SDN Node failed: %v", err)
}
}