Support setting a CRUSH weight on new OSDs

This commit is contained in:
2018-11-01 23:03:27 -04:00
parent 2ea8a14ba4
commit 9fcce4b09a
4 changed files with 59 additions and 31 deletions

View File

@ -69,7 +69,7 @@ class CephOSDInstance(object):
if data and data != self.stats:
self.stats = json.loads(data)
def add_osd(zk_conn, logger, node, device):
def add_osd(zk_conn, logger, node, device, weight):
# We are ready to create a new OSD on this node
logger.out('Creating new OSD disk', state='i')
try:
@ -117,8 +117,9 @@ def add_osd(zk_conn, logger, node, device):
# 5. Add it to the crush map
retcode, stdout, stderr = common.run_os_command(
'ceph osd crush add osd.{osdid} 1.0 root=default host={node}'.format(
'ceph osd crush add osd.{osdid} {weight} root=default host={node}'.format(
osdid=osd_id,
weight=weight,
node=node
)
)

View File

@ -669,13 +669,13 @@ def cmd(data, stat, event=''):
# Adding a new OSD
if command == 'osd_add':
node, device = args.split(',')
node, device, weight = args.split(',')
if node == this_node.name:
# Lock the command queue
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
with lock:
# Add the OSD
result = CephInstance.add_osd(zk_conn, logger, node, device)
result = CephInstance.add_osd(zk_conn, logger, node, device, weight)
# Command succeeded
if result:
# Update the command queue
@ -967,6 +967,7 @@ def update_zookeeper():
'utilization': osd['utilization'],
'var': osd['var'],
'pgs': osd['pgs'],
'kb': osd['kb'],
}
})
# Parse the status data