cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cloudstack] Spaceman1984 commented on a change in pull request #3748: Systemvm template api (WIP)
Date Fri, 13 Dec 2019 14:55:09 GMT
Spaceman1984 commented on a change in pull request #3748: Systemvm template api (WIP)
URL: https://github.com/apache/cloudstack/pull/3748#discussion_r357682611
 
 

 ##########
 File path: server/src/main/java/com/cloud/template/TemplateAdapterBase.java
 ##########
 @@ -316,19 +327,31 @@ private TemplateProfile prepareUploadParamsInternal(UploadParams params)
throws
                 params.isExtractable(), params.getFormat(), params.getGuestOSId(), zoneList,
                 params.getHypervisorType(), params.getChecksum(), params.isBootable(), params.getTemplateTag(),
owner,
                 params.getDetails(), params.isSshKeyEnabled(), params.getImageStoreUuid(),
-                params.isDynamicallyScalable(), params.isRoutingType() ? TemplateType.ROUTING
: TemplateType.USER, params.isDirectDownload());
+                params.isDynamicallyScalable(), params.isRoutingType() ? TemplateType.ROUTING
: TemplateType.valueOf(params.getType()), params.isDirectDownload());
     }
 
     @Override
     public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException
{
-        UploadParams params = new TemplateUploadParams(CallContext.current().getCallingUserId(),
cmd.getName(),
+        String templateType = TemplateType.USER.toString();
+        long userId = CallContext.current().getCallingUserId();
+        long entityOwnerId = cmd.getEntityOwnerId();
+        if (cmd.getSystem() != null && cmd.getSystem()){
+            templateType = TemplateType.SYSTEM.toString();
+            userId = 1L; //System account;
+            entityOwnerId = 1L;
+        }
+        UploadParams params = new TemplateUploadParams(userId, cmd.getName(),
                 cmd.getDisplayText(), cmd.getBits(), BooleanUtils.toBoolean(cmd.isPasswordEnabled()),
                 BooleanUtils.toBoolean(cmd.getRequiresHvm()), BooleanUtils.toBoolean(cmd.isPublic()),
                 BooleanUtils.toBoolean(cmd.isFeatured()), BooleanUtils.toBoolean(cmd.isExtractable()),
cmd.getFormat(), cmd.getOsTypeId(),
                 cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()), cmd.getChecksum(),
-                cmd.getTemplateTag(), cmd.getEntityOwnerId(), cmd.getDetails(), BooleanUtils.toBoolean(cmd.isSshKeyEnabled()),
-                BooleanUtils.toBoolean(cmd.isDynamicallyScalable()), BooleanUtils.toBoolean(cmd.isRoutingType()));
-        return prepareUploadParamsInternal(params);
+                cmd.getTemplateTag(), entityOwnerId, cmd.getDetails(), BooleanUtils.toBoolean(cmd.isSshKeyEnabled()),
+                BooleanUtils.toBoolean(cmd.isDynamicallyScalable()), BooleanUtils.toBoolean(cmd.isRoutingType()),
templateType, cmd.getActivate());
+        TemplateProfile profile = prepareUploadParamsInternal(params);
+        if (cmd.getActivate()) {
+            profile.setActivateAfterUpload(cmd.getActivate());
+        }
 
 Review comment:
   Have to store in the db here because a different process is going to do the activation.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message