mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-2835: VR Deployement from admin registered template is failing because registered template type is user. Additional parameter "isrouter" in register/update template API for the root admin. True if registered template is of type ROUTING.
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
This commit is contained in:
parent
0d1f512728
commit
9385cf0453
|
|
@ -85,6 +85,7 @@ public class Storage {
|
|||
}
|
||||
|
||||
public static enum TemplateType {
|
||||
ROUTING, // Router template
|
||||
SYSTEM, /* routing, system vm template */
|
||||
BUILTIN, /* buildin template */
|
||||
PERHOST, /* every host has this template, don't need to install it in secondary storage */
|
||||
|
|
|
|||
|
|
@ -511,6 +511,7 @@ public class ApiConstants {
|
|||
public static final String ACL_ID = "aclid";
|
||||
public static final String NUMBER = "number";
|
||||
public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
|
||||
public static final String ROUTING = "isrouting";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template/ISO contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
|
||||
private Boolean isDynamicallyScalable;
|
||||
|
||||
@Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true if the template type is routing i.e., if template is used to deploy router")
|
||||
protected Boolean isRoutingType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -96,4 +99,8 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
|
|||
public Boolean isDynamicallyScalable() {
|
||||
return isDynamicallyScalable;
|
||||
}
|
||||
|
||||
public Boolean isRoutingType() {
|
||||
return isRoutingType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ public class RegisterTemplateCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, type = CommandType.BOOLEAN, description = "true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory")
|
||||
protected Boolean isDynamicallyScalable;
|
||||
|
||||
@Parameter(name = ApiConstants.ROUTING, type = CommandType.BOOLEAN, description = "true if the template type is routing i.e., if template is used to deploy router")
|
||||
protected Boolean isRoutingType;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -208,6 +211,10 @@ public class RegisterTemplateCmd extends BaseCmd {
|
|||
return isDynamicallyScalable == null ? false : isDynamicallyScalable;
|
||||
}
|
||||
|
||||
public Boolean isRoutingType() {
|
||||
return isRoutingType == null ? false : isRoutingType;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd {
|
|||
if (result != null) {
|
||||
TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(result);
|
||||
response.setObjectName("template");
|
||||
response.setTemplateType(result.getTemplateType().toString());//Template can be either USER or ROUTING type
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -790,7 +790,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
@Override
|
||||
public VMTemplateVO findRoutingTemplate(HypervisorType hType, String templateName) {
|
||||
SearchCriteria<VMTemplateVO> sc = tmpltTypeHyperSearch2.create();
|
||||
sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
|
||||
sc.setParameters("templateType", TemplateType.ROUTING);
|
||||
sc.setParameters("hypervisorType", hType);
|
||||
if (templateName != null) {
|
||||
sc.setParameters("templateName", templateName);
|
||||
|
|
@ -803,7 +803,22 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||
if (tmplts.size() > 0) {
|
||||
return tmplts.get(0);
|
||||
} else {
|
||||
return null;
|
||||
sc = tmpltTypeHyperSearch2.create();
|
||||
sc.setParameters("templateType", TemplateType.SYSTEM);
|
||||
sc.setParameters("hypervisorType", hType);
|
||||
if (templateName != null) {
|
||||
sc.setParameters("templateName", templateName);
|
||||
}
|
||||
|
||||
// order by descending order of id and select the first (this is going
|
||||
// to be the latest)
|
||||
tmplts = listBy(sc, new Filter(VMTemplateVO.class, "id", false, null, 1l));
|
||||
|
||||
if (tmplts.size() > 0) {
|
||||
return tmplts.get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
s_logger.debug("Updating XenSever System Vms");
|
||||
//XenServer
|
||||
try {
|
||||
//Get 4.2.0 xenserer system Vm template Id
|
||||
//Get 4.2.0 XenServer system Vm template Id
|
||||
pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-xenserver-4.2' and removed is null order by id desc limit 1");
|
||||
rs = pstmt.executeQuery();
|
||||
if(rs.next()){
|
||||
|
|
@ -180,6 +180,10 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
// Change value of global configuration parameter router.template.xen
|
||||
pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.xen', 'systemvm-xenserver-4.2', 'Name of the default router template on Xenserver')");
|
||||
pstmt.execute();
|
||||
pstmt.close();
|
||||
} else {
|
||||
if (xenserver){
|
||||
throw new CloudRuntimeException("4.2.0 XenServer SystemVm template not found. Cannot upgrade system Vms");
|
||||
|
|
@ -209,7 +213,11 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
// update templete ID of system Vms
|
||||
pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = 'KVM'");
|
||||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.execute();
|
||||
pstmt.close();
|
||||
// Change value of global configuration parameter router.template.kvm
|
||||
pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.kvm', 'systemvm-kvm-4.2', 'Name of the default router template on KVM')");
|
||||
pstmt.execute();
|
||||
pstmt.close();
|
||||
} else {
|
||||
if (kvm){
|
||||
|
|
@ -242,6 +250,10 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
// Change value of global configuration parameter router.template.vmware
|
||||
pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.vmware', 'systemvm-vmware-4.2', 'Name of the default router template on Vmware')");
|
||||
pstmt.execute();
|
||||
pstmt.close();
|
||||
} else {
|
||||
if (VMware){
|
||||
throw new CloudRuntimeException("4.2.0 VMware SystemVm template not found. Cannot upgrade system Vms");
|
||||
|
|
@ -273,6 +285,10 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
// Change value of global configuration parameter router.template.hyperv
|
||||
pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.hyperv', 'systemvm-hyperv-4.2', 'Name of the default router template on Hyperv')");
|
||||
pstmt.execute();
|
||||
pstmt.close();
|
||||
} else {
|
||||
if (Hyperv){
|
||||
throw new CloudRuntimeException("4.2.0 HyperV SystemVm template not found. Cannot upgrade system Vms");
|
||||
|
|
@ -304,6 +320,10 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||
pstmt.setLong(1, templateId);
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
// Change value of global configuration parameter router.template.lxc
|
||||
pstmt = conn.prepareStatement("INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'router.template.lxc', 'systemvm-lxc-4.2', 'Name of the default router template on LXC')");
|
||||
pstmt.execute();
|
||||
pstmt.close();
|
||||
} else {
|
||||
if (LXC){
|
||||
throw new CloudRuntimeException("4.2.0 LXC SystemVm template not found. Cannot upgrade system Vms");
|
||||
|
|
|
|||
|
|
@ -486,6 +486,7 @@ import com.cloud.storage.GuestOsCategory;
|
|||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeManager;
|
||||
|
|
@ -506,6 +507,7 @@ import com.cloud.tags.dao.ResourceTagDao;
|
|||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountService;
|
||||
import com.cloud.user.SSHKeyPair;
|
||||
import com.cloud.user.SSHKeyPairVO;
|
||||
import com.cloud.user.User;
|
||||
|
|
@ -679,6 +681,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
UserVmManager _userVmMgr;
|
||||
@Inject
|
||||
VolumeDataFactory _volFactory;
|
||||
@Inject
|
||||
AccountService _accountService;
|
||||
|
||||
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
|
||||
private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AlertChecker"));
|
||||
|
|
@ -1732,6 +1736,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
Boolean bootable = cmd.isBootable();
|
||||
Integer sortKey = cmd.getSortKey();
|
||||
Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
|
||||
Boolean isRoutingTemplate = cmd.isRoutingType();
|
||||
Account account = UserContext.current().getCaller();
|
||||
|
||||
// verify that template exists
|
||||
|
|
@ -1752,8 +1757,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
// do a permission check
|
||||
_accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
|
||||
|
||||
if(cmd.isRoutingType() != null){
|
||||
if(!_accountService.isRootAdmin(account.getType())){
|
||||
throw new PermissionDeniedException("Parameter isrouting can only be specified by a Root Admin, permission denied");
|
||||
}
|
||||
}
|
||||
boolean updateNeeded = !(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null
|
||||
&& bootable == null && sortKey == null && isDynamicallyScalable == null);
|
||||
&& bootable == null && sortKey == null && isDynamicallyScalable == null && isRoutingTemplate == null);
|
||||
if (!updateNeeded) {
|
||||
return template;
|
||||
}
|
||||
|
|
@ -1806,6 +1816,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
template.setDynamicallyScalable(isDynamicallyScalable);
|
||||
}
|
||||
|
||||
if (isRoutingTemplate != null) {
|
||||
if (isRoutingTemplate) {
|
||||
template.setTemplateType(TemplateType.ROUTING);
|
||||
} else {
|
||||
template.setTemplateType(TemplateType.USER);
|
||||
}
|
||||
}
|
||||
|
||||
_templateDao.update(id, template);
|
||||
|
||||
return _templateDao.findById(id);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
|
||||
public class TemplateProfile {
|
||||
Long userId;
|
||||
|
|
@ -47,6 +48,7 @@ public class TemplateProfile {
|
|||
String templateTag;
|
||||
Map details;
|
||||
Boolean isDynamicallyScalable;
|
||||
TemplateType templateType;
|
||||
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
|
|
@ -86,11 +88,12 @@ public class TemplateProfile {
|
|||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled,
|
||||
Long imageStoreId, Boolean isDynamicallyScalable) {
|
||||
Long imageStoreId, Boolean isDynamicallyScalable, TemplateType templateType) {
|
||||
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
|
||||
hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
|
||||
this.templateTag = templateTag;
|
||||
this.isDynamicallyScalable = isDynamicallyScalable;
|
||||
this.templateType = templateType;
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
|
|
@ -265,4 +268,11 @@ public class TemplateProfile {
|
|||
this.isDynamicallyScalable = isDynamicallyScalabe;
|
||||
}
|
||||
|
||||
public TemplateType getTemplateType() {
|
||||
return templateType;
|
||||
}
|
||||
|
||||
public void setTemplateType(TemplateType templateType) {
|
||||
this.templateType = templateType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.TemplateProfile;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
|
||||
|
|
@ -69,6 +70,7 @@ public interface TemplateAdapter extends Adapter {
|
|||
public TemplateProfile prepare(boolean isIso, long userId, String name, String displayText, Integer bits,
|
||||
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
|
||||
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled, String imageStoreUuid, Boolean isDynamicallyScalable) throws ResourceAllocationException;
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled,
|
||||
String imageStoreUuid, Boolean isDynamicallyScalable, TemplateType templateType) throws ResourceAllocationException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
|||
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
|
||||
String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException {
|
||||
return prepare(isIso, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, format, guestOSId, zoneId, hypervisorType,
|
||||
chksum, bootable, null, null, details, false, null, false);
|
||||
chksum, bootable, null, null, details, false, null, false, TemplateType.USER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -114,7 +114,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
|||
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
|
||||
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled,
|
||||
String imageStoreUuid, Boolean isDynamicallyScalable) throws ResourceAllocationException {
|
||||
String imageStoreUuid, Boolean isDynamicallyScalable, TemplateType templateType) throws ResourceAllocationException {
|
||||
//Long accountId = null;
|
||||
// parameters verification
|
||||
|
||||
|
|
@ -214,8 +214,9 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
|||
|
||||
Long id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
UserContext.current().setEventDetails("Id: " +id+ " name: " + name);
|
||||
return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
|
||||
featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, null, isDynamicallyScalable);
|
||||
return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
|
||||
featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(),
|
||||
templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled, null, isDynamicallyScalable, templateType);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -228,10 +229,11 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
|||
|
||||
|
||||
|
||||
return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
|
||||
cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
|
||||
cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
|
||||
cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null, cmd.isDynamicallyScalable());
|
||||
return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
|
||||
cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
|
||||
cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
|
||||
cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null, cmd.isDynamicallyScalable(),
|
||||
cmd.isRoutingType() ? TemplateType.ROUTING : TemplateType.USER);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -242,15 +244,16 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
|
|||
Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
|
||||
_accountMgr.checkAccess(caller, null, true, owner);
|
||||
|
||||
return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
|
||||
true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
|
||||
cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false, cmd.getImageStoreUuid(), cmd.isDynamicallyScalable());
|
||||
return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
|
||||
true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
|
||||
cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false, cmd.getImageStoreUuid(), cmd.isDynamicallyScalable(),
|
||||
TemplateType.USER);
|
||||
}
|
||||
|
||||
protected VMTemplateVO persistTemplate(TemplateProfile profile) {
|
||||
Long zoneId = profile.getZoneId();
|
||||
VMTemplateVO template = new VMTemplateVO(profile.getTemplateId(), profile.getName(), profile.getFormat(), profile.getIsPublic(),
|
||||
profile.getFeatured(), profile.getIsExtractable(), TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(),
|
||||
profile.getFeatured(), profile.getIsExtractable(), profile.getTemplateType(), profile.getUrl(), profile.getRequiresHVM(),
|
||||
profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
|
||||
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(),
|
||||
profile.getDetails(), profile.getSshKeyEnabled());
|
||||
|
|
|
|||
|
|
@ -347,12 +347,17 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_CREATE, eventDescription = "creating template")
|
||||
public VirtualMachineTemplate registerTemplate(RegisterTemplateCmd cmd) throws URISyntaxException, ResourceAllocationException {
|
||||
Account account = UserContext.current().getCaller();
|
||||
if (cmd.getTemplateTag() != null) {
|
||||
Account account = UserContext.current().getCaller();
|
||||
if (!_accountService.isRootAdmin(account.getType())) {
|
||||
throw new PermissionDeniedException("Parameter templatetag can only be specified by a Root Admin, permission denied");
|
||||
}
|
||||
}
|
||||
if(cmd.isRoutingType() != null){
|
||||
if(!_accountService.isRootAdmin(account.getType())){
|
||||
throw new PermissionDeniedException("Parameter isrouting can only be specified by a Root Admin, permission denied");
|
||||
}
|
||||
}
|
||||
|
||||
TemplateAdapter adapter = getAdapter(HypervisorType.getType(cmd.getHypervisor()));
|
||||
TemplateProfile profile = adapter.prepare(cmd);
|
||||
|
|
|
|||
Loading…
Reference in New Issue