Committed by
Gerrit Code Review
CORD-333 Minimized OVSDB provider dependency
With this patch, cordvtn doesn't need to care for OVSDB connection state anymore. It will make a connection to OVSDB server like befor but just for node init and disconnect the OVSDB right after init is done. - Changed OvsdbNode to CordVtnNode - Removed OVSDB connect/disconnect and added initNode instead - Changed ovsdb* commands to cordvtn-node* command, and removed connect/disconnect command and added init instead - Fixed to remove OVSDB device from the system after node init or before making a connection to work around OVSDB device re-connect issue Change-Id: If69369a06526947122494b2f7e816e37aa931f2c
Showing
13 changed files
with
257 additions
and
373 deletions
This diff is collapsed. Click to expand it.
... | @@ -32,77 +32,82 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -32,77 +32,82 @@ import static com.google.common.base.Preconditions.checkNotNull; |
32 | */ | 32 | */ |
33 | public class CordVtnConfig extends Config<ApplicationId> { | 33 | public class CordVtnConfig extends Config<ApplicationId> { |
34 | 34 | ||
35 | - public static final String OVSDB_NODES = "ovsdbNodes"; | 35 | + public static final String CORDVTN_NODES = "nodes"; |
36 | - public static final String HOST = "host"; | 36 | + public static final String HOSTNAME = "hostname"; |
37 | - public static final String IP = "ip"; | 37 | + public static final String OVSDB_IP = "ovsdbIp"; |
38 | - public static final String PORT = "port"; | 38 | + public static final String OVSDB_PORT = "ovsdbPort"; |
39 | public static final String BRIDGE_ID = "bridgeId"; | 39 | public static final String BRIDGE_ID = "bridgeId"; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | - * Returns the set of ovsdb nodes read from network config. | 42 | + * Returns the set of nodes read from network config. |
43 | * | 43 | * |
44 | - * @return set of OvsdbNodeConfig or null | 44 | + * @return set of CordVtnNodeConfig or null |
45 | */ | 45 | */ |
46 | - public Set<OvsdbNodeConfig> ovsdbNodes() { | 46 | + public Set<CordVtnNodeConfig> cordVtnNodes() { |
47 | - Set<OvsdbNodeConfig> ovsdbNodes = Sets.newHashSet(); | 47 | + Set<CordVtnNodeConfig> nodes = Sets.newHashSet(); |
48 | 48 | ||
49 | - JsonNode nodes = object.get(OVSDB_NODES); | 49 | + JsonNode jsonNodes = object.get(CORDVTN_NODES); |
50 | - if (nodes == null) { | 50 | + if (jsonNodes == null) { |
51 | return null; | 51 | return null; |
52 | } | 52 | } |
53 | - nodes.forEach(jsonNode -> ovsdbNodes.add(new OvsdbNodeConfig( | 53 | + jsonNodes.forEach(jsonNode -> nodes.add(new CordVtnNodeConfig( |
54 | - jsonNode.path(HOST).asText(), | 54 | + jsonNode.path(HOSTNAME).asText(), |
55 | - IpAddress.valueOf(jsonNode.path(IP).asText()), | 55 | + IpAddress.valueOf(jsonNode.path(OVSDB_IP).asText()), |
56 | - TpPort.tpPort(jsonNode.path(PORT).asInt()), | 56 | + TpPort.tpPort(jsonNode.path(OVSDB_PORT).asInt()), |
57 | DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText())))); | 57 | DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText())))); |
58 | 58 | ||
59 | - return ovsdbNodes; | 59 | + return nodes; |
60 | } | 60 | } |
61 | 61 | ||
62 | /** | 62 | /** |
63 | - * Configuration for an ovsdb node. | 63 | + * Configuration for CordVtn node. |
64 | */ | 64 | */ |
65 | - public static class OvsdbNodeConfig { | 65 | + public static class CordVtnNodeConfig { |
66 | 66 | ||
67 | - private final String host; | 67 | + private final String hostname; |
68 | - private final IpAddress ip; | 68 | + private final IpAddress ovsdbIp; |
69 | - private final TpPort port; | 69 | + private final TpPort ovsdbPort; |
70 | private final DeviceId bridgeId; | 70 | private final DeviceId bridgeId; |
71 | 71 | ||
72 | - public OvsdbNodeConfig(String host, IpAddress ip, TpPort port, DeviceId bridgeId) { | 72 | + public CordVtnNodeConfig(String hostname, IpAddress ovsdbIp, TpPort ovsdbPort, DeviceId bridgeId) { |
73 | - this.host = checkNotNull(host); | 73 | + this.hostname = checkNotNull(hostname); |
74 | - this.ip = checkNotNull(ip); | 74 | + this.ovsdbIp = checkNotNull(ovsdbIp); |
75 | - this.port = checkNotNull(port); | 75 | + this.ovsdbPort = checkNotNull(ovsdbPort); |
76 | this.bridgeId = checkNotNull(bridgeId); | 76 | this.bridgeId = checkNotNull(bridgeId); |
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
80 | - * Returns host information of the node. | 80 | + * Returns hostname of the node. |
81 | * | 81 | * |
82 | - * @return host | 82 | + * @return hostname |
83 | */ | 83 | */ |
84 | - public String host() { | 84 | + public String hostname() { |
85 | - return this.host; | 85 | + return this.hostname; |
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | - * Returns ip address to access ovsdb-server of the node. | 89 | + * Returns OVSDB ip address of the node. |
90 | * | 90 | * |
91 | - * @return ip address | 91 | + * @return OVSDB server IP address |
92 | */ | 92 | */ |
93 | - public IpAddress ip() { | 93 | + public IpAddress ovsdbIp() { |
94 | - return this.ip; | 94 | + return this.ovsdbIp; |
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | - * Returns port number to access ovsdb-server of the node. | 98 | + * Returns OVSDB port number of the node. |
99 | * | 99 | * |
100 | * @return port number | 100 | * @return port number |
101 | */ | 101 | */ |
102 | - public TpPort port() { | 102 | + public TpPort ovsdbPort() { |
103 | - return this.port; | 103 | + return this.ovsdbPort; |
104 | } | 104 | } |
105 | 105 | ||
106 | + /** | ||
107 | + * Returns integration bridge id of the node. | ||
108 | + * | ||
109 | + * @return device id | ||
110 | + */ | ||
106 | public DeviceId bridgeId() { | 111 | public DeviceId bridgeId() { |
107 | return this.bridgeId; | 112 | return this.bridgeId; |
108 | } | 113 | } | ... | ... |
... | @@ -88,10 +88,10 @@ public class CordVtnConfigManager { | ... | @@ -88,10 +88,10 @@ public class CordVtnConfigManager { |
88 | return; | 88 | return; |
89 | } | 89 | } |
90 | 90 | ||
91 | - config.ovsdbNodes().forEach(node -> { | 91 | + config.cordVtnNodes().forEach(node -> { |
92 | - DefaultOvsdbNode ovsdb = new DefaultOvsdbNode( | 92 | + CordVtnNode cordVtnNode = new CordVtnNode( |
93 | - node.host(), node.ip(), node.port(), node.bridgeId()); | 93 | + node.hostname(), node.ovsdbIp(), node.ovsdbPort(), node.bridgeId()); |
94 | - cordVtnService.addNode(ovsdb); | 94 | + cordVtnService.addNode(cordVtnNode); |
95 | }); | 95 | }); |
96 | } | 96 | } |
97 | 97 | ... | ... |
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.cordvtn; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import org.onlab.packet.IpAddress; | ||
20 | +import org.onlab.packet.TpPort; | ||
21 | +import org.onosproject.net.DeviceId; | ||
22 | + | ||
23 | +import java.util.Comparator; | ||
24 | +import java.util.Objects; | ||
25 | + | ||
26 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
27 | + | ||
28 | +/** | ||
29 | + * Representation of a compute infrastructure node for CORD VTN service. | ||
30 | + */ | ||
31 | +public final class CordVtnNode { | ||
32 | + | ||
33 | + private final String hostname; | ||
34 | + private final IpAddress ovsdbIp; | ||
35 | + private final TpPort ovsdbPort; | ||
36 | + private final DeviceId bridgeId; | ||
37 | + | ||
38 | + public static final Comparator<CordVtnNode> CORDVTN_NODE_COMPARATOR = | ||
39 | + (node1, node2) -> node1.hostname().compareTo(node2.hostname()); | ||
40 | + | ||
41 | + /** | ||
42 | + * Creates a new node. | ||
43 | + * | ||
44 | + * @param hostname hostname | ||
45 | + * @param ovsdbIp OVSDB server IP address | ||
46 | + * @param ovsdbPort OVSDB server port number | ||
47 | + * @param bridgeId integration bridge identifier | ||
48 | + */ | ||
49 | + public CordVtnNode(String hostname, IpAddress ovsdbIp, TpPort ovsdbPort, DeviceId bridgeId) { | ||
50 | + this.hostname = checkNotNull(hostname); | ||
51 | + this.ovsdbIp = checkNotNull(ovsdbIp); | ||
52 | + this.ovsdbPort = checkNotNull(ovsdbPort); | ||
53 | + this.bridgeId = checkNotNull(bridgeId); | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Returns the OVSDB server IP address. | ||
58 | + * | ||
59 | + * @return ip address | ||
60 | + */ | ||
61 | + public IpAddress ovsdbIp() { | ||
62 | + return this.ovsdbIp; | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Returns the OVSDB server port number. | ||
67 | + * | ||
68 | + * @return port number | ||
69 | + */ | ||
70 | + public TpPort ovsdbPort() { | ||
71 | + return this.ovsdbPort; | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Returns the hostname. | ||
76 | + * | ||
77 | + * @return hostname | ||
78 | + */ | ||
79 | + public String hostname() { | ||
80 | + return this.hostname; | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * Returns the identifier of the integration bridge. | ||
85 | + * | ||
86 | + * @return device id | ||
87 | + */ | ||
88 | + public DeviceId intBrId() { | ||
89 | + return this.bridgeId; | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * Returns the identifier of the OVSDB device. | ||
94 | + * | ||
95 | + * @return device id | ||
96 | + */ | ||
97 | + public DeviceId ovsdbId() { | ||
98 | + return DeviceId.deviceId("ovsdb:" + this.ovsdbIp.toString()); | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public boolean equals(Object obj) { | ||
103 | + if (this == obj) { | ||
104 | + return true; | ||
105 | + } | ||
106 | + | ||
107 | + if (obj instanceof CordVtnNode) { | ||
108 | + CordVtnNode that = (CordVtnNode) obj; | ||
109 | + if (Objects.equals(hostname, that.hostname) && | ||
110 | + Objects.equals(ovsdbIp, that.ovsdbIp) && | ||
111 | + Objects.equals(ovsdbPort, that.ovsdbPort) && | ||
112 | + Objects.equals(bridgeId, that.bridgeId)) { | ||
113 | + return true; | ||
114 | + } | ||
115 | + } | ||
116 | + return false; | ||
117 | + } | ||
118 | + | ||
119 | + @Override | ||
120 | + public int hashCode() { | ||
121 | + return Objects.hash(hostname, ovsdbIp, ovsdbPort); | ||
122 | + } | ||
123 | + | ||
124 | + @Override | ||
125 | + public String toString() { | ||
126 | + return MoreObjects.toStringHelper(getClass()) | ||
127 | + .add("host", hostname) | ||
128 | + .add("ip", ovsdbIp) | ||
129 | + .add("port", ovsdbPort) | ||
130 | + .add("bridgeId", bridgeId) | ||
131 | + .toString(); | ||
132 | + } | ||
133 | +} |
... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.cordvtn; | 16 | package org.onosproject.cordvtn; |
17 | 17 | ||
18 | -import org.onosproject.net.DeviceId; | ||
19 | - | ||
20 | import java.util.List; | 18 | import java.util.List; |
21 | 19 | ||
22 | /** | 20 | /** |
... | @@ -28,30 +26,23 @@ public interface CordVtnService { | ... | @@ -28,30 +26,23 @@ public interface CordVtnService { |
28 | /** | 26 | /** |
29 | * Adds a new node to the service. | 27 | * Adds a new node to the service. |
30 | * | 28 | * |
31 | - * @param ovsdb ovsdb node | 29 | + * @param node cordvtn node |
32 | */ | 30 | */ |
33 | - void addNode(OvsdbNode ovsdb); | 31 | + void addNode(CordVtnNode node); |
34 | 32 | ||
35 | /** | 33 | /** |
36 | * Deletes a node from the service. | 34 | * Deletes a node from the service. |
37 | * | 35 | * |
38 | - * @param ovsdb ovsdb node | 36 | + * @param node cordvtn node |
39 | - */ | ||
40 | - void deleteNode(OvsdbNode ovsdb); | ||
41 | - | ||
42 | - /** | ||
43 | - * Connect to a node. | ||
44 | - * | ||
45 | - * @param ovsdb ovsdb node | ||
46 | */ | 37 | */ |
47 | - void connect(OvsdbNode ovsdb); | 38 | + void deleteNode(CordVtnNode node); |
48 | 39 | ||
49 | /** | 40 | /** |
50 | - * Disconnect a node. | 41 | + * Initiates node to serve virtual tenant network. |
51 | * | 42 | * |
52 | - * @param ovsdb ovsdb node | 43 | + * @param node cordvtn node |
53 | */ | 44 | */ |
54 | - void disconnect(OvsdbNode ovsdb); | 45 | + void initNode(CordVtnNode node); |
55 | 46 | ||
56 | /** | 47 | /** |
57 | * Returns the number of the nodes known to the service. | 48 | * Returns the number of the nodes known to the service. |
... | @@ -61,25 +52,17 @@ public interface CordVtnService { | ... | @@ -61,25 +52,17 @@ public interface CordVtnService { |
61 | int getNodeCount(); | 52 | int getNodeCount(); |
62 | 53 | ||
63 | /** | 54 | /** |
64 | - * Returns OvsdbNode with given device id. | 55 | + * Returns node initialization state. |
65 | - * | ||
66 | - * @param deviceId device id | ||
67 | - * @return ovsdb node | ||
68 | - */ | ||
69 | - OvsdbNode getNode(DeviceId deviceId); | ||
70 | - | ||
71 | - /** | ||
72 | - * Returns connection state of the node. | ||
73 | * | 56 | * |
74 | - * @param ovsdb ovsdb node | 57 | + * @param node cordvtn node |
75 | - * @return true if the node is connected, false otherwise | 58 | + * @return true if initial node setup is completed, otherwise false |
76 | */ | 59 | */ |
77 | - boolean isNodeConnected(OvsdbNode ovsdb); | 60 | + boolean getNodeInitState(CordVtnNode node); |
78 | 61 | ||
79 | /** | 62 | /** |
80 | * Returns all nodes known to the service. | 63 | * Returns all nodes known to the service. |
81 | * | 64 | * |
82 | * @return list of nodes | 65 | * @return list of nodes |
83 | */ | 66 | */ |
84 | - List<OvsdbNode> getNodes(); | 67 | + List<CordVtnNode> getNodes(); |
85 | } | 68 | } | ... | ... |
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.cordvtn; | ||
17 | - | ||
18 | -import com.google.common.base.MoreObjects; | ||
19 | -import org.onlab.packet.IpAddress; | ||
20 | -import org.onlab.packet.TpPort; | ||
21 | -import org.onosproject.net.DeviceId; | ||
22 | - | ||
23 | -import java.util.Objects; | ||
24 | - | ||
25 | -/** | ||
26 | - * OvsdbNode implementation. | ||
27 | - */ | ||
28 | -public class DefaultOvsdbNode implements OvsdbNode { | ||
29 | - | ||
30 | - private final String host; | ||
31 | - private final IpAddress ip; | ||
32 | - private final TpPort port; | ||
33 | - private final DeviceId brId; | ||
34 | - | ||
35 | - public DefaultOvsdbNode(String host, IpAddress ip, TpPort port, DeviceId brId) { | ||
36 | - this.host = host; | ||
37 | - this.ip = ip; | ||
38 | - this.port = port; | ||
39 | - this.brId = brId; | ||
40 | - } | ||
41 | - | ||
42 | - @Override | ||
43 | - public IpAddress ip() { | ||
44 | - return this.ip; | ||
45 | - } | ||
46 | - | ||
47 | - @Override | ||
48 | - public TpPort port() { | ||
49 | - return this.port; | ||
50 | - } | ||
51 | - | ||
52 | - @Override | ||
53 | - public String host() { | ||
54 | - return this.host; | ||
55 | - } | ||
56 | - | ||
57 | - @Override | ||
58 | - public DeviceId intBrId() { | ||
59 | - return this.brId; | ||
60 | - } | ||
61 | - | ||
62 | - @Override | ||
63 | - public DeviceId deviceId() { | ||
64 | - return DeviceId.deviceId("ovsdb:" + this.ip.toString()); | ||
65 | - } | ||
66 | - | ||
67 | - @Override | ||
68 | - public boolean equals(Object o) { | ||
69 | - if (this == o) { | ||
70 | - return true; | ||
71 | - } | ||
72 | - | ||
73 | - if (o instanceof DefaultOvsdbNode) { | ||
74 | - DefaultOvsdbNode that = (DefaultOvsdbNode) o; | ||
75 | - if (this.host.equals(that.host) && | ||
76 | - this.ip.equals(that.ip) && | ||
77 | - this.port.equals(that.port) && | ||
78 | - this.brId.equals(that.brId)) { | ||
79 | - return true; | ||
80 | - } | ||
81 | - } | ||
82 | - return false; | ||
83 | - } | ||
84 | - | ||
85 | - @Override | ||
86 | - public int hashCode() { | ||
87 | - return Objects.hash(host, ip, port); | ||
88 | - } | ||
89 | - | ||
90 | - @Override | ||
91 | - public String toString() { | ||
92 | - return MoreObjects.toStringHelper(getClass()) | ||
93 | - .add("host", host) | ||
94 | - .add("ip", ip) | ||
95 | - .add("port", port) | ||
96 | - .add("bridgeId", brId) | ||
97 | - .toString(); | ||
98 | - } | ||
99 | -} |
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.cordvtn; | ||
17 | - | ||
18 | -import org.onlab.packet.IpAddress; | ||
19 | -import org.onlab.packet.TpPort; | ||
20 | -import org.onosproject.net.DeviceId; | ||
21 | - | ||
22 | -import java.util.Comparator; | ||
23 | - | ||
24 | -/** | ||
25 | - * Representation of a node with ovsdb server. | ||
26 | - */ | ||
27 | -public interface OvsdbNode { | ||
28 | - | ||
29 | - Comparator<OvsdbNode> OVSDB_NODE_COMPARATOR = new Comparator<OvsdbNode>() { | ||
30 | - @Override | ||
31 | - public int compare(OvsdbNode ovsdb1, OvsdbNode ovsdb2) { | ||
32 | - return ovsdb1.host().compareTo(ovsdb2.host()); | ||
33 | - } | ||
34 | - }; | ||
35 | - | ||
36 | - /** | ||
37 | - * Returns the IP address of the ovsdb server. | ||
38 | - * | ||
39 | - * @return ip address | ||
40 | - */ | ||
41 | - IpAddress ip(); | ||
42 | - | ||
43 | - /** | ||
44 | - * Returns the port number of the ovsdb server. | ||
45 | - * | ||
46 | - * @return port number | ||
47 | - */ | ||
48 | - TpPort port(); | ||
49 | - | ||
50 | - /** | ||
51 | - * Returns the host information of the ovsdb server. | ||
52 | - * It could be hostname or ip address. | ||
53 | - * | ||
54 | - * @return host | ||
55 | - */ | ||
56 | - String host(); | ||
57 | - | ||
58 | - /** | ||
59 | - * Returns the device id of the ovsdb server. | ||
60 | - * | ||
61 | - * @return device id | ||
62 | - */ | ||
63 | - DeviceId deviceId(); | ||
64 | - | ||
65 | - /** | ||
66 | - * Returns the device id of the integration bridge associated with the node. | ||
67 | - * | ||
68 | - * @return device id | ||
69 | - */ | ||
70 | - DeviceId intBrId(); | ||
71 | -} |
... | @@ -22,27 +22,26 @@ import org.onlab.packet.IpAddress; | ... | @@ -22,27 +22,26 @@ import org.onlab.packet.IpAddress; |
22 | import org.onlab.packet.TpPort; | 22 | import org.onlab.packet.TpPort; |
23 | import org.onosproject.cli.AbstractShellCommand; | 23 | import org.onosproject.cli.AbstractShellCommand; |
24 | import org.onosproject.cordvtn.CordVtnService; | 24 | import org.onosproject.cordvtn.CordVtnService; |
25 | -import org.onosproject.cordvtn.DefaultOvsdbNode; | 25 | +import org.onosproject.cordvtn.CordVtnNode; |
26 | -import org.onosproject.cordvtn.OvsdbNode; | ||
27 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
28 | 27 | ||
29 | import static com.google.common.base.Preconditions.checkArgument; | 28 | import static com.google.common.base.Preconditions.checkArgument; |
30 | 29 | ||
31 | /** | 30 | /** |
32 | - * Adds a new OVSDB nodes. | 31 | + * Adds a new node to the service. |
33 | */ | 32 | */ |
34 | -@Command(scope = "onos", name = "ovsdb-add", | 33 | +@Command(scope = "onos", name = "cordvtn-node-add", |
35 | - description = "Adds a new OVSDB node to cordvtn") | 34 | + description = "Adds a new node to CORD VTN service") |
36 | -public class OvsdbNodeAddCommand extends AbstractShellCommand { | 35 | +public class CordVtnNodeAddCommand extends AbstractShellCommand { |
37 | 36 | ||
38 | - @Argument(index = 0, name = "host", description = "Hostname or IP", | 37 | + @Argument(index = 0, name = "hostname", description = "Hostname", |
39 | required = true, multiValued = false) | 38 | required = true, multiValued = false) |
40 | - private String host = null; | 39 | + private String hostname = null; |
41 | 40 | ||
42 | - @Argument(index = 1, name = "address", | 41 | + @Argument(index = 1, name = "ovsdb", |
43 | description = "OVSDB server listening address (ip:port)", | 42 | description = "OVSDB server listening address (ip:port)", |
44 | required = true, multiValued = false) | 43 | required = true, multiValued = false) |
45 | - private String address = null; | 44 | + private String ovsdb = null; |
46 | 45 | ||
47 | @Argument(index = 2, name = "bridgeId", | 46 | @Argument(index = 2, name = "bridgeId", |
48 | description = "Device ID of integration bridge", | 47 | description = "Device ID of integration bridge", |
... | @@ -51,15 +50,15 @@ public class OvsdbNodeAddCommand extends AbstractShellCommand { | ... | @@ -51,15 +50,15 @@ public class OvsdbNodeAddCommand extends AbstractShellCommand { |
51 | 50 | ||
52 | @Override | 51 | @Override |
53 | protected void execute() { | 52 | protected void execute() { |
54 | - checkArgument(address.contains(":"), "address should be ip:port format"); | 53 | + checkArgument(ovsdb.contains(":"), "OVSDB address should be ip:port format"); |
55 | checkArgument(bridgeId.startsWith("of:"), "bridgeId should be of:dpid format"); | 54 | checkArgument(bridgeId.startsWith("of:"), "bridgeId should be of:dpid format"); |
56 | 55 | ||
57 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); | 56 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); |
58 | - String[] ipPort = address.split(":"); | 57 | + String[] ipPort = ovsdb.split(":"); |
59 | - OvsdbNode ovsdb = new DefaultOvsdbNode(host, | 58 | + CordVtnNode node = new CordVtnNode(hostname, |
60 | IpAddress.valueOf(ipPort[0]), | 59 | IpAddress.valueOf(ipPort[0]), |
61 | TpPort.tpPort(Integer.parseInt(ipPort[1])), | 60 | TpPort.tpPort(Integer.parseInt(ipPort[1])), |
62 | DeviceId.deviceId(bridgeId)); | 61 | DeviceId.deviceId(bridgeId)); |
63 | - service.addNode(ovsdb); | 62 | + service.addNode(node); |
64 | } | 63 | } |
65 | } | 64 | } | ... | ... |
... | @@ -20,38 +20,38 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -20,38 +20,38 @@ import org.apache.karaf.shell.commands.Argument; |
20 | import org.apache.karaf.shell.commands.Command; | 20 | import org.apache.karaf.shell.commands.Command; |
21 | import org.onosproject.cli.AbstractShellCommand; | 21 | import org.onosproject.cli.AbstractShellCommand; |
22 | import org.onosproject.cordvtn.CordVtnService; | 22 | import org.onosproject.cordvtn.CordVtnService; |
23 | -import org.onosproject.cordvtn.OvsdbNode; | 23 | +import org.onosproject.cordvtn.CordVtnNode; |
24 | 24 | ||
25 | import java.util.NoSuchElementException; | 25 | import java.util.NoSuchElementException; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | - * Deletes OVSDB nodes from cordvtn. | 28 | + * Deletes nodes from the service. |
29 | */ | 29 | */ |
30 | -@Command(scope = "onos", name = "ovsdb-delete", | 30 | +@Command(scope = "onos", name = "cordvtn-node-delete", |
31 | - description = "Deletes OVSDB nodes from cordvtn") | 31 | + description = "Deletes nodes from CORD VTN service") |
32 | -public class OvsdbNodeDeleteCommand extends AbstractShellCommand { | 32 | +public class CordVtnNodeDeleteCommand extends AbstractShellCommand { |
33 | 33 | ||
34 | - @Argument(index = 0, name = "hosts", description = "Hostname(s) or IP(s)", | 34 | + @Argument(index = 0, name = "hostnames", description = "Hostname(s)", |
35 | required = true, multiValued = true) | 35 | required = true, multiValued = true) |
36 | - private String[] hosts = null; | 36 | + private String[] hostnames = null; |
37 | 37 | ||
38 | @Override | 38 | @Override |
39 | protected void execute() { | 39 | protected void execute() { |
40 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); | 40 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); |
41 | 41 | ||
42 | - for (String host : hosts) { | 42 | + for (String hostname : hostnames) { |
43 | - OvsdbNode ovsdb; | 43 | + CordVtnNode node; |
44 | try { | 44 | try { |
45 | - ovsdb = service.getNodes().stream() | 45 | + node = service.getNodes() |
46 | - .filter(node -> node.host().equals(host)) | 46 | + .stream() |
47 | + .filter(n -> n.hostname().equals(hostname)) | ||
47 | .findFirst().get(); | 48 | .findFirst().get(); |
48 | - | ||
49 | } catch (NoSuchElementException e) { | 49 | } catch (NoSuchElementException e) { |
50 | - print("Unable to find %s", host); | 50 | + print("Unable to find %s", hostname); |
51 | continue; | 51 | continue; |
52 | } | 52 | } |
53 | 53 | ||
54 | - service.deleteNode(ovsdb); | 54 | + service.deleteNode(node); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | } | 57 | } | ... | ... |
... | @@ -20,41 +20,38 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -20,41 +20,38 @@ import org.apache.karaf.shell.commands.Argument; |
20 | import org.apache.karaf.shell.commands.Command; | 20 | import org.apache.karaf.shell.commands.Command; |
21 | import org.onosproject.cli.AbstractShellCommand; | 21 | import org.onosproject.cli.AbstractShellCommand; |
22 | import org.onosproject.cordvtn.CordVtnService; | 22 | import org.onosproject.cordvtn.CordVtnService; |
23 | -import org.onosproject.cordvtn.OvsdbNode; | 23 | +import org.onosproject.cordvtn.CordVtnNode; |
24 | 24 | ||
25 | import java.util.NoSuchElementException; | 25 | import java.util.NoSuchElementException; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | - * Connects to OVSDBs. | 28 | + * Initializes nodes for CordVtn service. |
29 | */ | 29 | */ |
30 | -@Command(scope = "onos", name = "ovsdb-connect", | 30 | +@Command(scope = "onos", name = "cordvtn-node-init", |
31 | - description = "Connects to OVSDBs") | 31 | + description = "Initializes nodes for CORD VTN service") |
32 | -public class OvsdbNodeConnectCommand extends AbstractShellCommand { | 32 | +public class CordVtnNodeInitCommand extends AbstractShellCommand { |
33 | 33 | ||
34 | - @Argument(index = 0, name = "hosts", description = "Hostname(s) or IP(s)", | 34 | + @Argument(index = 0, name = "hostnames", description = "Hostname(s)", |
35 | required = true, multiValued = true) | 35 | required = true, multiValued = true) |
36 | - private String[] hosts = null; | 36 | + private String[] hostnames = null; |
37 | 37 | ||
38 | @Override | 38 | @Override |
39 | protected void execute() { | 39 | protected void execute() { |
40 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); | 40 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); |
41 | 41 | ||
42 | - for (String host : hosts) { | 42 | + for (String hostname : hostnames) { |
43 | - OvsdbNode ovsdb; | 43 | + CordVtnNode node; |
44 | try { | 44 | try { |
45 | - ovsdb = service.getNodes().stream() | 45 | + node = service.getNodes() |
46 | - .filter(node -> node.host().equals(host)) | 46 | + .stream() |
47 | + .filter(n -> n.hostname().equals(hostname)) | ||
47 | .findFirst().get(); | 48 | .findFirst().get(); |
48 | } catch (NoSuchElementException e) { | 49 | } catch (NoSuchElementException e) { |
49 | - print("Unable to find %s", host); | 50 | + print("Unable to find %s", hostname); |
50 | continue; | 51 | continue; |
51 | } | 52 | } |
52 | 53 | ||
53 | - if (service.isNodeConnected(ovsdb)) { | 54 | + service.initNode(node); |
54 | - print("OVSDB %s is already in connected state, do nothing", host); | ||
55 | - } else { | ||
56 | - service.connect(ovsdb); | ||
57 | - } | ||
58 | } | 55 | } |
59 | } | 56 | } |
60 | } | 57 | } | ... | ... |
... | @@ -22,53 +22,53 @@ import com.fasterxml.jackson.databind.node.ArrayNode; | ... | @@ -22,53 +22,53 @@ import com.fasterxml.jackson.databind.node.ArrayNode; |
22 | import org.apache.karaf.shell.commands.Command; | 22 | import org.apache.karaf.shell.commands.Command; |
23 | import org.onosproject.cli.AbstractShellCommand; | 23 | import org.onosproject.cli.AbstractShellCommand; |
24 | import org.onosproject.cordvtn.CordVtnService; | 24 | import org.onosproject.cordvtn.CordVtnService; |
25 | -import org.onosproject.cordvtn.OvsdbNode; | 25 | +import org.onosproject.cordvtn.CordVtnNode; |
26 | 26 | ||
27 | import java.util.Collections; | 27 | import java.util.Collections; |
28 | import java.util.List; | 28 | import java.util.List; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | - * Lists all OVSDB nodes. | 31 | + * Lists all nodes registered to the service. |
32 | */ | 32 | */ |
33 | -@Command(scope = "onos", name = "ovsdbs", | 33 | +@Command(scope = "onos", name = "cordvtn-nodes", |
34 | - description = "Lists all OVSDB nodes registered in cordvtn application") | 34 | + description = "Lists all nodes registered in CORD VTN service") |
35 | -public class OvsdbNodeListCommand extends AbstractShellCommand { | 35 | +public class CordVtnNodeListCommand extends AbstractShellCommand { |
36 | 36 | ||
37 | @Override | 37 | @Override |
38 | protected void execute() { | 38 | protected void execute() { |
39 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); | 39 | CordVtnService service = AbstractShellCommand.get(CordVtnService.class); |
40 | - List<OvsdbNode> ovsdbs = service.getNodes(); | 40 | + List<CordVtnNode> nodes = service.getNodes(); |
41 | - Collections.sort(ovsdbs, OvsdbNode.OVSDB_NODE_COMPARATOR); | 41 | + Collections.sort(nodes, CordVtnNode.CORDVTN_NODE_COMPARATOR); |
42 | 42 | ||
43 | if (outputJson()) { | 43 | if (outputJson()) { |
44 | - print("%s", json(service, ovsdbs)); | 44 | + print("%s", json(service, nodes)); |
45 | } else { | 45 | } else { |
46 | - for (OvsdbNode ovsdb : ovsdbs) { | 46 | + for (CordVtnNode node : nodes) { |
47 | - print("host=%s, address=%s, br-int=%s, state=%s", | 47 | + print("hostname=%s, ovsdb=%s, br-int=%s, init=%s", |
48 | - ovsdb.host(), | 48 | + node.hostname(), |
49 | - ovsdb.ip().toString() + ":" + ovsdb.port().toString(), | 49 | + node.ovsdbIp().toString() + ":" + node.ovsdbPort().toString(), |
50 | - ovsdb.intBrId().toString(), | 50 | + node.intBrId().toString(), |
51 | - getState(service, ovsdb)); | 51 | + getState(service, node)); |
52 | } | 52 | } |
53 | print("Total %s nodes", service.getNodeCount()); | 53 | print("Total %s nodes", service.getNodeCount()); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | - private JsonNode json(CordVtnService service, List<OvsdbNode> ovsdbs) { | 57 | + private JsonNode json(CordVtnService service, List<CordVtnNode> nodes) { |
58 | ObjectMapper mapper = new ObjectMapper(); | 58 | ObjectMapper mapper = new ObjectMapper(); |
59 | ArrayNode result = mapper.createArrayNode(); | 59 | ArrayNode result = mapper.createArrayNode(); |
60 | - for (OvsdbNode ovsdb : ovsdbs) { | 60 | + for (CordVtnNode node : nodes) { |
61 | - String ipPort = ovsdb.ip().toString() + ":" + ovsdb.port().toString(); | 61 | + String ipPort = node.ovsdbIp().toString() + ":" + node.ovsdbPort().toString(); |
62 | result.add(mapper.createObjectNode() | 62 | result.add(mapper.createObjectNode() |
63 | - .put("host", ovsdb.host()) | 63 | + .put("hostname", node.hostname()) |
64 | - .put("address", ipPort) | 64 | + .put("ovsdb", ipPort) |
65 | - .put("brInt", ovsdb.intBrId().toString()) | 65 | + .put("brInt", node.intBrId().toString()) |
66 | - .put("state", getState(service, ovsdb))); | 66 | + .put("init", getState(service, node))); |
67 | } | 67 | } |
68 | return result; | 68 | return result; |
69 | } | 69 | } |
70 | 70 | ||
71 | - private String getState(CordVtnService service, OvsdbNode ovsdb) { | 71 | + private String getState(CordVtnService service, CordVtnNode node) { |
72 | - return service.isNodeConnected(ovsdb) ? "CONNECTED" : "DISCONNECTED"; | 72 | + return service.getNodeInitState(node) ? "COMPLETE" : "INCOMPLETE"; |
73 | } | 73 | } |
74 | } | 74 | } | ... | ... |
apps/cordvtn/src/main/java/org/onosproject/cordvtn/cli/OvsdbNodeDisconnectCommand.java
deleted
100644 → 0
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.cordvtn.cli; | ||
18 | - | ||
19 | -import org.apache.karaf.shell.commands.Argument; | ||
20 | -import org.apache.karaf.shell.commands.Command; | ||
21 | -import org.onosproject.cli.AbstractShellCommand; | ||
22 | -import org.onosproject.cordvtn.CordVtnService; | ||
23 | -import org.onosproject.cordvtn.OvsdbNode; | ||
24 | - | ||
25 | -import java.util.NoSuchElementException; | ||
26 | - | ||
27 | -/** | ||
28 | - * Disconnects OVSDBs. | ||
29 | - */ | ||
30 | -@Command(scope = "onos", name = "ovsdb-disconnect", | ||
31 | - description = "Disconnects OVSDBs") | ||
32 | -public class OvsdbNodeDisconnectCommand extends AbstractShellCommand { | ||
33 | - | ||
34 | - @Argument(index = 0, name = "hosts", description = "Hostname(s) or IP(s)", | ||
35 | - required = true, multiValued = true) | ||
36 | - private String[] hosts = null; | ||
37 | - | ||
38 | - @Override | ||
39 | - protected void execute() { | ||
40 | - CordVtnService service = AbstractShellCommand.get(CordVtnService.class); | ||
41 | - | ||
42 | - for (String host : hosts) { | ||
43 | - OvsdbNode ovsdb; | ||
44 | - try { | ||
45 | - ovsdb = service.getNodes().stream() | ||
46 | - .filter(node -> node.host().equals(host)) | ||
47 | - .findFirst().get(); | ||
48 | - } catch (NoSuchElementException e) { | ||
49 | - print("Unable to find %s", host); | ||
50 | - continue; | ||
51 | - } | ||
52 | - | ||
53 | - if (!service.isNodeConnected(ovsdb)) { | ||
54 | - print("OVSDB %s is already in disconnected state, do nothing", host); | ||
55 | - } else { | ||
56 | - service.disconnect(ovsdb); | ||
57 | - } | ||
58 | - } | ||
59 | - } | ||
60 | -} |
... | @@ -17,19 +17,16 @@ | ... | @@ -17,19 +17,16 @@ |
17 | 17 | ||
18 | <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | 18 | <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> |
19 | <command> | 19 | <command> |
20 | - <action class="org.onosproject.cordvtn.cli.OvsdbNodeListCommand"/> | 20 | + <action class="org.onosproject.cordvtn.cli.CordVtnNodeListCommand"/> |
21 | </command> | 21 | </command> |
22 | <command> | 22 | <command> |
23 | - <action class="org.onosproject.cordvtn.cli.OvsdbNodeAddCommand"/> | 23 | + <action class="org.onosproject.cordvtn.cli.CordVtnNodeAddCommand"/> |
24 | </command> | 24 | </command> |
25 | <command> | 25 | <command> |
26 | - <action class="org.onosproject.cordvtn.cli.OvsdbNodeDeleteCommand"/> | 26 | + <action class="org.onosproject.cordvtn.cli.CordVtnNodeDeleteCommand"/> |
27 | </command> | 27 | </command> |
28 | <command> | 28 | <command> |
29 | - <action class="org.onosproject.cordvtn.cli.OvsdbNodeConnectCommand"/> | 29 | + <action class="org.onosproject.cordvtn.cli.CordVtnNodeInitCommand"/> |
30 | - </command> | ||
31 | - <command> | ||
32 | - <action class="org.onosproject.cordvtn.cli.OvsdbNodeDisconnectCommand"/> | ||
33 | </command> | 30 | </command> |
34 | </command-bundle> | 31 | </command-bundle> |
35 | </blueprint> | 32 | </blueprint> | ... | ... |
-
Please register or login to post a comment