mirror of https://github.com/apache/cloudstack.git
bug 13860: Added async job types to Account/User Async api commands and more logging.
Reviewed-by: Kelven Yang
This commit is contained in:
parent
b0f038c421
commit
856418e700
|
|
@ -28,6 +28,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
|
|
@ -102,4 +103,9 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
|
|||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete user account and all corresponding users");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.Account;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.AccountResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
|
@ -120,5 +121,10 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
|||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.Account;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
|
|
@ -95,5 +96,10 @@ public class DisableUserCmd extends BaseAsyncCmd {
|
|||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disable user");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.User;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package com.cloud.api.response;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.IdentityProxy;
|
||||
import com.cloud.api.ResponseObject;
|
||||
|
|
@ -28,6 +30,8 @@ import com.google.gson.annotations.SerializedName;
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
public class AsyncJobResponse extends BaseResponse {
|
||||
private static final Logger s_logger = Logger.getLogger(AsyncJobResponse.class.getName());
|
||||
|
||||
@SerializedName("accountid") @Param(description="the account that executed the async command")
|
||||
private IdentityProxy accountId = new IdentityProxy("account");
|
||||
|
||||
|
|
@ -123,7 +127,12 @@ public class AsyncJobResponse extends BaseResponse {
|
|||
this.jobInstanceId.setTableName("physical_network_service_providers");
|
||||
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.FirewallRule.toString())) {
|
||||
this.jobInstanceId.setTableName("firewall_rules");
|
||||
} else if (!jobInstanceType.equalsIgnoreCase(AsyncJob.Type.None.toString())){
|
||||
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.Account.toString())) {
|
||||
this.jobInstanceId.setTableName("account");
|
||||
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.User.toString())) {
|
||||
this.jobInstanceId.setTableName("user");
|
||||
} else if (!jobInstanceType.equalsIgnoreCase(AsyncJob.Type.None.toString())){
|
||||
s_logger.warn("Failed to get async job instanceId for job instance type " + jobInstanceType);
|
||||
// TODO : when we hit here, we need to add instanceType -> UUID entity table mapping
|
||||
assert(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ public interface AsyncJob extends Identity {
|
|||
PhysicalNetwork,
|
||||
TrafficType,
|
||||
PhysicalNetworkServiceProvider,
|
||||
FirewallRule
|
||||
FirewallRule,
|
||||
Account,
|
||||
User
|
||||
}
|
||||
|
||||
Long getId();
|
||||
|
|
|
|||
Loading…
Reference in New Issue