Skip to content

Commit 4534cef

Browse files
authored
backports for 4.11.1 from master (#2621)
* CLOUDSTACK-10147 Disabled Xenserver Cluster can still deploy VM's. Added code to skip disabled clusters when selecting a host (#2442) (cherry picked from commit c3488a5) Signed-off-by: Rohit Yadav <[email protected]> * CLOUDSTACK-10318: Bug on sorting ACL rules list in chrome (#2478) (cherry picked from commit 4412563) Signed-off-by: Rohit Yadav <[email protected]> * CLOUDSTACK-10284:Creating a snapshot from VM Snapshot generates error if hypervisor is not KVM. Signed-off-by: Rohit Yadav <[email protected]> * CLOUDSTACK-10221: Allow IPv6 when creating a Basic Network (#2397) Since CloudStack 4.10 Basic Networking supports IPv6 and thus should be allowed to be specified when creating a network. Signed-off-by: Wido den Hollander <[email protected]> (cherry picked from commit 9733a10) Signed-off-by: Rohit Yadav <[email protected]> * CLOUDSTACK-10214: Unable to remove local primary storage (#2390) Allow admins to remove primary storage pool. Cherry-picked from eba2e1d Signed-off-by: Rohit Yadav <[email protected]> * dateutil: constistency of tzdate input and output (#2392) Signed-off-by: Yoan Blanc <[email protected]> Signed-off-by: Daan Hoogland <[email protected]> (cherry picked from commit 2ad5202) Signed-off-by: Rohit Yadav <[email protected]> * CLOUDSTACK-10054:Volume download times out in 3600 seconds (#2244) (cherry picked from commit bb607d0) Signed-off-by: Rohit Yadav <[email protected]> * When creating a new account (via domain admin) it is possible to select “root admin” as the role for the new user (#2606) * create account with domain admin showing 'root admin' role Domain admins should not be able to assign the role of root admin to new users. Therefore, the role ‘root admin’ (or any other of the same type) should not be visible to domain admins. * License and formatting * Break long sentence into multiple lines * Fix wording of method 'getCurrentAccount' * fix typo in variable name * [CLOUDSTACK-10259] Missing float part of secondary storage data in listAccounts * [CLOUDSTACK-9338] ACS not accounting resources of VMs with custom service offering ACS is accounting the resources properly when deploying VMs with custom service offerings. However, there are other methods (such as updateResourceCount) that do not execute the resource accounting properly, and these methods update the resource count for an account in the database. Therefore, if a user deploys VMs with custom service offerings, and later this user calls the “updateResourceCount” method, it (the method) will only account for VMs with normal service offerings, and update this as the number of resources used by the account. This will result in a smaller number of resources to be accounted for the given account than the real used value. The problem becomes worse because if the user starts to delete these VMs, it is possible to reach negative values of resources allocated (breaking all of the resource limiting for accounts). This is a very serious attack vector for public cloud providers! * [CLOUDSTACK-10230] User should not be able to use removed “Guest OS type” (#2404) * [CLOUDSTACK-10230] User is able to change to “Guest OS type” that has been removed Users are able to change the OS type of VMs to “Guest OS type” that has been removed. This becomes a security issue when we try to force users to use HVM VMs (Meltdown/Spectre thing). A removed “guest os type” should not be usable by any users in the cloud. * Remove trailing lines that are breaking build due to checkstyle compliance * Remove unused imports * fix classes that were in the wrong folder structure * Updates to capacity management
1 parent bd09595 commit 4534cef

File tree

50 files changed

+1726
-725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1726
-725
lines changed

api/src/com/cloud/configuration/Resource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public enum ResourceType { // Primary and Secondary storage are allocated_storag
3838
private ResourceOwnerType[] supportedOwners;
3939
private int ordinal;
4040
public static final long bytesToKiB = 1024;
41-
public static final long bytesToMiB = 1024 * 1024;
42-
public static final long bytesToGiB = 1024 * 1024 * 1024;
41+
public static final long bytesToMiB = bytesToKiB * 1024;
42+
public static final long bytesToGiB = bytesToMiB * 1024;
4343

4444
ResourceType(String name, int ordinal, ResourceOwnerType... supportedOwners) {
4545
this.name = name;

api/src/main/java/com/cloud/exception/UnavailableCommandException.java renamed to api/src/com/cloud/exception/UnavailableCommandException.java

File renamed without changes.

api/src/org/apache/cloudstack/acl/RoleService.java

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,64 @@
1717

1818
package org.apache.cloudstack.acl;
1919

20+
import java.util.List;
21+
2022
import org.apache.cloudstack.acl.RolePermission.Permission;
2123
import org.apache.cloudstack.framework.config.ConfigKey;
2224

23-
import java.util.List;
24-
2525
public interface RoleService {
2626

2727
ConfigKey<Boolean> EnableDynamicApiChecker = new ConfigKey<>("Advanced", Boolean.class, "dynamic.apichecker.enabled", "false",
28-
"If set to true, this enables the dynamic role-based api access checker and disables the default static role-based api access checker.",
29-
true);
28+
"If set to true, this enables the dynamic role-based api access checker and disables the default static role-based api access checker.", true);
3029

3130
boolean isEnabled();
32-
Role findRole(final Long id);
33-
Role createRole(final String name, final RoleType roleType, final String description);
34-
Role updateRole(final Role role, final String name, final RoleType roleType, final String description);
35-
boolean deleteRole(final Role role);
3631

37-
RolePermission findRolePermission(final Long id);
38-
RolePermission findRolePermissionByUuid(final String uuid);
32+
/**
33+
* Searches for a role with the given ID. If the ID is null or less than zero, this method will return null.
34+
* This method will also return null if no role is found with the provided ID.
35+
* Moreover, we will check if the requested role is of 'Admin' type; roles with 'Admin' type should only be visible to 'root admins'.
36+
* Therefore, if a non-'root admin' user tries to search for an 'Admin' role, this method will return null.
37+
*/
38+
Role findRole(Long id);
39+
40+
Role createRole(String name, RoleType roleType, String description);
41+
42+
Role updateRole(Role role, String name, RoleType roleType, String description);
43+
44+
boolean deleteRole(Role role);
45+
46+
RolePermission findRolePermission(Long id);
47+
48+
RolePermission findRolePermissionByUuid(String uuid);
49+
50+
RolePermission createRolePermission(Role role, Rule rule, Permission permission, String description);
3951

40-
RolePermission createRolePermission(final Role role, final Rule rule, final Permission permission, final String description);
4152
/**
4253
* updateRolePermission updates the order/position of an role permission
4354
* @param role The role whose permissions needs to be re-ordered
4455
* @param newOrder The new list of ordered role permissions
4556
*/
46-
boolean updateRolePermission(final Role role, final List<RolePermission> newOrder);
47-
boolean updateRolePermission(final Role role, final RolePermission rolePermission, final Permission permission);
48-
boolean deleteRolePermission(final RolePermission rolePermission);
57+
boolean updateRolePermission(Role role, List<RolePermission> newOrder);
4958

59+
boolean updateRolePermission(Role role, RolePermission rolePermission, Permission permission);
60+
61+
boolean deleteRolePermission(RolePermission rolePermission);
62+
63+
/**
64+
* List all roles configured in the database. Roles that have the type {@link RoleType#Admin} will not be shown for users that are not 'root admin'.
65+
*/
5066
List<Role> listRoles();
51-
List<Role> findRolesByName(final String name);
52-
List<Role> findRolesByType(final RoleType roleType);
53-
List<RolePermission> findAllPermissionsBy(final Long roleId);
67+
68+
/**
69+
* Find all roles that have the giving {@link String} as part of their name.
70+
* If the user calling the method is not a 'root admin', roles of type {@link RoleType#Admin} wil lbe removed of the returned list.
71+
*/
72+
List<Role> findRolesByName(String name);
73+
74+
/**
75+
* Find all roles by {@link RoleType}. If the role type is {@link RoleType#Admin}, the calling account must be a root admin, otherwise we return an empty list.
76+
*/
77+
List<Role> findRolesByType(RoleType roleType);
78+
79+
List<RolePermission> findAllPermissionsBy(Long roleId);
5480
}

api/src/org/apache/cloudstack/api/command/admin/acl/ListRolesCmd.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,25 @@
1717

1818
package org.apache.cloudstack.api.command.admin.acl;
1919

20-
import com.cloud.exception.ConcurrentOperationException;
21-
import com.cloud.exception.InsufficientCapacityException;
22-
import com.cloud.exception.NetworkRuleConflictException;
23-
import com.cloud.exception.ResourceAllocationException;
24-
import com.cloud.exception.ResourceUnavailableException;
25-
import com.cloud.user.Account;
26-
import com.google.common.base.Strings;
20+
import java.util.ArrayList;
21+
import java.util.Collections;
22+
import java.util.List;
23+
2724
import org.apache.cloudstack.acl.Role;
2825
import org.apache.cloudstack.acl.RoleType;
2926
import org.apache.cloudstack.api.APICommand;
3027
import org.apache.cloudstack.api.ApiConstants;
3128
import org.apache.cloudstack.api.BaseCmd;
3229
import org.apache.cloudstack.api.Parameter;
33-
import org.apache.cloudstack.api.ServerApiException;
3430
import org.apache.cloudstack.api.response.ListResponse;
3531
import org.apache.cloudstack.api.response.RoleResponse;
32+
import org.apache.commons.lang3.StringUtils;
3633

37-
import java.util.ArrayList;
38-
import java.util.Collections;
39-
import java.util.List;
34+
import com.cloud.user.Account;
35+
import com.google.common.base.Strings;
4036

41-
@APICommand(name = ListRolesCmd.APINAME, description = "Lists dynamic roles in CloudStack", responseObject = RoleResponse.class,
42-
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
43-
since = "4.9.0",
44-
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin})
37+
@APICommand(name = ListRolesCmd.APINAME, description = "Lists dynamic roles in CloudStack", responseObject = RoleResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.9.0", authorized = {
38+
RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin})
4539
public class ListRolesCmd extends BaseCmd {
4640
public static final String APINAME = "listRoles";
4741

@@ -112,13 +106,13 @@ private void setupResponse(final List<Role> roles) {
112106
}
113107

114108
@Override
115-
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
116-
final List<Role> roles;
109+
public void execute() {
110+
List<Role> roles;
117111
if (getId() != null && getId() > 0L) {
118112
roles = Collections.singletonList(roleService.findRole(getId()));
119-
} else if (!Strings.isNullOrEmpty(getName())) {
113+
} else if (StringUtils.isNotBlank(getName())) {
120114
roles = roleService.findRolesByName(getName());
121-
} else if (getRoleType() != null){
115+
} else if (getRoleType() != null) {
122116
roles = roleService.findRolesByType(getRoleType());
123117
} else {
124118
roles = roleService.listRoles();

api/src/main/java/org/apache/cloudstack/api/command/admin/acl/RoleCmd.java renamed to api/src/org/apache/cloudstack/api/command/admin/acl/RoleCmd.java

File renamed without changes.

api/src/org/apache/cloudstack/api/response/AccountResponse.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.cloud.serializer.Param;
3030
import com.cloud.user.Account;
3131

32-
@SuppressWarnings("unused")
3332
@EntityReference(value = Account.class)
3433
public class AccountResponse extends BaseResponse implements ResourceLimitAndCountResponse {
3534
@SerializedName(ApiConstants.ID)
@@ -222,7 +221,7 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
222221

223222
@SerializedName("secondarystoragetotal")
224223
@Param(description = "the total secondary storage space (in GiB) owned by account", since = "4.2.0")
225-
private Long secondaryStorageTotal;
224+
private float secondaryStorageTotal;
226225

227226
@SerializedName("secondarystorageavailable")
228227
@Param(description = "the total secondary storage space (in GiB) available to be used for this account", since = "4.2.0")
@@ -501,7 +500,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) {
501500
}
502501

503502
@Override
504-
public void setSecondaryStorageTotal(Long secondaryStorageTotal) {
503+
public void setSecondaryStorageTotal(float secondaryStorageTotal) {
505504
this.secondaryStorageTotal = secondaryStorageTotal;
506505
}
507506

api/src/org/apache/cloudstack/api/response/DomainResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class DomainResponse extends BaseResponse implements ResourceLimitAndCoun
165165
private String secondaryStorageLimit;
166166

167167
@SerializedName("secondarystoragetotal") @Param(description="the total secondary storage space (in GiB) owned by domain", since="4.2.0")
168-
private Long secondaryStorageTotal;
168+
private float secondaryStorageTotal;
169169

170170
@SerializedName("secondarystorageavailable") @Param(description="the total secondary storage space (in GiB) available to be used for this domain", since="4.2.0")
171171
private String secondaryStorageAvailable;
@@ -399,7 +399,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) {
399399
}
400400

401401
@Override
402-
public void setSecondaryStorageTotal(Long secondaryStorageTotal) {
402+
public void setSecondaryStorageTotal(float secondaryStorageTotal) {
403403
this.secondaryStorageTotal = secondaryStorageTotal;
404404
}
405405

api/src/org/apache/cloudstack/api/response/ProjectResponse.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.cloud.serializer.Param;
3030

3131
@EntityReference(value = Project.class)
32-
@SuppressWarnings("unused")
3332
public class ProjectResponse extends BaseResponse implements ResourceLimitAndCountResponse {
3433

3534
@SerializedName(ApiConstants.ID)
@@ -134,7 +133,7 @@ public class ProjectResponse extends BaseResponse implements ResourceLimitAndCou
134133

135134
@SerializedName("secondarystoragetotal")
136135
@Param(description = "the total secondary storage space (in GiB) owned by project", since = "4.2.0")
137-
private Long secondaryStorageTotal;
136+
private float secondaryStorageTotal;
138137

139138
@SerializedName("secondarystorageavailable")
140139
@Param(description = "the total secondary storage space (in GiB) available to be used for this project", since = "4.2.0")
@@ -414,7 +413,7 @@ public void setSecondaryStorageLimit(String secondaryStorageLimit) {
414413
}
415414

416415
@Override
417-
public void setSecondaryStorageTotal(Long secondaryStorageTotal) {
416+
public void setSecondaryStorageTotal(float secondaryStorageTotal) {
418417
this.secondaryStorageTotal = secondaryStorageTotal;
419418
}
420419

api/src/org/apache/cloudstack/api/response/ResourceLimitAndCountResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public interface ResourceLimitAndCountResponse {
5454

5555
public void setSecondaryStorageLimit(String secondaryStorageLimit);
5656

57-
public void setSecondaryStorageTotal(Long secondaryStorageTotal);
57+
public void setSecondaryStorageTotal(float secondaryStorageTotal);
5858

5959
public void setSecondaryStorageAvailable(String secondaryStorageAvailable);
6060

core/src/com/cloud/storage/template/IsoProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public class IsoProcessor extends AdapterBase implements Processor {
3737

3838
@Override
3939
public FormatInfo process(String templatePath, ImageFormat format, String templateName) {
40+
return process(templatePath, format, templateName, 0);
41+
}
42+
43+
@Override
44+
public FormatInfo process(String templatePath, ImageFormat format, String templateName, long processTimeout) {
4045
if (format != null) {
4146
s_logger.debug("We don't handle conversion from " + format + " to ISO.");
4247
return null;

0 commit comments

Comments
 (0)