Bug 9584 - Delete pod - Failed - there are storage volumes for this pod

Changes:
- For 'volumes' and 'vm_instance' table, query needed to filter out the records with non-null 'removed' values
This commit is contained in:
prachi 2011-05-05 11:05:10 -07:00
parent 39a73cf174
commit b66b3f1c45
1 changed files with 48 additions and 48 deletions

View File

@ -491,7 +491,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
if (tableName.equals("host") || tableName.equals("cluster")) {
if (tableName.equals("host") || tableName.equals("cluster") || tableName.equals("volumes") || tableName.equals("vm_instance")) {
selectSql += " and removed IS NULL";
}
@ -544,9 +544,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
// Don't allow gateway to overlap with start/endIp
if(!skipGatewayOverlapCheck){
if (NetUtils.ipRangesOverlap(startIp, endIp, gateway, gateway)) {
throw new InvalidParameterValueException("The gateway shouldn't overlap start/end ip addresses");
}
if (NetUtils.ipRangesOverlap(startIp, endIp, gateway, gateway)) {
throw new InvalidParameterValueException("The gateway shouldn't overlap start/end ip addresses");
}
}
String checkPodCIDRs = _configDao.getValue("check.pod.cidrs");
@ -1088,27 +1088,27 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
int stopVnetRange = 0;
Boolean isPublic = cmd.isPublic();
String allocationStateStr = cmd.getAllocationState();
String dhcpProvider = cmd.getDhcpProvider();
Map detailsMap = cmd.getDetails();
Map<String, String> newDetails = new HashMap<String, String>();
if (detailsMap != null) {
Collection zoneDetailsCollection = detailsMap.values();
Iterator iter = zoneDetailsCollection.iterator();
while (iter.hasNext()) {
HashMap detail = (HashMap)iter.next();
String key = (String)detail.get("key");
String value = (String)detail.get("value");
if ((key == null) || (value == null)) {
throw new InvalidParameterValueException("Invalid Zone Detail specified, fields 'key' and 'value' cannot be null, please specify details in the form: details[0].key=XXX&details[0].value=YYY");
}
//validate the zone detail keys are known keys
/*if(!ZoneConfig.doesKeyExist(key)){
String dhcpProvider = cmd.getDhcpProvider();
Map detailsMap = cmd.getDetails();
Map<String, String> newDetails = new HashMap<String, String>();
if (detailsMap != null) {
Collection zoneDetailsCollection = detailsMap.values();
Iterator iter = zoneDetailsCollection.iterator();
while (iter.hasNext()) {
HashMap detail = (HashMap)iter.next();
String key = (String)detail.get("key");
String value = (String)detail.get("value");
if ((key == null) || (value == null)) {
throw new InvalidParameterValueException("Invalid Zone Detail specified, fields 'key' and 'value' cannot be null, please specify details in the form: details[0].key=XXX&details[0].value=YYY");
}
//validate the zone detail keys are known keys
/*if(!ZoneConfig.doesKeyExist(key)){
throw new InvalidParameterValueException("Invalid Zone Detail parameter: "+ key);
}*/
newDetails.put(key, value);
}
}
newDetails.put(key, value);
}
}
if (userId == null) {
userId = Long.valueOf(User.UID_SYSTEM);
@ -1205,15 +1205,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr);// not
// allowing
// updating
// domain
// associated
// with
// a
// zone,
// once
// created
// allowing
// updating
// domain
// associated
// with
// a
// zone,
// once
// created
zone.setName(zoneName);
zone.setDns1(dns1);
@ -1231,24 +1231,24 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
zone.setDomainId(null);
zone.setDomain(null);
}
Map<String, String> updatedDetails = new HashMap<String, String>();
_zoneDao.loadDetails(zone);
if(zone.getDetails() != null){
updatedDetails.putAll(zone.getDetails());
}
updatedDetails.putAll(newDetails);
zone.setDetails(updatedDetails);
Map<String, String> updatedDetails = new HashMap<String, String>();
_zoneDao.loadDetails(zone);
if(zone.getDetails() != null){
updatedDetails.putAll(zone.getDetails());
}
updatedDetails.putAll(newDetails);
zone.setDetails(updatedDetails);
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
zone.setAllocationState(allocationState);
}
if(dhcpProvider != null){
zone.setDhcpProvider(dhcpProvider);
}
if(dhcpProvider != null){
zone.setDhcpProvider(dhcpProvider);
}
if (!_zoneDao.update(zoneId, zone)) {
throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
}
@ -1297,7 +1297,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr);
byte[] bytes = (zoneName + System.currentTimeMillis()).getBytes();
String zoneToken = UUID.nameUUIDFromBytes(bytes).toString();
Transaction txn = Transaction.currentTxn();
@ -1490,11 +1490,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
Boolean limitCpuUse = cmd.GetLimitCpuUse();
if (limitCpuUse == null) {
limitCpuUse = false;
limitCpuUse = false;
}
return createServiceOffering(userId, cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(), localStorageRequired, offerHA,
limitCpuUse, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag());
limitCpuUse, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag());
}
@Override
@ -2110,7 +2110,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId)) {
throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support."); // It can be Direct IP or
// Public IP.
// Public IP.
}
if (account != null) {