@Override public String getEventDescription() { return "creating template: " + getTemplateName(); }
@Override public void create() throws ResourceAllocationException { VirtualMachineTemplate template = null; //TemplateOwner should be the caller https://issues.citrite.net/browse/CS-17530 template = _templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId())); if (template != null) { setEntityId(template.getId()); setEntityUuid(template.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a template"); } }
String name = cmd.getTemplateName(); if ((name == null) || (name.length() > 32)) { throw new InvalidParameterValueException("Template name cannot be null and should be less than 32 characters"); if (cmd.getTemplateTag() != null) { if (!_accountService.isRootAdmin(caller.getId())) { throw new PermissionDeniedException("Parameter templatetag can only be specified by a Root Admin, permission denied"); Integer bits = cmd.getBits(); Boolean requiresHvm = cmd.getRequiresHvm(); Boolean passwordEnabled = cmd.isPasswordEnabled(); Boolean sshKeyEnabled = cmd.isSshKeyEnabled(); Boolean isPublic = cmd.isPublic(); Boolean featured = cmd.isFeatured(); int bitsValue = ((bits == null) ? 64 : bits.intValue()); boolean requiresHvmValue = ((requiresHvm == null) ? true : requiresHvm.booleanValue()); boolean isDynamicScalingEnabled = cmd.isDynamicallyScalable(); Long volumeId = cmd.getVolumeId(); Long snapshotId = cmd.getSnapshotId(); if ((volumeId == null) && (snapshotId == null)) { throw new InvalidParameterValueException("Failed to create private template record, neither volume ID nor snapshot ID were specified."); Long guestOSId = cmd.getOsTypeId(); GuestOSVO guestOS = _guestOSDao.findById(guestOSId); if (guestOS == null) { String description = cmd.getDisplayText();
@Override public void execute() { CallContext.current().setEventDetails( "Template Id: " + getEntityUuid() + ((getSnapshotId() == null) ? " from volume Id: " + this._uuidMgr.getUuid(Volume.class, getVolumeId()) : " from snapshot Id: " + this._uuidMgr.getUuid(Snapshot.class, getSnapshotId()))); VirtualMachineTemplate template = null; template = _templateService.createPrivateTemplate(this); if (template != null) { List<TemplateResponse> templateResponses; if (isBareMetal()) { templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template.getId(), vmId); } else { templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template.getId(), snapshotId, volumeId, false); } TemplateResponse response = new TemplateResponse(); if (templateResponses != null && !templateResponses.isEmpty()) { response = templateResponses.get(0); } response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private template"); } } }
@ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_CREATE, eventDescription = "creating template", async = true) public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) throws CloudRuntimeException { final long templateId = command.getEntityId(); Long volumeId = command.getVolumeId(); Long snapshotId = command.getSnapshotId(); VMTemplateVO privateTemplate = null; final Long accountId = CallContext.current().getCallingAccountId();
@Override public long getEntityOwnerId() { Long volumeId = getVolumeId(); Long snapshotId = getSnapshotId(); Account callingAccount = CallContext.current().getCallingAccount(); if (volumeId != null) {