@Override @DB @ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_UPDATE, eventDescription = "updating guest OS mapping", async = true) public GuestOSHypervisor updateGuestOsMapping(final UpdateGuestOsMappingCmd cmd) { final Long id = cmd.getId(); final String osNameForHypervisor = cmd.getOsNameForHypervisor(); //check if mapping exists final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id); if (guestOsHypervisorHandle == null) { throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping"); } if (!guestOsHypervisorHandle.getIsUserDefined()) { throw new InvalidParameterValueException("Unable to modify system defined Guest OS mapping"); } final GuestOSHypervisorVO guestOsHypervisor = _guestOSHypervisorDao.createForUpdate(id); guestOsHypervisor.setGuestOsName(osNameForHypervisor); if (_guestOSHypervisorDao.update(id, guestOsHypervisor)) { return _guestOSHypervisorDao.findById(id); } else { return null; } }
@Override @DB @ActionEvent(eventType = EventTypes.EVENT_GUEST_OS_MAPPING_REMOVE, eventDescription = "removing guest OS mapping", async = true) public boolean removeGuestOsMapping(final RemoveGuestOsMappingCmd cmd) { final Long id = cmd.getId(); //check if mapping exists final GuestOSHypervisor guestOsHypervisorHandle = _guestOSHypervisorDao.findById(id); if (guestOsHypervisorHandle == null) { throw new InvalidParameterValueException("Guest OS Mapping not found. Please specify a valid ID for the Guest OS Mapping"); } if (!guestOsHypervisorHandle.getIsUserDefined()) { throw new InvalidParameterValueException("Unable to remove system defined Guest OS mapping"); } return _guestOSHypervisorDao.removeGuestOsMapping(id); }
@Override public VirtualMachineTO implement(VirtualMachineProfile vm) { VirtualMachineTO to = toVirtualMachineTO(vm); // Determine the VM's OS description GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId()); 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("Other"); } else { to.setPlatformEmulator(guestOsMapping.getGuestOsName()); } return to; }
@Override public Pair<List<? extends GuestOSHypervisor>, Integer> listGuestOSMappingByCriteria(final ListGuestOsMappingCmd cmd) { final Filter searchFilter = new Filter(GuestOSHypervisorVO.class, "hypervisorType", true, cmd.getStartIndex(), cmd.getPageSizeVal()); final Long id = cmd.getId(); final Long osTypeId = cmd.getOsTypeId(); final String hypervisor = cmd.getHypervisor(); final String hypervisorVersion = cmd.getHypervisorVersion(); //throw exception if hypervisor name is not passed, but version is if (hypervisorVersion != null && (hypervisor == null || hypervisor.isEmpty())) { throw new InvalidParameterValueException("Hypervisor version parameter cannot be used without specifying a hypervisor : XenServer, KVM or VMware"); } final SearchCriteria<GuestOSHypervisorVO> sc = _guestOSHypervisorDao.createSearchCriteria(); if (id != null) { sc.addAnd("id", SearchCriteria.Op.EQ, id); } if (osTypeId != null) { sc.addAnd("guestOsId", SearchCriteria.Op.EQ, osTypeId); } if (hypervisor != null) { sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisor); } if (hypervisorVersion != null) { sc.addAnd("hypervisorVersion", SearchCriteria.Op.EQ, hypervisorVersion); } final Pair<List<GuestOSHypervisorVO>, Integer> result = _guestOSHypervisorDao.searchAndCount(sc, searchFilter); return new Pair<List<? extends GuestOSHypervisor>, Integer>(result.first(), result.second()); }
final GuestOSHypervisorVO duplicate = _guestOSHypervisorDao.findByOsIdAndHypervisorAndUserDefined(guestOs.getId(), hypervisorType.toString(), hypervisorVersion, true); guestOsMapping.setHypervisorVersion(hypervisorVersion); guestOsMapping.setIsUserDefined(true); return _guestOSHypervisorDao.persist(guestOsMapping);
@Override public GuestOSHypervisorVO getGuestOsHypervisor(final Long guestOsHypervisorId) { return _guestOSHypervisorDao.findById(guestOsHypervisorId); }
@Override public VirtualMachineTO implement(VirtualMachineProfile vm) { VirtualMachineTO to = toVirtualMachineTO(vm); setVmQuotaPercentage(to, vm); // Determine the VM's OS description GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId()); 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("Other"); } else { to.setPlatformEmulator(guestOsMapping.getGuestOsName()); } return to; }
new CreateVMSnapshotCommand(virtualMachine.getInstanceName(), virtualMachine.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName()); HostVO host = hostDao.findById(hostId); GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion()); ccmd.setPlatformEmulator(guestOsMapping.getGuestOsName()); ccmd.setWait(wait);
RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, userVm.getUuid(), vmSnapshotTO, volumeTOs, guestOS.getDisplayName()); HostVO host = hostDao.findById(hostId); GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion()); if (guestOsMapping == null) { revertToSnapshotCommand.setPlatformEmulator(null);
GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), host.getHypervisorType().toString(), host.getHypervisorVersion());
GuestOSHypervisorVO guestOsMapping = null; if (host != null) { guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion());