]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: clean up mgr stuff for flake8 11314/head
authorJohn Spray <john.spray@redhat.com>
Tue, 4 Oct 2016 13:49:16 +0000 (14:49 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 4 Oct 2016 13:49:16 +0000 (14:49 +0100)
Signed-off-by: John Spray <john.spray@redhat.com>
src/pybind/mgr/fsstatus/__init__.py
src/pybind/mgr/fsstatus/module.py
src/pybind/mgr/rest/__init__.py
src/pybind/mgr/rest/app/management/commands/api_docs.py
src/pybind/mgr/rest/app/serializers/v2.py
src/pybind/mgr/rest/app/views/exceptions.py [deleted file]
src/pybind/mgr/rest/app/views/rpc_view.py
src/pybind/mgr/rest/app/views/v2.py
src/pybind/mgr/rest/module.py

index bd1113bf1b249c376cea515a8fb6817991077895..79f5b86fd50451f25ab12f6ec9f4896948e32fdc 100644 (file)
@@ -1,2 +1,2 @@
 
-from module import *
+from module import *  # NOQA
index f9bc0d87109f33b2ec6b297e924d4f7363d1eac5..f137a5466b0b7f2229917dd4682c519ea24bb55a 100644 (file)
@@ -1,12 +1,9 @@
 
 """
-High level status display for CephFS
+High level status display commands
 """
-from collections import defaultdict
 
-import logging
-import logging.config
-import json
+from collections import defaultdict
 from prettytable import PrettyTable
 import prettytable
 
@@ -242,7 +239,6 @@ class Module(MgrModule):
         osdmap = self.get("osd_map")
 
         # Build dict of OSD ID to stats
-        #return 0, "", json.dumps(self.get("osd_stats"))
         osd_stats = dict([(o['osd'], o) for o in self.get("osd_stats")['osd_stats']])
 
         for osd in osdmap['osds']:
index 622a611b6099ce87400e779f4970d3346b25367a..e87777b46fe80d726c3fecaa870824a9ec857a73 100644 (file)
@@ -1,3 +1,3 @@
 
-from module import *
+from module import *  # NOQA
 
index 398732bb6795e02890a921e6a34297fb389163fe..6d36d9646c18ac105e084e6864b5085b79af9529 100644 (file)
@@ -33,7 +33,7 @@ class ceph_state:
 sys.modules["ceph_state"] = ceph_state
 
 # Needed to avoid weird import loops
-from rest.module import global_instance
+from rest.module import global_instance  # NOQA
 
 from rest.app.serializers.v2 import ValidatingSerializer
 
index dc9cf65f7e5d2da77b031e3b1313b45c58561ce9..d1fa7869ec71eb2de8b890b76fb867a22113c0fc 100644 (file)
@@ -6,7 +6,7 @@ from rest_framework import serializers
 import rest.app.serializers.fields as fields
 from rest.app.types import CRUSH_RULE_TYPE_REPLICATED, \
     CRUSH_RULE_TYPE_ERASURE, USER_REQUEST_COMPLETE, \
-    USER_REQUEST_SUBMITTED, OSD_FLAGS, severity_str, SEVERITIES
+    USER_REQUEST_SUBMITTED, OSD_FLAGS
 
 
 class ValidatingSerializer(serializers.Serializer):
diff --git a/src/pybind/mgr/rest/app/views/exceptions.py b/src/pybind/mgr/rest/app/views/exceptions.py
deleted file mode 100644 (file)
index 9279d2c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-
-"""
-Convenience classes for raising HTTP status codes as exceptions,
-in addition to rest_framework's builtin exception classes
-"""
-
-from rest_framework import status
-from rest_framework.exceptions import APIException
-
-
-class ServiceUnavailable(APIException):
-    status_code = status.HTTP_503_SERVICE_UNAVAILABLE
-    default_detail = "Service unavailable"
index 0bceef6a974e55619cd99da775d825e1aceb3bb6..82cd263f946d99cf0a040b6f4b1a6605dcd6f37f 100644 (file)
@@ -2,21 +2,18 @@
 
 """
 Helpers for writing django views and rest_framework ViewSets that get
-their data from cthulhu with zeroRPC
+their data from calls into the C++ side of ceph-mgr
 """
 
 
-from rest.app.manager.osd_request_factory import OsdRequestFactory
-from rest.app.manager.pool_request_factory import PoolRequestFactory
-
 from rest_framework import viewsets, status
 from rest_framework.views import APIView
 
 from rest_framework.response import Response
 
-from rest.app.types import OsdMap, SYNC_OBJECT_STR_TYPE, OSD, OSD_MAP, POOL, CLUSTER, CRUSH_RULE, ServiceId,\
-    NotFound, SERVER
-
+from rest.app.manager.osd_request_factory import OsdRequestFactory
+from rest.app.manager.pool_request_factory import PoolRequestFactory
+from rest.app.types import OsdMap, OSD, OSD_MAP, POOL, CRUSH_RULE, NotFound
 from rest.module import global_instance as rest_plugin
 
 from rest.logger import logger
@@ -203,7 +200,6 @@ class MgrClient(object):
         Create and submit UserRequest for an apply, create, update or delete.
         """
 
-        # nosleep during preparation phase (may touch ClusterMonitor/ServerMonitor state)
         request_factory = self.get_request_factory(obj_type)
         request = getattr(request_factory, method)(*args, **kwargs)
 
@@ -232,7 +228,7 @@ class IsRoleAllowed(BasePermission):
         return True
 
         # TODO: reinstate read vs. read/write limitations on API keys
-        has_permission = False
+        has_permission = False
         # if request.user.groups.filter(name='readonly').exists():
         #     has_permission = request.method in SAFE_METHODS
         #     view.headers['Allow'] = ', '.join(SAFE_METHODS)
@@ -243,6 +239,7 @@ class IsRoleAllowed(BasePermission):
         #
         # return has_permission
 
+
 class RPCView(APIView):
     serializer_class = None
     log = log
index 7c588efdbbf4076303c8070684080ce49f8d92bf..b69682c4490a5233642e816bdd608fd400a81072 100644 (file)
@@ -1,34 +1,26 @@
 from collections import defaultdict
-import json
-import logging
-import shlex
 from distutils.version import StrictVersion
 
 from django.http import Http404
 import rest_framework
-from rest_framework.exceptions import ParseError, APIException, PermissionDenied
+from rest_framework.exceptions import ParseError
 from rest_framework.response import Response
-from rest_framework.decorators import api_view
-from rest_framework import status
-from django.contrib.auth.decorators import login_required
 
+from rest_framework import status
 
 from rest.app.serializers.v2 import PoolSerializer, CrushRuleSetSerializer, \
     CrushRuleSerializer, ServerSerializer, RequestSerializer, OsdSerializer, \
     ConfigSettingSerializer, MonSerializer, OsdConfigSerializer
-from rest.app.views.exceptions import ServiceUnavailable
 from rest.app.views.rpc_view import RPCViewSet, DataObject
 from rest.app.types import CRUSH_RULE, POOL, OSD, USER_REQUEST_COMPLETE, \
-    USER_REQUEST_SUBMITTED, OSD_IMPLEMENTED_COMMANDS, MON, OSD_MAP, \
-    SYNC_OBJECT_TYPES, ServiceId, severity_from_str, SEVERITIES, \
-    OsdMap, Config, MonMap, MonStatus, SYNC_OBJECT_STR_TYPE
+    USER_REQUEST_SUBMITTED, OSD_IMPLEMENTED_COMMANDS, OSD_MAP, \
+    SYNC_OBJECT_TYPES, OsdMap, Config, MonMap, MonStatus, SYNC_OBJECT_STR_TYPE
 
 
 from rest.logger import logger
 log = logger()
 
 
-#class RequestViewSet(RPCViewSet, PaginatedMixin):
 class RequestViewSet(RPCViewSet):
     """
 Calamari server requests, tracking long-running operations on the Calamari server.  Some
@@ -398,10 +390,9 @@ Filtering is available on this resource:
         osd_metadata = self.client.get_sync_object(OsdMap, ['osd_metadata'])
 
         osd_id_to_hostname = dict(
-            [(int(osd_id), osd_meta["hostname"]) for osd_id, osd_meta in
+            [(int(oid), osd_meta["hostname"]) for oid, osd_meta in
              osd_metadata.items()])
 
-
         osd['server'] = osd_id_to_hostname.get(osd['osd'], None)
 
         pools = self.client.get_sync_object(OsdMap, ['osd_pools', int(osd_id)])
index e3d5ed36e7fe99a8a4d93841247b620249a3e12e..f72b7ce30e4bab445e588712349a6147db7fa79d 100644 (file)
@@ -144,7 +144,7 @@ class Module(MgrModule):
                         obj = obj[part]
                     else:
                         obj = getattr(obj, part)
-            except (AttributeError, KeyError) as e:
+            except (AttributeError, KeyError):
                 raise NotFound(object_type, path)
 
         return obj