+ public boolean isPortOnBridge (Node node, Bridge bridge, String portName) {
+ OVSDBConfigService ovsdbTable = (OVSDBConfigService) ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this);
+
+ for (UUID portsUUID : bridge.getPorts()) {
+ try {
+ Port port = (Port) ovsdbTable.getRow(node, Port.NAME.getName(), portsUUID.toString());
+ if ((port != null) && port.getName().equalsIgnoreCase(portName)) {
+ return true;
+ }
+ } catch (Exception e) {
+ logger.error("Error getting port {} for bridge domain {}/{}", portsUUID, node, bridge.getName(), e);
+ }
+ }
+
+ return false;
+ }
+
+ public boolean isNetworkPatchCreated (Node node, Bridge intBridge, Bridge netBridge) {
+ boolean isPatchCreated = false;
+
+ String portName = adminConfigManager.getPatchToNetwork();
+ if (isPortOnBridge(node, intBridge, portName)) {
+ portName = adminConfigManager.getPatchToIntegration();
+ if (isPortOnBridge(node, netBridge, portName)) {
+ isPatchCreated = true;
+ }
+ }
+
+ return isPatchCreated;
+ }
+
+ /* Determine if internal network is ready for tunnel network types.
+ * - OF 1.0 requires br-int, br-net and a patch connecting them.
+ * - OF 1.3 requires br-int.
+ */
+ public boolean isInternalNetworkTunnelReady (Node node) {
+ /* Is br-int created? */
+ Bridge intBridge = this.getInternalBridge(node, adminConfigManager.getIntegrationBridgeName());
+ if (intBridge == null) {
+ return false;
+ }
+
+ if (providerNetworkManager == null) {
+ logger.error("Provider Network Manager is not available");
+ return false;
+ }
+ if (providerNetworkManager.getProvider().hasPerTenantTunneling()) {
+ /* Is br-net created? */
+ Bridge netBridge = this.getInternalBridge(node, adminConfigManager.getNetworkBridgeName());
+ if (netBridge == null) {
+ return false;
+ }
+
+ if (!isNetworkPatchCreated(node, intBridge, netBridge)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /* Determine if internal network is ready for vlan network types.
+ * - OF 1.0 requires br-int, br-net, a patch connecting them and
+ * physical device added to br-net.
+ * - OF 1.3 requires br-int and physical device added to br-int.
+ */
+ public boolean isInternalNetworkVlanReady (Node node, NeutronNetwork network) {
+ /* is br-int created */
+ Bridge intBridge = this.getInternalBridge(node, adminConfigManager.getIntegrationBridgeName());
+ if (intBridge == null) {
+ logger.trace("shague isInternalNetworkVlanReady: node: {}, br-int missing", node);
+ return false;
+ }
+
+ if (providerNetworkManager == null) {
+ logger.error("Provider Network Manager is not available");
+ return false;
+ }
+ if (providerNetworkManager.getProvider().hasPerTenantTunneling()) {
+ /* is br-net created? */
+ Bridge netBridge = this.getInternalBridge(node, adminConfigManager.getNetworkBridgeName());
+
+ if (netBridge == null) {
+ logger.trace("shague isInternalNetworkVlanReady: node: {}, br-net missing", node);
+ return false;
+ }
+
+ if (!isNetworkPatchCreated(node, intBridge, netBridge)) {
+ logger.trace("shague isInternalNetworkVlanReady: node: {}, patch missing", node);
+ return false;
+ }
+
+ /* Check if physical device is added to br-net. */
+ String phyNetName = adminConfigManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork());
+ if (isPortOnBridge(node, netBridge, phyNetName)) {
+ return true;
+ }
+ } else {
+ /* Check if physical device is added to br-int. */
+ String phyNetName = adminConfigManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork());
+ if (isPortOnBridge(node, intBridge, phyNetName)) {
+ return true;
+ }
+ }
+
+ logger.trace("shague isInternalNetworkVlanReady: node: {}, eth missing", node);
+ return false;
+ }
+
+ /*
+ * Create the integration bridge.
+ *
+ Bridge br-int
+ Port br-int
+ Interface br-int
+ type: internal
+ */
+ public void createIntegrationBridge (Node node) throws Exception {
+ String brInt = adminConfigManager.getIntegrationBridgeName();
+
+ Status status = this.addInternalBridge(node, brInt, null, null);
+ if (!status.isSuccess()) {
+ logger.debug("Integration Bridge Creation Status: {}", status);
+ }
+ }
+