CLOUDSTACK-2060

Global config to turn off dynamically scale vm functionality
This commit is contained in:
Nitin Mehta 2013-05-29 19:01:23 +05:30
parent cea9e3919a
commit 8d1189c2ae
6 changed files with 32 additions and 3 deletions

View File

@ -52,6 +52,7 @@ public class VirtualMachineTO {
boolean rebootOnCrash;
boolean enableHA;
boolean limitCpuUse;
boolean enableDynamicallyScaleVm;
String vncPassword;
String vncAddr;
Map<String, String> params;
@ -102,6 +103,14 @@ public class VirtualMachineTO {
this.id = id;
}
public boolean isEnableDynamicallyScaleVm() {
return enableDynamicallyScaleVm;
}
public void setEnableDynamicallyScaleVm(boolean enableDynamicallyScaleVm) {
this.enableDynamicallyScaleVm = enableDynamicallyScaleVm;
}
public String getName() {
return name;
}

View File

@ -137,7 +137,7 @@ public class XenServer56FP1Resource extends XenServer56Resource {
vmr.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY;
vmr.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
if (isDmcEnabled(conn, host)) {
if (isDmcEnabled(conn, host) && vmSpec.isEnableDynamicallyScaleVm()) {
//scaling is allowed
vmr.memoryStaticMin = mem_128m; //128MB
//TODO: Remove hardcoded 8GB and assign proportionate to ServiceOffering and mem overcommit ratio

View File

@ -180,7 +180,8 @@ public enum Config {
RouterTemplateLXC("Advanced", NetworkManager.class, String.class, "router.template.lxc", "SystemVM Template (LXC)", "Name of the default router template on LXC.", null, ConfigurationParameterScope.zone.toString()),
RouterExtraPublicNics("Advanced", NetworkManager.class, Integer.class, "router.extra.public.nics", "2", "specify extra public nics used for virtual router(up to 5)", "0-5"),
StartRetry("Advanced", AgentManager.class, Integer.class, "start.retry", "10", "Number of times to retry create and start commands", null),
ScaleRetry("Advanced", AgentManager.class, Integer.class, "scale.retry", "2", "Number of times to retry scaling up the vm", null),
EnableDynamicallyScaleVm("Advanced", ManagementServer.class, Boolean.class, "enable.dynamic.scale.vm", "false", "Enables/Diables dynamically scaling a vm", null, ConfigurationParameterScope.zone.toString()),
ScaleRetry("Advanced", ManagementServer.class, Integer.class, "scale.retry", "2", "Number of times to retry scaling up the vm", null),
StopRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "stop.retry.interval", "600", "Time in seconds between retries to stop or destroy a vm" , null),
StorageCleanupInterval("Advanced", StorageManager.class, Integer.class, "storage.cleanup.interval", "86400", "The interval (in seconds) to wait before running the storage cleanup thread.", null),
StorageCleanupEnabled("Advanced", StorageManager.class, Boolean.class, "storage.cleanup.enabled", "true", "Enables/disables the storage cleanup thread.", null),

View File

@ -25,7 +25,9 @@ import com.cloud.agent.api.Command;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.configuration.Config;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.ConfigurationServer;
import com.cloud.storage.dao.VMTemplateDetailsDao;
import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.NicProfile;
@ -43,6 +45,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
@Inject NicDao _nicDao;
@Inject VMInstanceDao _virtualMachineDao;
@Inject NicSecondaryIpDao _nicSecIpDao;
@Inject ConfigurationServer _configServer;
protected HypervisorGuruBase() {
super();
@ -121,7 +125,10 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
// Workaround to make sure the TO has the UUID we need for Niciri integration
VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
to.setUuid(vmInstance.getUuid());
//
to.setEnableDynamicallyScaleVm(Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vm.getDataCenterId())));
return to;
}

View File

@ -32,6 +32,7 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.server.ConfigurationServer;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupVO;
@ -400,6 +401,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
AffinityGroupVMMapDao _affinityGroupVMMapDao;
@Inject
AffinityGroupDao _affinityGroupDao;
@Inject
ConfigurationServer _configServer;
protected ScheduledExecutorService _executor = null;
protected int _expungeInterval;
@ -1141,6 +1144,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
boolean success = false;
if(vmInstance.getState().equals(State.Running)){
int retry = _scaleRetry;
boolean enableDynamicallyScaleVm = Boolean.parseBoolean(_configServer.getConfigValue(Config.EnableDynamicallyScaleVm.key(), Config.ConfigurationParameterScope.zone.toString(), vmInstance.getDataCenterId()));
if(!enableDynamicallyScaleVm){
throw new PermissionDeniedException("Dynamically scaling virtual machines is disabled for this zone, please contact your admin");
}
// Increment CPU and Memory count accordingly.
if (newCpu > currentCpu) {
_resourceLimitMgr.incrementResourceCount(caller.getAccountId(), ResourceType.cpu, new Long (newCpu - currentCpu));

View File

@ -1712,6 +1712,10 @@ update `cloud`.`vpc_gateways` set network_acl_id = 2;
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'VpcManager', 'blacklisted.routes', NULL, 'Routes that are blacklisted, can not be used for Static Routes creation for the VPC Private Gateway');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'enable.dynamic.scale.vm', 'false', 'Enables/Diables dynamically scaling a vm');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'scale.retry', '2', 'Number of times to retry scaling up the vm');
UPDATE `cloud`.`snapshots` set swift_id=null where swift_id=0;