Skip to content

Commit 8def6ff

Browse files
author
Vipin Jain
committed
Merge branch 'vtep_alloc_move'
2 parents 2a11f3a + b6df2cf commit 8def6ff

26 files changed

+910
-381
lines changed

core/core.go

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type StateDriver interface {
9898
Deinit()
9999
Write(key string, value []byte) error
100100
Read(key string) ([]byte, error)
101+
ReadAll(baseKey string) ([][]byte, error)
101102
WriteState(key string, value State,
102103
marshal func(interface{}) ([]byte, error)) error
103104
ReadState(key string, value State,

drivers/etcdstatedriver.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ func (d *EtcdStateDriver) Read(key string) ([]byte, error) {
6969
return []byte(resp.Node.Value), err
7070
}
7171

72-
func ReadAll(d core.StateDriver, baseKey string) ([][]byte, error) {
73-
etcdDriver := d.(*EtcdStateDriver)
74-
resp, err := etcdDriver.Client.Get(baseKey, true, false)
72+
func (d *EtcdStateDriver) ReadAll(baseKey string) ([][]byte, error) {
73+
resp, err := d.Client.Get(baseKey, true, false)
7574
if err != nil {
7675
return nil, err
7776
}

drivers/ovsdriver.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,9 @@ func (d *OvsDriver) CreateEndpoint(id string) error {
466466
}
467467

468468
// use the user provided interface name. The primary usecase for such
469-
// endpoints is for adding the host-interfaces to the ovs bridge. But other
470-
// usecases might involve user created linux interface devices for
471-
// containers like SRIOV, that need to be bridged using ovs
469+
// endpoints is for adding the host-interfaces to the ovs bridge.
470+
// But other usecases might involve user created linux interface
471+
// devices for containers like SRIOV, that need to be bridged using ovs
472472
// Also, if the interface name is provided by user then we don't create
473473
// ovs-internal interface
474474
if epCfg.IntfName != "" {

drivers/ovsdriver_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (d *testOvsStateDriver) Read(key string) ([]byte, error) {
6666
return []byte{}, &core.Error{Desc: "Shouldn't be called!"}
6767
}
6868

69+
func (d *testOvsStateDriver) ReadAll(baseKey string) ([][]byte, error) {
70+
return [][]byte{}, &core.Error{Desc: "Shouldn't be called!"}
71+
}
72+
6973
func (d *testOvsStateDriver) ClearState(key string) error {
7074
return nil
7175
}

drivers/ovsendpointstate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (s *OvsCfgEndpointState) Clear() error {
5353

5454
func ReadAllOvsCfgEndpoints(d core.StateDriver) ([]*OvsCfgEndpointState, error) {
5555
values := []*OvsCfgEndpointState{}
56-
byteValues, err := ReadAll(d, EP_CFG_PATH_PREFIX)
56+
byteValues, err := d.ReadAll(EP_CFG_PATH_PREFIX)
5757
if err != nil {
5858
return nil, err
5959
}

drivers/ovsendpointstate_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func (d *testEpStateDriver) Read(key string) ([]byte, error) {
4848
return []byte{}, &core.Error{Desc: "Shouldn't be called!"}
4949
}
5050

51+
func (d *testEpStateDriver) ReadAll(baseKey string) ([][]byte, error) {
52+
return [][]byte{}, &core.Error{Desc: "Shouldn't be called!"}
53+
}
54+
5155
func (d *testEpStateDriver) validateKey(key string) error {
5256
if key != epCfgKey && key != epOperKey {
5357
return &core.Error{Desc: fmt.Sprintf("Unexpected key. recvd: %s expected: %s or %s ",

drivers/ovsnetworkstate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (s *OvsCfgNetworkState) Read(id string) error {
6565

6666
func ReadAllOvsCfgNetworks(d core.StateDriver) ([]*OvsCfgNetworkState, error) {
6767
values := []*OvsCfgNetworkState{}
68-
byteValues, err := ReadAll(d, NW_CFG_PATH_PREFIX)
68+
byteValues, err := d.ReadAll(NW_CFG_PATH_PREFIX)
6969
if err != nil {
7070
return nil, err
7171
}

drivers/ovsnetworkstate_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ func (d *testNwStateDriver) Read(key string) ([]byte, error) {
4747
return []byte{}, &core.Error{Desc: "Shouldn't be called!"}
4848
}
4949

50+
func (d *testNwStateDriver) ReadAll(baseKey string) ([][]byte, error) {
51+
return [][]byte{}, &core.Error{Desc: "Shouldn't be called!"}
52+
}
53+
5054
func (d *testNwStateDriver) validateKey(key string) error {
5155
if key != nwCfgKey {
5256
return &core.Error{Desc: fmt.Sprintf("Unexpected key. "+
+13-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11

22
{
3+
"Hosts" : [{
4+
"Name" : "host1",
5+
"VtepIp" : "192.168.2.10"
6+
},
7+
{
8+
"Name" : "host2",
9+
"VtepIp" : "192.168.2.11"
10+
}],
311
"Tenants" : [ {
412
"Name" : "tenant-one",
513
"DefaultNetType" : "vxlan",
@@ -9,8 +17,7 @@
917
"Networks" : [
1018
{
1119
"Name" : "orange",
12-
"Endpoints" : [
13-
{
20+
"Endpoints" : [ {
1421
"Container" : "myContainer1",
1522
"Host" : "host1"
1623
},
@@ -21,22 +28,18 @@
2128
{
2229
"Container" : "myContainer3",
2330
"Host" : "host2"
24-
}
25-
]
31+
} ]
2632
},
2733
{
2834
"Name" : "purple",
29-
"Endpoints" : [
30-
{
35+
"Endpoints" : [ {
3136
"Container" : "myContainer2",
3237
"Host" : "host1"
3338
},
3439
{
3540
"Container" : "myContainer4",
3641
"Host" : "host2"
37-
}
38-
]
39-
}
40-
]
42+
} ]
43+
} ]
4144
} ]
4245
}

examples/two_host_vlan.json

+12-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11

22
{
3+
"Hosts" : [{
4+
"Name" : "host1",
5+
"Intf" : "eth2"
6+
},
7+
{
8+
"Name" : "host2",
9+
"Intf" : "eth2"
10+
}],
311
"Tenants" : [ {
412
"Name" : "tenant-one",
513
"DefaultNetType" : "vlan",
614
"SubnetPool" : "11.1.0.0/16",
715
"AllocSubnetLen" : 24,
816
"Vlans" : "11-48",
9-
"Networks" : [
10-
{
11-
"Name" : "infra",
12-
"PktTag" : "0",
13-
"Endpoints" : [
14-
{
15-
"Host" : "host1",
16-
"Intf" : "eth2"
17-
},
18-
{
19-
"Host" : "host2",
20-
"Intf" : "eth2"
21-
}
22-
]
23-
},
24-
{
17+
"Networks" : [ {
2518
"Name" : "orange",
26-
"Endpoints" : [
27-
{
19+
"Endpoints" : [ {
2820
"Container" : "myContainer1",
2921
"Host" : "host1"
3022
},
@@ -39,9 +31,7 @@
3931
{
4032
"Container" : "myContainer4",
4133
"Host" : "host2"
42-
}
43-
]
44-
}
45-
]
34+
} ]
35+
} ]
4636
} ]
4737
}

examples/two_host_vxlan.json

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11

22
{
3+
"Hosts" : [{
4+
"Name" : "host1",
5+
"VtepIp" : "192.168.2.10"
6+
},
7+
{
8+
"Name" : "host2",
9+
"VtepIp" : "192.168.2.11"
10+
}],
311
"Tenants" : [ {
412
"Name" : "tenant-one",
513
"DefaultNetType" : "vxlan",
@@ -9,25 +17,22 @@
917
"Networks" : [
1018
{
1119
"Name" : "orange",
12-
"Endpoints" : [
13-
{
20+
"Endpoints" : [ {
1421
"Container" : "myContainer1",
15-
"Host" : "host1"
22+
"Host" : "host1"
1623
},
1724
{
1825
"Container" : "myContainer2",
19-
"Host" : "host1"
26+
"Host" : "host1"
2027
},
2128
{
2229
"Container" : "myContainer3",
23-
"Host" : "host2"
30+
"Host" : "host2"
2431
},
2532
{
2633
"Container" : "myContainer4",
27-
"Host" : "host2"
28-
}
29-
]
30-
}
31-
]
34+
"Host" : "host2"
35+
} ]
36+
} ]
3237
} ]
3338
}
+14-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11

22
{
3+
"Hosts" : [{
4+
"Name" : "host1",
5+
"VtepIp" : "192.168.2.10"
6+
},
7+
{
8+
"Name" : "host2",
9+
"VtepIp" : "192.168.2.11"
10+
}],
311
"Tenants" : [ {
412
"Name" : "tenant-one",
513
"DefaultNetType" : "vxlan",
614
"SubnetPool" : "11.1.0.0/16",
715
"AllocSubnetLen" : 24,
816
"Vxlans" : "10001-20000",
9-
"Networks" : [
10-
{
17+
"Networks" : [ {
1118
"Name" : "orange",
1219
"Endpoints" : [
1320
{
@@ -17,19 +24,16 @@
1724
{
1825
"Container" : "myContainer3",
1926
"Host" : "host2"
20-
}
21-
]
22-
}
23-
]
27+
} ]
28+
} ]
2429
},
2530
{
2631
"Name" : "tenant-two",
2732
"DefaultNetType" : "vxlan",
2833
"SubnetPool" : "11.1.0.0/16",
2934
"AllocSubnetLen" : 24,
3035
"Vxlans" : "10001-20000",
31-
"Networks" : [
32-
{
36+
"Networks" : [ {
3337
"Name" : "purple",
3438
"Endpoints" : [
3539
{
@@ -39,9 +43,7 @@
3943
{
4044
"Container" : "myContainer4",
4145
"Host" : "host2"
42-
}
43-
]
44-
}
45-
]
46+
} ]
47+
} ]
4648
} ]
4749
}
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,49 @@
11

22
{
3-
"Tenants" : [ {
3+
"Hosts" : [{
4+
"Name" : "host1",
5+
"Intf" : "eth1",
6+
"VtepIp" : "192.168.2.10"
7+
},
8+
{
9+
"Name" : "host2",
10+
"Intf" : "eth1",
11+
"VtepIp" : "192.168.2.11"
12+
}],
13+
"Tenants" : [{
414
"Name" : "tenant-one",
515
"DefaultNetType" : "vlan",
616
"SubnetPool" : "11.1.0.0/16",
717
"AllocSubnetLen" : 24,
818
"Vlans" : "200-300",
9-
"Networks" : [
10-
{
11-
"Name" : "infra",
12-
"PktTag" : "0",
13-
"Endpoints" : [
14-
{
15-
"Host" : "host1",
16-
"Intf" : "eth1"
17-
},
18-
{
19-
"Host" : "host2",
20-
"Intf" : "eth1"
21-
}
22-
]
23-
},
24-
{
19+
"Networks" : [{
2520
"Name" : "orange",
26-
"Endpoints" : [
27-
{
21+
"Endpoints" : [{
2822
"Container" : "myContainer1",
2923
"Host" : "host1"
3024
},
3125
{
3226
"Container" : "myContainer3",
3327
"Host" : "host2"
34-
}
35-
]
36-
}
37-
]
28+
}]
29+
}]
3830
},
3931
{
4032
"Name" : "tenant-two",
4133
"DefaultNetType" : "vxlan",
4234
"SubnetPool" : "11.1.0.0/16",
4335
"AllocSubnetLen" : 24,
4436
"Vxlans" : "10001-20000",
45-
"Networks" : [
46-
{
37+
"Networks" : [{
4738
"Name" : "purple",
48-
"Endpoints" : [
49-
{
39+
"Endpoints" : [{
5040
"Container" : "myContainer2",
5141
"Host" : "host1"
5242
},
5343
{
5444
"Container" : "myContainer4",
5545
"Host" : "host2"
56-
}
57-
]
58-
}
59-
]
46+
}]
47+
}]
6048
} ]
6149
}

0 commit comments

Comments
 (0)