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.
This commit is contained in:
Vijayendra Bhamidipati 2012-05-24 13:58:44 -07:00
parent 7f26a43d48
commit daa190b4cb
3 changed files with 20 additions and 2 deletions

View File

@ -21,4 +21,5 @@ public interface ClusterVSMMapDao extends GenericDao<ClusterVSMMapVO, Long> {
ClusterVSMMapVO findByClusterId(long clusterId);
List<ClusterVSMMapVO> listByVSMId(long vsmId);
boolean removeByVsmId(long vsmId);
boolean removeByClusterId(long clusterId);
}

View File

@ -20,7 +20,6 @@ import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.db.Transaction;
@Local(value=ClusterVSMMapDao.class)
@ -50,6 +49,14 @@ public class ClusterVSMMapDaoImpl extends GenericDaoBase<ClusterVSMMapVO, Long>
return true;
}
@Override
public boolean removeByClusterId(long clusterId) {
SearchCriteria<ClusterVSMMapVO> sc = ClusterSearch.create();
sc.setParameters("clusterId", clusterId);
this.remove(sc);
return true;
}
@Override
public ClusterVSMMapVO findByClusterId(long clusterId) {
SearchCriteria<ClusterVSMMapVO> sc = ClusterSearch.create();

View File

@ -215,6 +215,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
protected VMTemplateDao _templateDao;
@Inject
protected ConfigurationManager _configMgr;
@Inject
protected ClusterVSMMapDao _clusterVSMMapDao;
protected long _nodeId = ManagementServerNode.getManagementServerId();
@ -919,7 +921,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
@DB
public boolean deleteCluster(DeleteClusterCmd cmd) {
Transaction txn = Transaction.currentTxn();
try {
try {
txn.start();
ClusterVO cluster = _clusterDao.lockRow(cmd.getId(), true);
if (cluster == null) {
@ -930,6 +932,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
throw new CloudRuntimeException("Cluster: " + cmd.getId() + " does not exist");
}
Hypervisor.HypervisorType hypervisorType = cluster.getHypervisorType();
List<HostVO> hosts = listAllHostsInCluster(cmd.getId());
if (hosts.size() > 0) {
if (s_logger.isDebugEnabled()) {
@ -951,6 +955,12 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
if (_clusterDao.remove(cmd.getId())){
_capacityDao.removeBy(null, null, null, cluster.getId(), null);
// If this cluster is of type vmware, and if the nexus vswitch global parameter setting is turned
// on, remove the row in cluster_vsm_map for this cluster id.
if (hypervisorType == HypervisorType.VMware &&
Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) {
_clusterVSMMapDao.removeByClusterId(cmd.getId());
}
}
txn.commit();