]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix dashboard python 3 support 21007/head
authorRicardo Dias <rdias@suse.com>
Thu, 22 Mar 2018 12:22:41 +0000 (12:22 +0000)
committerRicardo Dias <rdias@suse.com>
Thu, 22 Mar 2018 15:56:20 +0000 (15:56 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
qa/tasks/mgr/dashboard/helper.py
src/pybind/mgr/dashboard/.pylintrc
src/pybind/mgr/dashboard/controllers/cephfs.py
src/pybind/mgr/dashboard/controllers/osd.py
src/pybind/mgr/dashboard/controllers/perf_counters.py
src/pybind/mgr/dashboard/controllers/rbd.py
src/pybind/mgr/dashboard/tools.py

index 3e0c836e8b0585c3314a17ff4bac9a75182b56f7..ae4e9d1b851a9aa169c3ddea9caabb6759db4438 100644 (file)
@@ -78,7 +78,11 @@ class DashboardTestCase(MgrTestCase):
         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':
index ab5d1f8a7777f48d009b58e104731191ee859dd9..13e23167f608845bf55d04e9eda5739dad955cd7 100644 (file)
@@ -3,7 +3,7 @@
 # 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.
index c4786cebaf92fcf820849465fe9e50715a8dd40e..ea893560eb2c550c4d1c95bc020070365d139d6e 100644 (file)
@@ -192,7 +192,7 @@ class CephFS(BaseController):
 
         # 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
 
index e847b1fd891408a9298e59518516b3de4aaf0d27..f777f083457e5ec5c51e402186901f4bd31d699c 100644 (file)
@@ -58,7 +58,7 @@ class Osd(RESTController):
             # 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 = {}
index 59692d3309a16b014f2dd3c6b45b680ddd8c1479..5e6988af178dcdfaeb7f6ca3734261d5ee7e6f05 100644 (file)
@@ -22,8 +22,8 @@ class PerfCounter(RESTController):
         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()):
index b73697b0a16047ece45a496822a13a0dc4f9448a..8823bcc5cfaa5fc0511b7d30b8a56c7ed330b9d2 100644 (file)
@@ -77,6 +77,10 @@ class Rbd(RESTController):
             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])
index 8775a708730a26b83704101e523ab76d60910e81..e949b96122ed38f57df43cf7e61c18aecf089151 100644 (file)
@@ -124,6 +124,12 @@ class RequestLoggingTool(cherrypy.Tool):
     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)