]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
rgw.py: adding a safety check
authorJoe Buck <jbbuck@gmail.com>
Fri, 2 Aug 2013 03:54:38 +0000 (20:54 -0700)
committerJoe Buck <jbbuck@gmail.com>
Fri, 2 Aug 2013 04:05:15 +0000 (21:05 -0700)
Correcting a bug where specifying
a rgw server for a client but not specifying
a system user would throw an exception.

Signed-off-by: Joe Buck <jbbuck@gmail.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
teuthology/task/rgw.py

index 8501d5a22562fbd70ee1e693c2f698e825e8bafb..f48d860db969fa3eff7c634da36e9ab0d9f947e5 100644 (file)
@@ -248,6 +248,10 @@ def start_apache(ctx, config):
         run.wait(apaches.itervalues())
 
 def extract_user_info(client_config):
+    # test if there isn't a system user or if there isn't a name for that user, return None
+    if 'system user' not in client_config or 'name' not in client_config['system user']:
+        return None
+
     user_info = dict()
     user_info['system_key'] = dict(
         user=client_config['system user']['name'],
@@ -381,7 +385,11 @@ def configure_regions_and_zones(ctx, config, regions, role_endpoints):
 
     # extract the user info and append it to the payload tuple for the given client
     for client, c_config in config.iteritems():
-        user_info = extract_user_info(c_config)
+        if not c_config:
+            user_info = None
+        else:
+            user_info = extract_user_info(c_config)
+
         (region, zone, zone_info) = role_zones[client]
         role_zones[client] = (region, zone, zone_info, user_info)
 
@@ -404,9 +412,16 @@ def configure_regions_and_zones(ctx, config, regions, role_endpoints):
                               '--rgw-region', region],
                          check_status=True)
         for role, (_, zone, zone_info, user_info) in role_zones.iteritems():
+
+            # add the user_info (if it exists) to the zone_info 
+            if user_info:
+                new_dict = dict(zone_info.items() + user_info.items())
+            else:
+                new_dict = zone_info
+
             rgwadmin(ctx, client,
                      cmd=['-n', client, 'zone', 'set', '--rgw-zone', zone],
-                     stdin=StringIO(json.dumps(dict(zone_info.items() + user_info.items()))),
+                     stdin=StringIO(json.dumps(new_dict)),
                      check_status=True)
 
     first_mon = teuthology.get_first_mon(ctx, config)