Search in sources :

Example 1 with BootloaderType

use of com.cloud.template.VirtualMachineTemplate.BootloaderType in project cloudstack by apache.

the class XenServerGuru method implement.

@Override
public VirtualMachineTO implement(VirtualMachineProfile vm) {
    BootloaderType bt = BootloaderType.PyGrub;
    if (vm.getBootLoaderType() == BootloaderType.CD) {
        bt = vm.getBootLoaderType();
    }
    VirtualMachineTO to = toVirtualMachineTO(vm);
    UserVmVO userVmVO = userVmDao.findById(vm.getId());
    if (userVmVO != null) {
        HostVO host = hostDao.findById(userVmVO.getHostId());
        if (host != null) {
            List<HostVO> clusterHosts = hostDao.listByClusterAndHypervisorType(host.getClusterId(), host.getHypervisorType());
            HostVO hostWithMinSocket = clusterHosts.stream().min(Comparator.comparing(HostVO::getCpuSockets)).orElse(null);
            Integer vCpus = MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId());
            if (hostWithMinSocket != null && hostWithMinSocket.getCpuSockets() != null && hostWithMinSocket.getCpuSockets() < vCpus) {
                vCpus = hostWithMinSocket.getCpuSockets();
            }
            to.setVcpuMaxLimit(vCpus);
        }
    }
    to.setBootloader(bt);
    // Determine the VM's OS description
    GuestOSVO guestOS = guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId());
    Map<String, String> guestOsDetails = guestOsDetailsDao.listDetailsKeyPairs(vm.getVirtualMachine().getGuestOSId());
    to.setGuestOsDetails(guestOsDetails);
    to.setOs(guestOS.getDisplayName());
    HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId());
    GuestOSHypervisorVO guestOsMapping = null;
    if (host != null) {
        guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion());
    }
    if (guestOsMapping == null || host == null) {
        to.setPlatformEmulator(null);
    } else {
        to.setPlatformEmulator(guestOsMapping.getGuestOsName());
    }
    return to;
}
Also used : GuestOSHypervisorVO(com.cloud.storage.GuestOSHypervisorVO) UserVmVO(com.cloud.vm.UserVmVO) BootloaderType(com.cloud.template.VirtualMachineTemplate.BootloaderType) GuestOSVO(com.cloud.storage.GuestOSVO) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) HostVO(com.cloud.host.HostVO)

Example 2 with BootloaderType

use of com.cloud.template.VirtualMachineTemplate.BootloaderType in project cloudstack by apache.

the class Ovm3HypervisorResourceTest method createVm.

public VirtualMachineTO createVm(String vmName) throws Ovm3ResourceException {
    con = support.prepConnectionResults();
    Xen vdata = new Xen(con);
    Xen.Vm vm = vdata.getVmConfig(vmName);
    vdata.listVm(xen.getRepoId(), xen.getVmId());
    // Ovm3VmGuestTypes types = new Ovm3VmGuestTypes();
    Long id = 1L;
    String instanceName = vm.getVmName();
    VirtualMachine.Type type = Type.User;
    // vm.getVmCpus();
    int cpus = 1;
    Integer speed = 0;
    long minRam = vm.getVmMemory();
    long maxRam = vm.getVmMemory();
    BootloaderType bootloader = BootloaderType.PyGrub;
    String os = "Oracle Enterprise Linux 6.0 (64-bit)";
    boolean enableHA = true;
    boolean limitCpuUse = false;
    String vncPassword = "gobbeldygoo";
    VirtualMachineTO vmspec = new VirtualMachineTO(id, instanceName, type, cpus, speed, minRam, maxRam, bootloader, os, enableHA, limitCpuUse, vncPassword);
    vmspec.setBootArgs("");
    addDisksToSpec(vmspec, vm.getVmDisks());
    addNicsToSpec(vmspec, vm.getVmVifs());
    return vmspec;
}
Also used : Xen(com.cloud.hypervisor.ovm3.objects.Xen) Type(com.cloud.vm.VirtualMachine.Type) BootloaderType(com.cloud.template.VirtualMachineTemplate.BootloaderType) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 3 with BootloaderType

use of com.cloud.template.VirtualMachineTemplate.BootloaderType in project cosmic by MissionCriticalCloud.

the class XenServerGuru method implement.

@Override
public VirtualMachineTO implement(final VirtualMachineProfile vm) {
    BootloaderType bt = BootloaderType.PyGrub;
    if (vm.getBootLoaderType() == BootloaderType.CD) {
        bt = vm.getBootLoaderType();
    }
    final VirtualMachineTO to = toVirtualMachineTO(vm);
    final UserVmVO userVmVO = _userVmDao.findById(vm.getId());
    if (userVmVO != null) {
        final HostVO host = hostDao.findById(userVmVO.getHostId());
        if (host != null) {
            to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
        }
    }
    to.setBootloader(bt);
    // Determine the VM's OS description
    final GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId());
    to.setOs(guestOS.getDisplayName());
    final HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId());
    GuestOSHypervisorVO guestOsMapping = null;
    if (host != null) {
        guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion());
    }
    if (guestOsMapping == null || host == null) {
        to.setPlatformEmulator(null);
    } else {
        to.setPlatformEmulator(guestOsMapping.getGuestOsName());
    }
    return to;
}
Also used : GuestOSHypervisorVO(com.cloud.storage.GuestOSHypervisorVO) UserVmVO(com.cloud.vm.UserVmVO) BootloaderType(com.cloud.template.VirtualMachineTemplate.BootloaderType) GuestOSVO(com.cloud.storage.GuestOSVO) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) HostVO(com.cloud.host.HostVO)

Aggregations

VirtualMachineTO (com.cloud.agent.api.to.VirtualMachineTO)3 BootloaderType (com.cloud.template.VirtualMachineTemplate.BootloaderType)3 HostVO (com.cloud.host.HostVO)2 GuestOSHypervisorVO (com.cloud.storage.GuestOSHypervisorVO)2 GuestOSVO (com.cloud.storage.GuestOSVO)2 UserVmVO (com.cloud.vm.UserVmVO)2 Xen (com.cloud.hypervisor.ovm3.objects.Xen)1 VirtualMachine (com.cloud.vm.VirtualMachine)1 Type (com.cloud.vm.VirtualMachine.Type)1