Fixes bridge checking on jumphost for bm 33/40333/1
authorTim Rozet <trozet@redhat.com>
Sun, 27 Aug 2017 23:37:43 +0000 (19:37 -0400)
committerTim Rozet <trozet@redhat.com>
Sun, 27 Aug 2017 23:37:43 +0000 (19:37 -0400)
Change-Id: I5e90dd84383c7348d2cbe58a18370ca10d915598
Signed-off-by: Tim Rozet <trozet@redhat.com>
apex/network/jumphost.py

index 1afcea7..f3f06ad 100644 (file)
@@ -87,6 +87,17 @@ def attach_interface_to_ovs(bridge, interface, network):
         bridge, interface, network
     ))
 
+    try:
+        output = subprocess.check_output(['ovs-vsctl', 'show'],
+                                         stderr=subprocess.STDOUT)
+        if bridge not in output.decode('utf-8'):
+            logging.debug("Bridge {} not found. Creating...".format(bridge))
+            subprocess.check_call(['ovs-vsctl', 'add-br', bridge])
+        else:
+            logging.debug("Bridge {} found".format(bridge))
+    except subprocess.CalledProcessError:
+        logging.error("Unable to validate/create OVS bridge {}".format(bridge))
+        raise
     try:
         output = subprocess.check_output(['ovs-vsctl', 'list-ports', bridge],
                                          stderr=subprocess.STDOUT)