server: Fixes API permissions, global settings and template UX (#3534)

Fixes:

- This allows getUploadParamsForIso for all user role types, also fixes
authorised field for getUploadParamsForTemplate API.
- Fix global setting description to say what is used when value is empty/blank.
- For VM running/allocated usage description, use parenthesis to return the instance name and ID.
- Display template download progress when template is added to a project

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2019-08-01 13:30:34 +05:30 committed by GitHub
parent b2db8979f2
commit d3b292ace9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 12 deletions

View File

@ -16,11 +16,9 @@
// under the License.
package org.apache.cloudstack.api.command.user.iso;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import java.net.MalformedURLException;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.AbstractGetUploadParamsCmd;
import org.apache.cloudstack.api.ApiConstants;
@ -33,11 +31,16 @@ import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
import java.net.MalformedURLException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
@APICommand(name = GetUploadParamsForIsoCmd.APINAME,
description = "upload an existing ISO into the CloudStack cloud.",
responseObject = GetUploadParamsResponse.class, since = "4.13",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class GetUploadParamsForIsoCmd extends AbstractGetUploadParamsCmd {

View File

@ -22,6 +22,7 @@ import java.net.MalformedURLException;
import java.util.Collection;
import java.util.Map;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.AbstractGetUploadParamsCmd;
import org.apache.cloudstack.api.ApiConstants;
@ -35,8 +36,10 @@ import org.apache.log4j.Logger;
import com.cloud.exception.ResourceAllocationException;
@APICommand(name = "getUploadParamsForTemplate", description = "upload an existing template into the CloudStack cloud. ", responseObject = GetUploadParamsResponse.class, since =
"4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@APICommand(name = "getUploadParamsForTemplate", description = "upload an existing template into the CloudStack cloud. ",
responseObject = GetUploadParamsResponse.class, since = "4.6.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
public static final Logger s_logger = Logger.getLogger(GetUploadParamsForTemplateCmd.class.getName());

View File

@ -92,7 +92,7 @@ public interface QueryService {
static final ConfigKey<String> UserVMBlacklistedDetails = new ConfigKey<String>("Advanced", String.class,
"user.vm.blacklisted.details", "rootdisksize, cpuOvercommitRatio, memoryOvercommitRatio, Message.ReservedCapacityFreed.Flag",
"Determines whether users can view certain VM settings", true);
"Determines whether users can view certain VM settings. When set to empty, default value used is: rootdisksize, cpuOvercommitRatio, memoryOvercommitRatio, Message.ReservedCapacityFreed.Flag.", true);
static final ConfigKey<String> UserVMReadOnlyUIDetails = new ConfigKey<String>("Advanced", String.class,
"user.vm.readonly.ui.details", "dataDiskController, rootDiskController",

View File

@ -3373,7 +3373,7 @@ public class ApiResponseHelper implements ResponseGenerator {
builder.append("Allocated VM usage ");
}
if (vm != null) {
builder.append("for ").append(vm.getHostName()).append(" (").append(vm.getInstanceName()).append(", ").append(vm.getUuid()).append(") ");
builder.append("for ").append(vm.getHostName()).append(" (").append(vm.getInstanceName()).append(") (").append(vm.getUuid()).append(") ");
}
if (svcOffering != null) {
builder.append("using service offering ").append(svcOffering.getName()).append(" (").append(svcOffering.getUuid()).append(") ");

View File

@ -166,8 +166,10 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
templateResponse.setDomainId(template.getDomainUuid());
templateResponse.setDomainName(template.getDomainName());
// If the user is an 'Admin' or 'the owner of template', add the template download status
if (view == ResponseView.Full || template.getAccountId() == CallContext.current().getCallingAccount().getId() ) {
// If the user is an 'Admin' or 'the owner of template' or template belongs to a project, add the template download status
if (view == ResponseView.Full ||
template.getAccountId() == CallContext.current().getCallingAccount().getId() ||
template.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
String templateStatus = getTemplateStatus(template);
if (templateStatus != null) {
templateResponse.setStatus(templateStatus);