CNlucius
Committed by Gerrit Code Review

ONOS-2161 Add OVSDB adapter api in south bound.

Change-Id: I01e2976769b225444ab6fb94cb2fe9d26921ba1f
Showing 21 changed files with 1277 additions and 0 deletions
1 +<?xml version="1.0"?>
2 +<project
3 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4 + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5 + <modelVersion>4.0.0</modelVersion>
6 + <parent>
7 + <groupId>org.onosproject</groupId>
8 + <artifactId>onos-ovsdb</artifactId>
9 + <version>1.3.0-SNAPSHOT</version>
10 + </parent>
11 + <artifactId>onos-ovsdb-api</artifactId>
12 + <packaging>bundle</packaging>
13 +
14 + <dependencies>
15 + <dependency>
16 + <groupId>junit</groupId>
17 + <artifactId>junit</artifactId>
18 + <scope>test</scope>
19 + </dependency>
20 + <dependency>
21 + <groupId>commons-pool</groupId>
22 + <artifactId>commons-pool</artifactId>
23 + </dependency>
24 + <dependency>
25 + <groupId>io.netty</groupId>
26 + <artifactId>netty-transport</artifactId>
27 + </dependency>
28 + <dependency>
29 + <groupId>io.netty</groupId>
30 + <artifactId>netty-transport-native-epoll</artifactId>
31 + <version>${netty4.version}</version>
32 + </dependency>
33 + </dependencies>
34 +
35 +</project>
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.ovsdb.controller;
17 +
18 +/**
19 + * Represents for a entity that carry important information for listener.
20 + */
21 +public interface EventSubject {
22 +
23 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +
21 +import java.util.Objects;
22 +
23 +/**
24 + * The class representing a ovsdb bridge. This class is immutable.
25 + */
26 +public final class OvsdbBridge {
27 +
28 + private final OvsdbBridgeName bridgeName;
29 + private final OvsdbDatapathId datapathId;
30 +
31 + /**
32 + * Constructor from a OvsdbBridgeName bridgeName and a OvsdbDatapathId
33 + * datapathId.
34 + *
35 + * @param bridgeName the bridgeName to use
36 + * @param datapathId the datapathId to use
37 + */
38 + public OvsdbBridge(OvsdbBridgeName bridgeName, OvsdbDatapathId datapathId) {
39 + checkNotNull(bridgeName, "bridgeName is not null");
40 + checkNotNull(datapathId, "datapathId is not null");
41 + this.bridgeName = bridgeName;
42 + this.datapathId = datapathId;
43 + }
44 +
45 + /**
46 + * Gets the bridge name of the bridge.
47 + *
48 + * @return the bridge name of the bridge
49 + */
50 + public OvsdbBridgeName bridgeName() {
51 + return bridgeName;
52 + }
53 +
54 + /**
55 + * Gets the datapathId of the bridge.
56 + *
57 + * @return datapathId the datapathId to use
58 + */
59 + public OvsdbDatapathId datapathId() {
60 + return datapathId;
61 + }
62 +
63 + @Override
64 + public int hashCode() {
65 + return Objects.hash(bridgeName, datapathId);
66 + }
67 +
68 + @Override
69 + public boolean equals(Object obj) {
70 + if (this == obj) {
71 + return true;
72 + }
73 + if (obj instanceof OvsdbBridge) {
74 + final OvsdbBridge otherOvsdbBridge = (OvsdbBridge) obj;
75 + return Objects.equals(this.bridgeName, otherOvsdbBridge.bridgeName)
76 + && Objects.equals(this.datapathId,
77 + otherOvsdbBridge.datapathId);
78 + }
79 + return false;
80 + }
81 +
82 + @Override
83 + public String toString() {
84 + return toStringHelper(this).add("bridgeName", bridgeName.value())
85 + .add("datapathId", datapathId.value()).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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +
21 +import java.util.Objects;
22 +
23 +/**
24 + * The class representing a bridge name. This class is immutable.
25 + */
26 +public final class OvsdbBridgeName {
27 +
28 + private final String value;
29 +
30 + /**
31 + * Constructor from a String bridge name.
32 + *
33 + * @param value the bridge name to use
34 + */
35 + public OvsdbBridgeName(String value) {
36 + checkNotNull(value, "value is not null");
37 + this.value = value;
38 + }
39 +
40 + /**
41 + * Gets the value of the bridge name.
42 + *
43 + * @return the value of the bridge name
44 + */
45 + public String value() {
46 + return value;
47 + }
48 +
49 + @Override
50 + public int hashCode() {
51 + return Objects.hash(value);
52 + }
53 +
54 + @Override
55 + public boolean equals(Object obj) {
56 + if (this == obj) {
57 + return true;
58 + }
59 + if (obj instanceof OvsdbBridgeName) {
60 + final OvsdbBridgeName otherBridgeName = (OvsdbBridgeName) obj;
61 + return Objects.equals(this.value, otherBridgeName.value);
62 + }
63 + return false;
64 + }
65 +
66 + @Override
67 + public String toString() {
68 + return toStringHelper(this).add("value", value).toString();
69 + }
70 +
71 +}
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.ovsdb.controller;
17 +
18 +import java.util.Set;
19 +
20 +import org.onlab.packet.IpAddress;
21 +
22 +/**
23 + * Represents to provider facing side of a node.
24 + */
25 +public interface OvsdbClientService {
26 + /**
27 + * Gets the node identifier.
28 + *
29 + * @return node identifier
30 + */
31 + OvsdbNodeId nodeId();
32 +
33 + /**
34 + * Creates the configuration for the tunnel.
35 + *
36 + * @param srcIp source IP address
37 + * @param dstIp destination IP address
38 + */
39 + void createTunnel(IpAddress srcIp, IpAddress dstIp);
40 +
41 + /**
42 + * Drops the configuration for the tunnel.
43 + *
44 + * @param srcIp source IP address
45 + * @param dstIp destination IP address
46 + */
47 + void dropTunnel(IpAddress srcIp, IpAddress dstIp);
48 +
49 + /**
50 + * Gets tunnels of the node.
51 + *
52 + * @return set of tunnels; empty if no tunnel is find
53 + */
54 + Set<OvsdbTunnel> getTunnels();
55 +
56 + /**
57 + * Creates a bridge.
58 + *
59 + * @param bridgeName bridge name
60 + */
61 + void createBridge(String bridgeName);
62 +
63 + /**
64 + * Drops a bridge.
65 + *
66 + * @param bridgeName bridge name
67 + */
68 + void dropBridge(String bridgeName);
69 +
70 + /**
71 + * Gets bridges of the node.
72 + *
73 + * @return set of bridges; empty if no bridge is find
74 + */
75 + Set<OvsdbBridge> getBridges();
76 +
77 + /**
78 + * Creates a port.
79 + *
80 + * @param bridgeName bridge name
81 + * @param portName port name
82 + */
83 + void createPort(String bridgeName, String portName);
84 +
85 + /**
86 + * Drops a port.
87 + *
88 + * @param bridgeName bridge name
89 + * @param portName port name
90 + */
91 + void dropPort(String bridgeName, String portName);
92 +
93 + /**
94 + * Gets ports of the bridge.
95 + *
96 + * @return set of ports; empty if no ports is find
97 + */
98 + Set<OvsdbPort> getPorts();
99 +
100 + /**
101 + * Checks if the node is still connected.
102 + *
103 + * @return true if the node is still connected
104 + */
105 + boolean isConnected();
106 +
107 +}
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.ovsdb.controller;
17 +
18 +import java.util.List;
19 +
20 +/**
21 + * Abstraction of an ovsdb controller. Serves as a one stop shop for obtaining
22 + * OvsdbNode and (un)register listeners on ovsdb events and ovsdb node events.
23 + */
24 +public interface OvsdbController {
25 +
26 + /**
27 + * Adds Node Event Listener.
28 + *
29 + * @param listener node listener
30 + */
31 + void addNodeListener(OvsdbNodeListener listener);
32 +
33 + /**
34 + * Removes Node Event Listener.
35 + *
36 + * @param listener node listener
37 + */
38 + void removeNodeListener(OvsdbNodeListener listener);
39 +
40 + /**
41 + * Adds ovsdb event listener.
42 + *
43 + * @param listener event listener
44 + */
45 + void addOvsdbEventListener(OvsdbEventListener listener);
46 +
47 + /**
48 + * Removes ovsdb event listener.
49 + *
50 + * @param listener event listener
51 + */
52 + void removeOvsdbEventListener(OvsdbEventListener listener);
53 +
54 + /**
55 + * Gets all the nodes information.
56 + *
57 + * @return the list of node id
58 + */
59 + List<OvsdbNodeId> getNodeIds();
60 +
61 + /**
62 + * Gets a ovsdb client by node identifier.
63 + *
64 + * @param nodeId node identifier
65 + * @return OvsdbClient ovsdb node information
66 + */
67 + OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId);
68 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +import java.util.Objects;
21 +
22 +/**
23 + * The class representing a datapathid. This class is immutable.
24 + */
25 +public final class OvsdbDatapathId {
26 + private final String value;
27 +
28 + /**
29 + * Constructor from a String datapathid.
30 + *
31 + * @param value the datapathid to use
32 + */
33 + public OvsdbDatapathId(String value) {
34 + checkNotNull(value, "value is not null");
35 + this.value = value;
36 + }
37 +
38 + /**
39 + * Gets the value of the datapathid.
40 + *
41 + * @return the value of the datapathid
42 + */
43 + public String value() {
44 + return value;
45 + }
46 +
47 + @Override
48 + public int hashCode() {
49 + return Objects.hash(value);
50 + }
51 +
52 + @Override
53 + public boolean equals(Object obj) {
54 + if (this == obj) {
55 + return true;
56 + }
57 + if (obj instanceof OvsdbDatapathId) {
58 + final OvsdbDatapathId otherDatapathId = (OvsdbDatapathId) obj;
59 + return Objects.equals(this.value, otherDatapathId.value);
60 + }
61 + return false;
62 + }
63 +
64 + @Override
65 + public String toString() {
66 + return toStringHelper(this).add("value", value).toString();
67 + }
68 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +
20 +/**
21 + * The abstract event of ovsdb.
22 + */
23 +public final class OvsdbEvent<S> {
24 +
25 + public enum Type {
26 + /**
27 + * Signifies that a new ovs port update has been detected.
28 + */
29 + PORT_ADDED,
30 + /**
31 + * Signifies that a ovs port has been removed.
32 + */
33 + PORT_REMOVED
34 + }
35 +
36 + private final Type type;
37 + private final S subject;
38 +
39 + /**
40 + * Creates an event of a given type and for the specified event subject.
41 + *
42 + * @param type event type
43 + * @param subject event subject
44 + */
45 + public OvsdbEvent(Type type, S subject) {
46 + this.type = type;
47 + this.subject = subject;
48 + }
49 +
50 + /**
51 + * Returns the type of the event.
52 + *
53 + * @return event type
54 + */
55 + public Type type() {
56 + return type;
57 + }
58 +
59 + /**
60 + * Returns the subject of the event.
61 + *
62 + * @return subject to which this event pertains
63 + */
64 + public S subject() {
65 + return subject;
66 + }
67 +
68 + @Override
69 + public String toString() {
70 + return toStringHelper(this).add("type", type())
71 + .add("subject", subject()).toString();
72 + }
73 +
74 +}
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.ovsdb.controller;
17 +
18 +/**
19 + * Allows for providers interested in ovsdb events to be notified.
20 + */
21 +public interface OvsdbEventListener {
22 + /**
23 + * Handles the ovsdb event.
24 + *
25 + * @param event ovsdb event
26 + */
27 + void handle(OvsdbEvent<EventSubject> event);
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 +package org.onosproject.ovsdb.controller;
17 +
18 +import static com.google.common.base.Preconditions.checkNotNull;
19 +
20 +import java.util.Objects;
21 +
22 +import org.onlab.packet.IpAddress;
23 +
24 +/**
25 + * The class representing a OpenStack Compute or Network nodeId. This class is
26 + * immutable.
27 + */
28 +public final class OvsdbNodeId {
29 + private static final String SCHEME = "ovsdb";
30 + private final String nodeId;
31 + private final String ipAddress;
32 +
33 + /**
34 + * Creates a new node identifier from a IpAddress ipAddress, a long port.
35 + *
36 + * @param ipAddress node IP address
37 + * @param port node port
38 + */
39 + public OvsdbNodeId(IpAddress ipAddress, long port) {
40 + checkNotNull(ipAddress, "ipAddress is not null");
41 + this.ipAddress = ipAddress.toString();
42 + this.nodeId = ipAddress + ":" + port;
43 + }
44 +
45 + @Override
46 + public int hashCode() {
47 + return Objects.hash(nodeId);
48 + }
49 +
50 + @Override
51 + public boolean equals(Object other) {
52 + if (!(other instanceof OvsdbNodeId)) {
53 + return false;
54 + }
55 +
56 + OvsdbNodeId otherNodeId = (OvsdbNodeId) other;
57 +
58 + return Objects.equals(otherNodeId.nodeId, this.nodeId);
59 + }
60 +
61 + @Override
62 + public String toString() {
63 + return SCHEME + ":" + nodeId;
64 + }
65 +
66 + /**
67 + * Gets the value of the NodeId.
68 + *
69 + * @return the value of the NodeId.
70 + */
71 + public String nodeId() {
72 + return SCHEME + ":" + nodeId;
73 + }
74 +
75 + /**
76 + * Get the IP address of the node.
77 + *
78 + * @return the IP address of the node
79 + */
80 + public String getIpAddress() {
81 + return ipAddress;
82 + }
83 +}
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.ovsdb.controller;
17 +
18 +/**
19 + * Allows for providers interested in node events to be notified.
20 + */
21 +public interface OvsdbNodeListener {
22 +
23 + /**
24 + * Notifies that the node was added.
25 + *
26 + * @param nodeId the node where the event occurred
27 + */
28 + void nodeAdded(OvsdbNodeId nodeId);
29 +
30 + /**
31 + * Notifies that the node was removed.
32 + *
33 + * @param nodeId the node where the event occurred
34 + */
35 + void nodeRemoved(OvsdbNodeId nodeId);
36 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +
21 +import java.util.Objects;
22 +
23 +/**
24 + * The class representing a ovsdb port. This class is immutable.
25 + */
26 +public final class OvsdbPort {
27 +
28 + private final OvsdbPortNumber portNumber;
29 + private final OvsdbPortName portName;
30 +
31 + /**
32 + * Constructor from a OvsdbPortNumber portNumber, OvsdbPortName portName.
33 + *
34 + * @param portNumber the portNumber to use
35 + * @param portName the portName to use
36 + */
37 + public OvsdbPort(OvsdbPortNumber portNumber, OvsdbPortName portName) {
38 + checkNotNull(portNumber, "portNumber is not null");
39 + checkNotNull(portName, "portName is not null");
40 + this.portNumber = portNumber;
41 + this.portName = portName;
42 + }
43 +
44 + /**
45 + * Gets the port number of the port.
46 + *
47 + * @return the port number of the port
48 + */
49 + public OvsdbPortNumber portNumber() {
50 + return portNumber;
51 + }
52 +
53 + /**
54 + * Gets the port name of the port.
55 + *
56 + * @return the port name of the port
57 + */
58 + public OvsdbPortName portName() {
59 + return portName;
60 + }
61 +
62 + @Override
63 + public int hashCode() {
64 + return Objects.hash(portNumber, portName);
65 + }
66 +
67 + @Override
68 + public boolean equals(Object obj) {
69 + if (this == obj) {
70 + return true;
71 + }
72 + if (obj instanceof OvsdbPort) {
73 + final OvsdbPort otherOvsdbPort = (OvsdbPort) obj;
74 + return Objects.equals(this.portNumber, otherOvsdbPort.portNumber)
75 + && Objects.equals(this.portName, otherOvsdbPort.portName);
76 + }
77 + return false;
78 + }
79 +
80 + @Override
81 + public String toString() {
82 + return toStringHelper(this)
83 + .add("portNumber", String.valueOf(portNumber.value()))
84 + .add("portName", portName.value()).toString();
85 + }
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 +package org.onosproject.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +
21 +import java.util.Objects;
22 +
23 +/**
24 + * The class representing a port number. This class is immutable.
25 + */
26 +public final class OvsdbPortName {
27 +
28 + private final String value;
29 +
30 + /**
31 + * Constructor from a String port name.
32 + *
33 + * @param value the port name to use
34 + */
35 + public OvsdbPortName(String value) {
36 + checkNotNull(value, "value is not null");
37 + this.value = value;
38 + }
39 +
40 + /**
41 + * Gets the value of the port name.
42 + *
43 + * @return the value of the port name
44 + */
45 + public String value() {
46 + return value;
47 + }
48 +
49 + @Override
50 + public int hashCode() {
51 + return Objects.hash(value);
52 + }
53 +
54 + @Override
55 + public boolean equals(Object obj) {
56 + if (this == obj) {
57 + return true;
58 + }
59 + if (obj instanceof OvsdbPortName) {
60 + final OvsdbPortName otherOvsdbPortName = (OvsdbPortName) obj;
61 + return Objects.equals(this.value, otherOvsdbPortName.value);
62 + }
63 + return false;
64 + }
65 +
66 + @Override
67 + public String toString() {
68 + return toStringHelper(this).add("value", value).toString();
69 + }
70 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +
20 +import java.util.Objects;
21 +
22 +/**
23 + * The class representing a port number. This class is immutable.
24 + */
25 +public final class OvsdbPortNumber {
26 +
27 + private final long value;
28 +
29 + /**
30 + * Constructor from a long port number.
31 + *
32 + * @param value the port number to use
33 + */
34 + public OvsdbPortNumber(long value) {
35 + this.value = value;
36 + }
37 +
38 + /**
39 + * Gets the value of the port number.
40 + *
41 + * @return the value of the port number
42 + */
43 + public long value() {
44 + return value;
45 + }
46 +
47 + @Override
48 + public int hashCode() {
49 + return Objects.hash(value);
50 + }
51 +
52 + @Override
53 + public boolean equals(Object obj) {
54 + if (this == obj) {
55 + return true;
56 + }
57 + if (obj instanceof OvsdbPortNumber) {
58 + final OvsdbPortNumber ovsdbPortNumber = (OvsdbPortNumber) obj;
59 + return Objects.equals(this.value, ovsdbPortNumber.value);
60 + }
61 + return false;
62 + }
63 +
64 + @Override
65 + public String toString() {
66 + return toStringHelper(this).add("value", value).toString();
67 + }
68 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +
21 +import java.util.Objects;
22 +
23 +import org.onlab.packet.IpAddress;
24 +
25 +/**
26 + * The class representing a ovsdb tunnel. This class is immutable.
27 + */
28 +public final class OvsdbTunnel {
29 +
30 + private final IpAddress localIp;
31 + private final IpAddress remoteIp;
32 +
33 + public enum Type {
34 + VXLAN, GRE
35 + }
36 +
37 + private final Type tunnelType;
38 + private final OvsdbTunnelName tunnelName;
39 +
40 + /**
41 + * Constructor from a IpAddress localIp, IpAddress remoteIp Type tunnelType,
42 + * OvsdbTunnelName tunnelName.
43 + *
44 + * @param localIp the localIp to use
45 + * @param remoteIp the remoteIp to use
46 + * @param tunnelType the tunnelType to use
47 + * @param tunnelName the tunnelName to use
48 + */
49 + public OvsdbTunnel(IpAddress localIp, IpAddress remoteIp, Type tunnelType,
50 + OvsdbTunnelName tunnelName) {
51 + checkNotNull(localIp, "portName is not null");
52 + checkNotNull(remoteIp, "portName is not null");
53 + checkNotNull(tunnelName, "portName is not null");
54 + this.localIp = localIp;
55 + this.remoteIp = remoteIp;
56 + this.tunnelType = tunnelType;
57 + this.tunnelName = tunnelName;
58 + }
59 +
60 + /**
61 + * Gets the local IP of the tunnel.
62 + *
63 + * @return the local IP of the tunnel
64 + */
65 + public IpAddress localIp() {
66 + return localIp;
67 + }
68 +
69 + /**
70 + * Gets the remote IP of the tunnel.
71 + *
72 + * @return the remote IP of the tunnel
73 + */
74 + public IpAddress remoteIp() {
75 + return remoteIp;
76 + }
77 +
78 + /**
79 + * Gets the tunnel type of the tunnel.
80 + *
81 + * @return the tunnel type of the tunnel
82 + */
83 + public Type tunnelType() {
84 + return tunnelType;
85 + }
86 +
87 + /**
88 + * Gets the tunnel name of the tunnel.
89 + *
90 + * @return the tunnel name of the tunnel
91 + */
92 + public OvsdbTunnelName tunnelName() {
93 + return tunnelName;
94 + }
95 +
96 + @Override
97 + public int hashCode() {
98 + return Objects.hash(localIp, remoteIp, tunnelType, tunnelName);
99 + }
100 +
101 + @Override
102 + public boolean equals(Object obj) {
103 + if (this == obj) {
104 + return true;
105 + }
106 + if (obj instanceof OvsdbTunnel) {
107 + final OvsdbTunnel otherOvsdbTunnel = (OvsdbTunnel) obj;
108 + return Objects.equals(this.localIp, otherOvsdbTunnel.localIp)
109 + && Objects.equals(this.remoteIp, otherOvsdbTunnel.remoteIp)
110 + && Objects.equals(this.tunnelType,
111 + otherOvsdbTunnel.tunnelType)
112 + && Objects.equals(this.tunnelName,
113 + otherOvsdbTunnel.tunnelName);
114 + }
115 + return false;
116 + }
117 +
118 + @Override
119 + public String toString() {
120 + return toStringHelper(this).add("localIp", localIp.toString())
121 + .add("remoteIp", remoteIp.toString())
122 + .add("tunnelType", tunnelType).add("tunnelName", tunnelName)
123 + .toString();
124 + }
125 +}
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.ovsdb.controller;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +import static com.google.common.base.Preconditions.checkNotNull;
20 +
21 +import java.util.Objects;
22 +
23 +/**
24 + * The class representing a tunnel name. This class is immutable.
25 + */
26 +public final class OvsdbTunnelName {
27 + private final String value;
28 +
29 + /**
30 + * Constructor from a String tunnel name.
31 + *
32 + * @param value the tunnel name to use
33 + */
34 + public OvsdbTunnelName(String value) {
35 + checkNotNull(value, "value is not null");
36 + this.value = value;
37 + }
38 +
39 + /**
40 + * Gets the value of the tunnel name.
41 + *
42 + * @return the value of the tunnel name
43 + */
44 + public String value() {
45 + return value;
46 + }
47 +
48 + @Override
49 + public int hashCode() {
50 + return Objects.hash(value);
51 + }
52 +
53 + @Override
54 + public boolean equals(Object obj) {
55 + if (this == obj) {
56 + return true;
57 + }
58 + if (obj instanceof OvsdbTunnelName) {
59 + final OvsdbTunnelName otherOvsdbTunnelName = (OvsdbTunnelName) obj;
60 + return Objects.equals(this.value, otherOvsdbTunnelName.value);
61 + }
62 + return false;
63 + }
64 +
65 + @Override
66 + public String toString() {
67 + return toStringHelper(this).add("value", value).toString();
68 + }
69 +}
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.ovsdb.controller.driver;
17 +
18 +import org.onosproject.ovsdb.controller.OvsdbNodeId;
19 +import org.onosproject.ovsdb.controller.OvsdbClientService;
20 +
21 +/**
22 + * Responsible for keeping track of the current set of nodes connected to the
23 + * system.
24 + */
25 +public interface OvsdbAgent {
26 + /**
27 + * Add a node that has just connected to the system.
28 + *
29 + * @param nodeId the nodeId to add
30 + * @param ovsdbClient the actual node object.
31 + */
32 + void addConnectedNode(OvsdbNodeId nodeId, OvsdbClientService ovsdbClient);
33 +
34 + /**
35 + * Clear all state in controller node maps for a node that has disconnected
36 + * from the local controller. Also release control for that node from the
37 + * global repository. Notify node listeners.
38 + *
39 + * @param nodeId the node id to be removed.
40 + */
41 + void removeConnectedNode(OvsdbNodeId nodeId);
42 +}
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.ovsdb.controller.driver;
17 +
18 +import io.netty.channel.Channel;
19 +
20 +/**
21 + * Represents the driver side of an ovsdb node. This interface should never be
22 + * exposed to consumers.
23 + */
24 +public interface OvsdbProviderService {
25 + /**
26 + * Sets the ovsdb agent to be used. This method can only be called once.
27 + *
28 + * @param agent the agent to set.
29 + */
30 + void setAgent(OvsdbAgent agent);
31 +
32 + /**
33 + * Sets the associated Netty channel for this node.
34 + *
35 + * @param channel the Netty channel
36 + */
37 + void setChannel(Channel channel);
38 +
39 + /**
40 + * Announces to the ovsdb agent that this node has added.
41 + */
42 + void nodeAdded();
43 +
44 + /**
45 + * Announces to the ovsdb agent that this node has removed.
46 + */
47 + void nodeRemoved();
48 +
49 + /**
50 + * Sets whether the node is connected.
51 + *
52 + * @param connected whether the node is connected
53 + */
54 + void setConnection(boolean connected);
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 +
17 +/**
18 + * Ovsdb controller node driver API.
19 + */
20 +package org.onosproject.ovsdb.controller.driver;
...\ No newline at end of file ...\ No newline at end of file
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 +/**
18 + * Ovsdb controller API.
19 + */
20 +package org.onosproject.ovsdb.controller;
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4 + <modelVersion>4.0.0</modelVersion>
5 + <parent>
6 + <groupId>org.onosproject</groupId>
7 + <artifactId>onos</artifactId>
8 + <version>1.3.0-SNAPSHOT</version>
9 + </parent>
10 + <artifactId>onos-ovsdb</artifactId>
11 + <name>onos-ovsdb</name>
12 + <packaging>pom</packaging>
13 +
14 + <dependencies>
15 + <dependency>
16 + <groupId>junit</groupId>
17 + <artifactId>junit</artifactId>
18 + <scope>test</scope>
19 + </dependency>
20 + <dependency>
21 + <groupId>org.onosproject</groupId>
22 + <artifactId>onlab-misc</artifactId>
23 + </dependency>
24 + <dependency>
25 + <groupId>org.onosproject</groupId>
26 + <artifactId>onlab-junit</artifactId>
27 + </dependency>
28 + </dependencies>
29 +
30 + <build>
31 + <plugins>
32 + <plugin>
33 + <groupId>org.apache.felix</groupId>
34 + <artifactId>maven-bundle-plugin</artifactId>
35 + </plugin>
36 + </plugins>
37 + </build>
38 +
39 + <modules>
40 + <module>api</module>
41 + </modules>
42 +</project>
...\ No newline at end of file ...\ No newline at end of file