From fae12edde31017a609b0e8c5943e61c26d3fcf40 Mon Sep 17 00:00:00 2001 From: James McClune Date: Wed, 30 Jan 2019 16:01:22 -0500 Subject: [PATCH] mgr/restful: updated string formatting to str.format() Made changes per @tchaikov's request Signed-off-by: James McClune --- src/pybind/mgr/restful/api/config.py | 2 +- src/pybind/mgr/restful/api/mon.py | 2 +- src/pybind/mgr/restful/api/osd.py | 8 ++++---- src/pybind/mgr/restful/api/pool.py | 10 +++++----- src/pybind/mgr/restful/api/request.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pybind/mgr/restful/api/config.py b/src/pybind/mgr/restful/api/config.py index f19634da5c071..565896c879e6d 100644 --- a/src/pybind/mgr/restful/api/config.py +++ b/src/pybind/mgr/restful/api/config.py @@ -33,7 +33,7 @@ class ConfigOsd(RestController): valid_flags = set(args.keys()) & set(common.OSD_FLAGS) invalid_flags = list(set(args.keys()) - valid_flags) if invalid_flags: - context.instance.log.warn("%s not valid to set/unset" % invalid_flags) + context.instance.log.warn("%s not valid to set/unset", invalid_flags) for flag in list(valid_flags): if args[flag]: diff --git a/src/pybind/mgr/restful/api/mon.py b/src/pybind/mgr/restful/api/mon.py index 807d6df3bf790..341f7037769e8 100644 --- a/src/pybind/mgr/restful/api/mon.py +++ b/src/pybind/mgr/restful/api/mon.py @@ -23,7 +23,7 @@ class MonName(RestController): if len(mon) != 1: response.status = 500 - return {'message': 'Failed to identify the monitor node "%s"' % self.name} + return {'message': 'Failed to identify the monitor node "{}"'.format(self.name)} return mon[0] diff --git a/src/pybind/mgr/restful/api/osd.py b/src/pybind/mgr/restful/api/osd.py index 99f9ed4c8e72e..8577fae98eb40 100644 --- a/src/pybind/mgr/restful/api/osd.py +++ b/src/pybind/mgr/restful/api/osd.py @@ -20,7 +20,7 @@ class OsdIdCommand(RestController): if not osd: response.status = 500 - return {'message': 'Failed to identify the OSD id "%d"' % self.osd_id} + return {'message': 'Failed to identify the OSD id "{}"'.format(self.osd_id)} if osd['up']: return common.OSD_IMPLEMENTED_COMMANDS @@ -40,11 +40,11 @@ class OsdIdCommand(RestController): if not osd: response.status = 500 - return {'message': 'Failed to identify the OSD id "%d"' % self.osd_id} + return {'message': 'Failed to identify the OSD id "{}"'.format(self.osd_id)} if not osd['up'] or command not in common.OSD_IMPLEMENTED_COMMANDS: response.status = 500 - return {'message': 'Command "%s" not available' % command} + return {'message': 'Command "{}" not available'.format(command)} return context.instance.submit_request([[{ 'prefix': 'osd ' + command, @@ -68,7 +68,7 @@ class OsdId(RestController): osd = context.instance.get_osds(ids=[str(self.osd_id)]) if len(osd) != 1: response.status = 500 - return {'message': 'Failed to identify the OSD id "%d"' % self.osd_id} + return {'message': 'Failed to identify the OSD id "{}"'.format(self.osd_id)} return osd[0] diff --git a/src/pybind/mgr/restful/api/pool.py b/src/pybind/mgr/restful/api/pool.py index b7a771810d573..40de54eb95779 100644 --- a/src/pybind/mgr/restful/api/pool.py +++ b/src/pybind/mgr/restful/api/pool.py @@ -20,7 +20,7 @@ class PoolId(RestController): if not pool: response.status = 500 - return {'message': 'Failed to identify the pool id "%d"' % self.pool_id} + return {'message': 'Failed to identify the pool id "{}"'.format(self.pool_id)} # pgp_num is called pg_placement_num, deal with that if 'pg_placement_num' in pool: @@ -44,13 +44,13 @@ class PoolId(RestController): pool = context.instance.get_pool_by_id(self.pool_id) if not pool: response.status = 500 - return {'message': 'Failed to identify the pool id "%d"' % self.pool_id} + return {'message': 'Failed to identify the pool id "{}"'.format(self.pool_id)} # Check for invalid pool args invalid = common.invalid_pool_args(args) if invalid: response.status = 500 - return {'message': 'Invalid arguments found: "%s"' % str(invalid)} + return {'message': 'Invalid arguments found: "{}"'.format(invalid)} # Schedule the update request return context.instance.submit_request(common.pool_update_commands(pool['pool_name'], args), **kwargs) @@ -66,7 +66,7 @@ class PoolId(RestController): if not pool: response.status = 500 - return {'message': 'Failed to identify the pool id "%d"' % self.pool_id} + return {'message': 'Failed to identify the pool id "{}"'.format(self.pool_id)} return context.instance.submit_request([[{ 'prefix': 'osd pool delete', @@ -125,7 +125,7 @@ class Pool(RestController): invalid = common.invalid_pool_args(args) if invalid: response.status = 500 - return {'message': 'Invalid arguments found: "%s"' % str(invalid)} + return {'message': 'Invalid arguments found: "{}"'.format(invalid)} # Schedule the creation and update requests return context.instance.submit_request( diff --git a/src/pybind/mgr/restful/api/request.py b/src/pybind/mgr/restful/api/request.py index 82c7fe16a75da..486c6303f5261 100644 --- a/src/pybind/mgr/restful/api/request.py +++ b/src/pybind/mgr/restful/api/request.py @@ -23,7 +23,7 @@ class RequestId(RestController): if len(request) != 1: response.status = 500 - return {'message': 'Unknown request id "%s"' % str(self.request_id)} + return {'message': 'Unknown request id "{}"'.format(self.request_id)} request = request[0] return request -- 2.39.5