self.initial.osdmap.get_crush_version())
ls.append('# mode %s' % self.mode)
if len(self.compat_ws) and \
- '-1' not in self.initial.crush_dump.get('choose_args', {}):
+ not CRUSHMap.have_default_choose_args(self.initial.crush_dump):
ls.append('ceph osd crush weight-set create-compat')
for osd, weight in self.compat_ws.iteritems():
ls.append('ceph osd crush weight-set reweight-compat %s %f' %
return False
def get_compat_weight_set_weights(self, ms):
- if '-1' not in ms.crush_dump.get('choose_args', {}):
+ if not CRUSHMap.have_default_choose_args(ms.crush_dump):
# enable compat weight-set first
self.log.debug('ceph osd crush weight-set create-compat')
result = CommandResult('')
else:
crushmap = ms.crush_dump
- raw = crushmap.get('choose_args',{}).get('-1', [])
+ raw = CRUSHMap.get_default_choose_args(crushmap)
weight_set = {}
for b in raw:
bucket = None
# compat weight-set
if len(plan.compat_ws) and \
- '-1' not in plan.initial.crush_dump.get('choose_args', {}):
+ not CRUSHMap.have_default_choose_args(plan.initial.crush_dump):
self.log.debug('ceph osd crush weight-set create-compat')
result = CommandResult('')
self.send_command(result, 'mon', '', json.dumps({
class CRUSHMap(ceph_module.BasePyCRUSH):
ITEM_NONE = 0x7fffffff
+ DEFAULT_CHOOSE_ARGS = '-1'
def dump(self):
return self._dump()
uglymap = self._get_take_weight_osd_map(root)
return { int(k): v for k, v in uglymap.get('weights', {}).iteritems() }
+ @staticmethod
+ def have_default_choose_args(dump):
+ return CRUSHMap.DEFAULT_CHOOSE_ARGS in dump.get('choose_args', {})
+
+ @staticmethod
+ def get_default_choose_args(dump):
+ return dump.get('choose_args', {}).get(CRUSHMap.DEFAULT_CHOOSE_ARGS, [])
+
+
class MgrStandbyModule(ceph_module.BaseMgrStandbyModule):
"""
Standby modules only implement a serve and shutdown method, they