From: Ricardo Marques Date: Fri, 18 Oct 2019 16:43:38 +0000 (+0100) Subject: mgr/dashboard: Set iSCSI disk WWN and LUN number from the UI X-Git-Tag: v14.2.5~131^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=910b84007d608c8c3917d064b4a709dda05cccad;p=ceph.git mgr/dashboard: Set iSCSI disk WWN and LUN number from the UI Fixes: https://tracker.ceph.com/issues/41749 Signed-off-by: Ricardo Marques (cherry picked from commit 970c1253c8a73ec31363d9d4cbe5fdf008fb61f5) Conflicts: src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html src/pybind/mgr/dashboard/frontend/src/styles.scss Conflicts caused by "Master" using Bootstrap 4, but "Nautilus" using Bootstap 3. --- diff --git a/src/pybind/mgr/dashboard/controllers/iscsi.py b/src/pybind/mgr/dashboard/controllers/iscsi.py index fd8633db43f85..ca0eebf7d990f 100644 --- a/src/pybind/mgr/dashboard/controllers/iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/iscsi.py @@ -321,10 +321,12 @@ class IscsiTarget(RESTController): IscsiClient.instance(gateway_name=gateway_name).delete_group(target_iqn, group_id) TaskManager.current_task().inc_progress(task_progress_inc) + deleted_clients = [] for client_iqn in list(target_config['clients'].keys()): if IscsiTarget._client_deletion_required(target, new_target_iqn, new_target_controls, new_clients, client_iqn, new_groups, deleted_groups): + deleted_clients.append(client_iqn) IscsiClient.instance(gateway_name=gateway_name).delete_client(target_iqn, client_iqn) TaskManager.current_task().inc_progress(task_progress_inc) @@ -332,6 +334,14 @@ class IscsiTarget(RESTController): if IscsiTarget._target_lun_deletion_required(target, new_target_iqn, new_target_controls, new_disks, image_id): + all_clients = target_config['clients'].keys() + not_deleted_clients = [c for c in all_clients if c not in deleted_clients] + for client_iqn in not_deleted_clients: + client_image_ids = target_config['clients'][client_iqn]['luns'].keys() + for client_image_id in client_image_ids: + if image_id == client_image_id: + IscsiClient.instance(gateway_name=gateway_name).delete_client_lun( + target_iqn, client_iqn, client_image_id) IscsiClient.instance(gateway_name=gateway_name).delete_target_lun(target_iqn, image_id) pool, image = image_id.split('/', 1) @@ -633,13 +643,17 @@ class IscsiTarget(RESTController): image = disk['image'] image_id = '{}/{}'.format(pool, image) backstore = disk['backstore'] + wwn = disk.get('wwn') + lun = disk.get('lun') if image_id not in config['disks']: IscsiClient.instance(gateway_name=gateway_name).create_disk(pool, image, - backstore) + backstore, + wwn) if not target_config or image_id not in target_config['disks']: IscsiClient.instance(gateway_name=gateway_name).create_target_lun(target_iqn, - image_id) + image_id, + lun) controls = disk['controls'] d_conf_controls = {} @@ -661,18 +675,20 @@ class IscsiTarget(RESTController): if not target_config or client_iqn not in target_config['clients']: IscsiClient.instance(gateway_name=gateway_name).create_client(target_iqn, client_iqn) - for lun in client['luns']: - pool = lun['pool'] - image = lun['image'] - image_id = '{}/{}'.format(pool, image) - IscsiClient.instance(gateway_name=gateway_name).create_client_lun( - target_iqn, client_iqn, image_id) user = client['auth']['user'] password = client['auth']['password'] m_user = client['auth']['mutual_user'] m_password = client['auth']['mutual_password'] IscsiClient.instance(gateway_name=gateway_name).create_client_auth( target_iqn, client_iqn, user, password, m_user, m_password) + for lun in client['luns']: + pool = lun['pool'] + image = lun['image'] + image_id = '{}/{}'.format(pool, image) + if not target_config or client_iqn not in target_config['clients'] or \ + image_id not in target_config['clients'][client_iqn]['luns']: + IscsiClient.instance(gateway_name=gateway_name).create_client_lun( + target_iqn, client_iqn, image_id) TaskManager.current_task().inc_progress(task_progress_inc) for group in groups: group_id = group['group_id'] diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html index 6944dda3c6f7a..0562efa32d700 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html @@ -125,6 +125,8 @@ type="text" [value]="image" disabled /> +
lun: {{ imagesSettings[image]['lun'] }}