diff --git a/api/src/main/java/com/cloud/network/as/AutoScaleVmProfile.java b/api/src/main/java/com/cloud/network/as/AutoScaleVmProfile.java index 68d18a0edc91..afeba0bd7498 100644 --- a/api/src/main/java/com/cloud/network/as/AutoScaleVmProfile.java +++ b/api/src/main/java/com/cloud/network/as/AutoScaleVmProfile.java @@ -35,10 +35,6 @@ public interface AutoScaleVmProfile extends ControlledEntity, InternalIdentity, String getUserData(); - Long getUserDataId(); - - String getUserDataDetails(); - public String getUuid(); public Long getZoneId(); diff --git a/api/src/main/java/org/apache/cloudstack/api/BaseCmd.java b/api/src/main/java/org/apache/cloudstack/api/BaseCmd.java index 79e103a291dc..e431f63557cf 100644 --- a/api/src/main/java/org/apache/cloudstack/api/BaseCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/BaseCmd.java @@ -21,10 +21,8 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -44,7 +42,6 @@ import org.apache.cloudstack.query.QueryService; import org.apache.cloudstack.storage.ImageStoreService; import org.apache.cloudstack.usage.UsageService; -import org.apache.commons.collections.MapUtils; import org.apache.log4j.Logger; import com.cloud.configuration.ConfigurationService; @@ -459,18 +456,4 @@ public ApiCommandResourceType getApiResourceType() { return ApiCommandResourceType.None; } - public Map convertDetailsToMap(Map details) { - Map detailsMap = new HashMap(); - if (MapUtils.isNotEmpty(details)) { - Collection parameterCollection = details.values(); - Iterator iter = parameterCollection.iterator(); - while (iter.hasNext()) { - HashMap value = (HashMap)iter.next(); - for (Map.Entry entry: value.entrySet()) { - detailsMap.put(entry.getKey(),entry.getValue()); - } - } - } - return detailsMap; - } } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java index 76ad4d438d28..1381f6705276 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java @@ -51,7 +51,7 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the internal lb vm") private Long id; - @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.") + @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.") private Boolean forced; // /////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java index 2da38d904264..b9e156612686 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java @@ -49,7 +49,7 @@ public class StopRouterCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the router") private Long id; - @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.") + @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.") private Boolean forced; // /////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java index 4bb533ce5b6a..755c8e462056 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java @@ -54,7 +54,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd { description = "The ID of the system virtual machine") private Long id; - @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.") + @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.") private Boolean forced; ///////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java index db6ccd9ce53c..ba7149ea3d8f 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java @@ -35,7 +35,6 @@ import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.TemplateResponse; -import org.apache.cloudstack.api.response.UserDataResponse; import org.apache.cloudstack.api.response.UserResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; @@ -108,12 +107,6 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { since = "4.18.0") private String userData; - @Parameter(name = ApiConstants.USER_DATA_ID, type = CommandType.UUID, entityType = UserDataResponse.class, description = "the ID of the Userdata", since = "4.18.1") - private Long userDataId; - - @Parameter(name = ApiConstants.USER_DATA_DETAILS, type = CommandType.MAP, description = "used to specify the parameters values for the variables in userdata.", since = "4.18.1") - private Map userDataDetails; - @Parameter(name = ApiConstants.AUTOSCALE_USER_ID, type = CommandType.UUID, entityType = UserResponse.class, @@ -170,14 +163,6 @@ public String getUserData() { return userData; } - public Long getUserDataId() { - return userDataId; - } - - public Map getUserDataDetails() { - return convertDetailsToMap(userDataDetails); - } - public Long getAutoscaleUserId() { return autoscaleUserId; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java index 3e65d38e5201..c0b385932a98 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java @@ -35,7 +35,6 @@ import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.TemplateResponse; -import org.apache.cloudstack.api.response.UserDataResponse; import org.apache.cloudstack.api.response.UserResponse; import org.apache.cloudstack.context.CallContext; @@ -103,14 +102,6 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd { since = "4.18.0") private String userData; - @Parameter(name = ApiConstants.USER_DATA_ID, type = CommandType.UUID, entityType = UserDataResponse.class, description = "the ID of the userdata", - since = "4.18.1") - private Long userDataId; - - @Parameter(name = ApiConstants.USER_DATA_DETAILS, type = CommandType.MAP, description = "used to specify the parameters values for the variables in userdata.", - since = "4.18.1") - private Map userDataDetails; - @Parameter(name = ApiConstants.AUTOSCALE_USER_ID, type = CommandType.UUID, entityType = UserResponse.class, @@ -165,14 +156,6 @@ public String getUserData() { return userData; } - public Long getUserDataId() { - return userDataId; - } - - public Map getUserDataDetails() { - return convertDetailsToMap(userDataDetails); - } - public Long getAutoscaleUserId() { return autoscaleUserId; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java index ca379fb1596f..2315999124ac 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java @@ -118,9 +118,7 @@ public class CreateNetworkCmd extends BaseCmd implements UserCmd { private Long projectId; @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "domain ID of the account owning a network. " + - "If the account is not specified, but the acltype is Account or not specified, the network will be automatically assigned to the caller account and domain. " + - "To create a network under the domain without linking it to any account, make sure to include acltype=Domain parameter in the api call. " + - "If account is not specified, but acltype is Domain, the network will be created for the specified domain.") + "If no account is provided then network will be assigned to the caller account and domain") private Long domainId; @Parameter(name = ApiConstants.SUBDOMAIN_ACCESS, diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java index 56e112963a95..aee72b3dbae5 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java @@ -62,7 +62,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, - description = "The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume. If account is NOT provided then snapshot will be assigned to the caller account and domain.") + description = "The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume.") private Long domainId; @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class, required = true, description = "The ID of the disk volume") diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index 684c2e630148..bd050b154d2b 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -109,7 +109,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional account for the virtual machine. Must be used with domainId.") private String accountName; - @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used. If account is NOT provided then virtual machine will be assigned to the caller account and domain.") + @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used.") private Long domainId; //Network information @@ -317,8 +317,17 @@ public ApiConstants.BootType getBootType() { } public Map getDetails() { - Map customparameterMap = convertDetailsToMap(details); - + Map customparameterMap = new HashMap(); + if (details != null && details.size() != 0) { + Collection parameterCollection = details.values(); + Iterator iter = parameterCollection.iterator(); + while (iter.hasNext()) { + HashMap value = (HashMap)iter.next(); + for (Map.Entry entry: value.entrySet()) { + customparameterMap.put(entry.getKey(),entry.getValue()); + } + } + } if (getBootType() != null) { customparameterMap.put(getBootType().toString(), getBootMode().toString()); } @@ -457,7 +466,18 @@ public Long getUserdataId() { } public Map getUserdataDetails() { - return convertDetailsToMap(userdataDetails); + Map userdataDetailsMap = new HashMap(); + if (userdataDetails != null && userdataDetails.size() != 0) { + Collection parameterCollection = userdataDetails.values(); + Iterator iter = parameterCollection.iterator(); + while (iter.hasNext()) { + HashMap value = (HashMap)iter.next(); + for (Map.Entry entry: value.entrySet()) { + userdataDetailsMap.put(entry.getKey(),entry.getValue()); + } + } + } + return userdataDetailsMap; } public Long getZoneId() { diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ResetVMUserDataCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ResetVMUserDataCmd.java index 3ead67e21064..ad0592ca4ac6 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ResetVMUserDataCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ResetVMUserDataCmd.java @@ -39,6 +39,9 @@ import org.apache.cloudstack.context.CallContext; import org.apache.log4j.Logger; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.Map; @APICommand(name = "resetUserDataForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the UserData for virtual machine. " + @@ -114,7 +117,18 @@ public Long getUserdataId() { } public Map getUserdataDetails() { - return convertDetailsToMap(userdataDetails); + Map userdataDetailsMap = new HashMap(); + if (userdataDetails != null && userdataDetails.size() != 0) { + Collection parameterCollection = userdataDetails.values(); + Iterator iter = parameterCollection.iterator(); + while (iter.hasNext()) { + HashMap value = (HashMap)iter.next(); + for (Map.Entry entry: value.entrySet()) { + userdataDetailsMap.put(entry.getKey(),entry.getValue()); + } + } + } + return userdataDetailsMap; } @Override diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java index 5af45762ece6..e60bce2810ab 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java @@ -16,6 +16,9 @@ // under the License. package org.apache.cloudstack.api.command.user.vm; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -96,7 +99,17 @@ public Long getServiceOfferingId() { //it is because details.values() cannot be cast to a map. //it gives a exception public Map getDetails() { - Map customparameterMap = convertDetailsToMap(details); + Map customparameterMap = new HashMap(); + if (details != null && details.size() != 0) { + Collection parameterCollection = details.values(); + Iterator iter = parameterCollection.iterator(); + while (iter.hasNext()) { + HashMap value = (HashMap)iter.next(); + for (String key : value.keySet()) { + customparameterMap.put(key, value.get(key)); + } + } + } if (shrinkOk != null) customparameterMap.put(ApiConstants.SHRINK_OK, String.valueOf(isShrinkOk())); if (autoMigrate != null) customparameterMap.put(ApiConstants.AUTO_MIGRATE, String.valueOf(getAutoMigrate())); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java index 113ba9ed25db..529e09a0753a 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java @@ -55,8 +55,7 @@ public class StopVMCmd extends BaseAsyncCmd implements UserCmd { private Long id; @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM " - + "(vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted)." - + " This option is to be used if the caller knows the VM is stopped and should be marked as such.") + + "(vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). The caller knows the VM is stopped.") private Boolean forced; // /////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java index 32ce1f6db524..3e0ef75ecddd 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -175,7 +176,18 @@ public Long getUserdataId() { } public Map getUserdataDetails() { - return convertDetailsToMap(userdataDetails); + Map userdataDetailsMap = new HashMap(); + if (userdataDetails != null && userdataDetails.size() != 0) { + Collection parameterCollection = userdataDetails.values(); + Iterator iter = parameterCollection.iterator(); + while (iter.hasNext()) { + HashMap value = (HashMap)iter.next(); + for (Map.Entry entry: value.entrySet()) { + userdataDetailsMap.put(entry.getKey(),entry.getValue()); + } + } + } + return userdataDetailsMap; } public Boolean getDisplayVm() { diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java index 4b31c12ec0a3..b6acd71b4c4f 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java @@ -16,6 +16,9 @@ // under the License. package org.apache.cloudstack.api.command.user.vm; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; @@ -92,7 +95,17 @@ public Long getServiceOfferingId() { } public Map getDetails() { - Map customparameterMap = convertDetailsToMap(details); + Map customparameterMap = new HashMap(); + if (details != null && details.size() != 0) { + Collection parameterCollection = details.values(); + Iterator iter = parameterCollection.iterator(); + while (iter.hasNext()) { + HashMap value = (HashMap)iter.next(); + for (String key : value.keySet()) { + customparameterMap.put(key, value.get(key)); + } + } + } if (shrinkOk != null) customparameterMap.put(ApiConstants.SHRINK_OK, String.valueOf(isShrinkOk())); if (autoMigrate != null) customparameterMap.put(ApiConstants.AUTO_MIGRATE, String.valueOf(getAutoMigrate())); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java index 566e8a46bd94..3426a95686d7 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java @@ -70,8 +70,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd implements UserC type = CommandType.UUID, entityType = DomainResponse.class, description = "the domain ID associated with the disk offering. If used with the account parameter" - + " returns the disk volume associated with the account for the specified domain." + - "If account is NOT provided then the volume will be assigned to the caller account and domain.") + + " returns the disk volume associated with the account for the specified domain.") private Long domainId; @Parameter(name = ApiConstants.DISK_OFFERING_ID, diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java index c622081079d8..b40761d123a8 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java @@ -78,7 +78,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd implements UserCmd { @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, - description = "an optional domainId. If the account parameter is used, domainId must also be used. If account is NOT provided then volume will be assigned to the caller account and domain.") + description = "an optional domainId. If the account parameter is used, domainId must also be used.") private Long domainId; @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional accountName. Must be used with domainId.") diff --git a/api/src/main/java/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java index 9f2383447301..66d7296f406b 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java @@ -72,18 +72,6 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll @Param(description = "Base 64 encoded VM user data") private String userData; - @SerializedName(ApiConstants.USER_DATA_ID) @Param(description="the id of userdata used for the VM", since = "4.18.1") - private String userDataId; - - @SerializedName(ApiConstants.USER_DATA_NAME) @Param(description="the name of userdata used for the VM", since = "4.18.1") - private String userDataName; - - @SerializedName(ApiConstants.USER_DATA_POLICY) @Param(description="the userdata override policy with the userdata provided while deploying VM", since = "4.18.1") - private String userDataPolicy; - - @SerializedName(ApiConstants.USER_DATA_DETAILS) @Param(description="list of variables and values for the variables declared in userdata", since = "4.18.1") - private String userDataDetails; - @SerializedName(ApiConstants.AUTOSCALE_USER_ID) @Param(description = "the ID of the user used to launch and destroy the VMs") private String autoscaleUserId; @@ -165,22 +153,6 @@ public void setUserData(String userData) { this.userData = userData; } - public void setUserDataId(String userDataId) { - this.userDataId = userDataId; - } - - public void setUserDataName(String userDataName) { - this.userDataName = userDataName; - } - - public void setUserDataPolicy(String userDataPolicy) { - this.userDataPolicy = userDataPolicy; - } - - public void setUserDataDetails(String userDataDetails) { - this.userDataDetails = userDataDetails; - } - @Override public void setAccountName(String accountName) { this.accountName = accountName; @@ -221,24 +193,4 @@ public void setCsUrl(String csUrl) { public void setForDisplay(Boolean forDisplay) { this.forDisplay = forDisplay; } - - public String getUserData() { - return userData; - } - - public String getUserDataId() { - return userDataId; - } - - public String getUserDataName() { - return userDataName; - } - - public String getUserDataPolicy() { - return userDataPolicy; - } - - public String getUserDataDetails() { - return userDataDetails; - } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java index 114403da7bcb..f2903b2626c8 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java @@ -103,7 +103,7 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co private String group; @SerializedName(ApiConstants.ZONE_ID) - @Param(description = "the ID of the availability zone for the virtual machine") + @Param(description = "the ID of the availablility zone for the virtual machine") private String zoneId; @SerializedName(ApiConstants.ZONE_NAME) diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index 52bcf5033af4..f7c8c9c70bf5 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -123,7 +123,6 @@ import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePool; -import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.StorageUtil; import com.cloud.storage.VMTemplateStorageResourceAssoc; import com.cloud.storage.Volume; @@ -132,7 +131,6 @@ import com.cloud.storage.VolumeDetailVO; import com.cloud.storage.VolumeVO; import com.cloud.storage.dao.SnapshotDao; -import com.cloud.storage.dao.StoragePoolHostDao; import com.cloud.storage.dao.VMTemplateDetailsDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDetailsDao; @@ -245,8 +243,6 @@ public enum UserVmCloneType { VolumeApiService _volumeApiService; @Inject PassphraseDao passphraseDao; - @Inject - StoragePoolHostDao storagePoolHostDao; @Inject protected SnapshotHelper snapshotHelper; @@ -660,8 +656,7 @@ public VolumeInfo copyVolumeFromSecToPrimary(VolumeInfo volumeInfo, VirtualMachi } @DB - public VolumeInfo createVolume(VolumeInfo volumeInfo, VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod, Long clusterId, - Long hostId, ServiceOffering offering, DiskOffering diskOffering, + public VolumeInfo createVolume(VolumeInfo volumeInfo, VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod, Long clusterId, ServiceOffering offering, DiskOffering diskOffering, List avoids, long size, HypervisorType hyperType) { // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage) volumeInfo = volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volumeInfo.getId(), hyperType); @@ -696,7 +691,7 @@ public VolumeInfo createVolume(VolumeInfo volumeInfo, VirtualMachine vm, Virtual final HashSet avoidPools = new HashSet(avoids); - pool = findStoragePool(dskCh, dc, pod, clusterId, hostId, vm, avoidPools); + pool = findStoragePool(dskCh, dc, pod, clusterId, vm.getHostId(), vm, avoidPools); if (pool == null) { String msg = String.format("Unable to find suitable primary storage when creating volume [%s].", volumeToString); s_logger.error(msg); @@ -1127,17 +1122,10 @@ public VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, VolumeInfo vol if (s_logger.isTraceEnabled()) { s_logger.trace(String.format("storage-pool %s/%s is associated with cluster %d",storagePool.getName(), storagePool.getUuid(), clusterId)); } - Long hostId = vm.getHostId(); - if (hostId == null && storagePool.isLocal()) { - List poolHosts = storagePoolHostDao.listByPoolId(storagePool.getId()); - if (poolHosts.size() > 0) { - hostId = poolHosts.get(0).getHostId(); - } - } VolumeInfo vol = null; if (volumeInfo.getState() == Volume.State.Allocated) { - vol = createVolume(volumeInfo, vm, rootDiskTmplt, dcVO, pod, clusterId, hostId, svo, diskVO, new ArrayList(), volumeInfo.getSize(), rootDiskHyperType); + vol = createVolume(volumeInfo, vm, rootDiskTmplt, dcVO, pod, clusterId, svo, diskVO, new ArrayList(), volumeInfo.getSize(), rootDiskHyperType); } else if (volumeInfo.getState() == Volume.State.Uploaded) { vol = copyVolume(storagePool, volumeInfo, vm, rootDiskTmplt, dcVO, pod, diskVO, svo, rootDiskHyperType); if (vol != null) { diff --git a/engine/schema/src/main/java/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java b/engine/schema/src/main/java/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java index e8272825213b..9a1f29014f97 100644 --- a/engine/schema/src/main/java/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/hypervisor/dao/HypervisorCapabilitiesDaoImpl.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.cloudstack.utils.CloudStackVersion; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -74,12 +73,6 @@ public HypervisorCapabilitiesVO findByHypervisorTypeAndVersion(HypervisorType hy SearchCriteria sc = HypervisorTypeAndVersionSearch.create(); sc.setParameters("hypervisorType", hypervisorType); sc.setParameters("hypervisorVersion", hypervisorVersion); - HypervisorCapabilitiesVO result = findOneBy(sc); - if (result != null || !HypervisorType.VMware.equals(hypervisorType) || - CloudStackVersion.getVMwareParentVersion(hypervisorVersion) == null) { - return result; - } - sc.setParameters("hypervisorVersion", CloudStackVersion.getVMwareParentVersion(hypervisorVersion)); return findOneBy(sc); } diff --git a/engine/schema/src/main/java/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/main/java/com/cloud/network/as/AutoScaleVmProfileVO.java index 21291062756c..0a0ba1e62aa0 100644 --- a/engine/schema/src/main/java/com/cloud/network/as/AutoScaleVmProfileVO.java +++ b/engine/schema/src/main/java/com/cloud/network/as/AutoScaleVmProfileVO.java @@ -88,12 +88,6 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter @Basic(fetch = FetchType.LAZY) private String userData; - @Column(name = "user_data_id", nullable = true) - private Long userDataId = null; - - @Column(name = "user_data_details", updatable = true, length = 4096) - private String userDataDetails; - @Column(name = GenericDao.REMOVED_COLUMN) protected Date removed; @@ -234,24 +228,6 @@ public String getUserData() { return userData; } - @Override - public Long getUserDataId() { - return userDataId; - } - - public void setUserDataId(Long userDataId) { - this.userDataId = userDataId; - } - - @Override - public String getUserDataDetails() { - return userDataDetails; - } - - public void setUserDataDetails(String userDataDetails) { - this.userDataDetails = userDataDetails; - } - @Override public String getUuid() { return uuid; diff --git a/engine/schema/src/main/java/com/cloud/upgrade/GuestOsMapper.java b/engine/schema/src/main/java/com/cloud/upgrade/GuestOsMapper.java index 4aabaa3e182b..cc7172ea4375 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/GuestOsMapper.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/GuestOsMapper.java @@ -321,20 +321,4 @@ public boolean copyGuestOSHypervisorMappings(HypervisorType hypervisorType, Stri } return true; } - - public void updateGuestOsNameInHypervisorMapping(long categoryId, String displayName, GuestOSHypervisorMapping mapping) { - if (!isValidGuestOSHypervisorMapping(mapping)) { - return; - } - - long guestOsId = getGuestOsId(categoryId, displayName); - if (guestOsId == 0) { - LOG.error(String.format("no guest os found for category %d and name %s, skipping mapping it to %s/%s", guestOsId, displayName, mapping.getHypervisorType(), mapping.getHypervisorVersion())); - return; - } - - GuestOSHypervisorVO guestOsMapping = guestOSHypervisorDao.findByOsIdAndHypervisor(guestOsId, mapping.getHypervisorType(), mapping.getHypervisorVersion()); - guestOsMapping.setGuestOsName(mapping.getGuestOsName()); - guestOSHypervisorDao.update(guestOsMapping.getId(), guestOsMapping); - } } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41800to41810.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41800to41810.java index 8eb50666ec84..906ef930545d 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41800to41810.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41800to41810.java @@ -16,10 +16,7 @@ // under the License. package com.cloud.upgrade.dao; -import com.cloud.hypervisor.Hypervisor; -import com.cloud.storage.GuestOSHypervisorMapping; import com.cloud.upgrade.GuestOsMapper; -import com.cloud.storage.GuestOSVO; import com.cloud.upgrade.SystemVmTemplateRegistration; import com.cloud.utils.exception.CloudRuntimeException; import org.apache.log4j.Logger; @@ -65,17 +62,6 @@ public InputStream[] getPrepareScripts() { @Override public void performDataMigration(Connection conn) { fixForeignKeyNames(conn); - updateGuestOsMappings(conn); - copyGuestOsMappingsToVMware80u1(); - addForeignKeyToAutoscaleVmprofiles(conn); - mergeDuplicateGuestOSes(); - } - - private void mergeDuplicateGuestOSes() { - guestOsMapper.mergeDuplicates(); - List nines = guestOsMapper.listByDisplayName("Red Hat Enterprise Linux 9"); - GuestOSVO nineDotZero = guestOsMapper.listByDisplayName("Red Hat Enterprise Linux 9.0").get(0); - guestOsMapper.makeNormative(nineDotZero, new HashSet<>(nines)); } @Override @@ -104,115 +90,6 @@ public void updateSystemVmTemplates(Connection conn) { } } - private void updateGuestOsMappings(Connection conn) { - LOG.debug("Updating guest OS mappings"); - - GuestOsMapper guestOsMapper = new GuestOsMapper(); - List mappings = new ArrayList<>(); - - LOG.debug("Adding Ubuntu 20.04 support for VMware 6.5+"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.5", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7.1", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7.2", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "6.7.3", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0.1.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0.2.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "7.0.3.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - guestOsMapper.addGuestOsHypervisorMapping(new GuestOSHypervisorMapping("VMware", "8.0", "ubuntu64Guest"), 10, "Ubuntu 20.04 LTS"); - - LOG.debug("Adding Ubuntu 22.04 support for KVM and VMware 6.5+"); - mappings.add(new GuestOSHypervisorMapping("KVM", "default", "Ubuntu 22.04 LTS")); - mappings.add(new GuestOSHypervisorMapping("VMware", "6.5", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "6.7", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "6.7.1", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "6.7.2", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "6.7.3", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "7.0", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "7.0.1.0", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "7.0.2.0", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "7.0.3.0", "ubuntu64Guest")); - mappings.add(new GuestOSHypervisorMapping("VMware", "8.0", "ubuntu64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(10, "Ubuntu 22.04 LTS", mappings); - mappings.clear(); - - LOG.debug("Correcting guest OS names in hypervisor mappings for VMware 8.0 ad 8.0.0.1"); - final String hypervisorVMware = Hypervisor.HypervisorType.VMware.name(); - final String hypervisorVersionVmware8 = "8.0"; - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "AlmaLinux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "almalinux_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Oracle Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "oracleLinux9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Rocky Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "rockylinux_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "AlmaLinux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "almalinux_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Oracle Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "oracleLinux9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Rocky Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "rockylinux_64Guest")); - - LOG.debug("Correcting guest OS names in hypervisor mappings for Red Hat Enterprise Linux 9"); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0", "rhel9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0.1.0", "rhel9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0.2.0", "rhel9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "7.0.3.0", "rhel9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "rhel9_64Guest")); - guestOsMapper.updateGuestOsNameInHypervisorMapping(1, "Red Hat Enterprise Linux 9", new GuestOSHypervisorMapping(hypervisorVMware, "8.0.0.1", "rhel9_64Guest")); - - LOG.debug("Adding new guest OS ids in hypervisor mappings for VMware 8.0"); - // Add support for darwin22_64Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "darwin22_64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(7, "macOS 13 (64-bit)", mappings); - mappings.clear(); - - // Add support for darwin23_64Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "darwin23_64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(7, "macOS 14 (64-bit)", mappings); - mappings.clear(); - - // Add support for debian12_64Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "debian12_64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(2, "Debian GNU/Linux 12 (64-bit)", mappings); - mappings.clear(); - - // Add support for debian12Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "debian12Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(2, "Debian GNU/Linux 12 (32-bit)", mappings); - mappings.clear(); - - // Add support for freebsd14_64Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "freebsd14_64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(9, "FreeBSD 14 (64-bit)", mappings); - mappings.clear(); - - // Add support for freebsd14Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "freebsd14Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(9, "FreeBSD 14 (32-bit)", mappings); - mappings.clear(); - - // Add support for other6xLinux64Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "other6xLinux64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(7, "Linux 6.x Kernel (64-bit)", mappings); - mappings.clear(); - - // Add support for other6xLinuxGuest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "other6xLinuxGuest")); - guestOsMapper.addGuestOsAndHypervisorMappings(7, "Linux 6.x Kernel (32-bit)", mappings); - mappings.clear(); - - // Add support for vmkernel8Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "vmkernel8Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(7, "VMware ESXi 8.0", mappings); - mappings.clear(); - - // Add support for windows11_64Guest from VMware 8.0 - mappings.add(new GuestOSHypervisorMapping(hypervisorVMware, hypervisorVersionVmware8, "windows11_64Guest")); - guestOsMapper.addGuestOsAndHypervisorMappings(6, "Windows 11 (64-bit)", mappings); - mappings.clear(); - } - - private void copyGuestOsMappingsToVMware80u1() { - LOG.debug("Copying guest OS mappings from VMware 8.0 to VMware 8.0.1"); - GuestOsMapper guestOsMapper = new GuestOsMapper(); - guestOsMapper.copyGuestOSHypervisorMappings(Hypervisor.HypervisorType.VMware, "8.0", "8.0.1"); - } - private void fixForeignKeyNames(Connection conn) { //Alter foreign key name for user_vm table from fk_user_data_id to fk_user_vm__user_data_id (if exists) List keys = new ArrayList(); @@ -238,8 +115,4 @@ private void fixForeignKeyNames(Connection conn) { DbUpgradeUtils.dropKeysIfExist(conn, "cloud.volumes", keys, false); DbUpgradeUtils.addForeignKey(conn, "volumes", "passphrase_id","passphrase", "id"); } - - private void addForeignKeyToAutoscaleVmprofiles(Connection conn) { - DbUpgradeUtils.addForeignKey(conn, "autoscale_vmprofiles", "user_data_id", "user_data", "id"); - } } diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41800to41810.sql b/engine/schema/src/main/resources/META-INF/db/schema-41800to41810.sql index 4ea2bf572920..298b04b96315 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41800to41810.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41800to41810.sql @@ -19,9 +19,6 @@ -- Schema upgrade from 4.18.0.0 to 4.18.1.0 --; --- Add support for VMware 8.0u1 (8.0.1.x) -INSERT IGNORE INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'VMware', '8.0.1', 1024, 0, 59, 64, 1, 1); - -- Update conserve_mode of the default network offering for Tungsten Fabric (this fixes issue #7241) UPDATE `cloud`.`network_offerings` SET conserve_mode = 0 WHERE unique_name ='DefaultTungstenFarbicNetworkOffering'; @@ -35,10 +32,6 @@ CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'VM CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'VMware', '8.0.0.1', 'windows2019srvNext_64Guest'); CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'Xenserver', '8.2.0', 'Windows Server 2022 (64-bit)'); --- Support userdata ids and details in VM AutoScaling -CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.autoscale_vmprofiles', 'user_data_id', 'bigint unsigned DEFAULT NULL COMMENT "id of the user data" AFTER `user_data`'); -CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.autoscale_vmprofiles', 'user_data_details', 'mediumtext DEFAULT NULL COMMENT "value of the comma-separated list of parameters" AFTER `user_data_id`'); - -- Don't enable CPU cap for default system offerings, fixes regression from https://github.com/apache/cloudstack/pull/6420 UPDATE `cloud`.`service_offering` so SET so.limit_cpu_use = 0 diff --git a/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java b/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java index 7e9658e1dd35..6f49c3d4e1e4 100755 --- a/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java +++ b/engine/schema/src/test/java/com/cloud/network/as/AutoScaleVmProfileVOTest.java @@ -26,18 +26,6 @@ public class AutoScaleVmProfileVOTest { - static long zoneId = 1L; - static long domainId = 2L; - static long accountId = 3L; - static long serviceOfferingId = 4L; - static long templateId = 5L; - static String userdata = "userdata"; - static long userdataId = 6L; - static String userdataDetails = "userdataDetails"; - static String userdataNew = "userdataNew"; - - static long autoScaleUserId = 7L; - @Test public void testCounterParamsForUpdate() { AutoScaleVmProfileVO profile = new AutoScaleVmProfileVO(); @@ -74,23 +62,4 @@ public void tstSetOtherDeployParamsForUpdate() { Assert.assertEquals("rootdisksize", otherDeployParamsList.get(1).first()); Assert.assertEquals("10", otherDeployParamsList.get(1).second()); } - - @Test - public void testProperties() { - AutoScaleVmProfileVO profile = new AutoScaleVmProfileVO(zoneId, domainId, accountId, serviceOfferingId, templateId, null, null, userdata, null, autoScaleUserId); - Assert.assertEquals(new Long(zoneId), profile.getZoneId()); - Assert.assertEquals(domainId, profile.getDomainId()); - Assert.assertEquals(accountId, profile.getAccountId()); - Assert.assertEquals(new Long(serviceOfferingId), profile.getServiceOfferingId()); - Assert.assertEquals(new Long(templateId), profile.getTemplateId()); - Assert.assertEquals(userdata, profile.getUserData()); - Assert.assertEquals(new Long(autoScaleUserId), profile.getAutoScaleUserId()); - - profile.setUserData(userdataNew); - profile.setUserDataId(userdataId); - profile.setUserDataDetails(userdataDetails); - Assert.assertEquals(userdataNew, profile.getUserData()); - Assert.assertEquals(new Long(userdataId), profile.getUserDataId()); - Assert.assertEquals(userdataDetails, profile.getUserDataDetails()); - } } diff --git a/packaging/centos8/cloud.spec b/packaging/centos8/cloud.spec index 8d567f217ce7..fdaf155ed736 100644 --- a/packaging/centos8/cloud.spec +++ b/packaging/centos8/cloud.spec @@ -53,7 +53,7 @@ intelligent IaaS cloud implementation. %package management Summary: CloudStack management server UI Requires: java-11-openjdk -Requires: (tzdata-java or timezone-java) +Requires: tzdata-java Requires: python3 Requires: bash Requires: gawk diff --git a/plugins/acl/static-role-based/src/main/java/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java b/plugins/acl/static-role-based/src/main/java/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java index 7d12178f0f38..27f8305f5792 100644 --- a/plugins/acl/static-role-based/src/main/java/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java +++ b/plugins/acl/static-role-based/src/main/java/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java @@ -76,12 +76,12 @@ public boolean isEnabled() { if (roleService.isEnabled()) { LOGGER.debug("RoleService is enabled. We will use it instead of StaticRoleBasedAPIAccessChecker."); } - return !roleService.isEnabled(); + return roleService.isEnabled(); } @Override public List getApisAllowedToUser(Role role, User user, List apiNames) throws PermissionDeniedException { - if (!isEnabled()) { + if (isEnabled()) { return apiNames; } @@ -93,7 +93,7 @@ public List getApisAllowedToUser(Role role, User user, List apiN @Override public boolean checkAccess(User user, String commandName) throws PermissionDeniedException { - if (!isEnabled()) { + if (isEnabled()) { return true; } @@ -107,10 +107,6 @@ public boolean checkAccess(User user, String commandName) throws PermissionDenie @Override public boolean checkAccess(Account account, String commandName) { - if (!isEnabled()) { - return true; - } - RoleType roleType = accountService.getRoleType(account); if (isApiAllowed(commandName, roleType)) { return true; diff --git a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java index 5be0dfcb678c..7aca752252fc 100644 --- a/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java +++ b/plugins/api/rate-limit/src/main/java/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java @@ -53,7 +53,7 @@ public class ResetApiLimitCmd extends BaseCmd { ///////////////////////////////////////////////////// @ACL - @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.UUID, entityType = AccountResponse.class, description = "the ID of the account whose limit to be reset") + @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.UUID, entityType = AccountResponse.class, description = "the ID of the acount whose limit to be reset") private Long accountId; ///////////////////////////////////////////////////// diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java index 990a1875a57f..100e3d416a71 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java @@ -47,7 +47,6 @@ import com.cloud.vm.dao.NicDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.image.deployasis.DeployAsIsHelper; -import org.apache.cloudstack.utils.CloudStackVersion; import org.apache.commons.lang.BooleanUtils; import org.apache.log4j.Logger; @@ -166,7 +165,7 @@ VirtualMachineTO implement(VirtualMachineProfile vm, VirtualMachineTO to, long c GuestOSHypervisorVO guestOsMapping = null; if (host != null) { - guestOsMapping = getGuestOsMapping(guestOS, host.getHypervisorVersion()); + guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), Hypervisor.HypervisorType.VMware.toString(), host.getHypervisorVersion()); } if (guestOsMapping == null || host == null) { to.setPlatformEmulator(null); @@ -406,17 +405,4 @@ private NicTO[] sortNicsByDeviceId(NicTO[] nics) { return listForSort.toArray(new NicTO[0]); } - - protected GuestOSHypervisorVO getGuestOsMapping(GuestOSVO guestOS , String hypervisorVersion) { - GuestOSHypervisorVO guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), Hypervisor.HypervisorType.VMware.toString(), hypervisorVersion); - if (guestOsMapping == null) { - LOGGER.debug(String.format("Cannot find guest os mappings for guest os \"%s\" on VMware %s", guestOS.getDisplayName(), hypervisorVersion)); - String parentVersion = CloudStackVersion.getVMwareParentVersion(hypervisorVersion); - if (parentVersion != null) { - guestOsMapping = guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), Hypervisor.HypervisorType.VMware.toString(), parentVersion); - LOGGER.debug(String.format("Found guest os mappings for guest os \"%s\" on VMware %s: %s", guestOS.getDisplayName(), parentVersion, guestOsMapping)); - } - } - return guestOsMapping; - } } diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 481307de41d1..90bfdd6793c7 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -2636,9 +2636,7 @@ protected StartAnswer execute(StartCommand cmd) { // // Power-on VM // - if (powerOnVM(vmMo, vmInternalCSName, vmNameOnVcenter)) { - s_logger.debug(String.format("VM %s has been started successfully with hostname %s.", vmInternalCSName, vmNameOnVcenter)); - } else { + if (!vmMo.powerOn()) { throw new Exception("Failed to start VM. vmName: " + vmInternalCSName + " with hostname " + vmNameOnVcenter); } @@ -2710,23 +2708,6 @@ protected StartAnswer execute(StartCommand cmd) { } } - private boolean powerOnVM(final VirtualMachineMO vmMo, final String vmInternalCSName, final String vmNameOnVcenter) throws Exception { - int retry = 20; - while (retry-- > 0) { - try { - return vmMo.powerOn(); - } catch (Exception e) { - s_logger.info(String.format("Got exception while power on VM %s with hostname %s", vmInternalCSName, vmNameOnVcenter), e); - if (e.getMessage() != null && e.getMessage().contains("File system specific implementation of Ioctl[file] failed")) { - s_logger.debug(String.format("Failed to power on VM %s with hostname %s. Retrying", vmInternalCSName, vmNameOnVcenter)); - } else { - throw e; - } - } - } - return false; - } - private boolean multipleIsosAtached(DiskTO[] sortedDisks) { return Arrays.stream(sortedDisks).filter(disk -> disk.getType() == Volume.Type.ISO).count() > 1; } diff --git a/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VmwareVmImplementerTest.java b/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VmwareVmImplementerTest.java index c958fa70485d..80f73d619161 100755 --- a/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VmwareVmImplementerTest.java +++ b/plugins/hypervisors/vmware/src/test/java/com/cloud/hypervisor/guru/VmwareVmImplementerTest.java @@ -24,7 +24,6 @@ import java.util.Map; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,9 +37,6 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; import com.cloud.agent.api.to.VirtualMachineTO; -import com.cloud.storage.GuestOSHypervisorVO; -import com.cloud.storage.GuestOSVO; -import com.cloud.storage.dao.GuestOSHypervisorDao; import com.cloud.vm.VmDetailConstants; @RunWith(MockitoJUnitRunner.class) @@ -54,9 +50,6 @@ public class VmwareVmImplementerTest { @Mock VirtualMachineTO vmTO; - @Mock - GuestOSHypervisorDao guestOsHypervisorDao; - private Map vmDetails = new HashMap(); AutoCloseable closeable; @@ -157,43 +150,4 @@ public void testEnableNestedVirtualizationCaseGlobalNVFalseGlobalNVPVMFalseLocal executeAndVerifyTest(false, false, "false", false); } - @Test - public void testGetGuestOsMapping1() { - GuestOSVO guestOs = Mockito.mock(GuestOSVO.class); - GuestOSHypervisorVO guestOsMapping = Mockito.mock(GuestOSHypervisorVO.class); - Mockito.when(guestOs.getId()).thenReturn(200L); - Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1.0")).thenReturn(guestOsMapping); - GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0.1.0"); - Assert.assertEquals(guestOsMapping, result); - } - - @Test - public void testGetGuestOsMapping2() { - GuestOSVO guestOs = Mockito.mock(GuestOSVO.class); - GuestOSHypervisorVO guestOsMapping = Mockito.mock(GuestOSHypervisorVO.class); - Mockito.when(guestOs.getId()).thenReturn(200L); - Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1.0")).thenReturn(null); - Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1")).thenReturn(guestOsMapping); - GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0.1.0"); - Assert.assertEquals(guestOsMapping, result); - } - - @Test - public void testGetGuestOsMapping3() { - GuestOSVO guestOs = Mockito.mock(GuestOSVO.class); - Mockito.when(guestOs.getId()).thenReturn(200L); - Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1.0")).thenReturn(null); - Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0.1")).thenReturn(null); - GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0.1.0"); - Assert.assertNull(result); - } - - @Test - public void testGetGuestOsMapping4() { - GuestOSVO guestOs = Mockito.mock(GuestOSVO.class); - Mockito.when(guestOs.getId()).thenReturn(200L); - Mockito.when(guestOsHypervisorDao.findByOsIdAndHypervisor(200L, "VMware", "8.0")).thenReturn(null); - GuestOSHypervisorVO result = implementer.getGuestOsMapping(guestOs, "8.0"); - Assert.assertNull(result); - } } diff --git a/plugins/network-elements/netscaler/src/main/java/com/cloud/api/commands/StopNetScalerVMCmd.java b/plugins/network-elements/netscaler/src/main/java/com/cloud/api/commands/StopNetScalerVMCmd.java index 288e867277a4..5d754168e492 100644 --- a/plugins/network-elements/netscaler/src/main/java/com/cloud/api/commands/StopNetScalerVMCmd.java +++ b/plugins/network-elements/netscaler/src/main/java/com/cloud/api/commands/StopNetScalerVMCmd.java @@ -56,7 +56,7 @@ public class StopNetScalerVMCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the NetScaler vm") private Long id; - @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend, otherwise a force poweroff is attempted). To be used if the caller knows the VM is stopped and should be marked as such.") + @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.") private Boolean forced; // /////////////////////////////////////////////////// diff --git a/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/api/command/ListTungstenFabricTagCmd.java b/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/api/command/ListTungstenFabricTagCmd.java index 657bc431bc4d..dd64587ac147 100644 --- a/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/api/command/ListTungstenFabricTagCmd.java +++ b/plugins/network-elements/tungsten/src/main/java/org/apache/cloudstack/network/tungsten/api/command/ListTungstenFabricTagCmd.java @@ -61,7 +61,7 @@ public class ListTungstenFabricTagCmd extends BaseListCmd { @Parameter(name = ApiConstants.VM_UUID, type = CommandType.STRING, description = "the uuid of Tungsten-Fabric vm") private String vmUuid; - @Parameter(name = ApiConstants.NIC_UUID, type = CommandType.STRING, description = "the uuid of Tungsten-Fabric nic") + @Parameter(name = ApiConstants.NIC_UUID, type = CommandType.STRING, description = "tthe uuid of Tungsten-Fabric nic") private String nicUuid; @Parameter(name = ApiConstants.POLICY_UUID, type = CommandType.STRING, description = "the uuid of Tungsten-Fabric policy") diff --git a/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ListElastistorVolumeResponse.java b/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ListElastistorVolumeResponse.java index e141cc1dffc1..b251d7a3a3a4 100644 --- a/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ListElastistorVolumeResponse.java +++ b/plugins/storage/volume/cloudbyte/src/main/java/org/apache/cloudstack/storage/datastore/util/ListElastistorVolumeResponse.java @@ -48,7 +48,7 @@ public class ListElastistorVolumeResponse extends BaseResponse { private String compression; @SerializedName("sync") - @Param(description = "synchronization") + @Param(description = "syncronization") private String sync; public String getGraceAllowed() { diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java index 744c73d8e774..5c6fc8a02586 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LdapConfigurationResponse.java @@ -32,7 +32,7 @@ public class LdapConfigurationResponse extends BaseResponse { private String hostname; @SerializedName(ApiConstants.PORT) - @Param(description = "port the ldap server is running on") + @Param(description = "port teh ldap server is running on") private int port; @SerializedName(ApiConstants.DOMAIN_ID) diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkAccountToLdapResponse.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkAccountToLdapResponse.java index 6273273bdbff..8dacfb7ca3e3 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkAccountToLdapResponse.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkAccountToLdapResponse.java @@ -34,7 +34,7 @@ public class LinkAccountToLdapResponse extends BaseResponse { private String ldapDomain; @SerializedName(ApiConstants.TYPE) - @Param(description = "type of the name in LDAP which is linked to the domain") + @Param(description = "type of the name in LDAP which is linke to the domain") private String type; @SerializedName(ApiConstants.ACCOUNT_TYPE) diff --git a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkDomainToLdapResponse.java b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkDomainToLdapResponse.java index be057fd84180..bc552ee2cf6b 100644 --- a/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkDomainToLdapResponse.java +++ b/plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/api/response/LinkDomainToLdapResponse.java @@ -39,7 +39,7 @@ public class LinkDomainToLdapResponse extends BaseResponse { private String ldapDomain; @SerializedName(ApiConstants.TYPE) - @Param(description = "type of the name in LDAP which is linked to the domain") + @Param(description = "type of the name in LDAP which is linke to the domain") private String type; @SerializedName(ApiConstants.ACCOUNT_TYPE) diff --git a/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java b/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java index e09e95e2ce68..b596254994cd 100644 --- a/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java +++ b/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java @@ -21,7 +21,6 @@ import javax.inject.Inject; -import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.BaseAsyncCreateCmd; @@ -102,11 +101,6 @@ public void runJob(final AsyncJob job) { ctx.putContextParameters((Map) gson.fromJson(contextDetails, objectMapType)); } - String httpmethod = params.get(ApiConstants.HTTPMETHOD); - if (httpmethod != null) { - cmdObj.setHttpMethod(httpmethod); - } - try { // dispatch could ultimately queue the job _dispatcher.dispatch(cmdObj, params, true); diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index aa98b1fba35c..11476fcbfbf8 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -372,7 +372,6 @@ import com.cloud.user.UserAccount; import com.cloud.user.UserData; import com.cloud.user.UserStatisticsVO; -import com.cloud.user.dao.UserDataDao; import com.cloud.user.dao.UserStatisticsDao; import com.cloud.uservm.UserVm; import com.cloud.utils.Pair; @@ -465,8 +464,6 @@ public class ApiResponseHelper implements ResponseGenerator { NetworkServiceMapDao ntwkSrvcDao; @Inject FirewallRulesDao firewallRulesDao; - @Inject - UserDataDao userDataDao; @Override public UserResponse createUserResponse(User user) { @@ -3440,20 +3437,9 @@ public AutoScaleVmProfileResponse createAutoScaleVmProfileResponse(AutoScaleVmPr VMTemplateVO template = ApiDBUtils.findTemplateById(profile.getTemplateId()); if (template != null) { response.setTemplateId(template.getUuid()); - if (template.getUserDataOverridePolicy() != null) { - response.setUserDataPolicy(template.getUserDataOverridePolicy().toString()); - } } } response.setUserData(profile.getUserData()); - if (profile.getUserDataId() != null) { - UserData userData = userDataDao.findById(profile.getUserDataId()); - if (userData != null) { - response.setUserDataId(userData.getUuid()); - response.setUserDataName(userData.getName()); - } - } - response.setUserDataDetails(profile.getUserDataDetails()); response.setOtherDeployParams(profile.getOtherDeployParamsList()); response.setCounterParams(profile.getCounterParams()); response.setExpungeVmGracePeriod(profile.getExpungeVmGracePeriod()); diff --git a/server/src/main/java/com/cloud/api/ApiServer.java b/server/src/main/java/com/cloud/api/ApiServer.java index e88d7cf8b530..b62e59f5c279 100644 --- a/server/src/main/java/com/cloud/api/ApiServer.java +++ b/server/src/main/java/com/cloud/api/ApiServer.java @@ -740,9 +740,6 @@ private String queueCommand(final BaseCmd cmdObj, final Map para params.put("ctxStartEventId", String.valueOf(startEventId)); params.put("cmdEventType", asyncCmd.getEventType().toString()); params.put("ctxDetails", ApiGsonHelper.getBuilder().create().toJson(ctx.getContextParameters())); - if (asyncCmd.getHttpMethod() != null) { - params.put(ApiConstants.HTTPMETHOD, asyncCmd.getHttpMethod().toString()); - } Long instanceId = (objectId == null) ? asyncCmd.getApiResourceId() : objectId; diff --git a/server/src/main/java/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java b/server/src/main/java/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java index 63385e22e32e..53f45c5956cd 100644 --- a/server/src/main/java/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java +++ b/server/src/main/java/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java @@ -62,7 +62,7 @@ public class DefaultLoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthe @Parameter(name = ApiConstants.DOMAIN, type = CommandType.STRING, description = "Path of the domain that the user belongs to. Example: domain=/com/cloud/internal. If no domain is passed in, the ROOT (/) domain is assumed.") private String domain; - @Parameter(name = ApiConstants.DOMAIN__ID, type = CommandType.LONG, description = "The id of the domain that the user belongs to. If both domain and domainId are passed in, \"domainId\" parameter takes precedence.") + @Parameter(name = ApiConstants.DOMAIN__ID, type = CommandType.LONG, description = "The id of the domain that the user belongs to. If both domain and domainId are passed in, \"domainId\" parameter takes precendence") private Long domainId; @Inject diff --git a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java index 50c8f0b435f0..dc90b26c8c08 100644 --- a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java @@ -3968,7 +3968,7 @@ private List applyPublicTemplateRestriction(List @Override public ListResponse listIsos(ListIsosCmd cmd) { Pair, Integer> result = searchForIsosInternal(cmd); - ListResponse response = new ListResponse<>(); + ListResponse response = new ListResponse(); ResponseView respView = ResponseView.Restricted; if (cmd instanceof ListIsosCmdByAdmin) { @@ -3995,11 +3995,11 @@ private Pair, Integer> searchForIsosInternal(ListIsosCmd cm listAll = true; } - List permittedAccountIds = new ArrayList<>(); - Ternary domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null); + List permittedAccountIds = new ArrayList(); + Ternary domainIdRecursiveListProject = new Ternary(cmd.getDomainId(), cmd.isRecursive(), null); _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccountIds, domainIdRecursiveListProject, listAll, false); ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); - List permittedAccounts = new ArrayList<>(); + List permittedAccounts = new ArrayList(); for (Long accountId : permittedAccountIds) { permittedAccounts.add(_accountMgr.getAccount(accountId)); } diff --git a/server/src/main/java/com/cloud/api/query/ViewResponseHelper.java b/server/src/main/java/com/cloud/api/query/ViewResponseHelper.java index 48031425bb8e..ecfda39972ea 100644 --- a/server/src/main/java/com/cloud/api/query/ViewResponseHelper.java +++ b/server/src/main/java/com/cloud/api/query/ViewResponseHelper.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; +import java.util.Hashtable; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -149,7 +150,7 @@ public static List createUserVmResponse(ResponseView view, Strin public static List createUserVmResponse(ResponseView view, String objectName, Set details, Boolean accumulateStats, Boolean showUserData, UserVmJoinVO... userVms) { Account caller = CallContext.current().getCallingAccount(); - LinkedHashMap vmDataList = new LinkedHashMap<>(); + Hashtable vmDataList = new Hashtable(); // Initialise the vmdatalist with the input data for (UserVmJoinVO userVm : userVms) { @@ -168,7 +169,7 @@ public static List createUserVmResponse(ResponseView view, Strin public static List createDomainRouterResponse(DomainRouterJoinVO... routers) { Account caller = CallContext.current().getCallingAccount(); - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (DomainRouterJoinVO vr : routers) { DomainRouterResponse vrData = vrDataList.get(vr.getId()); @@ -186,7 +187,7 @@ public static List createDomainRouterResponse(DomainRouter public static List createSecurityGroupResponses(List securityGroups) { Account caller = CallContext.current().getCallingAccount(); - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (SecurityGroupJoinVO vr : securityGroups) { SecurityGroupResponse vrData = vrDataList.get(vr.getId()); @@ -204,7 +205,7 @@ public static List createSecurityGroupResponses(List createProjectResponse(EnumSet details, ProjectJoinVO... projects) { - LinkedHashMap prjDataList = new LinkedHashMap<>(); + Hashtable prjDataList = new Hashtable(); // Initialise the prjdatalist with the input data for (ProjectJoinVO p : projects) { ProjectResponse pData = prjDataList.get(p.getId()); @@ -246,7 +247,7 @@ public static List createProjectInvitationResponse(Pr } public static List createHostResponse(EnumSet details, HostJoinVO... hosts) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (HostJoinVO vr : hosts) { HostResponse vrData = ApiDBUtils.newHostResponse(vr, details); @@ -256,7 +257,7 @@ public static List createHostResponse(EnumSet details } public static List createHostForMigrationResponse(EnumSet details, HostJoinVO... hosts) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (HostJoinVO vr : hosts) { HostForMigrationResponse vrData = ApiDBUtils.newHostForMigrationResponse(vr, details); @@ -266,7 +267,7 @@ public static List createHostForMigrationResponse(Enum } public static List createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); DecimalFormat df = new DecimalFormat("0.0%"); for (VolumeJoinVO vr : volumes) { VolumeResponse vrData = vrDataList.get(vr.getId()); @@ -307,7 +308,7 @@ public static List createVolumeResponse(ResponseView view, Volum } public static List createStoragePoolResponse(StoragePoolJoinVO... pools) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (StoragePoolJoinVO vr : pools) { StoragePoolResponse vrData = vrDataList.get(vr.getId()); @@ -344,7 +345,7 @@ public static List createHostTagResponse(HostTagVO... hostTags) } public static List createImageStoreResponse(ImageStoreJoinVO... stores) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (ImageStoreJoinVO vr : stores) { ImageStoreResponse vrData = vrDataList.get(vr.getId()); @@ -361,7 +362,7 @@ public static List createImageStoreResponse(ImageStoreJoinVO } public static List createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); // Initialise the vrdatalist with the input data for (StoragePoolJoinVO vr : pools) { StoragePoolResponse vrData = vrDataList.get(vr.getId()); @@ -576,7 +577,7 @@ public static List createDataCenterResponse(ResponseView view, Boo } public static List createTemplateResponse(EnumSet detailsView, ResponseView view, TemplateJoinVO... templates) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + LinkedHashMap vrDataList = new LinkedHashMap(); for (TemplateJoinVO vr : templates) { TemplateResponse vrData = vrDataList.get(vr.getTempZonePair()); if (vrData == null) { @@ -593,7 +594,7 @@ public static List createTemplateResponse(EnumSet createTemplateUpdateResponse(ResponseView view, TemplateJoinVO... templates) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); for (TemplateJoinVO vr : templates) { TemplateResponse vrData = vrDataList.get(vr.getId()); if (vrData == null) { @@ -609,7 +610,7 @@ public static List createTemplateUpdateResponse(ResponseView v } public static List createIsoResponse(ResponseView view, TemplateJoinVO... templates) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); for (TemplateJoinVO vr : templates) { TemplateResponse vrData = vrDataList.get(vr.getTempZonePair()); if (vrData == null) { @@ -625,7 +626,7 @@ public static List createIsoResponse(ResponseView view, Templa } public static List createAffinityGroupResponses(List groups) { - LinkedHashMap vrDataList = new LinkedHashMap<>(); + Hashtable vrDataList = new Hashtable(); for (AffinityGroupJoinVO vr : groups) { AffinityGroupResponse vrData = vrDataList.get(vr.getId()); if (vrData == null) { diff --git a/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java index de8a3ff3c83c..29cc4cead0b4 100644 --- a/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java @@ -532,6 +532,7 @@ public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd c long zoneId = cmd.getZoneId(); long serviceOfferingId = cmd.getServiceOfferingId(); Long autoscaleUserId = cmd.getAutoscaleUserId(); + String userData = cmd.getUserData(); DataCenter zone = entityMgr.findById(DataCenter.class, zoneId); @@ -544,11 +545,6 @@ public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd c throw new InvalidParameterValueException("Unable to find service offering by id"); } - VirtualMachineTemplate template = entityMgr.findById(VirtualMachineTemplate.class, cmd.getTemplateId()); - if (template == null) { - throw new InvalidParameterValueException("Unable to find template by id " + cmd.getTemplateId()); - } - // validations HashMap deployParams = cmd.getDeployParamMap(); /* @@ -566,23 +562,9 @@ public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd c profileVO.setDisplay(cmd.getDisplay()); } - String userData = cmd.getUserData(); - Long userDataId = cmd.getUserDataId(); - String userDataDetails = null; - if (MapUtils.isNotEmpty(cmd.getUserDataDetails())) { - userDataDetails = cmd.getUserDataDetails().toString(); - } - userData = userVmMgr.finalizeUserData(userData, userDataId, template); - userData = userVmMgr.validateUserData(userData, cmd.getHttpMethod()); if (userData != null) { profileVO.setUserData(userData); } - if (userDataId != null) { - profileVO.setUserDataId(userDataId); - } - if (userDataDetails != null) { - profileVO.setUserDataDetails(userDataDetails); - } profileVO = checkValidityAndPersist(profileVO, true); s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId()); @@ -600,19 +582,12 @@ public AutoScaleVmProfile updateAutoScaleVmProfile(UpdateAutoScaleVmProfileCmd c Map> otherDeployParams = cmd.getOtherDeployParams(); Map counterParamList = cmd.getCounterParamList(); String userData = cmd.getUserData(); - Long userDataId = cmd.getUserDataId(); - String userDataDetails = null; - if (MapUtils.isNotEmpty(cmd.getUserDataDetails())) { - userDataDetails = cmd.getUserDataDetails().toString(); - } - boolean userdataUpdate = userData != null || userDataId != null || MapUtils.isNotEmpty(cmd.getUserDataDetails()); Integer expungeVmGracePeriod = cmd.getExpungeVmGracePeriod(); AutoScaleVmProfileVO vmProfile = getEntityInDatabase(CallContext.current().getCallingAccount(), "Auto Scale Vm Profile", profileId, autoScaleVmProfileDao); - boolean physicalParameterUpdate = (templateId != null || autoscaleUserId != null || counterParamList != null - || otherDeployParams != null || expungeVmGracePeriod != null || userdataUpdate); + boolean physicalParameterUpdate = (templateId != null || autoscaleUserId != null || counterParamList != null || otherDeployParams != null || expungeVmGracePeriod != null || userData != null); if (serviceOfferingId != null) { vmProfile.setServiceOfferingId(serviceOfferingId); @@ -634,6 +609,10 @@ public AutoScaleVmProfile updateAutoScaleVmProfile(UpdateAutoScaleVmProfileCmd c vmProfile.setCounterParamsForUpdate(counterParamList); } + if (userData != null) { + vmProfile.setUserData(userData); + } + if (expungeVmGracePeriod != null) { vmProfile.setExpungeVmGracePeriod(expungeVmGracePeriod); } @@ -646,18 +625,6 @@ public AutoScaleVmProfile updateAutoScaleVmProfile(UpdateAutoScaleVmProfileCmd c vmProfile.setDisplay(cmd.getDisplay()); } - if (userdataUpdate) { - if (templateId == null) { - templateId = vmProfile.getTemplateId(); - } - VirtualMachineTemplate template = entityMgr.findByIdIncludingRemoved(VirtualMachineTemplate.class, templateId); - userData = userVmMgr.finalizeUserData(userData, userDataId, template); - userData = userVmMgr.validateUserData(userData, cmd.getHttpMethod()); - vmProfile.setUserDataId(userDataId); - vmProfile.setUserData(userData); - vmProfile.setUserDataDetails(userDataDetails); - } - List vmGroupList = autoScaleVmGroupDao.listByAll(null, profileId); for (AutoScaleVmGroupVO vmGroupVO : vmGroupList) { if (physicalParameterUpdate && !vmGroupVO.getState().equals(AutoScaleVmGroup.State.DISABLED)) { @@ -1773,8 +1740,6 @@ protected long createNewVM(AutoScaleVmGroupVO asGroup) { } String userData = profileVo.getUserData(); - Long userDataId = profileVo.getUserDataId(); - String userDataDetails = profileVo.getUserDataDetails(); UserVm vm = null; IpAddresses addrs = new IpAddresses(null, null); @@ -1798,20 +1763,20 @@ protected long createNewVM(AutoScaleVmGroupVO asGroup) { if (zone.getNetworkType() == NetworkType.Basic) { vm = userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, null, owner, vmHostName, vmHostName, diskOfferingId, dataDiskSize, null, - hypervisorType, HTTPMethod.GET, userData, userDataId, userDataDetails, sshKeyPairs, + hypervisorType, HTTPMethod.GET, userData, null, null, sshKeyPairs, null, null, true, null, affinityGroupIdList, customParameters, null, null, null, null, true, overrideDiskOfferingId); } else { if (zone.isSecurityGroupEnabled()) { vm = userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, networkIds, null, owner, vmHostName,vmHostName, diskOfferingId, dataDiskSize, null, - hypervisorType, HTTPMethod.GET, userData, userDataId, userDataDetails, sshKeyPairs, + hypervisorType, HTTPMethod.GET, userData, null, null, sshKeyPairs, null, null, true, null, affinityGroupIdList, customParameters, null, null, null, null, true, overrideDiskOfferingId, null); } else { vm = userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, networkIds, owner, vmHostName, vmHostName, diskOfferingId, dataDiskSize, null, - hypervisorType, HTTPMethod.GET, userData, userDataId, userDataDetails, sshKeyPairs, + hypervisorType, HTTPMethod.GET, userData, null, null, sshKeyPairs, null, addrs, true, null, affinityGroupIdList, customParameters, null, null, null, null, true, null, overrideDiskOfferingId); } diff --git a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java index b423ce78fa80..abbbd4965a47 100644 --- a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java +++ b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java @@ -1071,7 +1071,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) { } else { return; } - SecurityGroupRulesCmd cmd = generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress(), vm.getId(), + SecurityGroupRulesCmd cmd = generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), vm.getPrivateMacAddress(), vm.getId(), generateRulesetSignature(ingressRules, egressRules), seqnum, ingressRules, egressRules, nicSecIps); Commands cmds = new Commands(cmd); try { diff --git a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java index b75c39560cf6..eadcc5f1e7de 100644 --- a/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java +++ b/server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl2.java @@ -188,7 +188,7 @@ public void sendRulesetUpdates(SecurityGroupWork work) { return; } SecurityGroupRulesCmd cmd = - generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress(), vm.getId(), null, work.getLogsequenceNumber(), + generateRulesetCmd(vm.getInstanceName(), nic.getIPv4Address(), nic.getIPv6Address(), vm.getPrivateMacAddress(), vm.getId(), null, work.getLogsequenceNumber(), ingressRules, egressRules, nicSecIps); cmd.setMsId(_serverId); if (s_logger.isDebugEnabled()) { diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index bb8affc18700..790d9163bf09 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -1219,7 +1219,7 @@ public TemplateInfo prepareIso(long isoId, long dcId, Long hostId, Long poolId) tmplt = _tmplFactory.getReadyBypassedTemplateOnPrimaryStore(isoId, poolId, hostId); bypassed = true; } else { - tmplt = _tmplFactory.getReadyTemplateOnImageStore(isoId, dcId); + tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId); } if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) { diff --git a/server/src/main/java/com/cloud/user/AccountManagerImpl.java b/server/src/main/java/com/cloud/user/AccountManagerImpl.java index 99896dc98272..c20e2fc2abf3 100644 --- a/server/src/main/java/com/cloud/user/AccountManagerImpl.java +++ b/server/src/main/java/com/cloud/user/AccountManagerImpl.java @@ -3327,7 +3327,7 @@ protected UserTwoFactorAuthenticationSetupResponse enableTwoFactorAuthentication protected UserTwoFactorAuthenticationSetupResponse disableTwoFactorAuthentication(Long userId, Account caller, Account owner) { UserVO userVO = null; if (userId != null) { - userVO = validateUser(userId); + userVO = validateUser(userId, caller.getDomainId()); owner = _accountService.getActiveAccountById(userVO.getAccountId()); } else { userId = CallContext.current().getCallingUserId(); @@ -3349,13 +3349,16 @@ protected UserTwoFactorAuthenticationSetupResponse disableTwoFactorAuthenticatio return response; } - private UserVO validateUser(Long userId) { + private UserVO validateUser(Long userId, Long domainId) { UserVO user = null; if (userId != null) { user = _userDao.findById(userId); if (user == null) { throw new InvalidParameterValueException("Invalid user ID provided"); } + if (_accountDao.findById(user.getAccountId()).getDomainId() != domainId) { + throw new InvalidParameterValueException("User doesn't belong to the specified account or domain"); + } } return user; } diff --git a/server/src/main/java/com/cloud/vm/UserVmManager.java b/server/src/main/java/com/cloud/vm/UserVmManager.java index 4f1396913cce..39f1e5d2d283 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManager.java +++ b/server/src/main/java/com/cloud/vm/UserVmManager.java @@ -92,10 +92,6 @@ public interface UserVmManager extends UserVmService { void removeInstanceFromInstanceGroup(long vmId); - String finalizeUserData(String userData, Long userDataId, VirtualMachineTemplate template); - - String validateUserData(String userData, HTTPMethod httpmethod); - boolean isVMUsingLocalStorage(VMInstanceVO vm); boolean expunge(UserVmVO vm); diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 1e92b14d82ee..65afc155b20c 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -4785,56 +4785,6 @@ public void doInTransactionWithoutResult(TransactionStatus status) { } } - @Override - public String validateUserData(String userData, HTTPMethod httpmethod) { - byte[] decodedUserData = null; - if (userData != null) { - - if (userData.contains("%")) { - try { - userData = URLDecoder.decode(userData, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new InvalidParameterValueException("Url decoding of userdata failed."); - } - } - - if (!Base64.isBase64(userData)) { - throw new InvalidParameterValueException("User data is not base64 encoded"); - } - // If GET, use 4K. If POST, support up to 1M. - if (httpmethod.equals(HTTPMethod.GET)) { - if (userData.length() >= MAX_HTTP_GET_LENGTH) { - throw new InvalidParameterValueException("User data is too long for an http GET request"); - } - if (userData.length() > VM_USERDATA_MAX_LENGTH.value()) { - throw new InvalidParameterValueException("User data has exceeded configurable max length : " + VM_USERDATA_MAX_LENGTH.value()); - } - decodedUserData = Base64.decodeBase64(userData.getBytes()); - if (decodedUserData.length > MAX_HTTP_GET_LENGTH) { - throw new InvalidParameterValueException("User data is too long for GET request"); - } - } else if (httpmethod.equals(HTTPMethod.POST)) { - if (userData.length() >= MAX_HTTP_POST_LENGTH) { - throw new InvalidParameterValueException("User data is too long for an http POST request"); - } - if (userData.length() > VM_USERDATA_MAX_LENGTH.value()) { - throw new InvalidParameterValueException("User data has exceeded configurable max length : " + VM_USERDATA_MAX_LENGTH.value()); - } - decodedUserData = Base64.decodeBase64(userData.getBytes()); - if (decodedUserData.length > MAX_HTTP_POST_LENGTH) { - throw new InvalidParameterValueException("User data is too long for POST request"); - } - } - - if (decodedUserData == null || decodedUserData.length < 1) { - throw new InvalidParameterValueException("User data is too short"); - } - // Re-encode so that the '=' paddings are added if necessary since 'isBase64' does not require it, but python does on the VR. - return Base64.encodeBase64String(decodedUserData); - } - return null; - } - @Override @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", async = true) public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException { @@ -5733,8 +5683,7 @@ public HypervisorType getHypervisorTypeOfUserVM(long vmId) { return userVm.getHypervisorType(); } - @Override - public String finalizeUserData(String userData, Long userDataId, VirtualMachineTemplate template) { + protected String finalizeUserData(String userData, Long userDataId, VirtualMachineTemplate template) { if (StringUtils.isEmpty(userData) && userDataId == null && (template == null || template.getUserDataId() == null)) { return null; } diff --git a/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java b/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java index fff6fb2a950b..f7cf7f58b2c8 100644 --- a/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java +++ b/server/src/test/java/com/cloud/api/ApiResponseHelperTest.java @@ -32,7 +32,6 @@ import org.apache.cloudstack.annotation.dao.AnnotationDao; import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse; -import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; import org.apache.cloudstack.api.response.DirectDownloadCertificateResponse; import org.apache.cloudstack.api.response.NicSecondaryIpResponse; import org.apache.cloudstack.api.response.UsageRecordResponse; @@ -53,22 +52,17 @@ import com.cloud.domain.DomainVO; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.network.as.AutoScaleVmGroupVO; -import com.cloud.network.as.AutoScaleVmProfileVO; import com.cloud.network.as.dao.AutoScaleVmGroupVmMapDao; import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.LoadBalancerVO; import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.dao.NetworkVO; -import com.cloud.storage.VMTemplateVO; import com.cloud.usage.UsageVO; import com.cloud.user.Account; import com.cloud.user.AccountManager; import com.cloud.user.AccountVO; import com.cloud.user.User; -import com.cloud.user.UserData; -import com.cloud.user.UserDataVO; import com.cloud.user.UserVO; -import com.cloud.user.dao.UserDataDao; import com.cloud.utils.net.Ip; import com.cloud.vm.NicSecondaryIp; @@ -92,27 +86,12 @@ public class ApiResponseHelperTest { @Mock AutoScaleVmGroupVmMapDao autoScaleVmGroupVmMapDaoMock; - @Mock - UserDataDao userDataDaoMock; - @Spy @InjectMocks ApiResponseHelper apiResponseHelper = new ApiResponseHelper(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss ZZZ"); - static long zoneId = 1L; - static long domainId = 2L; - static long accountId = 3L; - static long serviceOfferingId = 4L; - static long templateId = 5L; - static String userdata = "userdata"; - static long userdataId = 6L; - static String userdataDetails = "userdataDetails"; - static String userdataNew = "userdataNew"; - - static long autoScaleUserId = 7L; - @Before public void injectMocks() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { @@ -318,55 +297,4 @@ public void testAutoScaleVmGroupResponseWithNetwork() { assertEquals("8080", response.getPublicPort()); assertEquals("8081", response.getPrivatePort()); } - - @Test - @PrepareForTest(ApiDBUtils.class) - public void testAutoScaleVmProfileResponse() { - AutoScaleVmProfileVO vmProfile = new AutoScaleVmProfileVO(zoneId, domainId, accountId, serviceOfferingId, templateId, null, null, userdata, null, autoScaleUserId); - vmProfile.setUserDataId(userdataId); - vmProfile.setUserDataDetails(userdataDetails); - - PowerMockito.mockStatic(ApiDBUtils.class); - when(ApiDBUtils.findAccountById(anyLong())).thenReturn(new AccountVO()); - when(ApiDBUtils.findDomainById(anyLong())).thenReturn(new DomainVO()); - - UserData.UserDataOverridePolicy templatePolicy = UserData.UserDataOverridePolicy.APPEND; - VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class); - when(ApiDBUtils.findTemplateById(anyLong())).thenReturn(templateVO); - when(templateVO.getUserDataOverridePolicy()).thenReturn(templatePolicy); - - UserDataVO userDataVO = Mockito.mock(UserDataVO.class); - String userDataUuid = "userDataUuid"; - String userDataName = "userDataName"; - when(userDataDaoMock.findById(anyLong())).thenReturn(userDataVO); - when(userDataVO.getUuid()).thenReturn(userDataUuid); - when(userDataVO.getName()).thenReturn(userDataName); - - AutoScaleVmProfileResponse response = apiResponseHelper.createAutoScaleVmProfileResponse(vmProfile); - assertEquals(templatePolicy.toString(), response.getUserDataPolicy()); - assertEquals(userdata, response.getUserData()); - assertEquals(userDataUuid, response.getUserDataId()); - assertEquals(userDataName, response.getUserDataName()); - assertEquals(userdataDetails, response.getUserDataDetails()); - } - - @Test - @PrepareForTest(ApiDBUtils.class) - public void testAutoScaleVmProfileResponseWithoutUserData() { - AutoScaleVmProfileVO vmProfile = new AutoScaleVmProfileVO(zoneId, domainId, accountId, serviceOfferingId, templateId, null, null, null, null, autoScaleUserId); - - PowerMockito.mockStatic(ApiDBUtils.class); - when(ApiDBUtils.findAccountById(anyLong())).thenReturn(new AccountVO()); - when(ApiDBUtils.findDomainById(anyLong())).thenReturn(new DomainVO()); - - VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class); - when(ApiDBUtils.findTemplateById(anyLong())).thenReturn(templateVO); - - AutoScaleVmProfileResponse response = apiResponseHelper.createAutoScaleVmProfileResponse(vmProfile); - assertNull(response.getUserDataPolicy()); - assertNull(response.getUserData()); - assertNull(response.getUserDataId()); - assertNull(response.getUserDataName()); - assertNull(response.getUserDataDetails()); - } } diff --git a/server/src/test/java/com/cloud/network/as/AutoScaleManagerImplTest.java b/server/src/test/java/com/cloud/network/as/AutoScaleManagerImplTest.java index 08070faf92c7..e60ce86fc3f1 100644 --- a/server/src/test/java/com/cloud/network/as/AutoScaleManagerImplTest.java +++ b/server/src/test/java/com/cloud/network/as/AutoScaleManagerImplTest.java @@ -47,7 +47,6 @@ import org.apache.cloudstack.annotation.AnnotationService; import org.apache.cloudstack.annotation.dao.AnnotationDao; import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.command.admin.autoscale.CreateCounterCmd; import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScalePolicyCmd; import org.apache.cloudstack.api.command.user.autoscale.CreateAutoScaleVmGroupCmd; @@ -341,10 +340,6 @@ public class AutoScaleManagerImplTest { private static final Long scaleDownCounterId = 38L; private static final Long nextVmSeq = 39L; private static final Long networkOfferingId = 40L; - private static final String userData = "VGVzdFVzZXJEYXRh"; //TestUserData - private static final Long userDataId = 41L; - private static final Map> userDataDetails = new HashMap<>(); - private static final String userDataFinal = "VGVzdFVzZXJEYXRhRmluYWw="; //TestUserDataFinal @Mock DataCenterVO zoneMock; @@ -409,10 +404,6 @@ public void setUp() { Mockito.doNothing().when(accountManager).checkAccess(Mockito.any(Account.class), Mockito.isNull(), Mockito.anyBoolean(), Mockito.any()); when(asPolicyDao.persist(any(AutoScalePolicyVO.class))).thenReturn(asScaleUpPolicyMock); - - userDataDetails.put("0", new HashMap<>() {{ put("key1", "value1"); put("key2", "value2"); }}); - Mockito.doReturn(userDataFinal).when(userVmMgr).finalizeUserData(any(), any(), any()); - Mockito.doReturn(userDataFinal).when(userVmMgr).validateUserData(eq(userDataFinal), nullable(BaseCmd.HTTPMethod.class)); } @After @@ -757,48 +748,10 @@ public void testCreateAutoScaleVmProfile() { ReflectionTestUtils.setField(cmd, "otherDeployParams", otherDeployParams); ReflectionTestUtils.setField(cmd, "counterParamList", counterParamList); - ReflectionTestUtils.setField(cmd, "userData", userData); - ReflectionTestUtils.setField(cmd, "userDataId", userDataId); - ReflectionTestUtils.setField(cmd, "userDataDetails", userDataDetails); - AutoScaleVmProfile vmProfile = autoScaleManagerImplSpy.createAutoScaleVmProfile(cmd); Assert.assertEquals(asVmProfileMock, vmProfile); Mockito.verify(autoScaleVmProfileDao).persist(Mockito.any()); - - Mockito.verify(userVmMgr).finalizeUserData(any(), any(), any()); - Mockito.verify(userVmMgr).validateUserData(eq(userDataFinal), nullable(BaseCmd.HTTPMethod.class)); - } - - @Test(expected = InvalidParameterValueException.class) - @PrepareForTest(ComponentContext.class) - public void testCreateAutoScaleVmProfileFail() { - when(entityManager.findById(DataCenter.class, zoneId)).thenReturn(zoneMock); - when(entityManager.findById(ServiceOffering.class, serviceOfferingId)).thenReturn(serviceOfferingMock); - when(entityManager.findByIdIncludingRemoved(ServiceOffering.class, serviceOfferingId)).thenReturn(serviceOfferingMock); - when(entityManager.findById(VirtualMachineTemplate.class, templateId)).thenReturn(templateMock); - when(serviceOfferingMock.isDynamic()).thenReturn(false); - Mockito.doThrow(InvalidParameterValueException.class).when(userVmMgr).finalizeUserData(any(), any(), any()); - - DispatchChain dispatchChainMock = Mockito.mock(DispatchChain.class); - when(dispatchChainFactory.getStandardDispatchChain()).thenReturn(dispatchChainMock); - Mockito.doNothing().when(dispatchChainMock).dispatch(any()); - PowerMockito.mockStatic(ComponentContext.class); - when(ComponentContext.inject(DeployVMCmd.class)).thenReturn(Mockito.mock(DeployVMCmd.class)); - - CreateAutoScaleVmProfileCmd cmd = new CreateAutoScaleVmProfileCmd(); - - ReflectionTestUtils.setField(cmd, "zoneId", zoneId); - ReflectionTestUtils.setField(cmd, "serviceOfferingId", serviceOfferingId); - ReflectionTestUtils.setField(cmd, "templateId", templateId); - ReflectionTestUtils.setField(cmd, "expungeVmGracePeriod", expungeVmGracePeriod); - ReflectionTestUtils.setField(cmd, "otherDeployParams", otherDeployParams); - ReflectionTestUtils.setField(cmd, "counterParamList", counterParamList); - - ReflectionTestUtils.setField(cmd, "userData", userData); - ReflectionTestUtils.setField(cmd, "userDataId", userDataId); - - AutoScaleVmProfile vmProfile = autoScaleManagerImplSpy.createAutoScaleVmProfile(cmd); } @Test @@ -821,17 +774,10 @@ public void testUpdateAutoScaleVmProfile() { ReflectionTestUtils.setField(cmd, "serviceOfferingId", serviceOfferingId); ReflectionTestUtils.setField(cmd, "templateId", templateId); - ReflectionTestUtils.setField(cmd, "userData", userData); - ReflectionTestUtils.setField(cmd, "userDataId", userDataId); - ReflectionTestUtils.setField(cmd, "userDataDetails", userDataDetails); - AutoScaleVmProfile vmProfile = autoScaleManagerImplSpy.updateAutoScaleVmProfile(cmd); Assert.assertEquals(asVmProfileMock, vmProfile); Mockito.verify(autoScaleVmProfileDao).persist(Mockito.any()); - - Mockito.verify(userVmMgr).finalizeUserData(any(), any(), any()); - Mockito.verify(userVmMgr).validateUserData(eq(userDataFinal), nullable(BaseCmd.HTTPMethod.class)); } @Test @@ -1262,9 +1208,6 @@ public void testCreateNewVM1() throws ResourceUnavailableException, Insufficient when(asVmProfileMock.getAccountId()).thenReturn(accountId); when(asVmProfileMock.getZoneId()).thenReturn(zoneId); when(asVmProfileMock.getOtherDeployParams()).thenReturn(""); - when(asVmProfileMock.getUserData()).thenReturn(userData); - when(asVmProfileMock.getUserDataId()).thenReturn(userDataId); - when(asVmProfileMock.getUserDataDetails()).thenReturn(userDataDetails.toString()); when(accountService.getActiveAccountById(accountId)).thenReturn(account); when(entityManager.findById(DataCenter.class, zoneId)).thenReturn(zoneMock); @@ -1281,7 +1224,7 @@ public void testCreateNewVM1() throws ResourceUnavailableException, Insufficient when(userVmMock.getId()).thenReturn(virtualMachineId); when(zoneMock.getNetworkType()).thenReturn(DataCenter.NetworkType.Basic); when(userVmService.createBasicSecurityGroupVirtualMachine(any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any(), eq(userData), eq(userDataId), eq(userDataDetails.toString()), any(), any(), any(), eq(true), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any(), any(), any(), any(), any(), any(), eq(true), any())).thenReturn(userVmMock); long result = autoScaleManagerImplSpy.createNewVM(asVmGroupMock); @@ -1292,7 +1235,7 @@ public void testCreateNewVM1() throws ResourceUnavailableException, Insufficient "-" + asVmGroupMock.getNextVmSeq() + "-[a-z]{6}"; Mockito.verify(userVmService).createBasicSecurityGroupVirtualMachine(any(), any(), any(), any(), any(), matches(vmHostNamePattern), matches(vmHostNamePattern), - any(), any(), any(), any(), any(), eq(userData), eq(userDataId), eq(userDataDetails.toString()), any(), any(), any(), eq(true), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any(), any(), any(), any(), any(), any(), eq(true), any()); Mockito.verify(asVmGroupMock).setNextVmSeq(nextVmSeq + 1); } @@ -1310,9 +1253,6 @@ public void testCreateNewVM2() throws ResourceUnavailableException, Insufficient when(asVmProfileMock.getAccountId()).thenReturn(accountId); when(asVmProfileMock.getZoneId()).thenReturn(zoneId); when(asVmProfileMock.getOtherDeployParams()).thenReturn(""); - when(asVmProfileMock.getUserData()).thenReturn(userData); - when(asVmProfileMock.getUserDataId()).thenReturn(userDataId); - when(asVmProfileMock.getUserDataDetails()).thenReturn(userDataDetails.toString()); when(accountService.getActiveAccountById(accountId)).thenReturn(account); when(entityManager.findById(DataCenter.class, zoneId)).thenReturn(zoneMock); @@ -1330,7 +1270,7 @@ public void testCreateNewVM2() throws ResourceUnavailableException, Insufficient when(zoneMock.getNetworkType()).thenReturn(DataCenter.NetworkType.Advanced); when(zoneMock.isSecurityGroupEnabled()).thenReturn(true); when(userVmService.createAdvancedSecurityGroupVirtualMachine(any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any(), any(), eq(userData), eq(userDataId), eq(userDataDetails.toString()), any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any())).thenReturn(userVmMock); long result = autoScaleManagerImplSpy.createNewVM(asVmGroupMock); @@ -1341,7 +1281,7 @@ public void testCreateNewVM2() throws ResourceUnavailableException, Insufficient "-" + asVmGroupMock.getNextVmSeq() + "-[a-z]{6}"; Mockito.verify(userVmService).createAdvancedSecurityGroupVirtualMachine(any(), any(), any(), any(), any(), any(), matches(vmHostNamePattern), matches(vmHostNamePattern), - any(), any(), any(), any(), any(), eq(userData), eq(userDataId), eq(userDataDetails.toString()), any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any()); Mockito.verify(asVmGroupMock).setNextVmSeq(nextVmSeq + 2); } @@ -1359,9 +1299,6 @@ public void testCreateNewVM3() throws ResourceUnavailableException, Insufficient when(asVmProfileMock.getAccountId()).thenReturn(accountId); when(asVmProfileMock.getZoneId()).thenReturn(zoneId); when(asVmProfileMock.getOtherDeployParams()).thenReturn(""); - when(asVmProfileMock.getUserData()).thenReturn(userData); - when(asVmProfileMock.getUserDataId()).thenReturn(userDataId); - when(asVmProfileMock.getUserDataDetails()).thenReturn(userDataDetails.toString()); when(accountService.getActiveAccountById(accountId)).thenReturn(account); when(entityManager.findById(DataCenter.class, zoneId)).thenReturn(zoneMock); @@ -1379,7 +1316,7 @@ public void testCreateNewVM3() throws ResourceUnavailableException, Insufficient when(zoneMock.getNetworkType()).thenReturn(DataCenter.NetworkType.Advanced); when(zoneMock.isSecurityGroupEnabled()).thenReturn(false); when(userVmService.createAdvancedVirtualMachine(any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any(), eq(userData), eq(userDataId), eq(userDataDetails.toString()), any(), any(), any(), eq(true), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any())).thenReturn(userVmMock); long result = autoScaleManagerImplSpy.createNewVM(asVmGroupMock); @@ -1390,7 +1327,7 @@ public void testCreateNewVM3() throws ResourceUnavailableException, Insufficient "-" + asVmGroupMock.getNextVmSeq() + "-[a-z]{6}"; Mockito.verify(userVmService).createAdvancedVirtualMachine(any(), any(), any(), any(), any(), matches(vmHostNamePattern), matches(vmHostNamePattern), - any(), any(), any(), any(), any(), eq(userData), eq(userDataId), eq(userDataDetails.toString()), any(), any(), any(), eq(true), any(), any(), any(), + any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any(), any(), any(), any(), any(), any(), eq(true), any(), any()); Mockito.verify(asVmGroupMock).setNextVmSeq(nextVmSeq + 3); } diff --git a/server/src/test/java/com/cloud/user/AccountManagerImplTest.java b/server/src/test/java/com/cloud/user/AccountManagerImplTest.java index 2f3a68e20af6..c79b5069c2dd 100644 --- a/server/src/test/java/com/cloud/user/AccountManagerImplTest.java +++ b/server/src/test/java/com/cloud/user/AccountManagerImplTest.java @@ -875,17 +875,19 @@ public void testEnableUserTwoFactorAuthentication() { @Test public void testDisableUserTwoFactorAuthentication() { Long userId = 1L; - Long accountId = 2L; UserVO userVO = Mockito.mock(UserVO.class); Account caller = Mockito.mock(Account.class); - Account owner = Mockito.mock(Account.class); + AccountVO accountMock = Mockito.mock(AccountVO.class); Mockito.doNothing().when(accountManagerImpl).checkAccess(nullable(Account.class), Mockito.isNull(), nullable(Boolean.class), nullable(Account.class)); + Mockito.when(caller.getDomainId()).thenReturn(1L); Mockito.when(userDaoMock.findById(userId)).thenReturn(userVO); - Mockito.when(userVO.getAccountId()).thenReturn(accountId); - Mockito.when(_accountService.getActiveAccountById(accountId)).thenReturn(owner); + Mockito.when(userVO.getAccountId()).thenReturn(1L); + Mockito.when(_accountDao.findById(1L)).thenReturn(accountMock); + Mockito.when(accountMock.getDomainId()).thenReturn(1L); + Mockito.when(_accountService.getActiveAccountById(1L)).thenReturn(caller); userVoMock.setKeyFor2fa("EUJEAEDVOURFZTE6OGWVTJZMI54QGMIL"); userVoMock.setUser2faProvider("totp"); @@ -893,9 +895,8 @@ public void testDisableUserTwoFactorAuthentication() { Mockito.when(userDaoMock.createForUpdate()).thenReturn(userVoMock); - UserTwoFactorAuthenticationSetupResponse response = accountManagerImpl.disableTwoFactorAuthentication(userId, caller, owner); + UserTwoFactorAuthenticationSetupResponse response = accountManagerImpl.disableTwoFactorAuthentication(userId, caller, caller); - Mockito.verify(accountManagerImpl).checkAccess(caller, null, true, owner); Assert.assertNull(response.getSecretCode()); Assert.assertNull(userVoMock.getKeyFor2fa()); Assert.assertNull(userVoMock.getUser2faProvider()); diff --git a/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java b/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java index 27fabb53124b..2dfea2251fb6 100644 --- a/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java +++ b/services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java @@ -113,34 +113,30 @@ public void run() { if (client.isVncOverWebSocketConnectionOpen()) { updateFrontEndActivityTime(); } - connectionAlive = session.isOpen(); + connectionAlive = client.isVncOverWebSocketConnectionAlive(); try { Thread.sleep(1); - } catch (InterruptedException e) { - s_logger.error("Error on sleep for vnc over websocket", e); + } catch (Exception e) { + s_logger.warn("Error on sleep for vnc over websocket", e); } } else if (client.isVncOverNioSocket()) { byte[] bytesArr; int nextBytes = client.getNextBytes(); bytesArr = new byte[nextBytes]; client.readBytes(bytesArr, nextBytes); - s_logger.trace(String.format("Read [%s] bytes from client [%s]", nextBytes, clientId)); if (nextBytes > 0) { session.getRemote().sendBytes(ByteBuffer.wrap(bytesArr)); updateFrontEndActivityTime(); - } else { - connectionAlive = session.isOpen(); } } else { b = new byte[100]; readBytes = client.read(b); - s_logger.trace(String.format("Read [%s] bytes from client [%s]", readBytes, clientId)); if (readBytes == -1 || (readBytes > 0 && !sendReadBytesToNoVNC(b, readBytes))) { connectionAlive = false; } } } - s_logger.info(String.format("Connection with client [%s] is dead.", clientId)); + connectionAlive = false; } catch (IOException e) { s_logger.error("Error on VNC client", e); } diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py index 8dc341f4d14a..5864f7321bb0 100644 --- a/test/integration/smoke/test_internal_lb.py +++ b/test/integration/smoke/test_internal_lb.py @@ -485,7 +485,7 @@ def run_ssh_test_accross_hosts(self, clienthost, lb_address, max_requests=30): try: for x in range(0, max_requests): - cmd_test_http = "curl --connect-timeout 3 -L http://" + \ + cmd_test_http = "/usr/bin/wget -T2 -qO- http://" + \ lb_address + "/ 2>/dev/null" # self.debug( "SSH into VM public address: %s and port: %s" # %(.public_ip, vm.public_port)) @@ -677,8 +677,9 @@ def verify_lb_stats(self, stats_ip, ssh_client, settings): url = "http://" + stats_ip + ":" + \ settings["stats_port"] + settings["stats_uri"] - get_contents = "curl --connect-timeout 3 -L --user %s:%s %s" \ - % (settings["username"], settings["password"], url) + get_contents = "/usr/bin/wget -T3 -qO- --user=" + \ + settings["username"] + " --password=" + \ + settings["password"] + " " + url try: self.logger.debug( "Trying to connect to the haproxy stats url %s" % url) diff --git a/test/integration/smoke/test_vm_autoscaling.py b/test/integration/smoke/test_vm_autoscaling.py index 316f94fd5fde..d9fa7e23b79b 100644 --- a/test/integration/smoke/test_vm_autoscaling.py +++ b/test/integration/smoke/test_vm_autoscaling.py @@ -38,7 +38,6 @@ Domain, Project, ServiceOffering, - Template, VirtualMachine, Volume, Zone, @@ -48,7 +47,6 @@ LoadBalancerRule, VPC, VpcOffering, - UserData, SSHKeyPair) from marvin.lib.common import (get_domain, @@ -200,37 +198,6 @@ def setUpClass(cls): name="keypair2" ) - # 8-2. Register userdata - cls.apiUserdata = UserData.register( - cls.apiclient, - name="ApiUserdata", - userdata="QVBJdXNlcmRhdGE=", #APIuserdata - account=cls.regular_user.name, - domainid=cls.regular_user.domainid - ) - - # 8-3. Register userdata for template - cls.templateUserdata = UserData.register( - cls.apiclient, - name="TemplateUserdata", - userdata="IyMgdGVtcGxhdGU6IGppbmphCiNjbG91ZC1jb25maWcKcnVuY21kOgogICAgLSBlY2hvICdrZXkge3sgZHMubWV0YV9kYXRhLmtleTEgfX0nID4+IC9yb290L2luc3RhbmNlX21ldGFkYXRhCgo=", - # ## template: jinja - # #cloud-config - # runcmd: - # - echo 'key {{ ds.meta_data.key1 }}' >> /root/instance_metadata - # - account=cls.regular_user.name, - domainid=cls.regular_user.domainid - ) - - # 8-3. Link userdata to template - cls.template = Template.linkUserDataToTemplate( - cls.apiclient, - templateid=cls.template.id, - userdataid=cls.templateUserdata.userdata.id, - userdatapolicy="append" - ) - # 9. Get counters for cpu and memory counters = Autoscale.listCounters( cls.regular_user_apiclient, @@ -327,7 +294,6 @@ def setUpClass(cls): serviceofferingid=cls.service_offering.id, zoneid=cls.zone.id, templateid=cls.template.id, - userdata="VGVzdFVzZXJEYXRh", #TestUserData expungevmgraceperiod=DEFAULT_EXPUNGE_VM_GRACE_PERIOD, otherdeployparams=cls.otherdeployparams ) @@ -383,10 +349,6 @@ def addOtherDeployParam(cls, otherdeployparams, name, value): @classmethod def tearDownClass(cls): - cls.template = Template.linkUserDataToTemplate( - cls.apiclient, - templateid=cls.template.id - ) Configurations.update(cls.apiclient, CONFIG_NAME_DISK_CONTROLLER, cls.initial_vmware_root_disk_controller) @@ -428,7 +390,6 @@ def verifyVmCountAndProfiles(self, vmCount, autoscalevmgroupid=None, autoscalevm self.regular_user_apiclient, autoscalevmgroupid=autoscalevmgroupid, projectid=projectid, - userdata=True, listall=True ) self.assertEqual( @@ -544,31 +505,6 @@ def verifyVmProfile(self, vm, autoscalevmprofileid, networkid=None, projectid=No else: self.assertEquals(affinitygroupids, '') - userdata = None - userdatadetails = None - userdataid = None - if vm.userdata: - userdata = vm.userdata - if vm.userdatadetails: - userdatadetails = vm.userdatadetails - if vm.userdataid: - userdataid = vm.userdataid - - if vmprofile.userdataid: - self.assertEquals(userdataid, vmprofile.userdataid) - else: - self.assertIsNone(userdataid) - - if vmprofile.userdatadetails: - self.assertEquals(userdatadetails, vmprofile.userdatadetails) - else: - self.assertIsNone(userdatadetails) - - if vmprofile.userdata: - self.assertEquals(userdata, vmprofile.userdata) - else: - self.assertIsNone(userdata) - def wait_for_vm_start(self, vm=None, project_id=None): """ Wait until vm is Running """ def check_user_vm_state(): @@ -576,7 +512,6 @@ def check_user_vm_state(): self.apiclient, id=vm.id, projectid=project_id, - userdata=True, listall=True ) if isinstance(vms, list): @@ -641,8 +576,6 @@ def test_02_update_vmprofile_and_vmgroup(self): Autoscale.updateAutoscaleVMProfile( self.regular_user_apiclient, id = self.autoscaling_vmprofile.id, - userdataid=self.apiUserdata.userdata.id, - userdatadetails=[{"key1": "value2"}], serviceofferingid = self.service_offering_new.id, expungevmgraceperiod = DEFAULT_EXPUNGE_VM_GRACE_PERIOD + 1, otherdeployparams = otherdeployparams_new @@ -779,7 +712,6 @@ def test_04_stop_remove_vm_in_vmgroup(self): vms = VirtualMachine.list( self.regular_user_apiclient, autoscalevmgroupid=self.autoscaling_vmgroup.id, - userdata=True, listall=True ) self.assertEqual( @@ -957,7 +889,6 @@ def test_06_autoscaling_vmgroup_on_project_network(self): self.regular_user_apiclient, autoscalevmgroupid=autoscaling_vmgroup_project.id, projectid=project.id, - userdata=True, listall=True ) self.assertEqual( diff --git a/tools/apidoc/build-apidoc.sh b/tools/apidoc/build-apidoc.sh index 35551cda5979..21cceb0a2825 100755 --- a/tools/apidoc/build-apidoc.sh +++ b/tools/apidoc/build-apidoc.sh @@ -59,12 +59,8 @@ fi # Default case for Linux sed, just use "-i" sedi='-i' case "$(uname)" in - # For macOS, use two parameters, if gnu sed is not set up - Darwin*) - if ! $(which sed | grep -q gnu); then - sedi='-i ""' - fi - ;; + # For macOS, use two parameters + Darwin*) sedi='-i ""' esac set -e diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 0068a12d21ab..3340e2d6728e 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -1659,7 +1659,6 @@ "label.reset.config.value": "Reset to default value", "label.reset.ssh.key.pair": "Reset SSH key pair", "label.reset.to.default": "Reset to default", -"label.reset.userdata.on.autoscale.vm.group": "Reset Userdata on AutoScale VM Group", "label.reset.userdata.on.vm": "Reset Userdata on VM", "label.reset.vpn.connection": "Reset VPN connection", "label.resource": "Resource", diff --git a/ui/src/config/section/image.js b/ui/src/config/section/image.js index c1961fe216d3..b7aabb06cb37 100644 --- a/ui/src/config/section/image.js +++ b/ui/src/config/section/image.js @@ -214,7 +214,7 @@ export default { } return fields }, - details: ['name', 'id', 'displaytext', 'checksum', 'ostypename', 'size', 'bootable', 'isready', 'directdownload', 'isextractable', 'ispublic', 'isfeatured', 'crosszones', 'account', 'domain', 'created', 'userdatadetails', 'userdatapolicy', 'url'], + details: ['name', 'id', 'displaytext', 'checksum', 'ostypename', 'size', 'bootable', 'isready', 'directdownload', 'isextractable', 'ispublic', 'isfeatured', 'crosszones', 'account', 'domain', 'created', 'userdatadetails', 'userdatapolicy'], searchFilters: ['name', 'zoneid', 'tags'], related: [{ name: 'vm', diff --git a/ui/src/views/compute/AutoScaleVmProfile.vue b/ui/src/views/compute/AutoScaleVmProfile.vue index 208fa6a881e9..705bfb59d106 100644 --- a/ui/src/views/compute/AutoScaleVmProfile.vue +++ b/ui/src/views/compute/AutoScaleVmProfile.vue @@ -73,47 +73,6 @@ {{ getServiceOfferingName(serviceofferingid) }} -
-
-
- -
- {{ userdataid }} -
-
-
-
-
- -
- {{ userdataname }} -
-
-
-
-
- -
- {{ userdatadetails }} -
-
-
-
-
- -
- {{ userdatapolicy }} -
-
-
-
-
- -
- - -
-
@@ -121,12 +80,6 @@ {{ $t('label.edit.autoscale.vmprofile') }}
-
- - - {{ $t('label.reset.userdata.on.autoscale.vm.group') }} - -
@@ -283,26 +236,20 @@ +
+
+
+ +
+ + +
+
{{ $t('label.cancel') }} {{ $t('label.ok') }}
- - - - @@ -312,12 +259,10 @@ import { isAdmin, isAdminOrDomainAdmin } from '@/role' import Status from '@/components/widgets/Status' import TooltipButton from '@/components/widgets/TooltipButton' import TooltipLabel from '@/components/widgets/TooltipLabel' -import ResetUserData from '@views/compute/ResetUserData' export default { name: 'conditionsTab', components: { - ResetUserData, Status, TooltipButton, TooltipLabel @@ -333,17 +278,12 @@ export default { filterColumns: ['Actions'], loading: true, editProfileModalVisible: false, - showUpdateUserDataForm: false, profileid: null, autoscaleuserid: null, expungevmgraceperiod: null, templateid: null, serviceofferingid: null, userdata: null, - userdataid: null, - userdataname: null, - userdatadetails: null, - userdatapolicy: null, usersList: [], templatesList: [], serviceOfferingsList: [], @@ -456,11 +396,6 @@ export default { this.serviceofferingid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.serviceofferingid this.templateid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.templateid this.userdata = this.decodeUserData(decodeURIComponent(response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdata || '')) - this.userdataid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdataid - this.userdataname = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdataname - this.userdatadetails = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdatadetails - this.userdatapolicy = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdatapolicy - const counterparam = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.counterparam || {} const otherdeployparams = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.otherdeployparams || {} this.finalizeParams(counterparam, otherdeployparams) @@ -595,10 +530,13 @@ export default { if (this.autoscaleuserid) { params.autoscaleuserid = this.autoscaleuserid } + if (this.userdata && this.userdata.length > 0) { + params.userdata = this.$toBase64AndURIEncoded(this.userdata) + } - const httpMethod = 'GET' - const args = params - const data = {} + const httpMethod = params.userdata ? 'POST' : 'GET' + const args = httpMethod === 'POST' ? {} : params + const data = httpMethod === 'POST' ? params : {} api('updateAutoScaleVmProfile', args, httpMethod, data).then(response => { this.$pollJob({ diff --git a/ui/src/views/compute/CreateAutoScaleVmGroup.vue b/ui/src/views/compute/CreateAutoScaleVmGroup.vue index 981c2b0ab183..084828ef9c50 100644 --- a/ui/src/views/compute/CreateAutoScaleVmGroup.vue +++ b/ui/src/views/compute/CreateAutoScaleVmGroup.vue @@ -407,7 +407,7 @@ @@ -762,100 +762,13 @@ @select-affinity-group-item="($event) => updateAffinityGroups($event)" @handle-search-filter="($event) => handleSearchFilter('affinityGroups', $event)"/> - + - -
- - Userdata "{{ $t(this.template.userdataname) }}" is linked with template "{{ $t(this.template.name) }}" with override policy "{{ $t(this.template.userdatapolicy) }}" -

-
- - Enter the values for the variables in userdata - - - - - - -
-


-
- - {{ $t('label.userdata.do.override') }} - - - - {{ $t('label.userdata.do.append') }} - - - - - -
-
+ +
@@ -1045,7 +958,6 @@ import NetworkSelection from '@views/compute/wizard/NetworkSelection' import NetworkConfiguration from '@views/compute/wizard/NetworkConfiguration' import LoadBalancerSelection from '@views/compute/wizard/LoadBalancerSelection' import SshKeyPairSelection from '@views/compute/wizard/SshKeyPairSelection' -import UserDataSelection from '@views/compute/wizard/UserDataSelection' import SecurityGroupSelection from '@views/compute/wizard/SecurityGroupSelection' import TooltipLabel from '@/components/widgets/TooltipLabel' import InstanceNicsNetworkSelectListView from '@/components/view/InstanceNicsNetworkSelectListView.vue' @@ -1058,7 +970,6 @@ export default { name: 'Wizard', components: { SshKeyPairSelection, - UserDataSelection, NetworkConfiguration, NetworkSelection, LoadBalancerSelection, @@ -1105,10 +1016,6 @@ export default { zoneSelected: false, dynamicscalingenabled: true, templateKey: 0, - showRegisteredUserdata: true, - doUserdataOverride: false, - doUserdataAppend: false, - userdataDefaultOverridePolicy: 'ALLOWOVERRIDE', vm: { name: null, zoneid: null, @@ -1133,7 +1040,6 @@ export default { affinityGroups: [], networks: [], sshKeyPairs: [], - UserDatas: [], loadbalancers: [] }, rowCount: {}, @@ -1145,7 +1051,6 @@ export default { affinityGroups: false, networks: false, sshKeyPairs: false, - userDatas: false, loadbalancers: false, zones: false }, @@ -1224,32 +1129,6 @@ export default { zone: {}, sshKeyPairs: [], sshKeyPair: {}, - userData: {}, - userDataParams: [], - userDataParamCols: [ - { - title: this.$t('label.key'), - dataIndex: 'key' - }, - { - title: this.$t('label.value'), - dataIndex: 'value', - slots: { customRender: 'value' } - } - ], - userDataValues: {}, - templateUserDataCols: [ - { - title: this.$t('label.userdata'), - dataIndex: 'userdata' - }, - { - title: this.$t('label.userdatapolicy'), - dataIndex: 'userdataoverridepolicy' - } - ], - templateUserDataParams: [], - templateUserDataValues: {}, overrideDiskOffering: {}, templateFilter: [ 'featured', @@ -1261,7 +1140,6 @@ export default { defaultNetworkId: '', dataNetworkCreated: [], tabKey: 'templateid', - userdataTabKey: 'userdataregistered', dataPreFill: {}, showDetails: false, showRootDiskSizeChanger: false, @@ -1352,15 +1230,6 @@ export default { listall: false } }, - userDatas: { - list: 'listUserData', - options: { - page: 1, - pageSize: 10, - keyword: undefined, - listall: false - } - }, networks: { list: 'listNetworks', options: { @@ -1422,27 +1291,12 @@ export default { }] return tabList }, - userdataTabList () { - let tabList = [] - tabList = [{ - key: 'userdataregistered', - tab: this.$t('label.userdata.registered') - }, - { - key: 'userdatatext', - tab: this.$t('label.userdata.text') - }] - return tabList - }, showSecurityGroupSection () { return (this.networks.length > 0 && this.zone.securitygroupsenabled) || (this.zone && this.zone.networktype === 'Basic') }, isUserAllowedToListSshKeys () { return Boolean('listSSHKeyPairs' in this.$store.getters.apis) }, - isUserAllowedToListUserDatas () { - return Boolean('listUserData' in this.$store.getters.apis) - }, dynamicScalingVmConfigValue () { return this.options.dynamicScalingVmConfig?.[0]?.value === 'true' }, @@ -1573,8 +1427,6 @@ export default { template (oldValue, newValue) { if (oldValue && newValue && oldValue.id !== newValue.id) { this.dynamicscalingenabled = this.isDynamicallyScalable() - this.doUserdataOverride = false - this.doUserdataAppend = false } }, beforeCreate () { @@ -2007,8 +1859,6 @@ export default { if (template) { var size = template.size / (1024 * 1024 * 1024) || 0 // bytes to GB this.dataPreFill.minrootdisksize = Math.ceil(size) - this.updateTemplateLinkedUserData(this.template.userdataid) - this.userdataDefaultOverridePolicy = this.template.userdatapolicy } } else if (['cpuspeed', 'cpunumber', 'memory'].includes(name)) { this.vm[name] = value @@ -2173,56 +2023,6 @@ export default { this.form.keypairs = names this.sshKeyPairs = names.map((sshKeyPair) => { return sshKeyPair.name }) }, - updateUserData (id) { - if (id === '0') { - this.form.userdataid = undefined - return - } - this.form.userdataid = id - this.userDataParams = [] - api('listUserData', { id: id }).then(json => { - const resp = json?.listuserdataresponse?.userdata || [] - if (resp) { - var params = resp[0].params - if (params) { - var dataParams = params.split(',') - } - var that = this - dataParams.forEach(function (val, index) { - that.userDataParams.push({ - id: index, - key: val - }) - }) - } - }) - }, - updateTemplateLinkedUserData (id) { - if (id === '0') { - return - } - this.templateUserDataParams = [] - - api('listUserData', { id: id }).then(json => { - const resp = json?.listuserdataresponse?.userdata || [] - if (resp) { - var params = resp[0].params - if (params) { - var dataParams = params.split(',') - } - var that = this - that.templateUserDataParams = [] - if (dataParams) { - dataParams.forEach(function (val, index) { - that.templateUserDataParams.push({ - id: index, - key: val - }) - }) - } - } - }) - }, updateAffinityGroups (ids) { this.form.affinitygroupids = ids }, @@ -2241,20 +2041,16 @@ export default { }, 1000) }) }, - createVmProfile (createVmGroupData, createVmGroupUserDataDetails) { + createVmProfile (createVmGroupData) { this.addStep('message.creating.autoscale.vmprofile', 'createVmProfile') return new Promise((resolve, reject) => { const params = { - ...createVmGroupUserDataDetails, - ...{ - expungevmgraceperiod: createVmGroupData.expungevmgraceperiod, - serviceofferingid: createVmGroupData.serviceofferingid, - templateid: createVmGroupData.templateid, - userdata: createVmGroupData.userdata, - userdataid: createVmGroupData.userdataid, - zoneid: createVmGroupData.zoneid - } + expungevmgraceperiod: createVmGroupData.expungevmgraceperiod, + serviceofferingid: createVmGroupData.serviceofferingid, + templateid: createVmGroupData.templateid, + userdata: createVmGroupData.userdata, + zoneid: createVmGroupData.zoneid } if (createVmGroupData.autoscaleuserid) { params.autoscaleuserid = createVmGroupData.autoscaleuserid @@ -2635,13 +2431,9 @@ export default { // advanced settings createVmGroupData.keypairs = this.sshKeyPairs.join(',') createVmGroupData.affinitygroupids = (values.affinitygroupids || []).join(',') - const isUserdataAllowed = !this.userdataDefaultOverridePolicy || (this.userdataDefaultOverridePolicy === 'ALLOWOVERRIDE' && this.doUserdataOverride) || (this.userdataDefaultOverridePolicy === 'APPEND' && this.doUserdataAppend) - if (isUserdataAllowed && values.userdata && values.userdata.length > 0) { + if (values.userdata && values.userdata.length > 0) { createVmGroupData.userdata = this.$toBase64AndURIEncoded(values.userdata) } - if (isUserdataAllowed) { - createVmGroupData.userdataid = values.userdataid - } // vm profile details createVmGroupData.autoscaleuserid = values.autoscaleuserid @@ -2650,26 +2442,11 @@ export default { createVmGroupData = Object.fromEntries( Object.entries(createVmGroupData).filter(([key, value]) => value !== undefined)) - const createVmGroupUserDataDetails = {} - var idx = 0 - if (this.templateUserDataValues) { - for (const [key, value] of Object.entries(this.templateUserDataValues)) { - createVmGroupUserDataDetails['userdatadetails[' + idx + '].' + `${key}`] = value - idx++ - } - } - if (isUserdataAllowed && this.userDataValues) { - for (const [key, value] of Object.entries(this.userDataValues)) { - createVmGroupUserDataDetails['userdatadetails[' + idx + '].' + `${key}`] = value - idx++ - } - } - this.processStatusModalVisible = true this.processStatus = null // create autoscale vm profile - const vmprofile = await this.createVmProfile(createVmGroupData, createVmGroupUserDataDetails) + const vmprofile = await this.createVmProfile(createVmGroupData) // create scaleup conditions and policy const scaleUpPolicyIds = [] @@ -2776,7 +2553,7 @@ export default { return new Promise((resolve) => { this.loading.zones = true const param = this.params.zones - const args = { showicon: true } + const args = { listall: true, showicon: true } if (zoneId) args.id = zoneId api(param.list, args).then(json => { const zoneResponse = (json.listzonesresponse.zone || []).filter(item => item.securitygroupsenabled === false) @@ -2808,7 +2585,7 @@ export default { param.loading = true param.opts = [] const options = param.options || {} - if (!('listall' in options) && !['zones', 'pods', 'clusters', 'hosts', 'dynamicScalingVmConfig', 'hypervisors'].includes(name)) { + if (!('listall' in options)) { options.listall = true } api(param.list, options).then((response) => { @@ -2932,10 +2709,6 @@ export default { this.params[name].options = { ...this.params[name].options, ...options } this.fetchOptions(this.params[name], name) }, - onUserdataTabChange (key, type) { - this[type] = key - this.userDataParams = [] - }, fetchTemplateNics (template) { var nics = [] this.nicToNetworkSelection = [] diff --git a/ui/src/views/compute/ResetUserData.vue b/ui/src/views/compute/ResetUserData.vue index 33643368ddc1..7be1dad8fbdc 100644 --- a/ui/src/views/compute/ResetUserData.vue +++ b/ui/src/views/compute/ResetUserData.vue @@ -339,6 +339,7 @@ export default { this.loadingData = true console.log(values) const params = { + id: this.resource.id } if (values.userdata && values.userdata.length > 0) { params.userdata = this.$toBase64AndURIEncoded(values.userdata) @@ -359,14 +360,7 @@ export default { idx++ } } - params.id = this.resource.resetUserDataResourceId ? this.resource.resetUserDataResourceId : this.resource.id - - const resetUserDataApiName = this.resource.resetUserDataApiName ? this.resource.resetUserDataApiName : 'resetUserDataForVirtualMachine' - const httpMethod = params.userdata ? 'POST' : 'GET' - const args = httpMethod === 'POST' ? {} : params - const data = httpMethod === 'POST' ? params : {} - - api(resetUserDataApiName, args, httpMethod, data).then(json => { + api('resetUserDataForVirtualMachine', params).then(json => { this.$message.success({ content: `${this.$t('label.action.userdata.reset')} - ${this.$t('label.success')}`, duration: 2 diff --git a/ui/src/views/image/RegisterOrUploadIso.vue b/ui/src/views/image/RegisterOrUploadIso.vue index 1a461ee6bf6b..6c34ec8972a7 100644 --- a/ui/src/views/image/RegisterOrUploadIso.vue +++ b/ui/src/views/image/RegisterOrUploadIso.vue @@ -35,10 +35,8 @@ - + name="url" + :label="$t('label.url')"> - - + - - + - - + - - + - - + - - + - + ref="userdataid" + :label="$t('label.userdata')"> - - + - - - + @@ -356,7 +326,7 @@ export default { params.showicon = true this.zoneLoading = true - if (store.getters.userInfo.roletype === 'Admin') { + if (store.getters.userInfo.roletype === this.rootAdmin) { this.allowed = true } api('listZones', params).then(json => { diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue b/ui/src/views/image/RegisterOrUploadTemplate.vue index 6add11ab0ba6..f9578d4714d7 100644 --- a/ui/src/views/image/RegisterOrUploadTemplate.vue +++ b/ui/src/views/image/RegisterOrUploadTemplate.vue @@ -32,10 +32,7 @@ @finish="handleSubmit" layout="vertical">
- - +
- - + - - +
-
- - - + - - + - - + - - + @@ -240,10 +215,7 @@ - - + - - + ref="userdataid" + :label="$t('label.userdata')"> - traffic.type === 'guest') > -1) { - this.stepData.guestPhysicalNetworkId = physicalNetworkReturned.id - } } catch (e) { this.messageError = e this.processStatus = STATUS_FAILED @@ -1184,7 +1181,7 @@ export default { } const updateParams = {} - updateParams.id = this.stepData.guestPhysicalNetworkId + updateParams.id = this.stepData.physicalNetworkReturned.id updateParams.vlan = vlan try { diff --git a/utils/src/main/java/org/apache/cloudstack/utils/CloudStackVersion.java b/utils/src/main/java/org/apache/cloudstack/utils/CloudStackVersion.java index e29bd9c4e17b..91c5a9758ea4 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/CloudStackVersion.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/CloudStackVersion.java @@ -272,21 +272,4 @@ public int hashCode() { public String toString() { return Joiner.on(".").join(asList()); } - - /** - * Get the parent version of VMware hypervisor version - * @since 4.18.1.0 - */ - public static String getVMwareParentVersion(String hypervisorVersion) { - try { - CloudStackVersion version = CloudStackVersion.parse(hypervisorVersion); - String parentVersion = String.format("%s.%s", version.getMajorRelease(), version.getMinorRelease()); - if (version.getPatchRelease() != 0) { - parentVersion = String.format("%s.%s", parentVersion, version.getPatchRelease()); - } - return parentVersion; - } catch (Exception ex) { - return null; - } - } } diff --git a/utils/src/test/java/org/apache/cloudstack/utils/CloudStackVersionTest.java b/utils/src/test/java/org/apache/cloudstack/utils/CloudStackVersionTest.java index dabaf9bc97d3..eb7a76a2c0f0 100644 --- a/utils/src/test/java/org/apache/cloudstack/utils/CloudStackVersionTest.java +++ b/utils/src/test/java/org/apache/cloudstack/utils/CloudStackVersionTest.java @@ -21,7 +21,6 @@ import com.google.common.testing.EqualsTester; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -205,23 +204,4 @@ public void testTrimRouterVersion(final String value, final String expected) { assertEquals(expected, CloudStackVersion.trimRouterVersion(value)); } - - private void verifyGetVMwareParentVersion(String hypervisorVersion, String expectedParentVersion) { - if (expectedParentVersion == null) { - Assert.assertNull(CloudStackVersion.getVMwareParentVersion(hypervisorVersion)); - } else { - Assert.assertEquals(CloudStackVersion.getVMwareParentVersion(hypervisorVersion), expectedParentVersion); - } - } - @Test - public void testGetParentVersion() { - verifyGetVMwareParentVersion(null, null); - verifyGetVMwareParentVersion("6.5", null); - verifyGetVMwareParentVersion("6.7.3", "6.7.3"); - verifyGetVMwareParentVersion("7.0.3.0", "7.0.3"); - verifyGetVMwareParentVersion("8.0", null); - verifyGetVMwareParentVersion("8.0.0", "8.0"); - verifyGetVMwareParentVersion("8.0.0.2", "8.0"); - verifyGetVMwareParentVersion("8.0.1.0", "8.0.1"); - } }