From b7a312b56585b3895f2efac1bb56ce0730e495cb Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 18 Dec 2014 13:58:03 -0500 Subject: [PATCH] pep8/style changes to client.py Signed-off-by: Alfredo Deza --- radosgw_agent/client.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/radosgw_agent/client.py b/radosgw_agent/client.py index ac16276..f7343eb 100644 --- a/radosgw_agent/client.py +++ b/radosgw_agent/client.py @@ -156,22 +156,27 @@ def get_metadata(connection, section, name): return request(connection, 'get', 'admin/metadata/' + section, params=dict(key=name)) + def update_metadata(connection, section, name, metadata): if not isinstance(metadata, basestring): metadata = json.dumps(metadata) return request(connection, 'put', 'admin/metadata/' + section, params=dict(key=name), data=metadata) + def delete_metadata(connection, section, name): return request(connection, 'delete', 'admin/metadata/' + section, params=dict(key=name), expect_json=False) + def get_metadata_sections(connection): return request(connection, 'get', 'admin/metadata') + def list_metadata_keys(connection, section): return request(connection, 'get', 'admin/metadata/' + section) + def get_op_state(connection, client_id, op_id, bucket, obj): return request(connection, 'get', 'admin/opstate', params={ @@ -181,6 +186,7 @@ def get_op_state(connection, client_id, op_id, bucket, obj): } ) + def remove_op_state(connection, client_id, op_id, bucket, obj): return request(connection, 'delete', 'admin/opstate', params={ @@ -194,6 +200,7 @@ def remove_op_state(connection, client_id, op_id, bucket, obj): def get_bucket_list(connection): return list_metadata_keys(connection, 'bucket') + @boto_call def list_objects_in_bucket(connection, bucket_name): # use the boto library to do this @@ -201,11 +208,13 @@ def list_objects_in_bucket(connection, bucket_name): for key in bucket.list(): yield key.name + @boto_call def delete_object(connection, bucket_name, object_name): bucket = connection.get_bucket(bucket_name) bucket.delete_key(object_name) + def sync_object_intra_region(connection, bucket_name, object_name, src_zone, client_id, op_id): path = u'{bucket}/{object}'.format( @@ -223,6 +232,7 @@ def sync_object_intra_region(connection, bucket_name, object_name, src_zone, }, expect_json=False) + def lock_shard(connection, lock_type, shard_num, zone_id, timeout, locker_id): return request(connection, 'post', 'admin/log', params={ @@ -235,6 +245,7 @@ def lock_shard(connection, lock_type, shard_num, zone_id, timeout, locker_id): special_first_param='lock', expect_json=False) + def unlock_shard(connection, lock_type, shard_num, zone_id, locker_id): return request(connection, 'post', 'admin/log', params={ @@ -246,9 +257,11 @@ def unlock_shard(connection, lock_type, shard_num, zone_id, locker_id): special_first_param='unlock', expect_json=False) + def _id_name(type_): return 'bucket-instance' if type_ == 'bucket-index' else 'id' + def get_log(connection, log_type, marker, max_entries, id_): key = _id_name(log_type) return request(connection, 'get', 'admin/log', @@ -260,6 +273,7 @@ def get_log(connection, log_type, marker, max_entries, id_): }, ) + def get_log_info(connection, log_type, id_): key = _id_name(log_type) return request( @@ -271,10 +285,12 @@ def get_log_info(connection, log_type, id_): special_first_param='info', ) + def num_log_shards(connection, shard_type): out = request(connection, 'get', 'admin/log', dict(type=shard_type)) return out['num_objects'] + def set_worker_bound(connection, type_, marker, timestamp, daemon_id, id_, data=None): if data is None: @@ -294,6 +310,7 @@ def set_worker_bound(connection, type_, marker, timestamp, special_first_param='work_bound', ) + def del_worker_bound(connection, type_, daemon_id, id_): key = _id_name(type_) return request( @@ -307,6 +324,7 @@ def del_worker_bound(connection, type_, daemon_id, id_): expect_json=False, ) + def get_worker_bound(connection, type_, id_): key = _id_name(type_) out = request( @@ -324,6 +342,7 @@ def get_worker_bound(connection, type_, id_): retries = retries.union(names) return out['marker'], out['oldest_time'], retries + class Zone(object): def __init__(self, zone_info): self.name = zone_info['name'] @@ -338,6 +357,7 @@ class Zone(object): def __str__(self): return self.name + class Region(object): def __init__(self, region_info): self.name = region_info['key'] @@ -358,6 +378,7 @@ class Region(object): def __str__(self): return str(self.zones.keys()) + class RegionMap(object): def __init__(self, region_map): self.regions = {} @@ -382,14 +403,17 @@ class RegionMap(object): return region, zone raise ZoneNotFound('%s not found in region map' % endpoint) + def get_region_map(connection): region_map = request(connection, 'get', 'admin/config') return RegionMap(region_map) + def _validate_sync_dest(dest_region, dest_zone): if dest_region.is_master and dest_zone.is_master: raise InvalidZone('destination cannot be master zone of master region') + def _validate_sync_source(src_region, src_zone, dest_region, dest_zone, meta_only): if not src_zone.is_master: -- 2.47.3