vmware: Fix deploy-as-is not honoured on upload from local (#5015)

* Fix deploy-as-is not honoured on upload from local

* Missing param
This commit is contained in:
Nicolas Vazquez 2021-05-13 06:00:34 -03:00 committed by GitHub
parent 4ecef4bfb4
commit aa289542f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View File

@ -89,6 +89,11 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
@Parameter(name = ApiConstants.TEMPLATE_TAG, type = CommandType.STRING, description = "the tag for this template.") @Parameter(name = ApiConstants.TEMPLATE_TAG, type = CommandType.STRING, description = "the tag for this template.")
private String templateTag; private String templateTag;
@Parameter(name=ApiConstants.DEPLOY_AS_IS,
type = CommandType.BOOLEAN,
description = "(VMware only) true if VM deployments should preserve all the configurations defined for this template", since = "4.15.1")
private Boolean deployAsIs;
public String getDisplayText() { public String getDisplayText() {
return displayText; return displayText;
} }
@ -153,6 +158,11 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
return templateTag; return templateTag;
} }
public boolean isDeployAsIs() {
return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor) &&
Boolean.TRUE.equals(deployAsIs);
}
@Override @Override
public void execute() throws ServerApiException { public void execute() throws ServerApiException {
validateRequest(); validateRequest();

View File

@ -29,10 +29,10 @@ public class TemplateUploadParams extends UploadParamsBase {
Long zoneId, Hypervisor.HypervisorType hypervisorType, String chksum, Long zoneId, Hypervisor.HypervisorType hypervisorType, String chksum,
String templateTag, long templateOwnerId, String templateTag, long templateOwnerId,
Map details, Boolean sshkeyEnabled, Map details, Boolean sshkeyEnabled,
Boolean isDynamicallyScalable, Boolean isRoutingType) { Boolean isDynamicallyScalable, Boolean isRoutingType, boolean deployAsIs) {
super(userId, name, displayText, bits, passwordEnabled, requiresHVM, isPublic, featured, isExtractable, super(userId, name, displayText, bits, passwordEnabled, requiresHVM, isPublic, featured, isExtractable,
format, guestOSId, zoneId, hypervisorType, chksum, templateTag, templateOwnerId, details, format, guestOSId, zoneId, hypervisorType, chksum, templateTag, templateOwnerId, details,
sshkeyEnabled, isDynamicallyScalable, isRoutingType); sshkeyEnabled, isDynamicallyScalable, isRoutingType, deployAsIs);
setBootable(true); setBootable(true);
} }
} }

View File

@ -44,6 +44,7 @@ public abstract class UploadParamsBase implements UploadParams {
private boolean sshkeyEnabled; private boolean sshkeyEnabled;
private boolean isDynamicallyScalable; private boolean isDynamicallyScalable;
private boolean isRoutingType; private boolean isRoutingType;
private boolean deployAsIs;
UploadParamsBase(long userId, String name, String displayText, UploadParamsBase(long userId, String name, String displayText,
Integer bits, boolean passwordEnabled, boolean requiresHVM, Integer bits, boolean passwordEnabled, boolean requiresHVM,
@ -52,7 +53,7 @@ public abstract class UploadParamsBase implements UploadParams {
Long zoneId, Hypervisor.HypervisorType hypervisorType, String checksum, Long zoneId, Hypervisor.HypervisorType hypervisorType, String checksum,
String templateTag, long templateOwnerId, String templateTag, long templateOwnerId,
Map details, boolean sshkeyEnabled, Map details, boolean sshkeyEnabled,
boolean isDynamicallyScalable, boolean isRoutingType) { boolean isDynamicallyScalable, boolean isRoutingType, boolean deployAsIs) {
this.userId = userId; this.userId = userId;
this.name = name; this.name = name;
this.displayText = displayText; this.displayText = displayText;
@ -73,6 +74,7 @@ public abstract class UploadParamsBase implements UploadParams {
this.sshkeyEnabled = sshkeyEnabled; this.sshkeyEnabled = sshkeyEnabled;
this.isDynamicallyScalable = isDynamicallyScalable; this.isDynamicallyScalable = isDynamicallyScalable;
this.isRoutingType = isRoutingType; this.isRoutingType = isRoutingType;
this.deployAsIs = deployAsIs;
} }
UploadParamsBase(long userId, String name, String displayText, boolean isPublic, boolean isFeatured, UploadParamsBase(long userId, String name, String displayText, boolean isPublic, boolean isFeatured,
@ -216,7 +218,7 @@ public abstract class UploadParamsBase implements UploadParams {
@Override @Override
public boolean isDeployAsIs() { public boolean isDeployAsIs() {
return false; return deployAsIs;
} }
void setIso(boolean iso) { void setIso(boolean iso) {

View File

@ -337,7 +337,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
params.isExtractable(), params.getFormat(), params.getGuestOSId(), zoneList, params.isExtractable(), params.getFormat(), params.getGuestOSId(), zoneList,
params.getHypervisorType(), params.getChecksum(), params.isBootable(), params.getTemplateTag(), owner, params.getHypervisorType(), params.getChecksum(), params.isBootable(), params.getTemplateTag(), owner,
params.getDetails(), params.isSshKeyEnabled(), params.getImageStoreUuid(), params.getDetails(), params.isSshKeyEnabled(), params.getImageStoreUuid(),
params.isDynamicallyScalable(), params.isRoutingType() ? TemplateType.ROUTING : TemplateType.USER, params.isDirectDownload(), false); params.isDynamicallyScalable(), params.isRoutingType() ? TemplateType.ROUTING : TemplateType.USER, params.isDirectDownload(), params.isDeployAsIs());
} }
private Long getDefaultDeployAsIsGuestOsId() { private Long getDefaultDeployAsIsGuestOsId() {
@ -358,7 +358,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
BooleanUtils.toBoolean(cmd.isFeatured()), BooleanUtils.toBoolean(cmd.isExtractable()), cmd.getFormat(), osTypeId, BooleanUtils.toBoolean(cmd.isFeatured()), BooleanUtils.toBoolean(cmd.isExtractable()), cmd.getFormat(), osTypeId,
cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()), cmd.getChecksum(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()), cmd.getChecksum(),
cmd.getTemplateTag(), cmd.getEntityOwnerId(), cmd.getDetails(), BooleanUtils.toBoolean(cmd.isSshKeyEnabled()), cmd.getTemplateTag(), cmd.getEntityOwnerId(), cmd.getDetails(), BooleanUtils.toBoolean(cmd.isSshKeyEnabled()),
BooleanUtils.toBoolean(cmd.isDynamicallyScalable()), BooleanUtils.toBoolean(cmd.isRoutingType())); BooleanUtils.toBoolean(cmd.isDynamicallyScalable()), BooleanUtils.toBoolean(cmd.isRoutingType()), cmd.isDeployAsIs());
return prepareUploadParamsInternal(params); return prepareUploadParamsInternal(params);
} }