]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
VMware NSX: add sanity checks for NSX cluster backend
authorarmando-migliaccio <armamig@gmail.com>
Thu, 9 Jan 2014 13:53:09 +0000 (05:53 -0800)
committerarmando-migliaccio <armamig@gmail.com>
Wed, 15 Jan 2014 15:32:50 +0000 (07:32 -0800)
Ensure that all transport nodes registered are up
and running. A failure here, may prevent a lot of
failures down the lines.

Change-Id: I3473928e296ec6792f34bc27a4ae797fed337e7c
Closes-bug: #1267468

neutron/plugins/nicira/check_nsx_config.py

index 31bb0a992cb853d3fdecea62886db827224896ca..9da30a9fa927e91baa793aa6896ac3d135d98602 100644 (file)
@@ -68,6 +68,23 @@ def get_transport_zones(cluster):
     return [transport_zone['uuid'] for transport_zone in transport_zones]
 
 
+def get_transport_nodes(cluster):
+    transport_nodes = config_helper("transport-node", cluster)
+    return [transport_node['uuid'] for transport_node in transport_nodes]
+
+
+def is_transport_node_connected(cluster, node_uuid):
+    try:
+        return nvplib.do_request('GET',
+                                 "/ws.v1/transport-node/%s/status" % node_uuid,
+                                 cluster=cluster)['connection']['connected']
+    except Exception as e:
+        msg = (_("Error '%(err)s' when connecting to controller(s): %(ctl)s.")
+               % {'err': str(e),
+                  'ctl': ', '.join(get_nsx_controllers(cluster))})
+        raise Exception(msg)
+
+
 def main():
     if len(sys.argv) != 2:
         help(sys.argv[0])
@@ -125,10 +142,22 @@ def main():
                   "(%s) is missing from NSX transport zones!"
                   % cfg.CONF.default_tz_uuid)
             errors += 1
-
-    if errors:
+        transport_nodes = get_transport_nodes(cluster)
+        print("\tTransport nodes: %s" % transport_nodes)
+        node_errors = []
+        for node in transport_nodes:
+            if not is_transport_node_connected(cluster, node):
+                node_errors.append(node)
+
+    # Use different exit codes, so that we can distinguish
+    # between config and runtime errors
+    if len(node_errors):
+        print("\nThere are one or mode transport nodes that are "
+              "not connected: %s. Please, revise!" % node_errors)
+        sys.exit(10)
+    elif errors:
         print("\nThere are %d errors with your configuration. "
-              " Please, revise!" % errors)
-        sys.exit(1)
+              "Please, revise!" % errors)
+        sys.exit(12)
     else:
         print("Done.")