Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8dce419
CreateAutoScaleVmGroup.vue: fix spelling (6609)
weizhouapache Jul 24, 2023
8c5b19b
CreateAutoScaleVmGroup.vue: Remove unsupported params listall (6686)
weizhouapache Jul 24, 2023
030024f
CreateAutoScaleVmGroup.vue: support userdata ids (6202)
weizhouapache Jul 24, 2023
5ab2faf
CreateAutoScaleVmGroup.vue: fix same issue as DeployVM.vue (7758)
weizhouapache Jul 24, 2023
87d81eb
AutoScaling: support userdata id and userdata details
weizhouapache Jul 25, 2023
7d14881
AutoScaling: use DbUpgradeUtils.addForeignKey instead of SQL procedure
weizhouapache Jul 25, 2023
7d379fd
PR7769: add method convertDetailsToMap to BaseCmd
weizhouapache Jul 25, 2023
6d0088b
PR7769: use convertDetailsToMap in two other APIs
weizhouapache Jul 26, 2023
3199dd2
AutoScaling: update marvin test
weizhouapache Jul 27, 2023
5118b19
PR6669: fix userdata details are not passed on UI
weizhouapache Jul 28, 2023
cb31541
PR6669: add userdata id/name/details/policy to vmprofile response
weizhouapache Jul 28, 2023
f8938af
PR6669: set httpmethod for Async commands
weizhouapache Jul 28, 2023
e23124b
Merge remote-tracking branch 'apache/4.18' into 4.18-asgroup-add-user…
weizhouapache Aug 14, 2023
6a94a1a
PR7769: add unit tests in AutoScaleVmProfileVOTest
weizhouapache Aug 15, 2023
1f9da7f
PR7796: add unit tests in AutoScaleManagerImplTest
weizhouapache Aug 16, 2023
ea32253
PR7769: add unit tests in ApiResponseHelperTest
weizhouapache Aug 16, 2023
6e12939
PR7769: add more unit tests in AutoScaleManagerImplTest
weizhouapache Aug 16, 2023
bb79878
Merge remote-tracking branch 'apache/4.18' into 4.18-asgroup-add-user…
weizhouapache Aug 16, 2023
63e9aff
PR7769: add more unit tests in ApiResponseHelperTest
weizhouapache Aug 16, 2023
6a1df6e
Merge remote-tracking branch 'apache/4.18' into 4.18-asgroup-add-user…
weizhouapache Aug 17, 2023
8d4aa1a
Merge branch '4.18' into 4.18-asgroup-add-userdata-support
weizhouapache Aug 17, 2023
5ba953d
Merge branch '4.18' into 4.18-asgroup-add-userdata-support
weizhouapache Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public interface AutoScaleVmProfile extends ControlledEntity, InternalIdentity,

String getUserData();

Long getUserDataId();

String getUserDataDetails();

public String getUuid();

public Long getZoneId();
Expand Down
17 changes: 17 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/BaseCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
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;
Expand All @@ -42,6 +44,7 @@
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;
Expand Down Expand Up @@ -456,4 +459,18 @@ public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.None;
}

public Map<String, String> convertDetailsToMap(Map details) {
Map<String, String> detailsMap = new HashMap<String, String>();
if (MapUtils.isNotEmpty(details)) {
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (Map.Entry<String,String> entry: value.entrySet()) {
detailsMap.put(entry.getKey(),entry.getValue());
}
}
}
return detailsMap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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;
Expand Down Expand Up @@ -107,6 +108,12 @@ 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,
Expand Down Expand Up @@ -163,6 +170,14 @@ public String getUserData() {
return userData;
}

public Long getUserDataId() {
return userDataId;
}

public Map<String, String> getUserDataDetails() {
return convertDetailsToMap(userDataDetails);
}

