From fab2d1f880042922064569a9529a77c32dcc5ac2 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Thu, 3 Nov 2011 15:51:02 +0530 Subject: [PATCH] bug 11678: added vm.destory.forcestop config var to set force when destroying a vm --- server/src/com/cloud/configuration/Config.java | 1 + server/src/com/cloud/vm/VirtualMachineManagerImpl.java | 6 ++++-- setup/db/db/schema-2212to2213.sql | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 3541290639a..7658b10e4a9 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -203,6 +203,7 @@ public enum Config { CapacitySkipcountingHours("Advanced", ManagementServer.class, Integer.class, "capacity.skipcounting.hours", "3600", "Time (in seconds) to wait before release VM's cpu and memory when VM in stopped state", null), VmStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.stats.interval", "60000", "The interval (in milliseconds) when vm stats are retrieved from agents.", null), VmTransitionWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.tranisition.wait.interval", "3600", "Time (in seconds) to wait before taking over a VM in transition state", null), + VmDestroyForcestop("Advanced", ManagementServer.class, Boolean.class, "vm.destory.forcestop", "false", "On destory, force-stop takes this value ", null), ControlCidr("Advanced", ManagementServer.class, String.class, "control.cidr", "169.254.0.0/16", "Changes the cidr for the control network traffic. Defaults to using link local. Must be unique within pods", null), ControlGateway("Advanced", ManagementServer.class, String.class, "control.gateway", "169.254.0.1", "gateway for the control network traffic", null), diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 57e95498bb8..bf843c70c05 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -243,6 +243,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene protected long _cancelWait; protected long _opWaitInterval; protected int _lockStateRetry; + protected boolean _forceStop; @Override public void registerGuru(VirtualMachine.Type type, VirtualMachineGuru guru) { @@ -432,7 +433,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene _opWaitInterval = NumbersUtil.parseLong(params.get(Config.VmOpWaitInterval.key()), 120) * 1000; _lockStateRetry = NumbersUtil.parseInt(params.get(Config.VmOpLockStateRetry.key()), 5); _operationTimeout = NumbersUtil.parseInt(params.get(Config.Wait.key()), 1800) * 2; - + _forceStop = Boolean.parseBoolean(params.get(Config.VmDestroyForcestop.key())); + _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup")); _nodeId = _clusterMgr.getManagementNodeId(); @@ -1151,7 +1153,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene return true; } - if (!advanceStop(vm, false, user, caller)) { + if (!advanceStop(vm, _forceStop, user, caller)) { s_logger.debug("Unable to stop " + vm); return false; } diff --git a/setup/db/db/schema-2212to2213.sql b/setup/db/db/schema-2212to2213.sql index cc9eb8fdd5d..4b8d7c13509 100644 --- a/setup/db/db/schema-2212to2213.sql +++ b/setup/db/db/schema-2212to2213.sql @@ -60,4 +60,5 @@ update host_details set name='memory' where host_id in (select id from host wher update host_details set name='privateip' where host_id in (select id from host where hypervisor_type='BareMetal') and name='agentIp'; INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'vmware.root.disk.controller', 'ide', 'Specify the default disk controller for root volumes, valid values are scsi, ide'); +INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.destory.forcestop', 'false', 'On destory, force-stop takes this value');