]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #20197 from xiexingguo/wip-load-ws-from-ms
authorKefu Chai <tchaikov@gmail.com>
Fri, 2 Feb 2018 07:57:14 +0000 (15:57 +0800)
committerGitHub <noreply@github.com>
Fri, 2 Feb 2018 07:57:14 +0000 (15:57 +0800)
pybind/mgr/balancer: load weight-set from ms

Reviewed-by: Sage Weil <sage@redhat.com>
1  2 
src/pybind/mgr/balancer/module.py

index 3d48cbba69468d9326cc86200a76006c464c5c6f,3233688e8e863008ad554672e3fc5c2795926739..3b5d7f9379035dd35bac7b4997b6a4655b9030a9
@@@ -819,35 -800,37 +819,38 @@@ class Module(MgrModule)
          else:
              self.log.info('Failed to find further optimization, score %f',
                            pe.score)
 +            plan.compat_ws = {}
              return False
  
-     def get_compat_weight_set_weights(self):
-         # enable compat weight-set
-         self.log.debug('ceph osd crush weight-set create-compat')
-         result = CommandResult('')
-         self.send_command(result, 'mon', '', json.dumps({
-             'prefix': 'osd crush weight-set create-compat',
-             'format': 'json',
-         }), '')
-         r, outb, outs = result.wait()
-         if r != 0:
-             self.log.error('Error creating compat weight-set')
-             return
-         result = CommandResult('')
-         self.send_command(result, 'mon', '', json.dumps({
-             'prefix': 'osd crush dump',
-             'format': 'json',
-         }), '')
-         r, outb, outs = result.wait()
-         if r != 0:
-             self.log.error('Error dumping crush map')
-             return
-         try:
-             crushmap = json.loads(outb)
-         except:
-             raise RuntimeError('unable to parse crush map')
+     def get_compat_weight_set_weights(self, ms):
+         if '-1' not in ms.crush_dump.get('choose_args', {}):
+             # enable compat weight-set first
+             self.log.debug('ceph osd crush weight-set create-compat')
+             result = CommandResult('')
+             self.send_command(result, 'mon', '', json.dumps({
+                 'prefix': 'osd crush weight-set create-compat',
+                 'format': 'json',
+             }), '')
+             r, outb, outs = result.wait()
+             if r != 0:
+                 self.log.error('Error creating compat weight-set')
+                 return
+             result = CommandResult('')
+             self.send_command(result, 'mon', '', json.dumps({
+                 'prefix': 'osd crush dump',
+                 'format': 'json',
+             }), '')
+             r, outb, outs = result.wait()
+             if r != 0:
+                 self.log.error('Error dumping crush map')
+                 return
+             try:
+                 crushmap = json.loads(outb)
+             except:
+                 raise RuntimeError('unable to parse crush map')
+         else:
+             crushmap = ms.crush_dump
  
          raw = crushmap.get('choose_args',{}).get('-1', [])
          weight_set = {}