Bug 6873: disable/enable mode for clusters (and pods and zones and hosts)

Fixed problems in setting default 'allocation_state'. It is now set to 'Enabled' by default if not provided in the API command.
This commit is contained in:
prachi 2011-03-24 12:53:44 -07:00
parent 978a9c7df4
commit 514321cadf
6 changed files with 20 additions and 9 deletions

View File

@ -383,7 +383,8 @@ public class HostVO implements Host {
this(id, name, type, privateIpAddress, privateNetmask, privateMacAddress, publicIpAddress, publicNetmask, publicMacAddress, storageIpAddress, storageNetmask, storageMacAddress, guid, status, version, iqn, disconnectedOn, dcId, podId, serverId, ping, null, null, null, 0, null);
this.parent = parent;
this.totalSize = totalSize;
this.fsType = fsType;
this.fsType = fsType;
this.hostAllocationState = Host.HostAllocationState.Enabled;
}
public HostVO(long id,
@ -440,7 +441,8 @@ public class HostVO implements Host {
this.caps = caps;
this.disconnectedOn = disconnectedOn;
this.dom0MinMemory = dom0MinMemory;
this.storageUrl = url;
this.storageUrl = url;
this.hostAllocationState = Host.HostAllocationState.Enabled;
}
public void setPodId(Long podId) {

View File

@ -661,7 +661,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
}
}
if (allocationState == null) {
allocationState = Grouping.AllocationState.Disabled;
allocationState = Grouping.AllocationState.Enabled;
}
Discoverer discoverer = getMatchingDiscover(hypervisorType);
@ -818,7 +818,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
List<String> hostTags = cmd.getHostTags();
String allocationState = cmd.getAllocationState();
if (allocationState == null) {
allocationState = Host.HostAllocationState.Disabled.toString();
allocationState = Host.HostAllocationState.Enabled.toString();
}
return discoverHostsFull(dcId, podId, clusterId, clusterName, url,
@ -2549,8 +2549,11 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
server.setHostAllocationState(hostAllocationState);
}
}catch(IllegalArgumentException ex){
s_logger.error("Unable to resolve " + allocationState + " to a valid supported host allocation State");
s_logger.error("Unable to resolve " + allocationState + " to a valid supported host allocation State, defaulting to 'Enabled'");
server.setHostAllocationState(Host.HostAllocationState.Enabled);
}
}else{
server.setHostAllocationState(Host.HostAllocationState.Enabled);
}
updateHost(server, startup, type, _nodeId);

View File

@ -735,7 +735,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String allocationState = cmd.getAllocationState();
if(allocationState == null){
allocationState = Grouping.AllocationState.Disabled.toString();
allocationState = Grouping.AllocationState.Enabled.toString();
}
return createPod(userId.longValue(), name, zoneId, gateway, cidr, startIp, endIp, allocationState);
}
@ -1289,7 +1289,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
Boolean isBasic = false;
String allocationState = cmd.getAllocationState();
if (allocationState == null) {
allocationState = Grouping.AllocationState.Disabled.toString();
allocationState = Grouping.AllocationState.Enabled.toString();
}
if (!(type.equalsIgnoreCase(NetworkType.Basic.toString())) && !(type.equalsIgnoreCase(NetworkType.Advanced.toString()))) {

View File

@ -66,6 +66,7 @@ public class ClusterVO implements Cluster {
public ClusterVO() {
clusterType = Cluster.ClusterType.CloudManaged;
allocationState = Grouping.AllocationState.Enabled;
}
public ClusterVO(long dataCenterId, long podId, String name) {
@ -73,6 +74,7 @@ public class ClusterVO implements Cluster {
this.podId = podId;
this.name = name;
this.clusterType = Cluster.ClusterType.CloudManaged;
this.allocationState = Grouping.AllocationState.Enabled;
}
public long getId() {

View File

@ -32,6 +32,7 @@ import javax.persistence.TableGenerator;
import javax.persistence.Transient;
import com.cloud.network.Network.Provider;
import com.cloud.org.Grouping;
import com.cloud.utils.NumbersUtil;
@Entity
@ -165,7 +166,8 @@ public class DataCenterVO implements DataCenter {
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, NetworkType zoneType) {
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr, domain, domainId, zoneType, false);
this.id = id;
this.id = id;
this.allocationState = Grouping.AllocationState.Enabled;
}
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, NetworkType zoneType, boolean securityGroupEnabled) {
@ -180,7 +182,7 @@ public class DataCenterVO implements DataCenter {
this.domain = domain;
this.domainId = domainId;
this.networkType = zoneType;
this.allocationState = Grouping.AllocationState.Enabled;
this.securityGroupEnabled = securityGroupEnabled;
if (zoneType == NetworkType.Advanced) {

View File

@ -27,6 +27,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.org.Grouping;
import com.cloud.org.Grouping.AllocationState;
import com.cloud.utils.NumbersUtil;
@ -66,6 +67,7 @@ public class HostPodVO implements Pod {
this.cidrAddress = cidrAddress;
this.cidrSize = cidrSize;
this.description = description;
this.allocationState = Grouping.AllocationState.Enabled;
}
/*