public Long getAutoscaleUserId() {
return autoscaleUserId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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;

Expand Down Expand Up @@ -102,6 +103,14 @@ 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,
Expand Down Expand Up @@ -156,6 +165,14 @@ public String getUserData() {
return userData;
}

public Long getUserDataId() {
return userDataId;
}

public Map<String, String> getUserDataDetails() {
return convertDetailsToMap(userDataDetails);
}

public Long getAutoscaleUserId() {
return autoscaleUserId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,8 @@ public ApiConstants.BootType getBootType() {
}

public Map<String, String> getDetails() {
Map<String, String> customparameterMap = new HashMap<String, String>();
if (details != null && details.size() != 0) {
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (Map.Entry<String,String> entry: value.entrySet()) {
customparameterMap.put(entry.getKey(),entry.getValue());
}
}
}
Map<String, String> customparameterMap = convertDetailsToMap(details);

if (getBootType() != null) {
customparameterMap.put(getBootType().toString(), getBootMode().toString());
}
Expand Down Expand Up @@ -450,18 +441,7 @@ public Long getUserdataId() {
}

public Map<String, String> getUserdataDetails() {
Map<String, String> userdataDetailsMap = new HashMap<String, String>();
if (userdataDetails != null && userdataDetails.size() != 0) {
Collection parameterCollection = userdataDetails.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (Map.Entry<String,String> entry: value.entrySet()) {
userdataDetailsMap.put(entry.getKey(),entry.getValue());
}
}
}
return userdataDetailsMap;
return convertDetailsToMap(userdataDetails);
}

public Long getZoneId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
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. " +
Expand Down Expand Up @@ -117,18 +114,7 @@ public Long getUserdataId() {
}

public Map<String, String> getUserdataDetails() {
Map<String, String> userdataDetailsMap = new HashMap<String, String>();
if (userdataDetails != null && userdataDetails.size() != 0) {
Collection parameterCollection = userdataDetails.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (Map.Entry<String,String> entry: value.entrySet()) {
userdataDetailsMap.put(entry.getKey(),entry.getValue());
}
}
}
return userdataDetailsMap;
return convertDetailsToMap(userdataDetails);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
// 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;

Expand Down Expand Up @@ -99,17 +96,7 @@ public Long getServiceOfferingId() {
//it is because details.values() cannot be cast to a map.
//it gives a exception
public Map<String, String> getDetails() {
Map<String, String> customparameterMap = new HashMap<String, String>();
if (details != null && details.size() != 0) {
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (String key : value.keySet()) {
customparameterMap.put(key, value.get(key));
}
}
}
Map<String, String> customparameterMap = convertDetailsToMap(details);

if (shrinkOk != null) customparameterMap.put(ApiConstants.SHRINK_OK, String.valueOf(isShrinkOk()));
if (autoMigrate != null) customparameterMap.put(ApiConstants.AUTO_MIGRATE, String.valueOf(getAutoMigrate()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -176,18 +175,7 @@ public Long getUserdataId() {
}

public Map<String, String> getUserdataDetails() {
Map<String, String> userdataDetailsMap = new HashMap<String, String>();
if (userdataDetails != null && userdataDetails.size() != 0) {
Collection parameterCollection = userdataDetails.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (Map.Entry<String,String> entry: value.entrySet()) {
userdataDetailsMap.put(entry.getKey(),entry.getValue());
}
}
}
return userdataDetailsMap;
return convertDetailsToMap(userdataDetails);
}

public Boolean getDisplayVm() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
// 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;
Expand Down Expand Up @@ -95,17 +92,7 @@ public Long getServiceOfferingId() {
}

public Map<String, String> getDetails() {
Map<String, String> customparameterMap = new HashMap<String, String>();
if (details != null && details.size() != 0) {
Collection parameterCollection = details.values();
Iterator iter = parameterCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> value = (HashMap<String, String>)iter.next();
for (String key : value.keySet()) {
customparameterMap.put(key, value.get(key));
}
}
}
Map<String, String> customparameterMap = convertDetailsToMap(details);

if (shrinkOk != null) customparameterMap.put(ApiConstants.SHRINK_OK, String.valueOf(isShrinkOk()));
if (autoMigrate != null) customparameterMap.put(ApiConstants.AUTO_MIGRATE, String.valueOf(getAutoMigrate()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ 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;
Expand Down Expand Up @@ -153,6 +165,22 @@ 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;
Expand Down Expand Up @@ -193,4 +221,24 @@ 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ 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;

Expand Down Expand Up @@ -228,6 +234,24 @@ 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;
Expand Down
Loading