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}'})
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';
permission: 'delete',
icon: 'fa-times',
click: () => this.deleteIscsiTargetModal(),
- name: this.actionLabels.DELETE
+ name: this.actionLabels.DELETE,
+ disable: () => !this.selection.first() || !_.isUndefined(this.getDeleteDisableDesc()),
+ disableDesc: () => this.getDeleteDisableDesc()
}
];
}
}
}
+ 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}`);