Skip to content
Permalink
Browse files

Merge pull request #29133 from ricardoasmarques/prevent-iscsi-target-…

…delete-with-sessions

mgr/dashboard: Prevent deletion of iSCSI IQNs with open sessions

Reviewed-by: Ricardo Dias <rdias@suse.com>
  • Loading branch information...
rjfd committed Jul 31, 2019
2 parents 8378361 + 0d2e150 commit a8840f6d97e751d3979cd2b64d4a71a1181e31df
@@ -207,6 +207,11 @@ def delete(self, target_iqn):
raise DashboardException(msg='Target does not exist',
code='target_does_not_exist',
component='iscsi')
target_info = IscsiClient.instance().get_targetinfo(target_iqn)
if target_info['num_sessions'] > 0:
raise DashboardException(msg='Target has active sessions',
code='target_has_active_sessions',
component='iscsi')
IscsiTarget._delete(target_iqn, config, 0, 100)

@iscsi_target_task('create', {'target_iqn': '{target_iqn}'})
@@ -1,6 +1,7 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';

import { I18n } from '@ngx-translate/i18n-polyfill';
import * as _ from 'lodash';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { Subscription } from 'rxjs';

@@ -83,7 +84,9 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy {
permission: 'delete',
icon: Icons.destroy,
click: () => this.deleteIscsiTargetModal(),
name: this.actionLabels.DELETE
name: this.actionLabels.DELETE,
disable: () => !this.selection.first() || !_.isUndefined(this.getDeleteDisableDesc()),
disableDesc: () => this.getDeleteDisableDesc()
}
];
}
@@ -145,6 +148,12 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy {
}
}

getDeleteDisableDesc(): string | undefined {
if (this.selection.first() && this.selection.first()['info']['num_sessions']) {
return this.i18n('Target has active sessions');
}
}

prepareResponse(resp: any): any[] {
resp.forEach((element) => {
element.cdPortals = element.portals.map((portal) => `${portal.host}:${portal.ip}`);

0 comments on commit a8840f6

Please sign in to comment.
You can’t perform that action at this time.