فهرست منبع

Deprecate the detail() function

The detail() function fetches all progress update rows, which
leads to unjustified resource consumption.
Gabriel Adrian Samfira 4 سال پیش
والد
کامیت
766b62656c
2فایلهای تغییر یافته به همراه10 افزوده شده و 20 حذف شده
  1. 5 10
      coriolis/api/v1/migrations.py
  2. 5 10
      coriolis/api/v1/replicas.py

+ 5 - 10
coriolis/api/v1/migrations.py

@@ -30,7 +30,7 @@ class MigrationController(api_wsgi.Controller):
 
 
         return migration_view.single(req, migration)
         return migration_view.single(req, migration)
 
 
-    def index(self, req):
+    def _list(self, req):
         show_deleted = api_utils._get_show_deleted(
         show_deleted = api_utils._get_show_deleted(
             req.GET.get("show_deleted", None))
             req.GET.get("show_deleted", None))
         context = req.environ["coriolis.context"]
         context = req.environ["coriolis.context"]
@@ -40,16 +40,11 @@ class MigrationController(api_wsgi.Controller):
             req, self._migration_api.get_migrations(
             req, self._migration_api.get_migrations(
                 context, include_tasks=False))
                 context, include_tasks=False))
 
 
+    def index(self, req):
+        return self._list(req)
+
     def detail(self, req):
     def detail(self, req):
-        show_deleted = api_utils._get_show_deleted(
-            req.GET.get("show_deleted", None))
-        context = req.environ["coriolis.context"]
-        context.show_deleted = show_deleted
-        context.can(
-            migration_policies.get_migrations_policy_label("show_execution"))
-        return migration_view.collection(
-            req, self._migration_api.get_migrations(
-                context, include_tasks=True))
+        return self._list(req)
 
 
     @api_utils.format_keyerror_message(resource='migration', method='create')
     @api_utils.format_keyerror_message(resource='migration', method='create')
     def _validate_migration_input(self, context, body):
     def _validate_migration_input(self, context, body):

+ 5 - 10
coriolis/api/v1/replicas.py

@@ -31,7 +31,7 @@ class ReplicaController(api_wsgi.Controller):
 
 
         return replica_view.single(req, replica)
         return replica_view.single(req, replica)
 
 
-    def index(self, req):
+    def _list(self, req):
         show_deleted = api_utils._get_show_deleted(
         show_deleted = api_utils._get_show_deleted(
             req.GET.get("show_deleted", None))
             req.GET.get("show_deleted", None))
         context = req.environ["coriolis.context"]
         context = req.environ["coriolis.context"]
@@ -41,16 +41,11 @@ class ReplicaController(api_wsgi.Controller):
             req, self._replica_api.get_replicas(
             req, self._replica_api.get_replicas(
                 context, include_tasks_executions=False))
                 context, include_tasks_executions=False))
 
 
+    def index(self, req):
+        return self._list(req)
+
     def detail(self, req):
     def detail(self, req):
-        show_deleted = api_utils._get_show_deleted(
-            req.GET.get("show_deleted", None))
-        context = req.environ["coriolis.context"]
-        context.show_deleted = show_deleted
-        context.can(
-            replica_policies.get_replicas_policy_label("show_executions"))
-        return replica_view.collection(
-            req, self._replica_api.get_replicas(
-                context, include_tasks_executions=True))
+        return self._list(req)
 
 
     @api_utils.format_keyerror_message(resource='replica', method='create')
     @api_utils.format_keyerror_message(resource='replica', method='create')
     def _validate_create_body(self, context, body):
     def _validate_create_body(self, context, body):