final List<Exception> exceptions = new ArrayList<Exception>();
for (Pair<ManagedObjectReference, String> hostPair : lstHosts) {
HostMO host = new HostMO(context, hostPair.first());
HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();
boolean iScsiHbaConfigured = false;
for (HostHostBusAdapter hba : hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter()) {
if (hba instanceof HostInternetScsiHba) {
// just finding an instance of HostInternetScsiHba means that we have found at least one configured iSCSI HBA
// at least one iSCSI HBA must be configured before a CloudStack user can use this host for iSCSI storage
iScsiHbaConfigured = true;
final String iScsiHbaDevice = hba.getDevice();
final HostStorageSystemMO hss = hostStorageSystem;
executorService.submit(new Thread() {
@Override
public void run() {
try {
if (add) {
hss.addInternetScsiStaticTargets(iScsiHbaDevice, lstTargets);
}
else {
hss.removeInternetScsiStaticTargets(iScsiHbaDevice, lstTargets);
}
hss.rescanHba(iScsiHbaDevice);
hss.rescanVmfs();
}
catch (Exception ex) {
synchronized (exceptions) {
exceptions.add(ex);
}