|
52 | 52 | import com.cloud.agent.api.DeleteStoragePoolCommand; |
53 | 53 | import com.cloud.agent.api.StoragePoolInfo; |
54 | 54 | import com.cloud.dc.ClusterDetailsDao; |
| 55 | +import com.cloud.dc.ClusterDetailsVO; |
55 | 56 | import com.cloud.dc.ClusterVO; |
56 | 57 | import com.cloud.dc.dao.ClusterDao; |
57 | 58 | import com.cloud.dc.dao.DataCenterDao; |
@@ -491,6 +492,8 @@ public boolean deleteDataStore(DataStore dataStore) { |
491 | 492 | _tmpltMgr.evictTemplateFromStoragePool(templatePoolVO); |
492 | 493 | } |
493 | 494 |
|
| 495 | + Long clusterId = null; |
| 496 | + |
494 | 497 | for (StoragePoolHostVO host : hostPoolRecords) { |
495 | 498 | DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(storagePool); |
496 | 499 |
|
@@ -523,18 +526,48 @@ public boolean deleteDataStore(DataStore dataStore) { |
523 | 526 | if (answer != null && answer.getResult()) { |
524 | 527 | s_logger.info("Successfully deleted storage pool using Host ID " + host.getHostId()); |
525 | 528 |
|
| 529 | + HostVO hostVO = this._hostDao.findById(host.getHostId()); |
| 530 | + |
| 531 | + if (hostVO != null) { |
| 532 | + clusterId = hostVO.getClusterId(); |
| 533 | + } |
| 534 | + |
526 | 535 | break; |
527 | 536 | } |
528 | 537 | else { |
529 | 538 | s_logger.error("Failed to delete storage pool using Host ID " + host.getHostId() + ": " + answer.getResult()); |
530 | 539 | } |
531 | 540 | } |
532 | 541 |
|
| 542 | + if (clusterId != null) { |
| 543 | + removeVolumeFromVag(storagePool.getId(), clusterId); |
| 544 | + } |
| 545 | + |
533 | 546 | deleteSolidFireVolume(storagePool.getId()); |
534 | 547 |
|
535 | 548 | return _primaryDataStoreHelper.deletePrimaryDataStore(dataStore); |
536 | 549 | } |
537 | 550 |
|
| 551 | + private void removeVolumeFromVag(long storagePoolId, long clusterId) { |
| 552 | + long sfVolumeId = getVolumeId(storagePoolId); |
| 553 | + ClusterDetailsVO clusterDetail = _clusterDetailsDao.findDetail(clusterId, SolidFireUtil.getVagKey(storagePoolId)); |
| 554 | + |
| 555 | + String vagId = clusterDetail != null ? clusterDetail.getValue() : null; |
| 556 | + |
| 557 | + if (vagId != null) { |
| 558 | + List<HostVO> hosts = _hostDao.findByClusterId(clusterId); |
| 559 | + |
| 560 | + SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao); |
| 561 | + |
| 562 | + SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId)); |
| 563 | + |
| 564 | + String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts)); |
| 565 | + long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, false); |
| 566 | + |
| 567 | + SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds); |
| 568 | + } |
| 569 | + } |
| 570 | + |
538 | 571 | private void deleteSolidFireVolume(long storagePoolId) { |
539 | 572 | SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao); |
540 | 573 |
|
|
0 commit comments