Skip to content

Commit daa190b

Browse files
author
Vijayendra Bhamidipati
committed
CS-9919: Support for Nexus Swiches (Cisco Vswitches)
Description: Deleting the row in cluster_vsm_map after a cluster is deleted, if the cluster type is vmware and the global vswitch nexus config flag is set to true.
1 parent 7f26a43 commit daa190b

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

server/src/com/cloud/dc/dao/ClusterVSMMapDao.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ public interface ClusterVSMMapDao extends GenericDao<ClusterVSMMapVO, Long> {
2121
ClusterVSMMapVO findByClusterId(long clusterId);
2222
List<ClusterVSMMapVO> listByVSMId(long vsmId);
2323
boolean removeByVsmId(long vsmId);
24+
boolean removeByClusterId(long clusterId);
2425
}

server/src/com/cloud/dc/dao/ClusterVSMMapDaoImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.cloud.utils.db.GenericDaoBase;
2121
import com.cloud.utils.db.SearchBuilder;
2222
import com.cloud.utils.db.SearchCriteria;
23-
import com.cloud.utils.db.SearchCriteria.Op;
2423
import com.cloud.utils.db.Transaction;
2524

2625
@Local(value=ClusterVSMMapDao.class)
@@ -50,6 +49,14 @@ public boolean removeByVsmId(long vsmId) {
5049
return true;
5150
}
5251

52+
@Override
53+
public boolean removeByClusterId(long clusterId) {
54+
SearchCriteria<ClusterVSMMapVO> sc = ClusterSearch.create();
55+
sc.setParameters("clusterId", clusterId);
56+
this.remove(sc);
57+
return true;
58+
}
59+
5360
@Override
5461
public ClusterVSMMapVO findByClusterId(long clusterId) {
5562
SearchCriteria<ClusterVSMMapVO> sc = ClusterSearch.create();

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
215215
protected VMTemplateDao _templateDao;
216216
@Inject
217217
protected ConfigurationManager _configMgr;
218+
@Inject
219+
protected ClusterVSMMapDao _clusterVSMMapDao;
218220

219221
protected long _nodeId = ManagementServerNode.getManagementServerId();
220222

@@ -919,7 +921,7 @@ public boolean deleteHost(long hostId, boolean isForced, boolean isForceDeleteSt
919921
@DB
920922
public boolean deleteCluster(DeleteClusterCmd cmd) {
921923
Transaction txn = Transaction.currentTxn();
922-
try {
924+
try {
923925
txn.start();
924926
ClusterVO cluster = _clusterDao.lockRow(cmd.getId(), true);
925927
if (cluster == null) {
@@ -930,6 +932,8 @@ public boolean deleteCluster(DeleteClusterCmd cmd) {
930932
throw new CloudRuntimeException("Cluster: " + cmd.getId() + " does not exist");
931933
}
932934

935+
Hypervisor.HypervisorType hypervisorType = cluster.getHypervisorType();
936+
933937
List<HostVO> hosts = listAllHostsInCluster(cmd.getId());
934938
if (hosts.size() > 0) {
935939
if (s_logger.isDebugEnabled()) {
@@ -951,6 +955,12 @@ public boolean deleteCluster(DeleteClusterCmd cmd) {
951955

952956
if (_clusterDao.remove(cmd.getId())){
953957
_capacityDao.removeBy(null, null, null, cluster.getId(), null);
958+
// If this cluster is of type vmware, and if the nexus vswitch global parameter setting is turned
959+
// on, remove the row in cluster_vsm_map for this cluster id.
960+
if (hypervisorType == HypervisorType.VMware &&
961+
Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) {
962+
_clusterVSMMapDao.removeByClusterId(cmd.getId());
963+
}
954964
}
955965

956966
txn.commit();

0 commit comments

Comments
 (0)