Browse code

Windows: Enable compile

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/05/27 02:46:21
Showing 6 changed files
1 1
deleted file mode 100644
... ...
@@ -1,25 +0,0 @@
1
-package libnetwork
2
-
3
-import (
4
-	"github.com/docker/libnetwork/driverapi"
5
-	"github.com/docker/libnetwork/drivers/bridge"
6
-	"github.com/docker/libnetwork/drivers/host"
7
-	"github.com/docker/libnetwork/drivers/null"
8
-	"github.com/docker/libnetwork/drivers/remote"
9
-)
10
-
11
-type driverTable map[string]driverapi.Driver
12
-
13
-func initDrivers(dc driverapi.DriverCallback) error {
14
-	for _, fn := range [](func(driverapi.DriverCallback) error){
15
-		bridge.Init,
16
-		host.Init,
17
-		null.Init,
18
-		remote.Init,
19
-	} {
20
-		if err := fn(dc); err != nil {
21
-			return err
22
-		}
23
-	}
24
-	return nil
25
-}
26 1
new file mode 100644
... ...
@@ -0,0 +1,55 @@
0
+package windows
1
+
2
+import (
3
+	"github.com/docker/libnetwork/driverapi"
4
+	"github.com/docker/libnetwork/types"
5
+)
6
+
7
+const networkType = "windows"
8
+
9
+// TODO Windows. This is a placeholder for now
10
+
11
+type driver struct{}
12
+
13
+// Init registers a new instance of null driver
14
+func Init(dc driverapi.DriverCallback) error {
15
+	return dc.RegisterDriver(networkType, &driver{})
16
+}
17
+
18
+func (d *driver) Config(option map[string]interface{}) error {
19
+	return nil
20
+}
21
+
22
+func (d *driver) CreateNetwork(id types.UUID, option map[string]interface{}) error {
23
+	return nil
24
+}
25
+
26
+func (d *driver) DeleteNetwork(nid types.UUID) error {
27
+	return nil
28
+}
29
+
30
+func (d *driver) CreateEndpoint(nid, eid types.UUID, epInfo driverapi.EndpointInfo, epOptions map[string]interface{}) error {
31
+	return nil
32
+}
33
+
34
+func (d *driver) DeleteEndpoint(nid, eid types.UUID) error {
35
+	return nil
36
+}
37
+
38
+func (d *driver) EndpointOperInfo(nid, eid types.UUID) (map[string]interface{}, error) {
39
+	return make(map[string]interface{}, 0), nil
40
+}
41
+
42
+// Join method is invoked when a Sandbox is attached to an endpoint.
43
+func (d *driver) Join(nid, eid types.UUID, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
44
+	return nil
45
+}
46
+
47
+// Leave method is invoked when a Sandbox detaches from an endpoint.
48
+func (d *driver) Leave(nid, eid types.UUID) error {
49
+	return nil
50
+}
51
+
52
+func (d *driver) Type() string {
53
+	return networkType
54
+}
0 55
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+package libnetwork
1
+
2
+import (
3
+	"github.com/docker/libnetwork/driverapi"
4
+	"github.com/docker/libnetwork/drivers/bridge"
5
+	"github.com/docker/libnetwork/drivers/host"
6
+	"github.com/docker/libnetwork/drivers/null"
7
+	"github.com/docker/libnetwork/drivers/remote"
8
+)
9
+
10
+type driverTable map[string]driverapi.Driver
11
+
12
+func initDrivers(dc driverapi.DriverCallback) error {
13
+	for _, fn := range [](func(driverapi.DriverCallback) error){
14
+		bridge.Init,
15
+		host.Init,
16
+		null.Init,
17
+		remote.Init,
18
+	} {
19
+		if err := fn(dc); err != nil {
20
+			return err
21
+		}
22
+	}
23
+	return nil
24
+}
0 25
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+package libnetwork
1
+
2
+import (
3
+	"github.com/docker/libnetwork/driverapi"
4
+	"github.com/docker/libnetwork/drivers/windows"
5
+)
6
+
7
+type driverTable map[string]driverapi.Driver
8
+
9
+func initDrivers(dc driverapi.DriverCallback) error {
10
+	for _, fn := range [](func(driverapi.DriverCallback) error){
11
+		windows.Init,
12
+	} {
13
+		if err := fn(dc); err != nil {
14
+			return err
15
+		}
16
+	}
17
+	return nil
18
+}
... ...
@@ -10,6 +10,12 @@ var (
10 10
 
11 11
 // NewSandbox provides a new sandbox instance created in an os specific way
12 12
 // provided a key which uniquely identifies the sandbox
13
-func NewSandbox(key string) (Sandbox, error) {
13
+func NewSandbox(key string, osCreate bool) (Sandbox, error) {
14 14
 	return nil, ErrNotImplemented
15 15
 }
16
+
17
+// GenerateKey generates a sandbox key based on the passed
18
+// container id.
19
+func GenerateKey(containerID string) string {
20
+	return ""
21
+}
16 22
deleted file mode 100644
... ...
@@ -1,34 +0,0 @@
1
-package libnetwork
2
-
3
-import (
4
-	"fmt"
5
-	"runtime"
6
-	"syscall"
7
-)
8
-
9
-// Via http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7b21fddd087678a70ad64afc0f632e0f1071b092
10
-//
11
-// We need different setns values for the different platforms and arch
12
-// We are declaring the macro here because the SETNS syscall does not exist in th stdlib
13
-var setNsMap = map[string]uintptr{
14
-	"linux/386":     346,
15
-	"linux/amd64":   308,
16
-	"linux/arm":     374,
17
-	"linux/ppc64":   350,
18
-	"linux/ppc64le": 350,
19
-	"linux/s390x":   339,
20
-}
21
-
22
-func setns(fd uintptr, flags uintptr) error {
23
-	ns, exists := setNsMap[fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)]
24
-	if !exists {
25
-		return fmt.Errorf("unsupported platform %s/%s", runtime.GOOS, runtime.GOARCH)
26
-	}
27
-
28
-	_, _, err := syscall.RawSyscall(ns, fd, flags, 0)
29
-	if err != 0 {
30
-		return err
31
-	}
32
-
33
-	return nil
34
-}