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)
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):
"""
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
#
@api.route('/api/v1/ceph', methods=['GET'])
@api.route('/api/v1/ceph/status', methods=['GET'])
@authenticator
def api_ceph():
def api_ceph_status():
"""
Get the current Ceph cluster 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'])
@authenticator
def api_ceph_osd():

View File

@ -1145,7 +1145,23 @@ def ceph_status():
zk_conn = pvc_common.startZKConnection(zk_host)
retcode, retdata = pvc_ceph.get_status(zk_conn)
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 = ''
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)
cli_ceph.add_command(ceph_status)
cli_ceph.add_command(ceph_radosdf)
cli_ceph.add_command(ceph_osd)
cli_ceph.add_command(ceph_pool)
cli_ceph.add_command(ceph_volume)

View File

@ -109,14 +109,27 @@ def get_status(zk_conn):
# Create a data structure for the information
status_data = {
'type': 'status',
'primary_node': primary_node,
'ceph_status': ceph_status
'ceph_data': ceph_status
}
return True, status_data
def format_status(status_data):
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']))
click.echo(status_data['ceph_status'])
def get_radosdf(zk_conn):
primary_node = zkhandler.readdata(zk_conn, '/primary_node')
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('')
#

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.
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`
* Methods: `GET`
* Mandatory values: N/A