@Override public String getUuid() { return imageVO.getUuid(); }
/** * Perform basic checkings to make sure restore is possible. If not, #InvalidParameterValueException is thrown. * * @param vm vm * @param template template * @throws InvalidParameterValueException if restore is not possible */ private void checkRestoreVmFromTemplate(UserVmVO vm, VMTemplateVO template) { TemplateDataStoreVO tmplStore; if (!template.isDirectDownload()) { tmplStore = _templateStoreDao.findByTemplateZoneReady(template.getId(), vm.getDataCenterId()); if (tmplStore == null) { throw new InvalidParameterValueException("Cannot restore the vm as the template " + template.getUuid() + " isn't available in the zone"); } } else { tmplStore = _templateStoreDao.findByTemplate(template.getId(), DataStoreRole.Image); if (tmplStore == null || (tmplStore != null && !tmplStore.getDownloadState().equals(VMTemplateStorageResourceAssoc.Status.BYPASSED))) { throw new InvalidParameterValueException("Cannot restore the vm as the bypassed template " + template.getUuid() + " isn't available in the zone"); } } }
UploadStatusCommand cmd = new UploadStatusCommand(template.getUuid(), EntityType.Template); if (host != null && host.getManagementServerId() != null) { if (_nodeId == host.getManagementServerId().longValue()) { answer = ep.sendMessage(cmd); } catch (CloudRuntimeException e) { s_logger.warn("Unable to get upload status for template " + template.getUuid() + ". Error details: " + e.getMessage()); answer = new UploadStatusAnswer(cmd, UploadStatus.UNKNOWN, e.getMessage()); String error = "Template " + template.getUuid() + " failed to upload as SSVM is either destroyed or SSVM agent not in 'Up' state"; handleTemplateStatusResponse(new UploadStatusAnswer(cmd, UploadStatus.ERROR, error), template, templateDataStore);
tmpTemplateDataStore.getPhysicalSize(), tmpTemplateDataStore.getSize(), VirtualMachineTemplate.class.getName(), tmpTemplate.getUuid()); s_logger.debug("Template " + tmpTemplate.getUuid() + " uploaded successfully"); tmpTemplateDataStore.setState(State.Failed); stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationFailed, null, _templateDao); msg = "Template " + tmpTemplate.getUuid() + " failed to upload due to operation timed out"; s_logger.error(msg); sendAlert = true; tmpTemplateDataStore.setState(State.Failed); stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationFailed, null, _templateDao); msg = "Template " + tmpTemplate.getUuid() + " failed to upload. Error details: " + answer.getDetails(); s_logger.error(msg); sendAlert = true; tmpTemplateDataStore.setState(State.Failed); stateMachine.transitTo(tmpTemplate, VirtualMachineTemplate.Event.OperationTimeout, null, _templateDao); msg = "Template " + tmpTemplate.getUuid() + " failed to upload due to operation timed out"; s_logger.error(msg); sendAlert = true;
throw new InvalidParameterValueException("Specified Template " + template.getUuid()+ " not suitable for NS VPX Deployment. Please register the template with guest os type as unknow(64-bit)");
public UploadListener(DataStore host, Timer timerInput, UploadDao uploadDao, UploadVO uploadObj, UploadMonitorImpl uploadMonitor, UploadCommand cmd, Long accountId, String typeName, Type type, long eventId, long asyncJobId, AsyncJobManager asyncMgr) { sserver = host; this.uploadDao = uploadDao; this.uploadMonitor = uploadMonitor; this.cmd = cmd; uploadId = uploadObj.getId(); this.accountId = accountId; this.typeName = typeName; this.type = type; initStateMachine(); currState = getState(Status.NOT_UPLOADED.toString()); timer = timerInput; timeoutTask = new TimeoutTask(this); timer.schedule(timeoutTask, 3 * STATUS_POLL_INTERVAL); this.eventId = eventId; this.asyncJobId = asyncJobId; this.asyncMgr = asyncMgr; String extractId = null; if (type == Type.VOLUME) { extractId = ApiDBUtils.findVolumeById(uploadObj.getTypeId()).getUuid(); } else { extractId = ApiDBUtils.findTemplateById(uploadObj.getTypeId()).getUuid(); } resultObj = new ExtractResponse(extractId, typeName, ApiDBUtils.findAccountById(accountId).getUuid(), Status.NOT_UPLOADED.toString(), ApiDBUtils.findUploadById(uploadId) .getUuid()); resultObj.setResponseName(responseNameMap.get(type.toString())); updateDatabase(Status.NOT_UPLOADED, cmd.getUrl(), ""); }
private boolean preparePxeInBasicZone(VirtualMachineProfile profile, NicProfile nic, DeployDestination dest, ReservationContext context) throws AgentUnavailableException, OperationTimedoutException { NetworkVO nwVO = _nwDao.findById(nic.getNetworkId()); QueryBuilder<BaremetalPxeVO> sc = QueryBuilder.create(BaremetalPxeVO.class); sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString()); sc.and(sc.entity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId()); BaremetalPxeVO pxeVo = sc.find(); if (pxeVo == null) { throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM"); } VMTemplateVO template = _tmpDao.findById(profile.getTemplateId()); List<String> tuple = parseKickstartUrl(profile); String ks = tuple.get(0); String kernel = tuple.get(1); String initrd = tuple.get(2); PrepareKickstartPxeServerCommand cmd = new PrepareKickstartPxeServerCommand(); cmd.setKsFile(ks); cmd.setInitrd(initrd); cmd.setKernel(kernel); cmd.setMac(nic.getMacAddress()); cmd.setTemplateUuid(template.getUuid()); Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd); if (!aws.getResult()) { s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails()); return false; } return true; }
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(), template.getUuid(), tmpl.getInstallPath(), tmpl .getChecksum(), tmpl.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole().toString());
srcTmpltStore.getSize(), template.getClass().getName(), template.getUuid());
EndPoint ep = _epSelector.select(dataStore, templateDataStore.getExtractUrl()); if (ep == null) { s_logger.warn("There is no secondary storage VM for image store " + dataStore.getName() + ", cannot destroy uploaded template " + template.getUuid()); continue; TemplateApiResult result = future.get(); if (!result.isSuccess()) { s_logger.warn("Failed to delete template " + template.getUuid() + " from the image store " + dataStore.getName() + " due to: " + result.getResult()); continue; s_logger.warn("Unable to destroy uploaded template " + template.getUuid() + ". Error details: " + th.getMessage());
s_logger.error("Template Id " + templateId + " is not an ISO"); InvalidParameterValueException ex = new InvalidParameterValueException("Specified Template Id is not an ISO"); ex.addProxyObject(template.getUuid(), "templateId"); throw ex; s_logger.error("Incorrect format of the template id " + templateId); InvalidParameterValueException ex = new InvalidParameterValueException("Incorrect format " + template.getFormat() + " of the specified template id"); ex.addProxyObject(template.getUuid(), "templateId"); throw ex;
if (sZoneId != null) { UsageEventUtils.publishUsageEvent(eventType, template.getAccountId(), sZoneId, template.getId(), null, VirtualMachineTemplate.class.getName(), template.getUuid());
String domainId = _domainDao.findById(autoScaleVmProfile.getDomainId()).getUuid(); String serviceOfferingId = _offeringsDao.findById(autoScaleVmProfile.getServiceOfferingId()).getUuid(); String templateId = _templateDao.findById(autoScaleVmProfile.getTemplateId()).getUuid(); String vmName = "AutoScale-LB-" + lbName; String lbNetworkUuid = null;
@Override public ExtractResponse createExtractResponse(Long id, Long zoneId, Long accountId, String mode, String url) { ExtractResponse response = new ExtractResponse(); response.setObjectName("template"); VMTemplateVO template = ApiDBUtils.findTemplateById(id); response.setId(template.getUuid()); response.setName(template.getName()); if (zoneId != null) { DataCenter zone = ApiDBUtils.findZoneById(zoneId); response.setZoneId(zone.getUuid()); response.setZoneName(zone.getName()); } response.setMode(mode); response.setUrl(url); response.setState(Upload.Status.DOWNLOAD_URL_CREATED.toString()); Account account = ApiDBUtils.findAccountById(accountId); response.setAccountId(account.getUuid()); return response; }
@Override public ExtractResponse createExtractResponse(Long uploadId, Long id, Long zoneId, Long accountId, String mode, String url) { ExtractResponse response = new ExtractResponse(); response.setObjectName("template"); VMTemplateVO template = ApiDBUtils.findTemplateById(id); response.setId(template.getUuid()); response.setName(template.getName()); if (zoneId != null) { DataCenter zone = ApiDBUtils.findZoneById(zoneId); response.setZoneId(zone.getUuid()); response.setZoneName(zone.getName()); } response.setMode(mode); if (uploadId == null) { // region-wide image store response.setUrl(url); response.setState(Upload.Status.DOWNLOAD_URL_CREATED.toString()); } else { UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId); response.setUploadId(uploadInfo.getUuid()); response.setState(uploadInfo.getUploadState().toString()); response.setUrl(uploadInfo.getUploadUrl()); } Account account = ApiDBUtils.findAccountById(accountId); response.setAccountId(account.getUuid()); return response; }
VMTemplateVO template = ApiDBUtils.findTemplateById(profile.getTemplateId()); if (template != null) { response.setTemplateId(template.getUuid());
if (tmpl.getTemplateType() != TemplateType.ISODISK) { ChildTemplateResponse childTempl = new ChildTemplateResponse(); childTempl.setId(tmpl.getUuid()); childTempl.setName(tmpl.getName()); childTempl.setSize(Math.round(tmpl.getSize() / (1024 * 1024 * 1024)));
vmResponse.setTemplateId(template.getUuid());
VMTemplateVO template = ApiDBUtils.findTemplateById(job.getInstanceId()); if (template != null) { jobInstanceId = template.getUuid();