private boolean attachISOToVM(long vmId, long userId, long isoId, boolean attach) { UserVmVO vm = _userVmDao.findById(vmId); VMTemplateVO iso = _tmpltDao.findById(isoId); boolean success = attachISOToVM(vmId, isoId, attach); if (success && attach) { vm.setIsoId(iso.getId()); _userVmDao.update(vmId, vm); } if (success && !attach) { vm.setIsoId(null); _userVmDao.update(vmId, vm); } return success; }
/** * Store password in vm details so it can be picked up during VM start. */ private void storePasswordInVmDetails(VirtualMachineProfile vm) { final String password = (String) vm.getParameter(VirtualMachineProfile.Param.VmPassword); final String password_encrypted = DBEncryptionUtil.encrypt(password); final UserVmVO userVmVO = _userVmDao.findById(vm.getId()); _userVmDetailsDao.addDetail(vm.getId(), "password", password_encrypted, false); userVmVO.setUpdateParameters(true); _userVmDao.update(userVmVO.getId(), userVmVO); }
_nicDao.update(guestNic.getId(), guestNic); userVm.setPrivateIpAddress(guestNic.getIPv4Address()); _vmDao.update(userVm.getId(), userVm);
_vmDao.update(vm.getId(), vm);
vm.setGuestOSId(template.getGuestOSId()); vm.setTemplateId(newTemplateId); _vmDao.update(vmId, vm); } else { newVol = volumeMgr.allocateDuplicateVolume(root, newTemplateId); vm.setGuestOSId(template.getGuestOSId()); vm.setTemplateId(newTemplateId); _vmDao.update(vmId, vm); userVmDetailsDao.removeDetail(vm.getId(), "password"); _vmDao.update(vm.getId(), vm);
@Override public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) { UserVmVO userVm = _vmDao.findById(profile.getId()); List<NicVO> nics = _nicDao.listByVmId(userVm.getId()); for (NicVO nic : nics) { NetworkVO network = _networkDao.findById(nic.getNetworkId()); if (network.getTrafficType() == TrafficType.Guest || network.getTrafficType() == TrafficType.Public) { userVm.setPrivateIpAddress(nic.getIPv4Address()); userVm.setPrivateMacAddress(nic.getMacAddress()); _vmDao.update(userVm.getId(), userVm); } } List<VolumeVO> volumes = _volsDao.findByInstance(userVm.getId()); VmDiskStatisticsVO diskstats = null; for (VolumeVO volume : volumes) { diskstats = _vmDiskStatsDao.findBy(userVm.getAccountId(), userVm.getDataCenterId(), userVm.getId(), volume.getId()); if (diskstats == null) { diskstats = new VmDiskStatisticsVO(userVm.getAccountId(), userVm.getDataCenterId(), userVm.getId(), volume.getId()); _vmDiskStatsDao.persist(diskstats); } } finalizeCommandsOnStart(cmds, profile); return true; }