mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss
This commit is contained in:
commit
3735ba1466
|
|
@ -88,6 +88,7 @@ public class ApiConstants {
|
|||
public static final String IS_RECURSIVE = "isrecursive";
|
||||
public static final String ISO_FILTER = "isofilter";
|
||||
public static final String JOB_ID = "jobid";
|
||||
public static final String JOB_STATUS = "jobstatus";
|
||||
public static final String LASTNAME = "lastname";
|
||||
public static final String LEVEL = "level";
|
||||
public static final String LUN = "lun";
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package com.cloud.api;
|
||||
|
||||
import com.cloud.api.response.AsyncJobResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
|
||||
/**
|
||||
* A base command for supporting asynchronous API calls. When an API command is received, the command will be
|
||||
|
|
@ -76,4 +77,19 @@ public abstract class BaseAsyncCmd extends BaseCmd {
|
|||
public void setStartEventId(Long startEventId) {
|
||||
this.startEventId = startEventId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Async commands that want to be tracked as part of the listXXX commands need to
|
||||
* provide implementations of the two following methods, getInstanceId() and getInstanceType()
|
||||
*
|
||||
* getObjectId() should return the id of the object the async command is executing on
|
||||
* getObjectType() should return a type from the AsyncJobVO.Type enumeration
|
||||
*/
|
||||
public Long getInstanceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.None;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.cloud.api;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
|
||||
|
||||
public abstract class BaseListCmd extends BaseCmd {
|
||||
|
||||
|
|
@ -61,4 +63,8 @@ public abstract class BaseListCmd extends BaseCmd {
|
|||
}
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.None;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,33 @@ public interface ResponseObject {
|
|||
* @param name
|
||||
*/
|
||||
void setObjectName(String name);
|
||||
|
||||
/**
|
||||
* Returns the object Id
|
||||
*/
|
||||
Long getObjectId();
|
||||
|
||||
/**
|
||||
* Returns the job id
|
||||
* @return
|
||||
*/
|
||||
Long getJobId();
|
||||
|
||||
/**
|
||||
* Sets the job id
|
||||
* @param jobId
|
||||
*/
|
||||
void setJobId(Long jobId);
|
||||
|
||||
/**
|
||||
* Returns the job status
|
||||
* @return
|
||||
*/
|
||||
Integer getJobStatus();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param jobStatus
|
||||
*/
|
||||
void setJobStatus(Integer jobStatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InsufficientStorageCapacityException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
|
|
@ -191,6 +192,10 @@ public class DeployVMCmd extends BaseAsyncCmd {
|
|||
return "deploying Vm";
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
|
@ -81,6 +82,14 @@ public class DestroyVMCmd extends BaseAsyncCmd {
|
|||
public String getEventDescription() {
|
||||
return "destroying vm: " + getId();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@Implementation(description="List the virtual machines owned by the account.", responseObject=UserVmResponse.class)
|
||||
|
|
@ -126,6 +127,10 @@ public class ListVMsCmd extends BaseListCmd {
|
|||
return s_name;
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<? extends UserVm> result = _mgr.searchForUserVMs(this);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
|
@ -79,6 +80,14 @@ public class RebootVMCmd extends BaseAsyncCmd {
|
|||
return "rebooting user vm: " + getId();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserVm result = _userVmService.rebootVirtualMachine(this);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
|
@ -95,6 +96,14 @@ public class ResetVMPasswordCmd extends BaseAsyncCmd {
|
|||
public String getEventDescription() {
|
||||
return "resetting password for vm: " + getId();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
Random _rand = new Random(System.currentTimeMillis());
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -89,6 +90,14 @@ public class StartVMCmd extends BaseAsyncCmd {
|
|||
return "starting user vm: " + getId();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -84,6 +85,14 @@ public class StopVMCmd extends BaseAsyncCmd {
|
|||
public String getEventDescription() {
|
||||
return "stopping user vm: " + getId();
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.VirtualMachine;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ServerApiException, ConcurrentOperationException{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ResponseObject;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class BaseResponse implements ResponseObject {
|
||||
private transient String responseName;
|
||||
private transient String objectName;
|
||||
|
||||
|
||||
@Override
|
||||
public String getResponseName() {
|
||||
return responseName;
|
||||
|
|
@ -25,5 +28,32 @@ public class BaseResponse implements ResponseObject {
|
|||
public void setObjectName(String objectName) {
|
||||
this.objectName = objectName;
|
||||
}
|
||||
|
||||
|
||||
public Long getObjectId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// For use by list commands with pending async jobs
|
||||
@SerializedName(ApiConstants.JOB_ID) @Param(description="the ID of the latest async job acting on this object")
|
||||
private Long jobId;
|
||||
|
||||
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="the current status of the latest async job acting on this object")
|
||||
private Integer jobStatus;
|
||||
|
||||
public Long getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setJobId(Long jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
public void setJobStatus(Integer jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,6 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
|
||||
private Long id;
|
||||
|
||||
@SerializedName(ApiConstants.JOB_ID) @Param(description="the job ID associated with the router. This is only displayed if the router listed is part of a currently running asynchronous job.")
|
||||
private Long jobId;
|
||||
|
||||
@SerializedName("jobstatus") @Param(description="the job status associated with the router. This is only displayed if the router listed is part of a currently running asynchronous job.")
|
||||
private Integer jobStatus;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID for the router")
|
||||
private Long zoneId;
|
||||
|
||||
|
|
@ -117,22 +111,6 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setJobId(Long jobId) {
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
public void setJobStatus(Integer jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ public class UserVmResponse extends BaseResponse {
|
|||
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
|
||||
private Integer jobStatus;
|
||||
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,15 @@ package com.cloud.async;
|
|||
import java.util.Date;
|
||||
|
||||
public interface AsyncJob {
|
||||
public enum Type {
|
||||
None,
|
||||
VirtualMachine,
|
||||
Router,
|
||||
Volume,
|
||||
ConsoleProxy,
|
||||
Snapshot
|
||||
}
|
||||
|
||||
Long getId();
|
||||
long getUserId();
|
||||
long getAccountId();
|
||||
|
|
@ -38,7 +47,7 @@ public interface AsyncJob {
|
|||
Date getLastUpdated();
|
||||
Date getLastPolled();
|
||||
Date getRemoved();
|
||||
String getInstanceType();
|
||||
Type getInstanceType();
|
||||
Long getInstanceId();
|
||||
String getSessionKey();
|
||||
String getCmdOriginator();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@
|
|||
<classpathentry kind="lib" path="/thirdparty/vmware-vim.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/vmware-vim25.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/gson.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/xenserver-5.5.0-1.jar" sourcepath="/thirdparty/xen/XenServerJava"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/xenserver-5.6.0-1.jar" sourcepath="/thirdparty/XenServerJava"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import java.util.Date;
|
|||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
|
@ -81,9 +83,10 @@ public class AsyncJobVO implements AsyncJob {
|
|||
|
||||
@Column(name="job_result", length=65535)
|
||||
private String result;
|
||||
|
||||
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Column(name="instance_type", length=64)
|
||||
private String instanceType;
|
||||
private Type instanceType;
|
||||
|
||||
@Column(name="instance_id", length=64)
|
||||
private Long instanceId;
|
||||
|
|
@ -296,11 +299,11 @@ public class AsyncJobVO implements AsyncJob {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getInstanceType() {
|
||||
public Type getInstanceType() {
|
||||
return instanceType;
|
||||
}
|
||||
|
||||
public void setInstanceType(String instanceType) {
|
||||
public void setInstanceType(Type instanceType) {
|
||||
this.instanceType = instanceType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@
|
|||
<classpathentry kind="lib" path="/thirdparty/trilead-ssh2-build213.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/xstream-1.3.1.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/gson.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/xenserver-5.5.0-1.jar" sourcepath="/thirdparty/xen/XenServerJava"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/xenserver-5.6.0-1.jar" sourcepath="/thirdparty/XenServerJava"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.lang.reflect.Constructor;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
|
@ -143,6 +144,7 @@ import com.cloud.uservm.UserVm;
|
|||
import com.cloud.utils.ActionDelegate;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.UriUtils;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
|
@ -583,7 +585,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
|
|||
}
|
||||
|
||||
try {
|
||||
uri = new URI(url);
|
||||
uri = new URI(UriUtils.encodeURIComponent(url));
|
||||
if (uri.getScheme() == null)
|
||||
throw new InvalidParameterValueException("uri.scheme is null " + url + ", add nfs:// as a prefix");
|
||||
else if (uri.getScheme().equalsIgnoreCase("nfs")) {
|
||||
|
|
|
|||
|
|
@ -143,6 +143,14 @@ public class ApiDispatcher {
|
|||
public static void setupParameters(BaseCmd cmd, Map<String, String> params){
|
||||
Map<String, Object> unpackedParams = cmd.unpackParams(params);
|
||||
|
||||
if (cmd instanceof BaseListCmd) {
|
||||
if ((unpackedParams.get(ApiConstants.PAGE) == null) && (unpackedParams.get(ApiConstants.PAGE_SIZE) != null)) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "\"page\" parameter is required when \"pagesize\" is specified");
|
||||
} else if ((unpackedParams.get(ApiConstants.PAGE_SIZE) == null) && (unpackedParams.get(ApiConstants.PAGE) != null)) {
|
||||
throw new ServerApiException(BaseCmd.PARAM_ERROR, "\"pagesize\" parameter is required when \"page\" is specified");
|
||||
}
|
||||
}
|
||||
|
||||
Field[] fields = cmd.getClass().getDeclaredFields();
|
||||
Class<?> superClass = cmd.getClass().getSuperclass();
|
||||
while (BaseCmd.class.isAssignableFrom(superClass)) {
|
||||
|
|
|
|||
|
|
@ -606,12 +606,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
DomainRouterResponse routerResponse = new DomainRouterResponse();
|
||||
routerResponse.setId(router.getId());
|
||||
|
||||
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("domain_router", router.getId());
|
||||
if (asyncJob != null) {
|
||||
routerResponse.setJobId(asyncJob.getId());
|
||||
routerResponse.setJobStatus(asyncJob.getStatus());
|
||||
}
|
||||
|
||||
routerResponse.setZoneId(router.getDataCenterId());
|
||||
routerResponse.setZoneName(ApiDBUtils.findZoneById(router.getDataCenterId()).getName());
|
||||
routerResponse.setDns1(router.getDns1());
|
||||
|
|
@ -1266,12 +1260,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
routerResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
|
||||
}
|
||||
|
||||
AsyncJobVO asyncJob = ApiDBUtils.findInstancePendingAsyncJob("domain_router", router.getId());
|
||||
if (asyncJob != null) {
|
||||
routerResponse.setJobId(asyncJob.getId());
|
||||
routerResponse.setJobStatus(asyncJob.getStatus());
|
||||
}
|
||||
|
||||
List<? extends Nic> nics = ApiDBUtils.getNics(router);
|
||||
for (Nic singleNic : nics) {
|
||||
Long configId = singleNic.getNetworkId();
|
||||
|
|
@ -1912,7 +1900,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
jobResponse.setCreated(job.getCreated());
|
||||
jobResponse.setId(job.getId());
|
||||
jobResponse.setJobInstanceId(job.getInstanceId());
|
||||
jobResponse.setJobInstanceType(job.getInstanceType());
|
||||
jobResponse.setJobInstanceType(job.getInstanceType().toString());
|
||||
jobResponse.setJobProcStatus(job.getProcessStatus());
|
||||
jobResponse.setJobResult((ResponseObject)ApiSerializerHelper.fromSerializedString(job.getResult()));
|
||||
jobResponse.setJobResultCode(job.getResultCode());
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ import org.apache.http.protocol.ResponseServer;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.response.ApiResponseSerializer;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
|
|
@ -363,6 +365,9 @@ public class ApiServer implements HttpRequestHandler {
|
|||
}
|
||||
|
||||
private String queueCommand(BaseCmd cmdObj, Map<String, String> params) {
|
||||
UserContext ctx = UserContext.current();
|
||||
Long userId = ctx.getUserId();
|
||||
Account account = ctx.getAccount();
|
||||
if (cmdObj instanceof BaseAsyncCmd) {
|
||||
Long objectId = null;
|
||||
if (cmdObj instanceof BaseAsyncCreateCmd) {
|
||||
|
|
@ -375,10 +380,10 @@ public class ApiServer implements HttpRequestHandler {
|
|||
}
|
||||
|
||||
BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj;
|
||||
if (objectId != null) {
|
||||
objectId = asyncCmd.getInstanceId();
|
||||
}
|
||||
|
||||
UserContext ctx = UserContext.current();
|
||||
Long userId = ctx.getUserId();
|
||||
Account account = ctx.getAccount();
|
||||
if (userId != null) {
|
||||
params.put("ctxUserId", userId.toString());
|
||||
}
|
||||
|
|
@ -395,6 +400,8 @@ public class ApiServer implements HttpRequestHandler {
|
|||
}
|
||||
|
||||
AsyncJobVO job = new AsyncJobVO();
|
||||
job.setInstanceId(asyncCmd.getInstanceId());
|
||||
job.setInstanceType(asyncCmd.getInstanceType());
|
||||
job.setUserId(userId);
|
||||
if (account != null) {
|
||||
job.setAccountId(ctx.getAccount().getId());
|
||||
|
|
@ -414,8 +421,36 @@ public class ApiServer implements HttpRequestHandler {
|
|||
return ApiResponseSerializer.toSerializedString(asyncCmd.getResponse(jobId), asyncCmd.getResponseType());
|
||||
} else {
|
||||
_dispatcher.dispatch(cmdObj, params);
|
||||
|
||||
// if the command is of the listXXXCommand, we will need to also return the
|
||||
// the job id and status if possible
|
||||
if (cmdObj instanceof BaseListCmd) {
|
||||
buildAsyncListResponse((BaseListCmd)cmdObj, account);
|
||||
}
|
||||
return ApiResponseSerializer.toSerializedString((ResponseObject)cmdObj.getResponseObject(), cmdObj.getResponseType());
|
||||
}
|
||||
}
|
||||
|
||||
private void buildAsyncListResponse(BaseListCmd command, Account account) {
|
||||
List<ResponseObject> responses = ((ListResponse)command.getResponseObject()).getResponses();
|
||||
if (responses != null && responses.size() > 0) {
|
||||
List<? extends AsyncJob> jobs = _asyncMgr.findInstancePendingAsyncJobs(command.getInstanceType(), account.getId());
|
||||
if (jobs.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Using maps might possibly be more efficient if the set is large enough but for now, we'll just n squared
|
||||
// comparison of two lists. Either way, there shouldn't be too many async jobs active for the account.
|
||||
for (AsyncJob job : jobs) {
|
||||
if (job.getInstanceId() == null) continue;
|
||||
for (ResponseObject response : responses) {
|
||||
if (job.getInstanceId() == response.getObjectId()) {
|
||||
response.setJobId(job.getId());
|
||||
response.setJobStatus(job.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildAuditTrail(StringBuffer auditTrailSb, String command, String result) {
|
||||
|
|
|
|||
|
|
@ -18,16 +18,20 @@
|
|||
|
||||
package com.cloud.async;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.commands.QueryAsyncJobResultCmd;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.user.UserAccount;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface AsyncJobManager extends Manager {
|
||||
public AsyncJobExecutorContext getExecutorContext();
|
||||
|
||||
public AsyncJobVO getAsyncJob(long jobId);
|
||||
public AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId);
|
||||
public AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId);
|
||||
public List<? extends AsyncJob> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, long accountId);
|
||||
|
||||
public long submitAsyncJob(AsyncJobVO job);
|
||||
public long submitAsyncJob(AsyncJobVO job, boolean scheduleJobExecutionInContext);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,11 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
|
|||
@Override
|
||||
public AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId) {
|
||||
return _jobDao.findInstancePendingAsyncJob(instanceType, instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AsyncJobVO> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, long accountId) {
|
||||
return _jobDao.findInstancePendingAsyncJobs(instanceType, accountId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -111,7 +116,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
|
|||
Transaction txt = Transaction.currentTxn();
|
||||
try {
|
||||
txt.start();
|
||||
job.setInitMsid(getMsid());
|
||||
job.setInitMsid(getMsid());
|
||||
_jobDao.persist(job);
|
||||
txt.commit();
|
||||
|
||||
|
|
@ -210,7 +215,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
|
|||
txt.start();
|
||||
|
||||
AsyncJobVO job = _jobDao.createForUpdate();
|
||||
job.setInstanceType(instanceType);
|
||||
//job.setInstanceType(instanceType);
|
||||
job.setInstanceId(instanceId);
|
||||
job.setLastUpdated(DateUtil.currentGMTTime());
|
||||
_jobDao.update(jobId, job);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,12 @@ package com.cloud.async.dao;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface AsyncJobDao extends GenericDao<AsyncJobVO, Long> {
|
||||
AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId);
|
||||
List<AsyncJobVO> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, long accountId);
|
||||
List<AsyncJobVO> getExpiredJobs(Date cutTime, int limit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import javax.ejb.Local;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.async.AsyncJobResult;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
import com.cloud.utils.db.Filter;
|
||||
|
|
@ -36,7 +37,8 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long> implements AsyncJobDao {
|
||||
private static final Logger s_logger = Logger.getLogger(AsyncJobDaoImpl.class.getName());
|
||||
|
||||
private SearchBuilder<AsyncJobVO> pendingAsyncJobSearch;
|
||||
private SearchBuilder<AsyncJobVO> pendingAsyncJobSearch;
|
||||
private SearchBuilder<AsyncJobVO> pendingAsyncJobsSearch;
|
||||
private SearchBuilder<AsyncJobVO> expiringAsyncJobSearch;
|
||||
|
||||
public AsyncJobDaoImpl() {
|
||||
|
|
@ -49,6 +51,15 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long> implements
|
|||
SearchCriteria.Op.EQ);
|
||||
pendingAsyncJobSearch.done();
|
||||
|
||||
pendingAsyncJobsSearch = createSearchBuilder();
|
||||
pendingAsyncJobsSearch.and("instanceType", pendingAsyncJobsSearch.entity().getInstanceType(),
|
||||
SearchCriteria.Op.EQ);
|
||||
pendingAsyncJobsSearch.and("accountId", pendingAsyncJobsSearch.entity().getAccountId(),
|
||||
SearchCriteria.Op.EQ);
|
||||
pendingAsyncJobsSearch.and("status", pendingAsyncJobsSearch.entity().getStatus(),
|
||||
SearchCriteria.Op.EQ);
|
||||
pendingAsyncJobsSearch.done();
|
||||
|
||||
expiringAsyncJobSearch = createSearchBuilder();
|
||||
expiringAsyncJobSearch.and("created", expiringAsyncJobSearch.entity().getCreated(),
|
||||
SearchCriteria.Op.LTEQ);
|
||||
|
|
@ -72,6 +83,15 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long> implements
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<AsyncJobVO> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, long accountId) {
|
||||
SearchCriteria<AsyncJobVO> sc = pendingAsyncJobsSearch.create();
|
||||
sc.setParameters("instanceType", instanceType);
|
||||
sc.setParameters("accountId", accountId);
|
||||
sc.setParameters("status", AsyncJobResult.STATUS_IN_PROGRESS);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
public List<AsyncJobVO> getExpiredJobs(Date cutTime, int limit) {
|
||||
SearchCriteria<AsyncJobVO> sc = expiringAsyncJobSearch.create();
|
||||
sc.setParameters("created", cutTime);
|
||||
|
|
|
|||
|
|
@ -183,7 +183,6 @@ public enum Config {
|
|||
VmwarePrivateNetworkVSwitch("Advanced", ManagementServer.class, String.class, "vmware.private.vswitch", null, "Specify the vSwitch on host for private network", null),
|
||||
VmwarePublicNetworkVSwitch("Advanced", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null),
|
||||
VmwareGuestNetworkVSwitch("Advanced", ManagementServer.class, String.class, "vmware.guest.vswitch", null, "Specify the vSwitch on host for guest network", null),
|
||||
VmwarePrivateNetwork("Advanced", ManagementServer.class, String.class, "vmware.private.network", null, "Specify the private network on the vSwitch", null),
|
||||
|
||||
// Premium
|
||||
|
||||
|
|
|
|||
|
|
@ -423,9 +423,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="midmenu_navigationbox" id="middle_menu_pagination" style="display:none;">
|
||||
<div class="midmenu_prevbutton">
|
||||
<div id="midmenu_prevbutton" class="midmenu_prevbutton" style="display:none;">
|
||||
</div>
|
||||
<div class="midmenu_nextbutton">
|
||||
<div id="midmenu_nextbutton" class="midmenu_nextbutton" style="display:none;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -30,20 +30,76 @@ function afterLoadClusterJSP($leftmenuItem1) {
|
|||
clusterJsonToRightPanel($leftmenuItem1);
|
||||
var clusterId = $leftmenuItem1.data("jsonObj").id;
|
||||
var $midmenuContainer = $("#midmenu_container").empty();
|
||||
|
||||
disableMultipleSelectionInMidMenu();
|
||||
|
||||
var $container_host = $("<div id='midmenu_host_container'></div>");
|
||||
$midmenuContainer.append($container_host);
|
||||
var $header1 = $("#midmenu_itemheader_without_margin").clone().show(); //without margin on top
|
||||
$header1.find("#name").text("Host");
|
||||
$container_host.append($header1);
|
||||
listMidMenuItems2(("listHosts&type=Routing&clusterid="+clusterId), "listhostsresponse", "host", hostToMidmenu, hostToRightPanel, hostGetMidmenuId, false, true, $container_host);
|
||||
$container_host.append($header1);
|
||||
//listMidMenuItems2(("listHosts&type=Routing&clusterid="+clusterId), "listhostsresponse", "host", hostToMidmenu, hostToRightPanel, hostGetMidmenuId, false, 1);
|
||||
var count = 0;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listHosts&type=Routing&clusterid="+clusterId),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
selectedItemsInMidMenu = {};
|
||||
var items = json.listhostsresponse.host;
|
||||
if(items != null && items.length > 0) {
|
||||
for(var i=0; i<items.length;i++) {
|
||||
var $midmenuItem1 = $("#midmenu_item").clone();
|
||||
$midmenuItem1.data("toRightPanelFn", hostToRightPanel);
|
||||
hostToMidmenu(items[i], $midmenuItem1);
|
||||
bindClickToMidMenu($midmenuItem1, hostToRightPanel, hostGetMidmenuId);
|
||||
|
||||
$container_host.append($midmenuItem1.show());
|
||||
if(i == 0) { //click the 1st item in middle menu as default
|
||||
$midmenuItem1.click();
|
||||
}
|
||||
}
|
||||
count = items.length;
|
||||
}
|
||||
else {
|
||||
$container_host.append($("#midmenu_container_no_items_available").clone().show());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var $container_primarystorage = $("<div id='midmenu_primarystorage_container'></div>");
|
||||
$midmenuContainer.append($container_primarystorage);
|
||||
var $header2 = $("#midmenu_itemheader_with_margin").clone().show(); //with margin on top
|
||||
$header2.find("#name").text("Primary Storage");
|
||||
$container_primarystorage.append($header2);
|
||||
listMidMenuItems2(("listStoragePools&clusterid="+clusterId), "liststoragepoolsresponse", "storagepool", primarystorageToMidmenu, primarystorageToRightPanel, primarystorageGetMidmenuId, false, false, $container_primarystorage);
|
||||
//listMidMenuItems2(("listStoragePools&clusterid="+clusterId), "liststoragepoolsresponse", "storagepool", primarystorageToMidmenu, primarystorageToRightPanel, primarystorageGetMidmenuId, false, 1);
|
||||
var count = 0;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listStoragePools&clusterid="+clusterId),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
selectedItemsInMidMenu = {};
|
||||
var items = json.liststoragepoolsresponse.storagepool;
|
||||
if(items != null && items.length > 0) {
|
||||
for(var i=0; i<items.length;i++) {
|
||||
var $midmenuItem1 = $("#midmenu_item").clone();
|
||||
$midmenuItem1.data("toRightPanelFn", primarystorageToRightPanel);
|
||||
primarystorageToMidmenu(items[i], $midmenuItem1);
|
||||
bindClickToMidMenu($midmenuItem1, primarystorageToRightPanel, primarystorageGetMidmenuId);
|
||||
$container_primarystorage.append($midmenuItem1.show());
|
||||
}
|
||||
count = items.length;
|
||||
}
|
||||
else {
|
||||
$container_primarystorage.append($("#midmenu_container_no_items_available").clone().show());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clusterJsonToRightPanel($leftmenuItem1) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function afterLoadDashboardJSP() {
|
|||
//$("#menutab_dashboard_root, #menutab_vm, #menutab_networking_old, #menutab_networking, #menutab_templates, #menutab_events, #menutab_hosts, #menutab_storage, #menutab_accounts, #menutab_domain").hide();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true"+maxPageSize),
|
||||
data: createURL("command=listZones&available=true"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -165,7 +165,7 @@ function afterLoadDashboardJSP() {
|
|||
$thisSection.find("#capacity_zone_select").bind("change", function(event) {
|
||||
var zoneId = $(this).val();
|
||||
$.ajax({
|
||||
data: createURL("command=listPods&zoneId="+zoneId+maxPageSize),
|
||||
data: createURL("command=listPods&zoneId="+zoneId),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function drawRootNode(rootDomainId) {
|
|||
var $domainTree = $("#leftmenu_domain_tree").find("#tree_container").hide();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listDomains&id="+rootDomainId+"&pageSize=-1"), //pageSize=-1 will return all items (no limitation)
|
||||
data: createURL("command=listDomains&id="+rootDomainId),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -72,7 +72,7 @@ function drawNode(json, level, container) {
|
|||
|
||||
function drawTree(id, level, container) {
|
||||
$.ajax({
|
||||
data: createURL("command=listDomainChildren&id="+id+"&pageSize=-1"),
|
||||
data: createURL("command=listDomainChildren&id="+id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -142,7 +142,7 @@ function domainToRightPanel2($leftmenuItem1) {
|
|||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listAccounts&domainid="+domainId+maxPageSize),
|
||||
data: createURL("command=listAccounts&domainid="+domainId),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var accounts = json.listaccountsresponse.account;
|
||||
|
|
@ -298,7 +298,7 @@ function listAdminAccounts(domainId) {
|
|||
var accountType = (domainId==1)? 1: 2;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listAccounts&domainid="+domainId+"&accounttype="+accountType+maxPageSize),
|
||||
data: createURL("command=listAccounts&domainid="+domainId+"&accounttype="+accountType),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listaccountsresponse.account;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function populateGlobalSettingGrid() {
|
|||
$thisTab.find("#tab_spinning_wheel").show();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listConfigurations"+maxPageSize),
|
||||
data: createURL("command=listConfigurations"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listconfigurationsresponse.configuration;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,19 @@ function hostJsonToDetailsTab() {
|
|||
if(jsonObj == null)
|
||||
return;
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listHosts&id="+jsonObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var items = json.listhostsresponse.host;
|
||||
if(items != null && items.length > 0) {
|
||||
jsonObj = items[0];
|
||||
$midmenuItem1.data("jsonObj", jsonObj);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var $thisTab = $("#right_panel_content #tab_content_details");
|
||||
$thisTab.find("#tab_container").hide();
|
||||
$thisTab.find("#tab_spinning_wheel").show();
|
||||
|
|
@ -370,7 +383,7 @@ function hostClearDetailsTab() {
|
|||
|
||||
function populateForUpdateOSDialog(oscategoryid) {
|
||||
$.ajax({
|
||||
data: createURL("command=listOsCategories"+maxPageSize),
|
||||
data: createURL("command=listOsCategories"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var categories = json.listoscategoriesresponse.oscategory;
|
||||
|
|
|
|||
|
|
@ -210,8 +210,27 @@ $(document).ready(function() {
|
|||
return;
|
||||
}
|
||||
|
||||
//pagination
|
||||
$("#middle_menu_pagination").unbind("clik").bind("click", function(event) {
|
||||
var params = $(this).data("params");
|
||||
if(params == null)
|
||||
return;
|
||||
|
||||
var $target = $(event.target);
|
||||
var targetId = $target.attr("id");
|
||||
|
||||
if(targetId == "midmenu_prevbutton") {
|
||||
listMidMenuItems2(params.commandString, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, (params.page-1));
|
||||
}
|
||||
else if(targetId == "midmenu_nextbutton") {
|
||||
listMidMenuItems2(params.commandString, params.jsonResponse1, params.jsonResponse2, params.toMidmenuFn, params.toRightPanelFn, params.getMidmenuIdFn, params.isMultipleSelectionInMidMenu, (params.page+1));
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// refresh button
|
||||
$("#refresh_link").bind("click", function(event) {
|
||||
$("#refresh_link").unbind("clik").bind("click", function(event) {
|
||||
var onRefreshFn = $("#right_panel").data("onRefreshFn");
|
||||
if(onRefreshFn != null)
|
||||
onRefreshFn();
|
||||
|
|
@ -219,13 +238,13 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
// Initialize help drop down dialog
|
||||
$("#help_link").bind("click", function(event) {
|
||||
$("#help_link").unbind("clik").bind("click", function(event) {
|
||||
$("#help_dropdown_dialog").show();
|
||||
$("#help_button").addClass("selected");
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#help_dropdown_close").bind("click", function(event) {
|
||||
$("#help_dropdown_close").unbind("clik").bind("click", function(event) {
|
||||
$("#help_dropdown_dialog").hide();
|
||||
$("#help_button").removeClass("selected");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ function initVMWizard() {
|
|||
return false; //event.preventDefault() + event.stopPropagation()
|
||||
});
|
||||
|
||||
var vmPopupStep2PageSize = 11; //max number of templates each page in step2 of New VM wizard is 11
|
||||
var vmPopupTemplatePageSize = 6; //max number of templates in VM wizard
|
||||
function listTemplatesInVmPopup() {
|
||||
var zoneId = $vmPopup.find("#wizard_zone").val();
|
||||
if(zoneId == null || zoneId.length == 0)
|
||||
|
|
@ -520,18 +520,20 @@ function initVMWizard() {
|
|||
if (selectedTemplateTypeInVmPopup != "blank") { //*** template ***
|
||||
templateType = "template";
|
||||
if (searchInput != null && searchInput.length > 0)
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&keyword="+searchInput+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&keyword="+searchInput;
|
||||
else
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
commandString = "command=listTemplates&templatefilter="+selectedTemplateTypeInVmPopup+"&zoneid="+zoneId;
|
||||
}
|
||||
else { //*** ISO ***
|
||||
templateType = "ISO";
|
||||
if (searchInput != null && searchInput.length > 0)
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&keyword="+searchInput+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&keyword="+searchInput;
|
||||
else
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
commandString = "command=listIsos&isReady=true&bootable=true&zoneid="+zoneId;
|
||||
}
|
||||
|
||||
|
||||
commandString += "&pagesize="+vmPopupTemplatePageSize+"&page="+currentPageInTemplateGridInVmPopup;
|
||||
|
||||
var loading = $vmPopup.find("#wiz_template_loading").show();
|
||||
if(currentPageInTemplateGridInVmPopup==1)
|
||||
$vmPopup.find("#prevPage").hide();
|
||||
|
|
@ -561,7 +563,7 @@ function initVMWizard() {
|
|||
vmWizardTemplateJsonToTemplate(items[i], $newTemplate, templateType, i);
|
||||
container.append($newTemplate.show());
|
||||
}
|
||||
if(items.length < vmPopupStep2PageSize)
|
||||
if(items.length < vmPopupTemplatePageSize)
|
||||
$vmPopup.find("#nextPage").hide();
|
||||
else
|
||||
$vmPopup.find("#nextPage").show();
|
||||
|
|
@ -1422,7 +1424,7 @@ function vmJsonToVolumeTab() {
|
|||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listVolumes&virtualMachineId="+jsonObj.id+maxPageSize),
|
||||
data: createURL("command=listVolumes&virtualMachineId="+jsonObj.id),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listvolumesresponse.volume;
|
||||
|
|
@ -1487,7 +1489,7 @@ function vmJsonToRouterTab() {
|
|||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listRouters&domainid="+vmObj.domainid+"&account="+vmObj.account+maxPageSize),
|
||||
data: createURL("command=listRouters&domainid="+vmObj.domainid+"&account="+vmObj.account),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listroutersresponse.router;
|
||||
|
|
@ -1669,7 +1671,7 @@ function appendInstanceGroup(groupId, groupName) {
|
|||
var groupId = $(this).data("groupId");
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listVirtualMachines&groupid="+groupId+"&pagesize="+midmenuItemCount),
|
||||
data: createURL("command=listVirtualMachines&groupid="+groupId+"&pagesize="+midmenuItemCount+"&page=1"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ function afterLoadIpJSP() {
|
|||
|
||||
//*** Acquire New IP (begin) ***
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true"+maxPageSize),
|
||||
data: createURL("command=listZones&available=true"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var zones = json.listzonesresponse.zone;
|
||||
|
|
|
|||
|
|
@ -567,7 +567,9 @@ function setBooleanEditField(value, $field) {
|
|||
function clearMiddleMenu() {
|
||||
$("#midmenu_container").empty();
|
||||
$("#midmenu_action_link").hide();
|
||||
clearAddButtonsOnTop();
|
||||
clearAddButtonsOnTop();
|
||||
$("#midmenu_prevbutton, #midmenu_nextbutton").hide();
|
||||
$("#middle_menu_pagination").data("params", null);
|
||||
}
|
||||
|
||||
function clearAddButtonsOnTop() {
|
||||
|
|
@ -581,11 +583,7 @@ function clearAddButtonsOnTop() {
|
|||
$("#midmenu_add_vlan_button").unbind("click").hide();
|
||||
$("#midmenu_add_directIpRange_button").unbind("click").hide();
|
||||
$("#midmenu_Update_SSL_Certificate_button").unbind("click").hide();
|
||||
/*
|
||||
$("#midmenu_add2_link").unbind("click").hide();
|
||||
$("#midmenu_add3_link").unbind("click").hide();
|
||||
*/
|
||||
|
||||
|
||||
$("#midmenu_startvm_link").unbind("click").hide();
|
||||
$("#midmenu_stopvm_link").unbind("click").hide();
|
||||
$("#midmenu_rebootvm_link").unbind("click").hide();
|
||||
|
|
@ -928,7 +926,21 @@ function getMidmenuId(jsonObj) {
|
|||
return "midmenuItem_" + jsonObj.id;
|
||||
}
|
||||
|
||||
function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, clickFirstItem, $midMenuContainer) {
|
||||
function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, page) {
|
||||
var params = {
|
||||
"commandString": commandString,
|
||||
"jsonResponse1": jsonResponse1,
|
||||
"jsonResponse2": jsonResponse2,
|
||||
"toMidmenuFn": toMidmenuFn,
|
||||
"toRightPanelFn": toRightPanelFn,
|
||||
"getMidmenuIdFn": getMidmenuIdFn,
|
||||
"isMultipleSelectionInMidMenu": isMultipleSelectionInMidMenu,
|
||||
"page": page
|
||||
}
|
||||
$("#middle_menu_pagination").data("params", params);
|
||||
|
||||
(page > 1)? $("#midmenu_prevbutton").show(): $("#midmenu_prevbutton").hide();
|
||||
|
||||
if(isMultipleSelectionInMidMenu == true)
|
||||
enableMultipleSelectionInMidMenu();
|
||||
else
|
||||
|
|
@ -937,24 +949,23 @@ function listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmen
|
|||
var count = 0;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command="+commandString+"&pagesize="+midmenuItemCount),
|
||||
data: createURL("command="+commandString+"&pagesize="+midmenuItemCount+"&page="+page),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
selectedItemsInMidMenu = {};
|
||||
success: function(json) {
|
||||
selectedItemsInMidMenu = {};
|
||||
$("#midmenu_container").empty();
|
||||
var items = json[jsonResponse1][jsonResponse2];
|
||||
if(items != null && items.length > 0) {
|
||||
(items.length == midmenuItemCount)? $("#midmenu_nextbutton").show(): $("#midmenu_nextbutton").hide();
|
||||
for(var i=0; i<items.length;i++) {
|
||||
var $midmenuItem1 = $("#midmenu_item").clone();
|
||||
$midmenuItem1.data("toRightPanelFn", toRightPanelFn);
|
||||
toMidmenuFn(items[i], $midmenuItem1);
|
||||
bindClickToMidMenu($midmenuItem1, toRightPanelFn, getMidmenuIdFn);
|
||||
|
||||
if($midMenuContainer == null)
|
||||
$midMenuContainer = $("#midmenu_container");
|
||||
|
||||
$midMenuContainer.append($midmenuItem1.show());
|
||||
if(clickFirstItem == true && i == 0) { //click the 1st item in middle menu as default
|
||||
|
||||
$("#midmenu_container").append($midmenuItem1.show());
|
||||
if(i == 0) { //click the 1st item in middle menu as default
|
||||
$midmenuItem1.click();
|
||||
if(isMultipleSelectionInMidMenu == true) {
|
||||
$midmenuItem1.addClass("ui-selected"); //because instance page is using JQuery selectable widget to do multiple-selection
|
||||
|
|
@ -997,7 +1008,7 @@ function listMidMenuItems(commandString, jsonResponse1, jsonResponse2, rightPane
|
|||
});
|
||||
removeDialogs();
|
||||
afterLoadRightPanelJSPFn();
|
||||
listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, true);
|
||||
listMidMenuItems2(commandString, jsonResponse1, jsonResponse2, toMidmenuFn, toRightPanelFn, getMidmenuIdFn, isMultipleSelectionInMidMenu, 1);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1150,9 +1161,6 @@ function getSystemVmUseLocalStorage() { return g_systemVmUseLocalStorage; }
|
|||
//keyboard keycode
|
||||
var keycode_Enter = 13;
|
||||
|
||||
//dropdown field size
|
||||
var maxPageSize = "&pagesize=500";
|
||||
|
||||
//XMLHttpResponse.status
|
||||
var ERROR_ACCESS_DENIED_DUE_TO_UNAUTHORIZED = 401;
|
||||
var ERROR_INTERNET_NAME_NOT_RESOLVED = 12007;
|
||||
|
|
@ -1334,6 +1342,7 @@ function convertMilliseconds(string) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function drawGrid(items, submenuContent, template, fnJSONToTemplate) {
|
||||
var grid = submenuContent.find("#grid_content").empty();
|
||||
if (items != null && items.length > 0) {
|
||||
|
|
@ -1457,7 +1466,7 @@ function submenuContentEventBinder(submenuContent, listFunction) {
|
|||
var zoneSelect = submenuContent.find("#advanced_search #adv_search_zone");
|
||||
if(zoneSelect.length>0) { //if zone dropdown is found on Advanced Search dialog
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true&response=json"+maxPageSize),
|
||||
data: createURL("command=listZones&available=true&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var zones = json.listzonesresponse.zone;
|
||||
|
|
@ -1484,7 +1493,7 @@ function submenuContentEventBinder(submenuContent, listFunction) {
|
|||
podLabel.css("color", "black");
|
||||
podSelect.removeAttr("disabled");
|
||||
$.ajax({
|
||||
data: createURL("command=listPods&zoneId="+zoneId+"&response=json"+maxPageSize),
|
||||
data: createURL("command=listPods&zoneId="+zoneId+"&response=json"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -1509,7 +1518,7 @@ function submenuContentEventBinder(submenuContent, listFunction) {
|
|||
if(domainSelect.length>0 && isAdmin()) {
|
||||
var domainSelect = domainSelect.empty();
|
||||
$.ajax({
|
||||
data: createURL("command=listDomains&available=true&response=json"+maxPageSize),
|
||||
data: createURL("command=listDomains&available=true&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var domains = json.listdomainsresponse.domain;
|
||||
|
|
@ -1527,7 +1536,7 @@ function submenuContentEventBinder(submenuContent, listFunction) {
|
|||
vmSelect.empty();
|
||||
vmSelect.append("<option value=''></option>");
|
||||
$.ajax({
|
||||
data: createURL("command=listVirtualMachines&response=json"+maxPageSize),
|
||||
data: createURL("command=listVirtualMachines&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listvirtualmachinesresponse.virtualmachine;
|
||||
|
|
@ -1540,6 +1549,7 @@ function submenuContentEventBinder(submenuContent, listFunction) {
|
|||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Validation functions
|
||||
function showError(isValid, field, errMsgField, errMsg) {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,19 @@ function primarystorageJsonToDetailsTab() {
|
|||
if(jsonObj == null)
|
||||
return;
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listStoragePools&id="+jsonObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var items = json.liststoragepoolsresponse.storagepool;
|
||||
if(items != null && items.length > 0) {
|
||||
jsonObj = items[0];
|
||||
$midmenuItem1.data("jsonObj", jsonObj);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var $thisTab = $("#right_panel_content").find("#tab_content_details");
|
||||
$thisTab.find("#tab_container").hide();
|
||||
$thisTab.find("#tab_spinning_wheel").show();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function buildZoneTree() {
|
|||
var $zoneTree = $("#leftmenu_zone_tree").find("#tree_container").hide();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true"+maxPageSize),
|
||||
data: createURL("command=listZones&available=true"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listzonesresponse.zone;
|
||||
|
|
@ -55,7 +55,7 @@ function buildZoneTree() {
|
|||
$zoneContent.show();
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listPods&zoneid="+zoneObj.id+maxPageSize),
|
||||
data: createURL("command=listPods&zoneid="+zoneObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -126,7 +126,7 @@ function buildZoneTree() {
|
|||
function refreshClusterUnderPod($podNode, newClusterName, existingClusterId, noClicking) {
|
||||
var podId = $podNode.data("podId");
|
||||
$.ajax({
|
||||
data: createURL("command=listClusters&podid="+podId+maxPageSize),
|
||||
data: createURL("command=listClusters&podid="+podId),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -176,7 +176,7 @@ function zoneJSONToTreeNode(json, $zoneNode) {
|
|||
zoneName.data("jsonObj", json);
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listPods&zoneid="+zoneid+maxPageSize),
|
||||
data: createURL("command=listPods&zoneid="+zoneid),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -216,34 +216,38 @@ function resourceLoadPage(pageToShow, $midmenuItem1) { //$midmenuItem1 is eith
|
|||
if(pageToShow == "jsp/resource.jsp") {
|
||||
afterLoadResourceJSP($midmenuItem1);
|
||||
}
|
||||
else if(pageToShow == "jsp/zone.jsp") {
|
||||
afterLoadZoneJSP($midmenuItem1);
|
||||
|
||||
else if(pageToShow == "jsp/zone.jsp") {
|
||||
$(this).data("onRefreshFn", function() {
|
||||
zoneJsonToDetailsTab();
|
||||
});
|
||||
});
|
||||
afterLoadZoneJSP($midmenuItem1);
|
||||
}
|
||||
else if(pageToShow == "jsp/pod.jsp") {
|
||||
afterLoadPodJSP($midmenuItem1);
|
||||
|
||||
else if(pageToShow == "jsp/pod.jsp") {
|
||||
$(this).data("onRefreshFn", function() {
|
||||
podJsonToDetailsTab();
|
||||
});
|
||||
afterLoadPodJSP($midmenuItem1);
|
||||
}
|
||||
else if(pageToShow == "jsp/cluster.jsp") {
|
||||
afterLoadClusterJSP($midmenuItem1);
|
||||
|
||||
$(this).data("onRefreshFn", function() {
|
||||
clusterJsonToDetailsTab();
|
||||
});
|
||||
});
|
||||
afterLoadClusterJSP($midmenuItem1);
|
||||
}
|
||||
else if(pageToShow == "jsp/host.jsp") {
|
||||
afterLoadHostJSP($midmenuItem1);
|
||||
else if(pageToShow == "jsp/host.jsp") {
|
||||
$(this).data("onRefreshFn", function() {
|
||||
hostJsonToDetailsTab();
|
||||
});
|
||||
afterLoadHostJSP($midmenuItem1);
|
||||
|
||||
copyActionInfoFromMidMenuToRightPanel($midmenuItem1);
|
||||
$("#right_panel_content").data("$midmenuItem1", $midmenuItem1);
|
||||
$("#tab_details").click();
|
||||
}
|
||||
else if(pageToShow == "jsp/primarystorage.jsp") {
|
||||
$(this).data("onRefreshFn", function() {
|
||||
primarystorageJsonToDetailsTab();
|
||||
});
|
||||
afterLoadPrimaryStorageJSP($midmenuItem1);
|
||||
}
|
||||
});
|
||||
|
|
@ -624,7 +628,7 @@ function initAddZoneWizard() {
|
|||
|
||||
var domainDropdown = $addZoneWizard.find("#domain_dropdown").empty();
|
||||
$.ajax({
|
||||
data: createURL("command=listDomains"+maxPageSize),
|
||||
data: createURL("command=listDomains"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ function afterLoadTemplateJSP() {
|
|||
if (isAdmin())
|
||||
addTemplateZoneField.append("<option value='-1'>All Zones</option>");
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true"+maxPageSize),
|
||||
data: createURL("command=listZones&available=true"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var zones = json.listzonesresponse.zone;
|
||||
|
|
@ -135,7 +135,7 @@ function afterLoadTemplateJSP() {
|
|||
});
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listOsTypes&response=json"+maxPageSize),
|
||||
data: createURL("command=listOsTypes&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
types = json.listostypesresponse.ostype;
|
||||
|
|
@ -154,7 +154,7 @@ function afterLoadTemplateJSP() {
|
|||
});
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listServiceOfferings&response=json"+maxPageSize),
|
||||
data: createURL("command=listServiceOfferings&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listserviceofferingsresponse.serviceoffering;
|
||||
|
|
@ -167,7 +167,7 @@ function afterLoadTemplateJSP() {
|
|||
});
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listDiskOfferings&response=json"+maxPageSize),
|
||||
data: createURL("command=listDiskOfferings&response=json"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listdiskofferingsresponse.diskoffering;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function afterLoadVolumeJSP() {
|
|||
});
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true"+maxPageSize),
|
||||
data: createURL("command=listZones&available=true"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var zones = json.listzonesresponse.zone;
|
||||
|
|
@ -773,7 +773,7 @@ function doRecurringSnapshot($actionLink, $detailsTab, $midmenuItem1) {
|
|||
function populateVirtualMachineField(domainId, account, zoneId) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listVirtualMachines&state=Running&zoneid="+zoneId+"&domainid="+domainId+"&account="+account+maxPageSize),
|
||||
data: createURL("command=listVirtualMachines&state=Running&zoneid="+zoneId+"&domainid="+domainId+"&account="+account),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
||||
|
|
@ -785,7 +785,7 @@ function populateVirtualMachineField(domainId, account, zoneId) {
|
|||
}
|
||||
$.ajax({
|
||||
cache: false,
|
||||
data: createURL("command=listVirtualMachines&state=Stopped&zoneid="+zoneId+"&domainid="+domainId+"&account="+account+maxPageSize),
|
||||
data: createURL("command=listVirtualMachines&state=Stopped&zoneid="+zoneId+"&domainid="+domainId+"&account="+account),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ function initAddVLANButton($button, $leftmenuItem1) {
|
|||
dialogAddVlanForZone.find("#add_publicip_vlan_type_container").show();
|
||||
var podSelect = dialogAddVlanForZone.find("#add_publicip_vlan_pod").empty();
|
||||
$.ajax({
|
||||
data: createURL("command=listPods&zoneId="+zoneObj.id+maxPageSize),
|
||||
data: createURL("command=listPods&zoneId="+zoneObj.id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
@ -395,7 +395,7 @@ function initAddVLANButton($button, $leftmenuItem1) {
|
|||
|
||||
function populateDomainDropdown(id) {
|
||||
$.ajax({
|
||||
data: createURL("command=listDomainChildren&id="+id+"&pageSize=-1"),
|
||||
data: createURL("command=listDomainChildren&id="+id),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.cloud.utils;
|
|||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
|
|
@ -51,4 +52,31 @@ public class UriUtils {
|
|||
|
||||
return file.toURI().toString();
|
||||
}
|
||||
|
||||
// a simple URI component helper (Note: it does not deal with URI paramemeter area)
|
||||
public static String encodeURIComponent(String url) {
|
||||
int schemeTail = url.indexOf("://");
|
||||
|
||||
int pathStart = 0;
|
||||
if(schemeTail > 0)
|
||||
pathStart = url.indexOf('/', schemeTail + 3);
|
||||
else
|
||||
pathStart = url.indexOf('/');
|
||||
|
||||
if(pathStart > 0) {
|
||||
String[] tokens = url.substring(pathStart + 1).split("/");
|
||||
if(tokens != null) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(url.substring(0, pathStart));
|
||||
for(String token : tokens) {
|
||||
sb.append("/").append(URLEncoder.encode(token));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// no need to do URL component encoding
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ systemjars = {
|
|||
'CentOS':
|
||||
(
|
||||
"tomcat6-servlet-2.5-api.jar",
|
||||
"tomcat6-jsp-2.1-api-6.0.24.jar",
|
||||
"tomcat6-el-1.0-api-6.0.24.jar",
|
||||
#"tomcat6/catalina.jar", # all supported distros put the file there
|
||||
),
|
||||
'Ubuntu':
|
||||
|
|
|
|||
Loading…
Reference in New Issue