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;
}
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;
}
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;
}
Aggregations