mirror of https://github.com/apache/cloudstack.git
volume upload: disabled all zones during template upload
This commit is contained in:
parent
ce823a3a26
commit
5c152e5f3a
|
|
@ -22,7 +22,6 @@ import java.net.MalformedURLException;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.AbstractGetUploadParamsCmd;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
|
|
@ -34,6 +33,8 @@ import org.apache.cloudstack.api.response.GuestOSResponse;
|
|||
import org.apache.cloudstack.context.CallContext;
|
||||
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)
|
||||
public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
|
||||
|
|
@ -149,6 +150,7 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws ServerApiException {
|
||||
validateRequest();
|
||||
try {
|
||||
GetUploadParamsResponse response = _templateService.registerTemplateForPostUpload(this);
|
||||
response.setResponseName(getCommandName());
|
||||
|
|
@ -159,6 +161,12 @@ public class GetUploadParamsForTemplateCmd extends AbstractGetUploadParamsCmd {
|
|||
}
|
||||
}
|
||||
|
||||
private void validateRequest() {
|
||||
if (getZoneId() <= 0) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "invalid zoneid");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
|
|
|
|||
|
|
@ -691,41 +691,18 @@
|
|||
label: 'label.zone',
|
||||
docID: 'helpRegisterTemplateZone',
|
||||
select: function(args) {
|
||||
if (g_regionsecondaryenabled == true) {
|
||||
args.response.success({
|
||||
data: [{
|
||||
id: -1,
|
||||
description: "All Zones"
|
||||
}]
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: createURL("listZones&available=true"),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function(json) {
|
||||
var zoneObjs = [];
|
||||
var items = json.listzonesresponse.zone;
|
||||
if (items != null) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
zoneObjs.push({
|
||||
id: items[i].id,
|
||||
description: items[i].name
|
||||
});
|
||||
}
|
||||
}
|
||||
if (isAdmin() && !(cloudStack.context.projects && cloudStack.context.projects[0])) {
|
||||
zoneObjs.unshift({
|
||||
id: -1,
|
||||
description: "All Zones"
|
||||
});
|
||||
}
|
||||
args.response.success({
|
||||
data: zoneObjs
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$.ajax({
|
||||
url: createURL("listZones&available=true"),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function(json) {
|
||||
var zoneObjs = json.listzonesresponse.zone;
|
||||
args.response.success({
|
||||
descriptionField: 'name',
|
||||
data: zoneObjs
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue