From c988a44f068b2697df08bf8911fa1311fca104e7 Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Wed, 3 Apr 2019 08:56:27 +0100 Subject: [PATCH] mgr/dashboard: Display number of sessions on iSCSI overview page Signed-off-by: Ricardo Marques --- src/pybind/mgr/dashboard/controllers/iscsi.py | 11 +++++++++-- .../src/app/ceph/block/iscsi/iscsi.component.ts | 4 ++++ .../mgr/dashboard/frontend/src/locale/messages.xlf | 4 ++++ src/pybind/mgr/dashboard/services/iscsi_client.py | 5 +++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/iscsi.py b/src/pybind/mgr/dashboard/controllers/iscsi.py index 36a0823b757..f8b0e3063b5 100644 --- a/src/pybind/mgr/dashboard/controllers/iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/iscsi.py @@ -90,12 +90,19 @@ class IscsiUi(BaseController): for gateway_name in gateways_names: gateway = { 'name': gateway_name, - 'state': 'N/A', - 'num_targets': 'N/A' + 'state': '', + 'num_targets': 'n/a', + 'num_sessions': 'n/a' } try: IscsiClient.instance(gateway_name=gateway_name).ping() gateway['state'] = 'up' + if config: + gateway['num_sessions'] = 0 + if gateway_name in config['gateways']: + gatewayinfo = IscsiClient.instance( + gateway_name=gateway_name).get_gatewayinfo() + gateway['num_sessions'] = gatewayinfo['num_sessions'] except RequestException: gateway['state'] = 'down' if config: diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts index 27266f4339e..9b771dbb268 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts @@ -47,6 +47,10 @@ export class IscsiComponent implements OnInit { { name: this.i18n('# Targets'), prop: 'num_targets' + }, + { + name: this.i18n('# Sessions'), + prop: 'num_sessions' } ]; this.imagesColumns = [ diff --git a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf index e0040aeeeaf..8a1f6be6909 100644 --- a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf +++ b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf @@ -4246,6 +4246,10 @@ src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts 1 + + src/app/ceph/block/iscsi/iscsi.component.ts + 1 + State diff --git a/src/pybind/mgr/dashboard/services/iscsi_client.py b/src/pybind/mgr/dashboard/services/iscsi_client.py index 887b0ca0d68..58f02fdcc74 100644 --- a/src/pybind/mgr/dashboard/services/iscsi_client.py +++ b/src/pybind/mgr/dashboard/services/iscsi_client.py @@ -102,6 +102,11 @@ class IscsiClient(RestClient): 'skipchecks': 'true' }) + @RestClient.api_get('/api/gatewayinfo') + def get_gatewayinfo(self, request=None): + logger.debug("iSCSI: Getting gatewayinfo") + return request() + @RestClient.api_put('/api/disk/{pool}/{image}') def create_disk(self, pool, image, backstore, request=None): logger.debug("iSCSI: Creating disk: %s/%s", pool, image) -- 2.39.5