Search in sources :

Example 1 with DeployVMCmdByAdmin

use of org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin in project cloudstack by apache.

the class UserVmManagerImpl method startVirtualMachine.

@Override
@ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "starting Vm", async = true)
public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
    long vmId = cmd.getEntityId();
    Long podId = null;
    Long clusterId = null;
    Long hostId = cmd.getHostId();
    Map<VirtualMachineProfile.Param, Object> additionalParams = new HashMap<>();
    Map<Long, DiskOffering> diskOfferingMap = cmd.getDataDiskTemplateToDiskOfferingMap();
    Map<String, String> details = cmd.getDetails();
    if (cmd instanceof DeployVMCmdByAdmin) {
        DeployVMCmdByAdmin adminCmd = (DeployVMCmdByAdmin) cmd;
        podId = adminCmd.getPodId();
        clusterId = adminCmd.getClusterId();
    }
    UserVmDetailVO uefiDetail = userVmDetailsDao.findDetail(cmd.getEntityId(), ApiConstants.BootType.UEFI.toString());
    if (uefiDetail != null) {
        addVmUefiBootOptionsToParams(additionalParams, uefiDetail.getName(), uefiDetail.getValue());
    }
    if (cmd.getBootIntoSetup() != null) {
        additionalParams.put(VirtualMachineProfile.Param.BootIntoSetup, cmd.getBootIntoSetup());
    }
    return startVirtualMachine(vmId, podId, clusterId, hostId, diskOfferingMap, additionalParams, cmd.getDeploymentPlanner());
}
Also used : DiskOffering(com.cloud.offering.DiskOffering) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DeployVMCmdByAdmin(org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin) ActionEvent(com.cloud.event.ActionEvent)

Aggregations

ActionEvent (com.cloud.event.ActionEvent)1 DiskOffering (com.cloud.offering.DiskOffering)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DeployVMCmdByAdmin (org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin)1