log.info("request %s to %s", method, url)
if method == 'GET':
self._resp = self._session.get(url)
- return self._resp.json()
+ try:
+ return self._resp.json()
+ except ValueError as ex:
+ log.exception("Failed to decode response: %s", self._resp.text)
+ raise ex
elif method == 'POST':
self._resp = self._session.post(url, json=data)
elif method == 'DELETE':
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
-extension-pkg-whitelist=rados,rbd
+extension-pkg-whitelist=rados,rbd,math
# Add files or directories to the blacklist. They should be base names, not
# paths.
# Find the standby replays
# pylint: disable=unused-variable
- for gid_str, daemon_info in mdsmap['info'].iteritems():
+ for gid_str, daemon_info in mdsmap['info'].items():
if daemon_info['state'] != "up:standby-replay":
continue
# Gauge stats
for s in ['osd.numpg', 'osd.stat_bytes', 'osd.stat_bytes_used']:
o['stats'][s.split('.')[1]] = self.get_latest(osd_spec, s)
- return osds.values()
+ return list(osds.values())
def get_osd_map(self):
osds = {}
return 0
def get(self, service_id):
- schema = mgr.get_perf_schema(
- self._service_type, str(service_id)).values()[0]
+ schema_dict = mgr.get_perf_schema(self._service_type, str(service_id))
+ schema = schema_dict["{}.{}".format(self._service_type, service_id)]
counters = []
for key, value in sorted(schema.items()):
stat['features'] = features
stat['features_name'] = self._format_bitmask(features)
+ # the following keys are deprecated
+ del stat['parent_pool']
+ del stat['parent_name']
+
try:
parent_info = i.parent_info()
parent = "{}@{}".format(parent_info[0], parent_info[1])
def _format_bytes(self, num):
units = ['B', 'K', 'M', 'G']
+ if isinstance(num, str):
+ try:
+ num = int(num)
+ except ValueError:
+ return "n/a"
+
format_str = "{:.0f}{}"
for i, unit in enumerate(units):
div = 2**(10*i)