samuel

Updated. Build a OVSDB driver and its associated behaviors for

supporting application to create VxLAN/GRE tunnels
This code is for JIRA ONOS-2181.

Change-Id: If7f341a422620a9e885741d4cc412fad39438d89
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import java.util.Collection;
19 +
20 +import org.onosproject.net.device.PortDescription;
21 +import org.onosproject.net.driver.HandlerBehaviour;
22 +
23 +/**
24 + * Behaviour for handling various drivers for bridge configurations.
25 + */
26 +public interface BridgeConfig extends HandlerBehaviour {
27 +
28 + /**
29 + * Add a bridge.
30 + *
31 + * @param bridgeName bridge name
32 + */
33 + void addBridge(BridgeName bridgeName);
34 +
35 + /**
36 + * Remove a bridge.
37 + *
38 + * @param bridgeName bridge name
39 + */
40 + void deleteBridge(BridgeName bridgeName);
41 +
42 + /**
43 + * Remove a bridge.
44 + *
45 + * @return bridge collection
46 + */
47 + Collection<BridgeDescription> getBridges();
48 +
49 + /**
50 + * Add a logical/virtual port.
51 + *
52 + * @param port port number
53 + */
54 + void addPort(PortDescription port);
55 +
56 + /**
57 + * Delete a logical/virtual port.
58 + *
59 + * @param port port number
60 + */
61 + void deletePort(PortDescription port);
62 +
63 + /**
64 + * Delete a logical/virtual port.
65 + *
66 + * return collection of port
67 + */
68 + Collection<PortDescription> getPorts();
69 +}
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import org.onosproject.net.Description;
19 +import org.onosproject.net.DeviceId;
20 +
21 +/**
22 + * The abstraction of bridge in OVSDB protocol.
23 + */
24 +public interface BridgeDescription extends Description {
25 +
26 + /**
27 + * Returns bridge name.
28 + *
29 + * @return bridge name
30 + */
31 + BridgeName bridgeName();
32 +
33 + /**
34 + * Returns controller identifier that this bridge belongs to.
35 + *
36 + * @return controller identifier
37 + */
38 + DeviceId cotrollerDeviceId();
39 +
40 + /**
41 + * Returns bridge identifier .
42 + *
43 + * @return bridge identifier
44 + */
45 + DeviceId deviceId();
46 +}
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import java.util.Objects;
19 +
20 +import com.google.common.base.MoreObjects;
21 +
22 +/**
23 + * Represents for a bridge name.
24 + */
25 +public final class BridgeName {
26 +
27 + private final String name;
28 +
29 + // Public construction is prohibited
30 + private BridgeName(String name) {
31 + this.name = name;
32 + }
33 +
34 + /**
35 + * Creates a bridge name using the supplied string.
36 + *
37 + * @param name bridge name
38 + * @return BridgeName
39 + */
40 + public static BridgeName bridgeName(String name) {
41 + return new BridgeName(name);
42 + }
43 +
44 + /**
45 + * Returns the bridge name string.
46 + *
47 + * @return name string
48 + */
49 + public String name() {
50 + return name;
51 + }
52 +
53 + @Override
54 + public int hashCode() {
55 + return Objects.hash(name);
56 + }
57 +
58 + @Override
59 + public boolean equals(Object obj) {
60 + if (this == obj) {
61 + return true;
62 + }
63 + if (obj instanceof BridgeName) {
64 + final BridgeName that = (BridgeName) obj;
65 + return this.getClass() == that.getClass() &&
66 + Objects.equals(this.name, that.name);
67 + }
68 + return false;
69 + }
70 +
71 + @Override
72 + public String toString() {
73 + return MoreObjects.toStringHelper(getClass())
74 + .add("name", name)
75 + .toString();
76 + }
77 +
78 +}
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import java.util.Objects;
19 +
20 +import org.onosproject.net.AbstractDescription;
21 +import org.onosproject.net.DeviceId;
22 +import org.onosproject.net.SparseAnnotations;
23 +
24 +import com.google.common.base.MoreObjects;
25 +
26 +/**
27 + * The default implementation of bridge.
28 + */
29 +public final class DefaultBridgeDescription extends AbstractDescription
30 + implements BridgeDescription {
31 +
32 + private final BridgeName name;
33 + private final DeviceId deviceId;
34 + private final DeviceId controllerId;
35 +
36 + public DefaultBridgeDescription(BridgeName name, DeviceId controllerId,
37 + DeviceId deviceId,
38 + SparseAnnotations... annotations) {
39 + super(annotations);
40 + this.name = name;
41 + this.deviceId = deviceId;
42 + this.controllerId = controllerId;
43 + }
44 +
45 + @Override
46 + public BridgeName bridgeName() {
47 + return name;
48 + }
49 +
50 + @Override
51 + public DeviceId deviceId() {
52 + return deviceId;
53 + }
54 +
55 + @Override
56 + public DeviceId cotrollerDeviceId() {
57 + return controllerId;
58 + }
59 +
60 + @Override
61 + public int hashCode() {
62 + return Objects.hash(name, deviceId, controllerId);
63 + }
64 +
65 + @Override
66 + public boolean equals(Object obj) {
67 + if (this == obj) {
68 + return true;
69 + }
70 + if (obj instanceof DefaultBridgeDescription) {
71 + final DefaultBridgeDescription that = (DefaultBridgeDescription) obj;
72 + return this.getClass() == that.getClass()
73 + && Objects.equals(this.name, that.name)
74 + && Objects.equals(this.deviceId, that.deviceId)
75 + && Objects.equals(this.controllerId, that.controllerId);
76 + }
77 + return false;
78 + }
79 +
80 + @Override
81 + public String toString() {
82 + return MoreObjects.toStringHelper(getClass()).add("name", name)
83 + .add("deviceId", deviceId).add("controllerId", controllerId)
84 + .toString();
85 + }
86 +
87 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import org.onosproject.net.AbstractDescription;
19 +import org.onosproject.net.SparseAnnotations;
20 +
21 +import com.google.common.annotations.Beta;
22 +import com.google.common.base.MoreObjects;
23 +
24 +/**
25 + * Default implementation of immutable tunnel description entity.
26 + */
27 +@Beta
28 +public class DefaultTunnelDescription extends AbstractDescription
29 + implements TunnelDescription {
30 +
31 + private final TunnelEndPoint src;
32 + private final TunnelEndPoint dst;
33 + private final Type type;
34 + // which a tunnel match up
35 + // tunnel producer
36 + private final TunnelName tunnelName; // name of a tunnel
37 +
38 + /**
39 + * Creates a tunnel description using the supplied information.
40 + *
41 + * @param src TunnelPoint source
42 + * @param dst TunnelPoint destination
43 + * @param type tunnel type
44 + * @param tunnelName tunnel name
45 + * @param annotations optional key/value annotations
46 + */
47 + public DefaultTunnelDescription(TunnelEndPoint src,
48 + TunnelEndPoint dst, Type type,
49 + TunnelName tunnelName,
50 + SparseAnnotations... annotations) {
51 + super(annotations);
52 + this.src = src;
53 + this.dst = dst;
54 + this.type = type;
55 + this.tunnelName = tunnelName;
56 + }
57 +
58 + @Override
59 + public TunnelEndPoint src() {
60 + return src;
61 + }
62 +
63 + @Override
64 + public TunnelEndPoint dst() {
65 + return dst;
66 + }
67 +
68 + @Override
69 + public Type type() {
70 + return type;
71 + }
72 +
73 + @Override
74 + public TunnelName tunnelName() {
75 + return tunnelName;
76 + }
77 +
78 + @Override
79 + public String toString() {
80 + return MoreObjects.toStringHelper(this)
81 + .add("src", src())
82 + .add("dst", dst())
83 + .add("type", type())
84 + .add("tunnelName", tunnelName())
85 + .toString();
86 + }
87 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import java.util.Collection;
19 +
20 +import org.onosproject.net.driver.HandlerBehaviour;
21 +
22 +/**
23 + * Behaviour for handling various drivers for tunnel configuration.
24 + */
25 +public interface TunnelConfig extends HandlerBehaviour {
26 +
27 + /**
28 + * Create a tunnel.
29 + *
30 + * @param tunnel tunnel entity
31 + */
32 + void createTunnel(TunnelDescription tunnel);
33 +
34 + /**
35 + * Remove a tunnel.
36 + *
37 + * @param tunnel tunnel entity
38 + */
39 + void removeTunnel(TunnelDescription tunnel);
40 +
41 + /**
42 + * Update a tunnel.
43 + *
44 + * @param tunnel tunnel entity
45 + */
46 + void updateTunnel(TunnelDescription tunnel);
47 +
48 + /**
49 + * Gets tunnels.
50 + *
51 + * return collection of tunnel
52 + */
53 + Collection<TunnelDescription> getTunnels();
54 +
55 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.behaviour;
17 +
18 +import org.onosproject.net.Annotated;
19 +import org.onosproject.net.Description;
20 +
21 +import com.google.common.annotations.Beta;
22 +
23 +/**
24 + * Describes a tunnel.
25 + */
26 +@Beta
27 +public interface TunnelDescription extends Description, Annotated {
28 +
29 + /**
30 + * Tunnel technology type.
31 + */
32 + enum Type {
33 + /**
34 + * Signifies that this is a MPLS tunnel.
35 + */
36 + MPLS,
37 + /**
38 + * Signifies that this is a L2 tunnel.
39 + */
40 + VLAN,
41 + /**
42 + * Signifies that this is a DC L2 extension tunnel.
43 + */
44 + VXLAN,
45 + /**
46 + * Signifies that this is a L3 tunnel.
47 + */
48 + GRE,
49 + /**
50 + * Signifies that this is a L1 OTN tunnel.
51 + */
52 + ODUK,
53 + /**
54 + * Signifies that this is a L0 OCH tunnel.
55 + */
56 + OCH
57 + }
58 +
59 + /**
60 + * Returns the connection point source.
61 + *
62 + * @return tunnel source ConnectionPoint
63 + */
64 + TunnelEndPoint src();
65 +
66 + /**
67 + * Returns the connection point destination.
68 + *
69 + * @return tunnel destination
70 + */
71 + TunnelEndPoint dst();
72 +
73 + /**
74 + * Returns the tunnel type.
75 + *
76 + * @return tunnel type
77 + */
78 + Type type();
79 +
80 + /**
81 + * Return the name of a tunnel.
82 + *
83 + * @return Tunnel Name
84 + */
85 + TunnelName tunnelName();
86 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.net.behaviour;
18 +
19 +import com.google.common.annotations.Beta;
20 +
21 +/**
22 + * Represents for source end point or destination end point of a tunnel. Maybe a tunnel
23 + * based on ConnectPoint, IpAddress, MacAddress and so on is built.
24 + */
25 +@Beta
26 +public interface TunnelEndPoint {
27 +
28 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.net.behaviour;
18 +
19 +import com.google.common.annotations.Beta;
20 +
21 +import java.util.Objects;
22 +
23 +/**
24 + * Represents for a unique tunnel name. TunnelId is generated by ONOS while
25 + * TunnelName is given by producer. The consumer can borrow tunnels with
26 + * TunnelId or TunnelName.
27 + */
28 +@Beta
29 +public final class TunnelName {
30 + private final String str;
31 +
32 + // Default constructor for serialization
33 + private TunnelName(String tunnelName) {
34 + this.str = tunnelName;
35 + }
36 +
37 +
38 + /**
39 + * Creates a tunnel name using the supplied URI string.
40 + *
41 + * @param tunnelName tunnel name string
42 + * @return tunnel name object
43 + */
44 + public static TunnelName tunnelName(String tunnelName) {
45 + return new TunnelName(tunnelName);
46 + }
47 +
48 + /**
49 + * The string of tunnel name.
50 + *
51 + * @return the string of tunnel name
52 + */
53 + public String value() {
54 + return str;
55 + }
56 +
57 + @Override
58 + public int hashCode() {
59 + return Objects.hash(str);
60 + }
61 +
62 + @Override
63 + public boolean equals(Object obj) {
64 + if (this == obj) {
65 + return true;
66 + }
67 + if (obj instanceof TunnelName) {
68 + final TunnelName that = (TunnelName) obj;
69 + return this.getClass() == that.getClass()
70 + && Objects.equals(this.str, that.str);
71 + }
72 + return false;
73 + }
74 +
75 + @Override
76 + public String toString() {
77 + return str;
78 + }
79 +}