def sync_meta(self, section, name): log.debug('syncing metadata type %s key "%s"', section, name) try: metadata = client.get_metadata(self.src_conn, section, name) except NotFound: log.debug('%s "%s" not found on master, deleting from secondary', section, name) try: client.delete_metadata(self.dest_conn, section, name) except NotFound: # Since this error is handled appropriately, return success return RESULT_SUCCESS except Exception as e: log.warn('error getting metadata for %s "%s": %s', section, name, e, exc_info=True) return RESULT_ERROR else: try: client.update_metadata(self.dest_conn, section, name, metadata) return RESULT_SUCCESS except Exception as e: log.warn('error updating metadata for %s "%s": %s', section, name, e, exc_info=True) return RESULT_ERROR
def sync_meta(self, section, name): log.debug('syncing metadata type %s key "%s"', section, name) try: metadata = client.get_metadata(self.source_conn, section, name) except client.HttpError as e: log.error('error getting metadata for %s "%s": %s', section, name, e) raise except client.NotFound: client.delete_metadata(self.dest_conn, section, name) else: client.update_metadata(self.dest_conn, section, name, metadata)
def sync_meta(self, section, name): log.debug('syncing metadata type %s key %r', section, name) try: metadata = client.get_metadata(self.source_conn, section, name) except client.NotFound: log.debug('%s %r not found on master, deleting from secondary', section, name) try: client.delete_metadata(self.dest_conn, section, name) except client.NotFound: pass except client.HttpError as e: log.error('error getting metadata for %s "%s": %s', section, name, e) raise else: client.update_metadata(self.dest_conn, section, name, metadata)
def sync_meta(self, section, name): log.debug('syncing metadata type %s key %r', section, name) try: metadata = client.get_metadata(self.source_conn, section, name) except client.NotFound: log.debug('%s %r not found on master, deleting from secondary', section, name) try: client.delete_metadata(self.dest_conn, section, name) except client.NotFound: # Since this error is handled appropriately, return success return RESULT_SUCCESS except client.HttpError as e: log.error('error getting metadata for %s "%s": %s', section, name, e) return RESULT_ERROR else: try: client.update_metadata(self.dest_conn, section, name, metadata) return RESULT_SUCCESS except client.HttpError as e: log.error('error getting metadata for %s "%s": %s', section, name, e) return RESULT_ERROR
def get_bucket_instance(self, bucket): metadata = client.get_metadata(self.src_conn, 'bucket', bucket) return bucket + ':' + metadata['data']['bucket']['bucket_id']
def test_get_metadata_no_re_encoding(self): self.register() client.get_metadata(self.connection, 'bucket.instance', 'mybar:r0z0.4140.1') server_request = httpretty.last_request() assert server_request.path == '/admin/metadata/bucket.instance?key=mybar%3Ar0z0.4140.1'
def test_get_metadata(self): self.register() client.get_metadata(self.connection, 'bucket.instance', 'foo') server_request = httpretty.last_request() assert server_request.path == '/admin/metadata/bucket.instance?key=foo'
def get_bucket_instance(self, bucket): metadata = client.get_metadata(self.src_conn, "bucket", bucket) return bucket + ":" + metadata["data"]["bucket"]["bucket_id"]