Committed by
Gerrit Code Review
CORD-471 Added physical port and data plane IP as node attribtes
Change-Id: I4c28053151e61feb4b9b0ca60e98f7e0e4af0207
Showing
9 changed files
with
241 additions
and
30 deletions
... | @@ -105,9 +105,13 @@ public class CordVtn implements CordVtnService { | ... | @@ -105,9 +105,13 @@ public class CordVtn implements CordVtnService { |
105 | .register(KryoNamespaces.API) | 105 | .register(KryoNamespaces.API) |
106 | .register(CordVtnNode.class) | 106 | .register(CordVtnNode.class) |
107 | .register(NodeState.class); | 107 | .register(NodeState.class); |
108 | + | ||
108 | private static final String DEFAULT_BRIDGE = "br-int"; | 109 | private static final String DEFAULT_BRIDGE = "br-int"; |
109 | private static final String VPORT_PREFIX = "tap"; | 110 | private static final String VPORT_PREFIX = "tap"; |
110 | private static final String DEFAULT_TUNNEL = "vxlan"; | 111 | private static final String DEFAULT_TUNNEL = "vxlan"; |
112 | + private static final String OK = "OK"; | ||
113 | + private static final String NO = "NO"; | ||
114 | + | ||
111 | private static final Map<String, String> DEFAULT_TUNNEL_OPTIONS = new HashMap<String, String>() { | 115 | private static final Map<String, String> DEFAULT_TUNNEL_OPTIONS = new HashMap<String, String>() { |
112 | { | 116 | { |
113 | put("key", "flow"); | 117 | put("key", "flow"); |
... | @@ -213,6 +217,8 @@ public class CordVtn implements CordVtnService { | ... | @@ -213,6 +217,8 @@ public class CordVtn implements CordVtnService { |
213 | } | 217 | } |
214 | }; | 218 | }; |
215 | 219 | ||
220 | + // TODO Add physical port add state | ||
221 | + | ||
216 | public abstract void process(CordVtn cordVtn, CordVtnNode node); | 222 | public abstract void process(CordVtn cordVtn, CordVtnNode node); |
217 | } | 223 | } |
218 | 224 | ||
... | @@ -307,6 +313,27 @@ public class CordVtn implements CordVtnService { | ... | @@ -307,6 +313,27 @@ public class CordVtn implements CordVtnService { |
307 | } | 313 | } |
308 | 314 | ||
309 | @Override | 315 | @Override |
316 | + public String checkNodeInitState(CordVtnNode node) { | ||
317 | + checkNotNull(node); | ||
318 | + | ||
319 | + NodeState state = getNodeState(node); | ||
320 | + if (state == null) { | ||
321 | + log.warn("Failed to get init state of {}", node.hostname()); | ||
322 | + return null; | ||
323 | + } | ||
324 | + | ||
325 | + String result = String.format( | ||
326 | + "Integration bridge created/connected : %s (%s)%n" + | ||
327 | + "VXLAN interface created : %s%n" + | ||
328 | + "Physical interface added : %s (%s)", | ||
329 | + checkIntegrationBridge(node) ? OK : NO, DEFAULT_BRIDGE, | ||
330 | + checkTunnelInterface(node) ? OK : NO, | ||
331 | + checkPhyInterface(node) ? OK : NO, node.phyPortName()); | ||
332 | + | ||
333 | + return result; | ||
334 | + } | ||
335 | + | ||
336 | + @Override | ||
310 | public void createServiceDependency(CordServiceId tServiceId, CordServiceId pServiceId) { | 337 | public void createServiceDependency(CordServiceId tServiceId, CordServiceId pServiceId) { |
311 | CordService tService = getCordService(tServiceId); | 338 | CordService tService = getCordService(tServiceId); |
312 | CordService pService = getCordService(pServiceId); | 339 | CordService pService = getCordService(pServiceId); |
... | @@ -374,7 +401,12 @@ public class CordVtn implements CordVtnService { | ... | @@ -374,7 +401,12 @@ public class CordVtn implements CordVtnService { |
374 | checkNotNull(node); | 401 | checkNotNull(node); |
375 | 402 | ||
376 | if (checkIntegrationBridge(node) && checkTunnelInterface(node)) { | 403 | if (checkIntegrationBridge(node) && checkTunnelInterface(node)) { |
404 | + // TODO add physical port add state | ||
405 | + if (checkPhyInterface(node)) { | ||
377 | return NodeState.COMPLETE; | 406 | return NodeState.COMPLETE; |
407 | + } else { | ||
408 | + return NodeState.INCOMPLETE; | ||
409 | + } | ||
378 | } else if (checkIntegrationBridge(node)) { | 410 | } else if (checkIntegrationBridge(node)) { |
379 | return NodeState.BRIDGE_CREATED; | 411 | return NodeState.BRIDGE_CREATED; |
380 | } else if (getOvsdbConnectionState(node)) { | 412 | } else if (getOvsdbConnectionState(node)) { |
... | @@ -488,6 +520,16 @@ public class CordVtn implements CordVtnService { | ... | @@ -488,6 +520,16 @@ public class CordVtn implements CordVtnService { |
488 | } | 520 | } |
489 | 521 | ||
490 | /** | 522 | /** |
523 | + * Returns port name. | ||
524 | + * | ||
525 | + * @param port port | ||
526 | + * @return port name | ||
527 | + */ | ||
528 | + private String getPortName(Port port) { | ||
529 | + return port.annotations().value("portName"); | ||
530 | + } | ||
531 | + | ||
532 | + /** | ||
491 | * Returns OVSDB client for a given node. | 533 | * Returns OVSDB client for a given node. |
492 | * | 534 | * |
493 | * @param node cordvtn node | 535 | * @param node cordvtn node |
... | @@ -520,6 +562,7 @@ public class CordVtn implements CordVtnService { | ... | @@ -520,6 +562,7 @@ public class CordVtn implements CordVtnService { |
520 | ControllerInfo ctrlInfo = new ControllerInfo(controller.ip(), OFPORT, "tcp"); | 562 | ControllerInfo ctrlInfo = new ControllerInfo(controller.ip(), OFPORT, "tcp"); |
521 | controllers.add(ctrlInfo); | 563 | controllers.add(ctrlInfo); |
522 | }); | 564 | }); |
565 | + | ||
523 | String dpid = node.intBrId().toString().substring(DPID_BEGIN); | 566 | String dpid = node.intBrId().toString().substring(DPID_BEGIN); |
524 | 567 | ||
525 | try { | 568 | try { |
... | @@ -545,9 +588,11 @@ public class CordVtn implements CordVtnService { | ... | @@ -545,9 +588,11 @@ public class CordVtn implements CordVtnService { |
545 | for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) { | 588 | for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) { |
546 | optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key)); | 589 | optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key)); |
547 | } | 590 | } |
548 | - TunnelDescription description = | 591 | + |
549 | - new DefaultTunnelDescription(null, null, VXLAN, TunnelName.tunnelName(DEFAULT_TUNNEL), | 592 | + TunnelDescription description = new DefaultTunnelDescription( |
593 | + null, null, VXLAN, TunnelName.tunnelName(DEFAULT_TUNNEL), | ||
550 | optionBuilder.build()); | 594 | optionBuilder.build()); |
595 | + | ||
551 | try { | 596 | try { |
552 | DriverHandler handler = driverService.createHandler(node.ovsdbId()); | 597 | DriverHandler handler = driverService.createHandler(node.ovsdbId()); |
553 | TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class); | 598 | TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class); |
... | @@ -578,7 +623,26 @@ public class CordVtn implements CordVtnService { | ... | @@ -578,7 +623,26 @@ public class CordVtn implements CordVtnService { |
578 | try { | 623 | try { |
579 | deviceService.getPorts(node.intBrId()) | 624 | deviceService.getPorts(node.intBrId()) |
580 | .stream() | 625 | .stream() |
581 | - .filter(p -> p.annotations().value("portName").contains(DEFAULT_TUNNEL) | 626 | + .filter(p -> getPortName(p).contains(DEFAULT_TUNNEL) |
627 | + && p.isEnabled()) | ||
628 | + .findAny().get(); | ||
629 | + return true; | ||
630 | + } catch (NoSuchElementException e) { | ||
631 | + return false; | ||
632 | + } | ||
633 | + } | ||
634 | + | ||
635 | + /** | ||
636 | + * Checks if physical interface exists. | ||
637 | + * | ||
638 | + * @param node cordvtn node | ||
639 | + * @return true if the interface exists, false otherwise | ||
640 | + */ | ||
641 | + private boolean checkPhyInterface(CordVtnNode node) { | ||
642 | + try { | ||
643 | + deviceService.getPorts(node.intBrId()) | ||
644 | + .stream() | ||
645 | + .filter(p -> getPortName(p).contains(node.phyPortName()) | ||
582 | && p.isEnabled()) | 646 | && p.isEnabled()) |
583 | .findAny().get(); | 647 | .findAny().get(); |
584 | return true; | 648 | return true; |
... | @@ -596,7 +660,7 @@ public class CordVtn implements CordVtnService { | ... | @@ -596,7 +660,7 @@ public class CordVtn implements CordVtnService { |
596 | private PortNumber getTunnelPort(DeviceId bridgeId) { | 660 | private PortNumber getTunnelPort(DeviceId bridgeId) { |
597 | try { | 661 | try { |
598 | return deviceService.getPorts(bridgeId).stream() | 662 | return deviceService.getPorts(bridgeId).stream() |
599 | - .filter(p -> p.annotations().value("portName").contains(DEFAULT_TUNNEL) | 663 | + .filter(p -> getPortName(p).contains(DEFAULT_TUNNEL) |
600 | && p.isEnabled()) | 664 | && p.isEnabled()) |
601 | .findFirst().get().number(); | 665 | .findFirst().get().number(); |
602 | } catch (NoSuchElementException e) { | 666 | } catch (NoSuchElementException e) { |
... | @@ -613,8 +677,7 @@ public class CordVtn implements CordVtnService { | ... | @@ -613,8 +677,7 @@ public class CordVtn implements CordVtnService { |
613 | private Ip4Address getRemoteIp(DeviceId bridgeId) { | 677 | private Ip4Address getRemoteIp(DeviceId bridgeId) { |
614 | CordVtnNode node = getNodeByBridgeId(bridgeId); | 678 | CordVtnNode node = getNodeByBridgeId(bridgeId); |
615 | if (node != null) { | 679 | if (node != null) { |
616 | - // TODO get data plane IP for tunneling | 680 | + return node.localIp().getIp4Address(); |
617 | - return node.ovsdbIp().getIp4Address(); | ||
618 | } else { | 681 | } else { |
619 | return null; | 682 | return null; |
620 | } | 683 | } |
... | @@ -712,7 +775,7 @@ public class CordVtn implements CordVtnService { | ... | @@ -712,7 +775,7 @@ public class CordVtn implements CordVtnService { |
712 | private boolean isVm(Host host) { | 775 | private boolean isVm(Host host) { |
713 | Port port = deviceService.getPort(host.location().deviceId(), | 776 | Port port = deviceService.getPort(host.location().deviceId(), |
714 | host.location().port()); | 777 | host.location().port()); |
715 | - return port.annotations().value("portName").contains(VPORT_PREFIX); | 778 | + return getPortName(port).contains(VPORT_PREFIX); |
716 | } | 779 | } |
717 | 780 | ||
718 | /** | 781 | /** |
... | @@ -866,43 +929,50 @@ public class CordVtn implements CordVtnService { | ... | @@ -866,43 +929,50 @@ public class CordVtn implements CordVtnService { |
866 | 929 | ||
867 | /** | 930 | /** |
868 | * Handles port added situation. | 931 | * Handles port added situation. |
869 | - * If the added port is tunnel port, proceed remaining node initialization. | 932 | + * If the added port is tunnel or physical port, proceed remaining node |
870 | - * Otherwise, do nothing. | 933 | + * initialization. Otherwise, do nothing. |
871 | * | 934 | * |
872 | * @param port port | 935 | * @param port port |
873 | */ | 936 | */ |
874 | public void portAdded(Port port) { | 937 | public void portAdded(Port port) { |
938 | + CordVtnNode node = getNodeByBridgeId((DeviceId) port.element().id()); | ||
939 | + if (node == null) { | ||
940 | + return; | ||
941 | + } | ||
942 | + | ||
875 | // TODO add host by updating network config | 943 | // TODO add host by updating network config |
876 | - if (!port.annotations().value("portName").contains(DEFAULT_TUNNEL)) { | 944 | + String portName = getPortName(port); |
945 | + if (!portName.contains(DEFAULT_TUNNEL) && !portName.equals(node.phyPortName())) { | ||
877 | return; | 946 | return; |
878 | } | 947 | } |
879 | 948 | ||
880 | - CordVtnNode node = getNodeByBridgeId((DeviceId) port.element().id()); | 949 | + log.info("Port {} is added to {}", portName, node.hostname()); |
881 | - if (node != null) { | ||
882 | setNodeState(node, checkNodeState(node)); | 950 | setNodeState(node, checkNodeState(node)); |
883 | } | 951 | } |
884 | - } | ||
885 | 952 | ||
886 | /** | 953 | /** |
887 | * Handles port removed situation. | 954 | * Handles port removed situation. |
888 | - * If the removed port is tunnel port, proceed remaining node initialization. | 955 | + * If the removed port is tunnel or physical port, proceed remaining node |
889 | - * Others, do nothing. | 956 | + * initialization.Others, do nothing. |
890 | * | 957 | * |
891 | * @param port port | 958 | * @param port port |
892 | */ | 959 | */ |
893 | public void portRemoved(Port port) { | 960 | public void portRemoved(Port port) { |
961 | + CordVtnNode node = getNodeByBridgeId((DeviceId) port.element().id()); | ||
962 | + if (node == null) { | ||
963 | + return; | ||
964 | + } | ||
965 | + | ||
894 | // TODO remove host by updating network config | 966 | // TODO remove host by updating network config |
895 | - if (!port.annotations().value("portName").contains(DEFAULT_TUNNEL)) { | 967 | + String portName = getPortName(port); |
968 | + if (!portName.contains(DEFAULT_TUNNEL) && !portName.equals(node.phyPortName())) { | ||
896 | return; | 969 | return; |
897 | } | 970 | } |
898 | 971 | ||
899 | - CordVtnNode node = getNodeByBridgeId((DeviceId) port.element().id()); | 972 | + log.info("Port {} is removed from {}", portName, node.hostname()); |
900 | - if (node != null) { | ||
901 | - log.info("Tunnel interface is removed from {}", node.hostname()); | ||
902 | setNodeState(node, NodeState.INCOMPLETE); | 973 | setNodeState(node, NodeState.INCOMPLETE); |
903 | } | 974 | } |
904 | } | 975 | } |
905 | - } | ||
906 | 976 | ||
907 | private class VmHandler implements ConnectionHandler<Host> { | 977 | private class VmHandler implements ConnectionHandler<Host> { |
908 | 978 | ... | ... |
... | @@ -37,6 +37,8 @@ public class CordVtnConfig extends Config<ApplicationId> { | ... | @@ -37,6 +37,8 @@ public class CordVtnConfig extends Config<ApplicationId> { |
37 | public static final String OVSDB_IP = "ovsdbIp"; | 37 | public static final String OVSDB_IP = "ovsdbIp"; |
38 | public static final String OVSDB_PORT = "ovsdbPort"; | 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 | + public static final String PHYSICAL_PORT_NAME = "phyPortName"; | ||
41 | + public static final String LOCAL_IP = "localIp"; | ||
40 | 42 | ||
41 | /** | 43 | /** |
42 | * Returns the set of nodes read from network config. | 44 | * Returns the set of nodes read from network config. |
... | @@ -54,7 +56,9 @@ public class CordVtnConfig extends Config<ApplicationId> { | ... | @@ -54,7 +56,9 @@ public class CordVtnConfig extends Config<ApplicationId> { |
54 | jsonNode.path(HOSTNAME).asText(), | 56 | jsonNode.path(HOSTNAME).asText(), |
55 | IpAddress.valueOf(jsonNode.path(OVSDB_IP).asText()), | 57 | IpAddress.valueOf(jsonNode.path(OVSDB_IP).asText()), |
56 | TpPort.tpPort(jsonNode.path(OVSDB_PORT).asInt()), | 58 | TpPort.tpPort(jsonNode.path(OVSDB_PORT).asInt()), |
57 | - DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText())))); | 59 | + DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()), |
60 | + jsonNode.path(PHYSICAL_PORT_NAME).asText(), | ||
61 | + IpAddress.valueOf(jsonNode.path(LOCAL_IP).asText())))); | ||
58 | 62 | ||
59 | return nodes; | 63 | return nodes; |
60 | } | 64 | } |
... | @@ -68,12 +72,17 @@ public class CordVtnConfig extends Config<ApplicationId> { | ... | @@ -68,12 +72,17 @@ public class CordVtnConfig extends Config<ApplicationId> { |
68 | private final IpAddress ovsdbIp; | 72 | private final IpAddress ovsdbIp; |
69 | private final TpPort ovsdbPort; | 73 | private final TpPort ovsdbPort; |
70 | private final DeviceId bridgeId; | 74 | private final DeviceId bridgeId; |
75 | + private final String phyPortName; | ||
76 | + private final IpAddress localIp; | ||
71 | 77 | ||
72 | - public CordVtnNodeConfig(String hostname, IpAddress ovsdbIp, TpPort ovsdbPort, DeviceId bridgeId) { | 78 | + public CordVtnNodeConfig(String hostname, IpAddress ovsdbIp, TpPort ovsdbPort, |
79 | + DeviceId bridgeId, String phyPortName, IpAddress localIp) { | ||
73 | this.hostname = checkNotNull(hostname); | 80 | this.hostname = checkNotNull(hostname); |
74 | this.ovsdbIp = checkNotNull(ovsdbIp); | 81 | this.ovsdbIp = checkNotNull(ovsdbIp); |
75 | this.ovsdbPort = checkNotNull(ovsdbPort); | 82 | this.ovsdbPort = checkNotNull(ovsdbPort); |
76 | this.bridgeId = checkNotNull(bridgeId); | 83 | this.bridgeId = checkNotNull(bridgeId); |
84 | + this.phyPortName = checkNotNull(phyPortName); | ||
85 | + this.localIp = checkNotNull(localIp); | ||
77 | } | 86 | } |
78 | 87 | ||
79 | /** | 88 | /** |
... | @@ -111,5 +120,23 @@ public class CordVtnConfig extends Config<ApplicationId> { | ... | @@ -111,5 +120,23 @@ public class CordVtnConfig extends Config<ApplicationId> { |
111 | public DeviceId bridgeId() { | 120 | public DeviceId bridgeId() { |
112 | return this.bridgeId; | 121 | return this.bridgeId; |
113 | } | 122 | } |
123 | + | ||
124 | + /** | ||
125 | + * Returns physical port name. | ||
126 | + * | ||
127 | + * @return physical port name | ||
128 | + */ | ||
129 | + public String phyPortName() { | ||
130 | + return this.phyPortName; | ||
131 | + } | ||
132 | + | ||
133 | + /** | ||
134 | + * Returns local IP address. | ||
135 | + * | ||
136 | + * @return ip address | ||
137 | + */ | ||
138 | + public IpAddress localIp() { | ||
139 | + return this.localIp; | ||
140 | + } | ||
114 | } | 141 | } |
115 | } | 142 | } | ... | ... |
... | @@ -97,7 +97,13 @@ public class CordVtnConfigManager { | ... | @@ -97,7 +97,13 @@ public class CordVtnConfigManager { |
97 | 97 | ||
98 | config.cordVtnNodes().forEach(node -> { | 98 | config.cordVtnNodes().forEach(node -> { |
99 | CordVtnNode cordVtnNode = new CordVtnNode( | 99 | CordVtnNode cordVtnNode = new CordVtnNode( |
100 | - node.hostname(), node.ovsdbIp(), node.ovsdbPort(), node.bridgeId()); | 100 | + node.hostname(), |
101 | + node.ovsdbIp(), | ||
102 | + node.ovsdbPort(), | ||
103 | + node.bridgeId(), | ||
104 | + node.phyPortName(), | ||
105 | + node.localIp()); | ||
106 | + | ||
101 | cordVtnService.addNode(cordVtnNode); | 107 | cordVtnService.addNode(cordVtnNode); |
102 | }); | 108 | }); |
103 | } | 109 | } | ... | ... |
... | @@ -34,6 +34,8 @@ public final class CordVtnNode { | ... | @@ -34,6 +34,8 @@ public final class CordVtnNode { |
34 | private final IpAddress ovsdbIp; | 34 | private final IpAddress ovsdbIp; |
35 | private final TpPort ovsdbPort; | 35 | private final TpPort ovsdbPort; |
36 | private final DeviceId bridgeId; | 36 | private final DeviceId bridgeId; |
37 | + private final String phyPortName; | ||
38 | + private final IpAddress localIp; | ||
37 | 39 | ||
38 | public static final Comparator<CordVtnNode> CORDVTN_NODE_COMPARATOR = | 40 | public static final Comparator<CordVtnNode> CORDVTN_NODE_COMPARATOR = |
39 | (node1, node2) -> node1.hostname().compareTo(node2.hostname()); | 41 | (node1, node2) -> node1.hostname().compareTo(node2.hostname()); |
... | @@ -45,12 +47,17 @@ public final class CordVtnNode { | ... | @@ -45,12 +47,17 @@ public final class CordVtnNode { |
45 | * @param ovsdbIp OVSDB server IP address | 47 | * @param ovsdbIp OVSDB server IP address |
46 | * @param ovsdbPort OVSDB server port number | 48 | * @param ovsdbPort OVSDB server port number |
47 | * @param bridgeId integration bridge identifier | 49 | * @param bridgeId integration bridge identifier |
50 | + * @param phyPortName physical port name | ||
51 | + * @param localIp local ip address of data plane | ||
48 | */ | 52 | */ |
49 | - public CordVtnNode(String hostname, IpAddress ovsdbIp, TpPort ovsdbPort, DeviceId bridgeId) { | 53 | + public CordVtnNode(String hostname, IpAddress ovsdbIp, TpPort ovsdbPort, |
54 | + DeviceId bridgeId, String phyPortName, IpAddress localIp) { | ||
50 | this.hostname = checkNotNull(hostname); | 55 | this.hostname = checkNotNull(hostname); |
51 | this.ovsdbIp = checkNotNull(ovsdbIp); | 56 | this.ovsdbIp = checkNotNull(ovsdbIp); |
52 | this.ovsdbPort = checkNotNull(ovsdbPort); | 57 | this.ovsdbPort = checkNotNull(ovsdbPort); |
53 | this.bridgeId = checkNotNull(bridgeId); | 58 | this.bridgeId = checkNotNull(bridgeId); |
59 | + this.phyPortName = checkNotNull(phyPortName); | ||
60 | + this.localIp = checkNotNull(localIp); | ||
54 | } | 61 | } |
55 | 62 | ||
56 | /** | 63 | /** |
... | @@ -98,6 +105,24 @@ public final class CordVtnNode { | ... | @@ -98,6 +105,24 @@ public final class CordVtnNode { |
98 | return DeviceId.deviceId("ovsdb:" + this.ovsdbIp.toString()); | 105 | return DeviceId.deviceId("ovsdb:" + this.ovsdbIp.toString()); |
99 | } | 106 | } |
100 | 107 | ||
108 | + /** | ||
109 | + * Returns physical port name. | ||
110 | + * | ||
111 | + * @return physical port name | ||
112 | + */ | ||
113 | + public String phyPortName() { | ||
114 | + return this.phyPortName; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Returns local IP address. | ||
119 | + * | ||
120 | + * @return ip address | ||
121 | + */ | ||
122 | + public IpAddress localIp() { | ||
123 | + return this.localIp; | ||
124 | + } | ||
125 | + | ||
101 | @Override | 126 | @Override |
102 | public boolean equals(Object obj) { | 127 | public boolean equals(Object obj) { |
103 | if (this == obj) { | 128 | if (this == obj) { |
... | @@ -106,10 +131,7 @@ public final class CordVtnNode { | ... | @@ -106,10 +131,7 @@ public final class CordVtnNode { |
106 | 131 | ||
107 | if (obj instanceof CordVtnNode) { | 132 | if (obj instanceof CordVtnNode) { |
108 | CordVtnNode that = (CordVtnNode) obj; | 133 | CordVtnNode that = (CordVtnNode) obj; |
109 | - if (Objects.equals(hostname, that.hostname) && | 134 | + 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; | 135 | return true; |
114 | } | 136 | } |
115 | } | 137 | } |
... | @@ -128,6 +150,8 @@ public final class CordVtnNode { | ... | @@ -128,6 +150,8 @@ public final class CordVtnNode { |
128 | .add("ip", ovsdbIp) | 150 | .add("ip", ovsdbIp) |
129 | .add("port", ovsdbPort) | 151 | .add("port", ovsdbPort) |
130 | .add("bridgeId", bridgeId) | 152 | .add("bridgeId", bridgeId) |
153 | + .add("phyPortName", phyPortName) | ||
154 | + .add("localIp", localIp) | ||
131 | .toString(); | 155 | .toString(); |
132 | } | 156 | } |
133 | } | 157 | } | ... | ... |
... | @@ -60,6 +60,19 @@ public interface CordVtnService { | ... | @@ -60,6 +60,19 @@ public interface CordVtnService { |
60 | boolean getNodeInitState(CordVtnNode node); | 60 | boolean getNodeInitState(CordVtnNode node); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | + * Returns detailed node initialization state. | ||
64 | + * Return string includes the following information. | ||
65 | + * | ||
66 | + * Integration bridge created/connected: OK or NO | ||
67 | + * VXLAN interface created: OK or NO | ||
68 | + * Physical interface added: OK or NO | ||
69 | + * | ||
70 | + * @param node cordvtn node | ||
71 | + * @return string including detailed node init state | ||
72 | + */ | ||
73 | + String checkNodeInitState(CordVtnNode node); | ||
74 | + | ||
75 | + /** | ||
63 | * Returns all nodes known to the service. | 76 | * Returns all nodes known to the service. |
64 | * | 77 | * |
65 | * @return list of nodes | 78 | * @return list of nodes | ... | ... |
... | @@ -48,6 +48,16 @@ public class CordVtnNodeAddCommand extends AbstractShellCommand { | ... | @@ -48,6 +48,16 @@ public class CordVtnNodeAddCommand extends AbstractShellCommand { |
48 | required = true, multiValued = false) | 48 | required = true, multiValued = false) |
49 | private String bridgeId = null; | 49 | private String bridgeId = null; |
50 | 50 | ||
51 | + @Argument(index = 3, name = "phyPortName", | ||
52 | + description = "Physical port name", | ||
53 | + required = true, multiValued = false) | ||
54 | + private String phyPortName = null; | ||
55 | + | ||
56 | + @Argument(index = 4, name = "localIp", | ||
57 | + description = "Local data plane IP address", | ||
58 | + required = true, multiValued = false) | ||
59 | + private String localIp = null; | ||
60 | + | ||
51 | @Override | 61 | @Override |
52 | protected void execute() { | 62 | protected void execute() { |
53 | checkArgument(ovsdb.contains(":"), "OVSDB address should be ip:port format"); | 63 | checkArgument(ovsdb.contains(":"), "OVSDB address should be ip:port format"); |
... | @@ -58,7 +68,9 @@ public class CordVtnNodeAddCommand extends AbstractShellCommand { | ... | @@ -58,7 +68,9 @@ public class CordVtnNodeAddCommand extends AbstractShellCommand { |
58 | CordVtnNode node = new CordVtnNode(hostname, | 68 | CordVtnNode node = new CordVtnNode(hostname, |
59 | IpAddress.valueOf(ipPort[0]), | 69 | IpAddress.valueOf(ipPort[0]), |
60 | TpPort.tpPort(Integer.parseInt(ipPort[1])), | 70 | TpPort.tpPort(Integer.parseInt(ipPort[1])), |
61 | - DeviceId.deviceId(bridgeId)); | 71 | + DeviceId.deviceId(bridgeId), |
72 | + phyPortName, | ||
73 | + IpAddress.valueOf(localIp)); | ||
62 | service.addNode(node); | 74 | service.addNode(node); |
63 | } | 75 | } |
64 | } | 76 | } | ... | ... |
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.CordVtnNode; | ||
23 | +import org.onosproject.cordvtn.CordVtnService; | ||
24 | + | ||
25 | +/** | ||
26 | + * Checks detailed node init state. | ||
27 | + */ | ||
28 | +@Command(scope = "onos", name = "cordvtn-node-check", | ||
29 | + description = "Shows detailed node init state") | ||
30 | +public class CordVtnNodeCheckCommand extends AbstractShellCommand { | ||
31 | + | ||
32 | + @Argument(index = 0, name = "hostname", description = "Hostname", | ||
33 | + required = true, multiValued = false) | ||
34 | + private String hostname = null; | ||
35 | + | ||
36 | + @Override | ||
37 | + protected void execute() { | ||
38 | + CordVtnService service = AbstractShellCommand.get(CordVtnService.class); | ||
39 | + CordVtnNode node = service.getNodes() | ||
40 | + .stream() | ||
41 | + .filter(n -> n.hostname().equals(hostname)) | ||
42 | + .findFirst() | ||
43 | + .orElse(null); | ||
44 | + | ||
45 | + if (node == null) { | ||
46 | + print("Cannot find %s from registered nodes", hostname); | ||
47 | + return; | ||
48 | + } | ||
49 | + | ||
50 | + print(service.checkNodeInitState(node)); | ||
51 | + } | ||
52 | +} |
... | @@ -44,10 +44,12 @@ public class CordVtnNodeListCommand extends AbstractShellCommand { | ... | @@ -44,10 +44,12 @@ public class CordVtnNodeListCommand extends AbstractShellCommand { |
44 | print("%s", json(service, nodes)); | 44 | print("%s", json(service, nodes)); |
45 | } else { | 45 | } else { |
46 | for (CordVtnNode node : nodes) { | 46 | for (CordVtnNode node : nodes) { |
47 | - print("hostname=%s, ovsdb=%s, br-int=%s, init=%s", | 47 | + print("hostname=%s, ovsdb=%s, br-int=%s, phyPort=%s, localIp=%s, init=%s", |
48 | node.hostname(), | 48 | node.hostname(), |
49 | node.ovsdbIp().toString() + ":" + node.ovsdbPort().toString(), | 49 | node.ovsdbIp().toString() + ":" + node.ovsdbPort().toString(), |
50 | node.intBrId().toString(), | 50 | node.intBrId().toString(), |
51 | + node.phyPortName(), | ||
52 | + node.localIp().toString(), | ||
51 | getState(service, node)); | 53 | getState(service, node)); |
52 | } | 54 | } |
53 | print("Total %s nodes", service.getNodeCount()); | 55 | print("Total %s nodes", service.getNodeCount()); |
... | @@ -63,6 +65,8 @@ public class CordVtnNodeListCommand extends AbstractShellCommand { | ... | @@ -63,6 +65,8 @@ public class CordVtnNodeListCommand extends AbstractShellCommand { |
63 | .put("hostname", node.hostname()) | 65 | .put("hostname", node.hostname()) |
64 | .put("ovsdb", ipPort) | 66 | .put("ovsdb", ipPort) |
65 | .put("brInt", node.intBrId().toString()) | 67 | .put("brInt", node.intBrId().toString()) |
68 | + .put("phyPort", node.phyPortName()) | ||
69 | + .put("localIp", node.localIp().toString()) | ||
66 | .put("init", getState(service, node))); | 70 | .put("init", getState(service, node))); |
67 | } | 71 | } |
68 | return result; | 72 | return result; | ... | ... |
... | @@ -28,5 +28,8 @@ | ... | @@ -28,5 +28,8 @@ |
28 | <command> | 28 | <command> |
29 | <action class="org.onosproject.cordvtn.cli.CordVtnNodeInitCommand"/> | 29 | <action class="org.onosproject.cordvtn.cli.CordVtnNodeInitCommand"/> |
30 | </command> | 30 | </command> |
31 | + <command> | ||
32 | + <action class="org.onosproject.cordvtn.cli.CordVtnNodeCheckCommand"/> | ||
33 | + </command> | ||
31 | </command-bundle> | 34 | </command-bundle> |
32 | </blueprint> | 35 | </blueprint> | ... | ... |
-
Please register or login to post a comment