Skip to content

Commit a2e38a6

Browse files
authored
Ac 88 delay vm boot (#31)
* New param on start vm command to specify a boot delay implemented through the kvm boot menu timeout * Translating the profile param to a concrete field in the transfer object. * Adding the boot delay to the admin start vm form. * Adding default value to form. * Fixing default value for form * Adding boot delay option to user form. Fixing text to indicate to the user the units. * Adding help text and fixing label to not wrap. * Missed a few languages.
1 parent 5a89c9d commit a2e38a6

File tree

26 files changed

+99
-3
lines changed

26 files changed

+99
-3
lines changed

api/src/com/cloud/agent/api/to/VirtualMachineTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class VirtualMachineTO {
5151
String os;
5252
String platformEmulator;
5353
String bootArgs;
54+
Integer bootDelay = 0;
5455
String[] bootupScripts;
5556
boolean enableHA;
5657
boolean limitCpuUse;
@@ -223,6 +224,14 @@ public void setBootArgs(Map<String, String> bootParams) {
223224
bootArgs = buf.toString();
224225
}
225226

227+
public Integer getBootDelay() {
228+
return bootDelay;
229+
}
230+
231+
public void setBootDelay(Integer bootDelay) {
232+
this.bootDelay = bootDelay;
233+
}
234+
226235
public String[] getBootupScripts() {
227236
return bootupScripts;
228237
}

api/src/com/cloud/vm/VirtualMachineProfile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static class Param {
6060
public static final Param PxeSeverType = new Param("PxeSeverType");
6161
public static final Param HaTag = new Param("HaTag");
6262
public static final Param HaOperation = new Param("HaOperation");
63+
public static final Param BootDelay = new Param("BootDelay");
6364

6465
private String name;
6566

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ public class ApiConstants {
717717
public static final String HAS_ANNOTATION = "hasannotation";
718718
public static final String LAST_ANNOTATED = "lastannotated";
719719
public static final String LDAP_DOMAIN = "ldapdomain";
720+
public static final String BOOT_DELAY = "bootdelay";
720721

721722

722723
public enum HostDetails {

api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public class StartVMCmd extends BaseAsyncCmd {
7070
@Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4", authorized = { RoleType.Admin })
7171
private String deploymentPlanner;
7272

73+
@Parameter(name = ApiConstants.BOOT_DELAY, type = CommandType.INTEGER, description = "Seconds to delay the boot at the boot menu", since = "4.11.3")
74+
private Integer bootDelay;
75+
7376
// ///////////////////////////////////////////////////
7477
// ///////////////// Accessors ///////////////////////
7578
// ///////////////////////////////////////////////////
@@ -99,6 +102,10 @@ public String getDeploymentPlanner() {
99102
return deploymentPlanner;
100103
}
101104

105+
public Integer getBootDelay() {
106+
return bootDelay;
107+
}
108+
102109
@Override
103110
public long getEntityOwnerId() {
104111
UserVm vm = _responseGenerator.findUserVmById(getId());

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,7 @@ public LibvirtVMDef createVMFromSpec(final VirtualMachineTO vmTO) {
20472047
guest.setUuid(uuid);
20482048
guest.setBootOrder(GuestDef.BootOrder.CDROM);
20492049
guest.setBootOrder(GuestDef.BootOrder.HARDISK);
2050+
guest.setBootDelay(vmTO.getBootDelay());
20502051

20512052
vm.addComp(guest);
20522053

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public String toString() {
6868
private String _uuid;
6969
private final List<BootOrder> _bootdevs = new ArrayList<BootOrder>();
7070
private String _machine;
71+
private Integer _bootDelay = 0;
7172

7273
public void setGuestType(GuestType type) {
7374
_type = type;
@@ -104,6 +105,10 @@ public void setUuid(String uuid) {
104105
_uuid = uuid;
105106
}
106107

108+
public void setBootDelay(Integer bootDelay) {
109+
this._bootDelay = bootDelay;
110+
}
111+
107112
@Override
108113
public String toString() {
109114
if (_type == GuestType.KVM) {
@@ -132,6 +137,10 @@ public String toString() {
132137
}
133138
}
134139
guestDef.append("<smbios mode='sysinfo'/>\n");
140+
if (_bootDelay != null && _bootDelay > 0) {
141+
s_logger.info("Delaying VM start " + this._uuid);
142+
guestDef.append("<bootmenu enable='yes' timeout='" + _bootDelay * 1000 + "'/>");
143+
}
135144
guestDef.append("</os>\n");
136145
return guestDef.toString();
137146
} else if (_type == GuestType.LXC) {

server/src/com/cloud/hypervisor/HypervisorGuruBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
134134
VirtualMachineTO to = new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), minspeed, maxspeed, minMemory * 1024l * 1024l,
135135
offering.getRamSize() * 1024l * 1024l, null, null, vm.isHaEnabled(), vm.limitCpuUse(), vm.getVncPassword());
136136
to.setBootArgs(vmProfile.getBootArgs());
137+
if (vmProfile.getParameter(VirtualMachineProfile.Param.BootDelay) != null)
138+
s_logger.info("Delaying start of VM " + vm.getId());
139+
to.setBootDelay((Integer) vmProfile.getParameter(VirtualMachineProfile.Param.BootDelay));
137140

138141
List<NicProfile> nicProfiles = vmProfile.getNics();
139142
NicTO[] nics = new NicTO[nicProfiles.size()];

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2707,7 +2707,12 @@ protected boolean applyUserData(HypervisorType hyperVisorType, UserVm vm, Nic ni
27072707
@Override
27082708
@ActionEvent(eventType = EventTypes.EVENT_VM_START, eventDescription = "starting Vm", async = true)
27092709
public UserVm startVirtualMachine(StartVMCmd cmd) throws ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
2710-
return startVirtualMachine(cmd.getId(), cmd.getHostId(), null, cmd.getDeploymentPlanner()).first();
2710+
Map<VirtualMachineProfile.Param, Object> additionalParams = null;
2711+
if (cmd.getBootDelay() != null && cmd.getBootDelay() > 0) {
2712+
additionalParams = new HashMap<>();
2713+
additionalParams.put(VirtualMachineProfile.Param.BootDelay, cmd.getBootDelay());
2714+
}
2715+
return startVirtualMachine(cmd.getId(), cmd.getHostId(), additionalParams, cmd.getDeploymentPlanner()).first();
27112716
}
27122717

27132718
@Override

ui/l10n/ar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ var dictionary = {
474474
"label.blade.id": "Blade ID",
475475
"label.blades": "Blades",
476476
"label.bootable": "Bootable",
477+
"label.bootDelay": "Boot Delay",
477478
"label.broadcast.domain.range": "Broadcast domain range",
478479
"label.broadcast.domain.type": "Broadcast Domain Type",
479480
"label.broadcast.uri": "بث الرابط",

ui/l10n/ca.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ var dictionary = {
474474
"label.blade.id": "Blade ID",
475475
"label.blades": "Blades",
476476
"label.bootable": "Bootable",
477+
"label.bootDelay": "Boot Delay",
477478
"label.broadcast.domain.range": "Rang del domini de broadcast",
478479
"label.broadcast.domain.type": "Broadcast Domain Type",
479480
"label.broadcast.uri": "Broadcast URI",

0 commit comments

Comments
 (0)