Show radosdf output in clients

This commit is contained in:
Joshua Boniface 2019-07-08 10:56:33 -04:00
parent cda690e94f
commit 31b4dd9aed
5 changed files with 77 additions and 6 deletions

View File

@ -537,6 +537,20 @@ def ceph_status():
pvc_common.stopZKConnection(zk_conn) pvc_common.stopZKConnection(zk_conn)
return flask.jsonify(retdata), retcode return flask.jsonify(retdata), retcode
def ceph_radosdf():
"""
Get the current Ceph cluster utilization.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_ceph.get_radosdf(zk_conn)
if retflag:
retcode = 200
else:
retcode = 510
pvc_common.stopZKConnection(zk_conn)
return flask.jsonify(retdata), retcode
def ceph_osd_list(limit=None): def ceph_osd_list(limit=None):
""" """
Get the list of OSDs in the Ceph storage cluster. Get the list of OSDs in the Ceph storage cluster.

View File

@ -700,13 +700,22 @@ def api_net_acl_remove(network, acl):
# Ceph endpoints # Ceph endpoints
# #
@api.route('/api/v1/ceph', methods=['GET']) @api.route('/api/v1/ceph', methods=['GET'])
@api.route('/api/v1/ceph/status', methods=['GET'])
@authenticator @authenticator
def api_ceph(): def api_ceph_status():
""" """
Get the current Ceph cluster status. Get the current Ceph cluster status.
""" """
return pvcapi.ceph_status() return pvcapi.ceph_status()
@api.route('/api/v1/ceph/df', methods=['GET'])
@authenticator
def api_ceph_radosdf():
"""
Get the current Ceph cluster utilization.
"""
return pvcapi.ceph_radosdf()
@api.route('/api/v1/ceph/osd', methods=['GET']) @api.route('/api/v1/ceph/osd', methods=['GET'])
@authenticator @authenticator
def api_ceph_osd(): def api_ceph_osd():

View File

@ -1145,7 +1145,23 @@ def ceph_status():
zk_conn = pvc_common.startZKConnection(zk_host) zk_conn = pvc_common.startZKConnection(zk_host)
retcode, retdata = pvc_ceph.get_status(zk_conn) retcode, retdata = pvc_ceph.get_status(zk_conn)
if retcode: if retcode:
pvc_ceph.format_status(retdata) pvc_ceph.format_raw_output(retdata)
retdata = ''
cleanup(retcode, retdata, zk_conn)
###############################################################################
# pvc ceph df
###############################################################################
@click.command(name='df', short_help='Show storage cluster utilization.')
def ceph_radosdf():
"""
Show utilization of the storage cluster.
"""
zk_conn = pvc_common.startZKConnection(zk_host)
retcode, retdata = pvc_ceph.get_radosdf(zk_conn)
if retcode:
pvc_ceph.format_raw_output(retdata)
retdata = '' retdata = ''
cleanup(retcode, retdata, zk_conn) cleanup(retcode, retdata, zk_conn)
@ -1748,6 +1764,7 @@ ceph_volume_snapshot.add_command(ceph_volume_snapshot_remove)
ceph_volume_snapshot.add_command(ceph_volume_snapshot_list) ceph_volume_snapshot.add_command(ceph_volume_snapshot_list)
cli_ceph.add_command(ceph_status) cli_ceph.add_command(ceph_status)
cli_ceph.add_command(ceph_radosdf)
cli_ceph.add_command(ceph_osd) cli_ceph.add_command(ceph_osd)
cli_ceph.add_command(ceph_pool) cli_ceph.add_command(ceph_pool)
cli_ceph.add_command(ceph_volume) cli_ceph.add_command(ceph_volume)

View File

@ -109,14 +109,27 @@ def get_status(zk_conn):
# Create a data structure for the information # Create a data structure for the information
status_data = { status_data = {
'type': 'status',
'primary_node': primary_node, 'primary_node': primary_node,
'ceph_status': ceph_status 'ceph_data': ceph_status
} }
return True, status_data return True, status_data
def format_status(status_data): def get_radosdf(zk_conn):
click.echo('{bold}Ceph cluster status (primary node {end}{blue}{primary}{end}{bold}){end}\n'.format(bold=ansiprint.bold(), end=ansiprint.end(), blue=ansiprint.blue(), primary=status_data['primary_node'])) primary_node = zkhandler.readdata(zk_conn, '/primary_node')
click.echo(status_data['ceph_status']) ceph_df = zkhandler.readdata(zk_conn, '/ceph/radosdf').rstrip()
# Create a data structure for the information
status_data = {
'type': 'utilization',
'primary_node': primary_node,
'ceph_data': ceph_df
}
return True, status_data
def format_raw_output(status_data):
click.echo('{bold}Ceph cluster {stype} (primary node {end}{blue}{primary}{end}{bold}){end}\n'.format(bold=ansiprint.bold(), end=ansiprint.end(), blue=ansiprint.blue(), stype=status_data['type'], primary=status_data['primary_node']))
click.echo(status_data['ceph_data'])
click.echo('') click.echo('')
# #

View File

@ -422,6 +422,24 @@ These endpoints manage PVC Ceph storage cluster state and operation.
Return a JSON document containing information about the current Ceph cluster status. Return a JSON document containing information about the current Ceph cluster status.
The JSON element `ceph_data` contains the raw output of a `ceph status` command.
#### `/api/v1/ceph/status`
* Methods: `GET`
* Mandatory values: N/A
* Optional values: N/A
This endpoint is an alias for `/api/v1/ceph`.
#### `/api/v1/ceph/df`
* Methods: `GET`
* Mandatory values: N/A
* Optional values: N/A
Return a JSON document containing information about the current Ceph cluster utilization.
The JSON element `ceph_data` contains the raw output of a `rados df` command.
#### `/api/v1/ceph/osd` #### `/api/v1/ceph/osd`
* Methods: `GET` * Methods: `GET`
* Mandatory values: N/A * Mandatory values: N/A