diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 39e59680..eab0ee40 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -938,6 +938,41 @@ def ceph_osd(): """ pass +############################################################################### +# pvc ceph osd add +############################################################################### +@click.command(name='add', short_help='Add new OSD.') +@click.argument( + 'node' +) +@click.argument( + 'device' +) +def ceph_osd_add(node, device): + """ + Add a new Ceph OSD on node NODE with block device DEVICE to the cluster. + """ + + zk_conn = pvc_common.startZKConnection(zk_host) + retcode, retmsg = pvc_ceph.add_osd(zk_conn, node, device) + cleanup(retcode, retmsg, zk_conn) + +############################################################################### +# pvc ceph osd remove +############################################################################### +@click.command(name='remove', short_help='Remove OSD.') +@click.argument( + 'osdid' +) +def ceph_osd_remove(node, device): + """ + Remove a Ceph OSD with ID OSDID from the cluster. + """ + + zk_conn = pvc_common.startZKConnection(zk_host) + retcode, retmsg = pvc_ceph.remove_osd(zk_conn, osdid) + cleanup(retcode, retmsg, zk_conn) + ############################################################################### # pvc ceph pool ############################################################################### @@ -1077,7 +1112,7 @@ net_acl.add_command(net_acl_add) net_acl.add_command(net_acl_remove) net_acl.add_command(net_acl_list) -#ceph_osd.add_command(ceph_osd_add) +ceph_osd.add_command(ceph_osd_add) #ceph_osd.add_command(ceph_osd_remove) #ceph_osd.add_command(ceph_osd_in) #ceph_osd.add_command(ceph_osd_out) diff --git a/client-common/ceph.py b/client-common/ceph.py index 9240c14f..93c589e6 100644 --- a/client-common/ceph.py +++ b/client-common/ceph.py @@ -53,3 +53,19 @@ def get_status(zk_conn): click.echo(status_data) click.echo('') return True, '' + +def add_osd(zk_conn, node, device): + if not common.verifyNode(zk_conn, node): + return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node) + + # Tell the cluster to create a new OSD for the host + new_osd_string = 'new {},{}'.format(node, device) + zkhandler.writedata(zk_conn, {'/ceph/osd_cmd': new_osd_string}) + click.echo('Created new OSD with block device {} on node {}.'.format(device, node)) + return True, '' + +def remove_osd(zk_conn, osd_id): + remove_osd_string = 'remove {}'.format(osd_id) + zkhandler.writedata(zk_conn, {'/ceph/osd_cmd': remove_osd_string}) + click.echo('Remove OSD {} from the cluster.'.format(osd_id)) + return True, ''