]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Improve detection of config errors in nvp.ini file
authorarmando-migliaccio <amigliaccio@nicira.com>
Tue, 11 Jun 2013 19:47:48 +0000 (12:47 -0700)
committerarmando-migliaccio <amigliaccio@nicira.com>
Tue, 11 Jun 2013 19:48:57 +0000 (12:48 -0700)
Detect if default params specified in the config file match
what it is returned by NVP.

Fixes bug #1190032

Change-Id: I8084dc938726e050ba82410cbc02a161cc0aa17f

quantum/plugins/nicira/check_nvp_config.py

index 1d1c6e28e076ecae8b97ce72c7396cabc26a384e..9a74ce298da22045e0857f8c11c0e1705f0f2733 100644 (file)
@@ -86,10 +86,30 @@ def main(argv):
         print "\tController endpoint: %s" % controller
         nvplib.check_cluster_connectivity(cluster)
         gateway_services = get_gateway_services(cluster)
-        for svc_type in ["L2GatewayServiceConfig",
-                         "L3GatewayServiceConfig"]:
+        default_gateways = {
+            "L2GatewayServiceConfig": cfg.CONF.default_l2_gw_service_uuid,
+            "L3GatewayServiceConfig": cfg.CONF.default_l3_gw_service_uuid}
+        errors = 0
+        for svc_type in default_gateways.keys():
             for uuid in gateway_services[svc_type]:
                 print "\t\tGateway(%s) uuid: %s" % (svc_type, uuid)
+            if (default_gateways[svc_type] and
+                default_gateways[svc_type] not in gateway_services):
+                print ("\t\t\tError: specified default %s gateway (%s) is "
+                       "missing from NVP Gateway Services!" % (svc_type,
+                       default_gateways[svc_type]))
+                errors += 1
         transport_zones = get_transport_zones(cluster)
         print "\tTransport zones: %s" % transport_zones
-    print "Done."
+        if cfg.CONF.default_tz_uuid not in transport_zones:
+            print ("\t\tError: specified default transport zone "
+                   "(%s) is missing from NVP transport zones!"
+                   % cfg.CONF.default_tz_uuid)
+            errors += 1
+
+    if errors:
+        print ("\nThere are %d errors with your configuration. "
+               " Please, revise!" % errors)
+        sys.exit(1)
+    else:
+        print "Done."