]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/pg_autoscaler: extract CrushSubtreeResourceStatus out
authorKefu Chai <kchai@redhat.com>
Mon, 28 Jun 2021 04:28:17 +0000 (12:28 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 30 Jun 2021 06:03:33 +0000 (14:03 +0800)
as it also serves as part of interface of get_subtree_resource_status(),
not only its internals. to ease adding the type annotations, this class
is promoted out of the class.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/pg_autoscaler/module.py

index 6c07377c2a3861867aba7f8529a1434ce8747480..c1cc1393aa70f7fdc0a4048a9bdf8c057eb3265b 100644 (file)
@@ -79,6 +79,23 @@ class PgAdjustmentProgress(object):
                       refs=[("pool", self.pool_id)])
 
 
+class CrushSubtreeResourceStatus:
+    def __init__(self):
+        self.root_ids = []
+        self.osds = set()
+        self.osd_count = None  # Number of OSDs
+        self.pg_target = None  # Ideal full-capacity PG count?
+        self.pg_current = 0  # How many PGs already?
+        self.pg_left = 0
+        self.capacity = None  # Total capacity of OSDs in subtree
+        self.pool_ids = []
+        self.pool_names = []
+        self.pool_count = None
+        self.pool_used = 0
+        self.total_target_ratio = 0.0
+        self.total_target_bytes = 0 # including replication / EC overhead
+
+
 class PgAutoscaler(MgrModule):
     """
     PG autoscaler.
@@ -248,22 +265,6 @@ class PgAutoscaler(MgrModule):
         pool_root = {}
         roots = []
 
-        class CrushSubtreeResourceStatus(object):
-            def __init__(self):
-                self.root_ids = []
-                self.osds = set()
-                self.osd_count = None  # Number of OSDs
-                self.pg_target = None  # Ideal full-capacity PG count?
-                self.pg_current = 0  # How many PGs already?
-                self.pg_left = 0
-                self.capacity = None  # Total capacity of OSDs in subtree
-                self.pool_ids = []
-                self.pool_names = []
-                self.pool_count = None
-                self.pool_used = 0
-                self.total_target_ratio = 0.0
-                self.total_target_bytes = 0 # including replication / EC overhead
-
         # identify subtrees (note that they may overlap!)
         for pool_id, pool in osdmap.get_pools().items():
             cr_name = crush.get_rule_by_id(pool['crush_rule'])['rule_name']