Skip to content

Commit fab2d1f

Browse files
author
Abhinandan Prateek
committed
bug 11678: added vm.destory.forcestop config var to set force when destroying a vm
1 parent 267b12d commit fab2d1f

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎server/src/com/cloud/configuration/Config.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public enum Config {
203203
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),
204204
VmStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.stats.interval", "60000", "The interval (in milliseconds) when vm stats are retrieved from agents.", null),
205205
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),
206+
VmDestroyForcestop("Advanced", ManagementServer.class, Boolean.class, "vm.destory.forcestop", "false", "On destory, force-stop takes this value ", null),
206207

207208
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),
208209
ControlGateway("Advanced", ManagementServer.class, String.class, "control.gateway", "169.254.0.1", "gateway for the control network traffic", null),

‎server/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
243243
protected long _cancelWait;
244244
protected long _opWaitInterval;
245245
protected int _lockStateRetry;
246+
protected boolean _forceStop;
246247

247248
@Override
248249
public <T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru) {
@@ -432,7 +433,8 @@ public boolean configure(String name, Map<String, Object> xmlParams) throws Conf
432433
_opWaitInterval = NumbersUtil.parseLong(params.get(Config.VmOpWaitInterval.key()), 120) * 1000;
433434
_lockStateRetry = NumbersUtil.parseInt(params.get(Config.VmOpLockStateRetry.key()), 5);
434435
_operationTimeout = NumbersUtil.parseInt(params.get(Config.Wait.key()), 1800) * 2;
435-
436+
_forceStop = Boolean.parseBoolean(params.get(Config.VmDestroyForcestop.key()));
437+
436438
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup"));
437439
_nodeId = _clusterMgr.getManagementNodeId();
438440

@@ -1151,7 +1153,7 @@ public <T extends VMInstanceVO> boolean destroy(T vm, User user, Account caller)
11511153
return true;
11521154
}
11531155

1154-
if (!advanceStop(vm, false, user, caller)) {
1156+
if (!advanceStop(vm, _forceStop, user, caller)) {
11551157
s_logger.debug("Unable to stop " + vm);
11561158
return false;
11571159
}

‎setup/db/db/schema-2212to2213.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ update host_details set name='memory' where host_id in (select id from host wher
6060
update host_details set name='privateip' where host_id in (select id from host where hypervisor_type='BareMetal') and name='agentIp';
6161

6262
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');
63+
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.destory.forcestop', 'false', 'On destory, force-stop takes this value');
6364

0 commit comments

Comments
 (0)