Hyunsun Moon
Committed by Gerrit Code Review

CORD-470 Added physical interface add state

Change-Id: Ia1a86422cdb046bde86fd314da4868ce3f9f4b3e
...@@ -200,6 +200,17 @@ public class CordVtnNodeManager { ...@@ -200,6 +200,17 @@ public class CordVtnNodeManager {
200 } 200 }
201 } 201 }
202 }, 202 },
203 + TUNNEL_INTERFACE_CREATED {
204 + @Override
205 + public void process(CordVtnNodeManager nodeManager, CordVtnNode node) {
206 + if (!nodeManager.getOvsdbConnectionState(node)) {
207 + nodeManager.connectOvsdb(node);
208 + } else {
209 + nodeManager.createPhyInterface(node);
210 + }
211 + }
212 +
213 + },
203 COMPLETE { 214 COMPLETE {
204 @Override 215 @Override
205 public void process(CordVtnNodeManager nodeManager, CordVtnNode node) { 216 public void process(CordVtnNodeManager nodeManager, CordVtnNode node) {
...@@ -422,13 +433,11 @@ public class CordVtnNodeManager { ...@@ -422,13 +433,11 @@ public class CordVtnNodeManager {
422 private NodeState checkNodeState(CordVtnNode node) { 433 private NodeState checkNodeState(CordVtnNode node) {
423 checkNotNull(node); 434 checkNotNull(node);
424 435
425 - if (checkIntegrationBridge(node) && checkTunnelInterface(node)) { 436 + if (checkIntegrationBridge(node) && checkTunnelInterface(node) &&
426 - // TODO add physical port add state 437 + checkPhyInterface(node)) {
427 - if (checkPhyInterface(node)) { 438 + return NodeState.COMPLETE;
428 - return NodeState.COMPLETE; 439 + } else if (checkTunnelInterface(node)) {
429 - } else { 440 + return NodeState.TUNNEL_INTERFACE_CREATED;
430 - return NodeState.INCOMPLETE;
431 - }
432 } else if (checkIntegrationBridge(node)) { 441 } else if (checkIntegrationBridge(node)) {
433 return NodeState.BRIDGE_CREATED; 442 return NodeState.BRIDGE_CREATED;
434 } else if (getOvsdbConnectionState(node)) { 443 } else if (getOvsdbConnectionState(node)) {
...@@ -569,7 +578,7 @@ public class CordVtnNodeManager { ...@@ -569,7 +578,7 @@ public class CordVtnNodeManager {
569 BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class); 578 BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
570 bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE), dpid, controllers); 579 bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE), dpid, controllers);
571 } catch (ItemNotFoundException e) { 580 } catch (ItemNotFoundException e) {
572 - log.warn("Failed to create integration bridge on {}", node.ovsdbId()); 581 + log.warn("Failed to create integration bridge on {}", node.hostname());
573 } 582 }
574 } 583 }
575 584
...@@ -597,7 +606,26 @@ public class CordVtnNodeManager { ...@@ -597,7 +606,26 @@ public class CordVtnNodeManager {
597 TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class); 606 TunnelConfig tunnelConfig = handler.behaviour(TunnelConfig.class);
598 tunnelConfig.createTunnelInterface(BridgeName.bridgeName(DEFAULT_BRIDGE), description); 607 tunnelConfig.createTunnelInterface(BridgeName.bridgeName(DEFAULT_BRIDGE), description);
599 } catch (ItemNotFoundException e) { 608 } catch (ItemNotFoundException e) {
600 - log.warn("Failed to create tunnel interface on {}", node.ovsdbId()); 609 + log.warn("Failed to create tunnel interface on {}", node.hostname());
610 + }
611 + }
612 +
613 + /**
614 + * Creates physical interface to a given node.
615 + *
616 + * @param node cordvtn node
617 + */
618 + private void createPhyInterface(CordVtnNode node) {
619 + if (checkPhyInterface(node)) {
620 + return;
621 + }
622 +
623 + try {
624 + DriverHandler handler = driverService.createHandler(node.ovsdbId());
625 + BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
626 + bridgeConfig.addPort(BridgeName.bridgeName(DEFAULT_BRIDGE), node.phyPortName());
627 + } catch (ItemNotFoundException e) {
628 + log.warn("Failed to add {} on {}", node.phyPortName(), node.hostname());
601 } 629 }
602 } 630 }
603 631
......