zone creation complete once more

This commit is contained in:
Alex Huang 2013-06-07 18:15:55 -07:00
parent 5e6d2cf559
commit ebbd4008ad
26 changed files with 117 additions and 104 deletions

View File

@ -42,11 +42,11 @@ public class NetworkTO {
public NetworkTO() {
}
public String getUuid() {
public String getNicUuid() {
return uuid;
}
public void setUuid(String uuid) {
public void setNicUuid(String uuid) {
this.uuid = uuid;
}

View File

@ -23,7 +23,7 @@ public class NicTO extends NetworkTO {
Integer networkRateMbps;
Integer networkRateMulticastMbps;
boolean defaultNic;
String uuid;
String nicUuid;
List <String> nicSecIps;
public NicTO() {
@ -59,13 +59,13 @@ public class NicTO extends NetworkTO {
}
@Override
public String getUuid() {
return uuid;
public String getNicUuid() {
return nicUuid;
}
@Override
public void setUuid(String uuid) {
this.uuid = uuid;
public void setNicUuid(String uuid) {
this.nicUuid = uuid;
}
@Override

View File

@ -54,6 +54,7 @@ public class DataCenterDeployment implements DeploymentPlan {
_poolId = poolId;
_physicalNetworkId = physicalNetworkId;
_context = context;
_avoids = new ExcludeList();
}
@Override

View File

@ -40,9 +40,6 @@ public class AsyncJobResponse extends BaseResponse {
@SerializedName("cmd") @Param(description="the async command executed")
private String cmd;
@SerializedName("jobstatus") @Param(description="the current job status-should be 0 for PENDING")
private Integer jobStatus;
@SerializedName("jobprocstatus") @Param(description="the progress information of the PENDING job")
private Integer jobProcStatus;
@ -76,11 +73,6 @@ public class AsyncJobResponse extends BaseResponse {
this.cmd = cmd;
}
@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
public void setJobProcStatus(Integer jobProcStatus) {
this.jobProcStatus = jobProcStatus;
}

View File

@ -35,12 +35,6 @@ public class SystemVmResponse extends BaseResponse {
@SerializedName("systemvmtype") @Param(description="the system VM type")
private String systemVmType;
@SerializedName("jobid") @Param(description="the job ID associated with the system VM. This is only displayed if the router listed is part of a currently running asynchronous job.")
private String jobId;
@SerializedName("jobstatus") @Param(description="the job status associated with the system VM. This is only displayed if the router listed is part of a currently running asynchronous job.")
private Integer jobStatus;
@SerializedName("zoneid") @Param(description="the Zone ID for the system VM")
private String zoneId;
@ -119,7 +113,7 @@ public class SystemVmResponse extends BaseResponse {
@Override
public String getObjectId() {
return this.getId();
return getId();
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.context;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
@ -26,6 +27,7 @@ import com.cloud.dao.EntityManager;
import com.cloud.exception.CloudAuthenticationException;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.UuidUtils;
import com.cloud.utils.exception.CloudRuntimeException;
/**
@ -37,7 +39,7 @@ public class CallContext {
private static final Logger s_logger = Logger.getLogger(CallContext.class);
private static ThreadLocal<CallContext> s_currentContext = new ThreadLocal<CallContext>();
private String sessionId;
private String contextId;
private Account account;
private long startEventId = 0;
private String eventDetails;
@ -53,10 +55,10 @@ public class CallContext {
public CallContext() {
}
protected CallContext(User user, Account account, String sessionId) {
protected CallContext(User user, Account account, String contextId) {
this.user = user;
this.account = account;
this.sessionId = sessionId;
this.contextId = contextId;
}
public void putContextParameter(String key, Object value) {
@ -75,8 +77,8 @@ public class CallContext {
return user;
}
public String getSessionId() {
return sessionId;
public String getContextId() {
return contextId;
}
public Account getCallingAccount() {
@ -87,17 +89,18 @@ public class CallContext {
return s_currentContext.get();
}
public static CallContext register(User callingUser, Account callingAccount, String sessionId) {
public static CallContext register(User callingUser, Account callingAccount, String contextId) {
assert s_currentContext.get() == null : "There's a context already so what does this new register context mean? " + s_currentContext.get().toString();
if (s_currentContext.get() != null) { // FIXME: This should be removed soon. I added this check only to surface all the places that have this problem.
throw new CloudRuntimeException("There's a context already so what does this new register context mean? " + s_currentContext.get().toString());
}
CallContext callingContext = new CallContext(callingUser, callingAccount, sessionId);
s_currentContext.set(callingContext);
if (sessionId != null) {
NDC.push("job-" + sessionId);
if (contextId == null) {
contextId = UUID.randomUUID().toString();
}
s_logger.debug("Setting calling context: " + s_currentContext.get());
CallContext callingContext = new CallContext(callingUser, callingAccount, contextId);
s_currentContext.set(callingContext);
NDC.push("ctx-" + UuidUtils.first(contextId));
s_logger.debug("Setting calling context: " + callingContext);
return callingContext;
}
@ -111,7 +114,7 @@ public class CallContext {
return context;
}
public static CallContext register(String callingUserUuid, String callingAccountUuid, String sessionId) {
public static CallContext register(String callingUserUuid, String callingAccountUuid, String contextId) {
Account account = s_entityMgr.findByUuid(Account.class, callingAccountUuid);
if (account == null) {
throw new CloudAuthenticationException("The account is no longer current.").add(Account.class, callingAccountUuid);
@ -121,10 +124,10 @@ public class CallContext {
if (user == null) {
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, callingUserUuid);
}
return register(user, account, sessionId);
return register(user, account, contextId);
}
public static CallContext register(long callingUserId, long callingAccountId, String sessionId) throws CloudAuthenticationException {
public static CallContext register(long callingUserId, long callingAccountId, String contextId) throws CloudAuthenticationException {
Account account = s_entityMgr.findById(Account.class, callingAccountId);
if (account == null) {
throw new CloudAuthenticationException("The account is no longer current.").add(Account.class, Long.toString(callingAccountId));
@ -133,15 +136,15 @@ public class CallContext {
if (user == null) {
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, Long.toString(callingUserId));
}
return register(user, account, sessionId);
return register(user, account, contextId);
}
public static CallContext register(long callingUserId, Account callingAccount, String sessionId, boolean apiServer) {
public static CallContext register(long callingUserId, Account callingAccount, String contextId, boolean apiServer) {
User user = s_entityMgr.findById(User.class, callingUserId);
if (user == null) {
throw new CloudAuthenticationException("The user is no longer current.").add(User.class, Long.toString(callingUserId));
}
return register(user, callingAccount, sessionId);
return register(user, callingAccount, contextId);
}
public static CallContext unregister() {
@ -152,17 +155,15 @@ public class CallContext {
}
s_currentContext.remove();
s_logger.debug("Context removed " + context);
String sessionId = context.getSessionId();
if (sessionId != null) {
String sessionIdOnStack = null;
String sessionIdPushedToNDC = "job-" + sessionId;
while ((sessionIdOnStack = NDC.pop()) != null) {
if (sessionIdPushedToNDC.equals(sessionIdOnStack)) {
break;
}
if (s_logger.isTraceEnabled()) {
s_logger.trace("Popping from NDC: " + sessionId);
}
String contextId = context.getContextId();
String sessionIdOnStack = null;
String sessionIdPushedToNDC = "ctx-" + UuidUtils.first(contextId);
while ((sessionIdOnStack = NDC.pop()) != null) {
if (sessionIdPushedToNDC.equals(sessionIdOnStack)) {
break;
}
if (s_logger.isTraceEnabled()) {
s_logger.trace("Popping from NDC: " + contextId);
}
}
return context;
@ -200,7 +201,7 @@ public class CallContext {
public String toString() {
return new StringBuffer("CallContext[acct=").append(account.getId())
.append("; user=").append(user.getId())
.append("; session=").append(sessionId)
.append("; session=").append(contextId)
.append("]").toString();
}
}

View File

@ -17,8 +17,6 @@
package com.cloud.agent.api;
public class StopAnswer extends RebootAnswer {
Integer vncPort;
protected StopAnswer() {
}
@ -37,9 +35,4 @@ public class StopAnswer extends RebootAnswer {
super(cmd, e);
}
@Override
public Integer getVncPort() {
return vncPort;
}
}

View File

@ -27,7 +27,6 @@ import javax.persistence.Table;
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Type;
@Entity
@ -56,7 +55,11 @@ public class VmWorkJobVO extends AsyncJobVO {
@Column(name="vm_instance_id")
long vmInstanceId;
public VmWorkJobVO() {
protected VmWorkJobVO() {
}
public VmWorkJobVO(String related) {
setRelated(related);
}
public Step getStep() {

View File

@ -101,4 +101,6 @@ public interface AsyncJob extends Job {
SyncQueueItem getSyncSource();
void setSyncSource(SyncQueueItem item);
String getRelated();
}

View File

@ -71,6 +71,9 @@ public class AsyncJobVO implements AsyncJob, Job {
@Column(name="job_cmd_ver")
private int cmdVersion;
@Column(name = "related")
private String related;
@Column(name="job_cmd_info", length=65535)
private String cmdInfo;
@ -123,14 +126,16 @@ public class AsyncJobVO implements AsyncJob, Job {
public AsyncJobVO() {
uuid = UUID.randomUUID().toString();
related = UUID.randomUUID().toString();
}
public AsyncJobVO(String uuid, long userId, long accountId, String cmd, String cmdInfo, Long instanceId, String instanceType) {
public AsyncJobVO(String related, long userId, long accountId, String cmd, String cmdInfo, Long instanceId, String instanceType) {
this.userId = userId;
this.accountId = accountId;
this.cmd = cmd;
this.cmdInfo = cmdInfo;
this.uuid = uuid;
uuid = UUID.randomUUID().toString();
this.related = related;
this.instanceId = instanceId;
this.instanceType = instanceType;
}
@ -149,6 +154,15 @@ public class AsyncJobVO implements AsyncJob, Job {
return UuidUtils.first(uuid);
}
public void setRelated(String related) {
this.related = related;
}
@Override
public String getRelated() {
return related;
}
@Override
public String getType() {
return type;

View File

@ -93,7 +93,7 @@ public class OvsVifDriver extends VifDriverBase {
}
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + logicalSwitchUuid);
intf.setVirtualPortInterfaceId(nic.getUuid());
intf.setVirtualPortInterfaceId(nic.getNicUuid());
String brName = (trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("private");
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
}

View File

@ -1055,7 +1055,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
protected VIF createVif(Connection conn, String vmName, VM vm, NicTO nic) throws XmlRpcException, XenAPIException {
assert(nic.getUuid() != null) : "Nic should have a uuid value";
assert(nic.getNicUuid() != null) : "Nic should have a uuid value";
if (s_logger.isDebugEnabled()) {
s_logger.debug("Creating VIF for " + vmName + " on nic " + nic);
@ -1067,7 +1067,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
// Nicira needs these IDs to find the NIC
vifr.otherConfig = new HashMap<String, String>();
vifr.otherConfig.put("nicira-iface-id", nic.getUuid());
vifr.otherConfig.put("nicira-iface-id", nic.getNicUuid());
vifr.otherConfig.put("nicira-vm-id", vm.getUuid(conn));
vifr.network = getNetwork(conn, nic);

View File

@ -145,7 +145,7 @@ public class MidoNetVifDriver extends VifDriverBase {
if (b.getName().equals(netName)) {
for (BridgePort p : b.getPorts()) {
UUID pvif = p.getVifId();
if (pvif != null && p.getVifId().toString().equals(nic.getUuid())){
if (pvif != null && p.getVifId().toString().equals(nic.getNicUuid())){
getMyHost(api).addHostInterfacePort()
.interfaceName(tapName)
.portId(p.getId())

View File

@ -87,7 +87,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
accountObject = _accountDao.findById(Long.parseLong(acctIdStr));
}
CallContext.register(userId, accountObject, "job-" + job.getShortUuid(), false);
CallContext.register(userId, accountObject, job.getRelated(), false);
try {
// dispatch could ultimately queue the job
_dispatcher.dispatch(cmdObj, params, true);

View File

@ -520,7 +520,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
params.put("ctxStartEventId", String.valueOf(startEventId));
Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId;
AsyncJobVO job = new AsyncJobVO(ctx.getSessionId(), callerUserId, caller.getId(), cmdObj.getClass().getName(),
AsyncJobVO job = new AsyncJobVO(ctx.getContextId(), callerUserId, caller.getId(), cmdObj.getClass().getName(),
ApiGsonHelper.getBuilder().create().toJson(params), instanceId,
asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString() : null);
job.setDispatcher(_asyncDispatcher.getName());

View File

@ -266,7 +266,7 @@ public class ApiServlet extends HttpServlet {
writeResponse(resp, serializedResponse, HttpServletResponse.SC_BAD_REQUEST, responseType);
return;
}
CallContext.register(userId, ((Account)accountObj).getId(), session.getId());
CallContext.register(userId, ((Account)accountObj).getId(), null);
} else {
// Invalidate the session to ensure we won't allow a request across management server
// restarts if the userId was serialized to the stored session
@ -332,7 +332,7 @@ public class ApiServlet extends HttpServlet {
s_logger.debug("===END=== " + StringUtils.cleanString(reqStr));
}
// cleanup user context to prevent from being peeked in other request context ???
CallContext.unregister();
CallContext.unregister();
} catch(Throwable e) {
s_logger.error("Really unexpected exception", e);
}

View File

@ -73,7 +73,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
// Workaround to make sure the TO has the UUID we need for Niciri integration
NicVO nicVO = _nicDao.findById(profile.getId());
to.setUuid(nicVO.getUuid());
to.setNicUuid(nicVO.getUuid());
//check whether the this nic has secondary ip addresses set
//set nic secondary ip address in NicTO which are used for security group
// configuration. Use full when vm stop/start

View File

@ -1771,7 +1771,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
Integer networkRate = _networkModel.getNetworkRate(config.getId(), null);
to.setNetworkRateMbps(networkRate);
to.setUuid(config.getUuid());
to.setNicUuid(config.getUuid());
return to;
}

View File

@ -1282,7 +1282,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
@Override
public void run() {
try {
CallContext.register(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, null);
CallContext.registerOnceOnly();
while (true) {
try {
Long networkId = _vrUpdateQueue.take();

View File

@ -351,7 +351,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
@Override
public VirtualMachineGuru getVmGuru(VirtualMachine vm) {
return _vmGurus.values().iterator().next();
return _vmGurus.get(vm.getType());
}
@Override
@ -540,6 +540,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
RootVolumeSearch = _entityMgr.createSearchBuilder(VolumeVO.class);
VolumeVO rvsEntity = RootVolumeSearch.entity();
RootVolumeSearch.and(rvsEntity.getVolumeType(), SearchCriteria.Op.EQ).values(Volume.Type.ROOT)
.and(rvsEntity.getState(), SearchCriteria.Op.EQ).values(Volume.State.Ready)
.and(rvsEntity.getInstanceId(), SearchCriteria.Op.EQ, "instance")
.and(rvsEntity.getDeviceId(), SearchCriteria.Op.EQ).values(0)
.done();
@ -761,7 +762,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
assert(pendingWorkJobs.size() == 1);
workJob = pendingWorkJobs.get(0);
} else {
workJob = new VmWorkJobVO();
workJob = new VmWorkJobVO(context.getContextId());
workJob.setDispatcher(VmWorkJobDispatcher.VM_WORK_JOB_DISPATCHER);
workJob.setCmd(VmWorkJobDispatcher.Start);
@ -848,6 +849,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (vol.isRecreatable() && volTemplateId != null &&
vm.getTemplateId() != -1 && volTemplateId.longValue() != vm.getTemplateId()) {
job.log(s_logger, "Recreating" + vol + " of " + vm + " because its template has changed.");
plan.setPoolId(null);
} else {
StoragePool pool = (StoragePool)dataStoreMgr.getPrimaryDataStore(vol.getPoolId());
Long rootVolPodId = pool.getPodId();
@ -1176,6 +1178,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
@Override
public void advanceStop(final String vmUuid, boolean forced, User user, Account account) throws ResourceUnavailableException,
OperationTimedoutException, ConcurrentOperationException {
CallContext context = CallContext.current();
final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
VmWorkJobVO workJob = null;
Transaction txn = Transaction.currentTxn();
@ -1191,7 +1194,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
assert(pendingWorkJobs.size() == 1);
workJob = pendingWorkJobs.get(0);
} else {
workJob = new VmWorkJobVO();
workJob = new VmWorkJobVO(context.getContextId());
workJob.setDispatcher(VmWorkJobDispatcher.VM_WORK_JOB_DISPATCHER);
workJob.setCmd(VmWorkJobDispatcher.Stop);
@ -1953,6 +1956,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
public VirtualMachine migrateWithStorage(String vmUuid, long srcHostId, long destHostId,
Map<VolumeVO, StoragePoolVO> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException,
ManagementServerException, VirtualMachineMigrationException {
CallContext context = CallContext.current();
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
HostVO srcHost = _hostDao.findById(srcHostId);
@ -1989,7 +1993,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
VirtualMachineTO to = hvGuru.implement(profile);
VmWorkJobVO work = new VmWorkJobVO();
VmWorkJobVO work = new VmWorkJobVO(context.getContextId());
// VmWorkJobVO work = new VmWorkJobVO(UUID.randomUUID().toString(), _nodeId, State.Migrating, vm.getType(), vm.getId());
// work.setStep(Step.Prepare);
// work.setResourceType(ItWorkVO.ResourceType.Host);

View File

@ -59,7 +59,7 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch
work = (VmWork)ApiSerializerHelper.fromSerializedString(job.getCmdInfo());
assert(work != null);
CallContext context = CallContext.register(work.getUserId(), work.getAccountId(), "job-" + job.getShortUuid());
CallContext.register(work.getUserId(), work.getAccountId(), job.getRelated());
VMInstanceVO vm = _instanceDao.findById(work.getVmId());
if (vm == null) {

View File

@ -20,9 +20,12 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.inject.Inject;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -32,7 +35,14 @@ import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import junit.framework.TestCase;
import com.google.gson.Gson;
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
import org.apache.cloudstack.vm.jobs.VmWorkJobDao;
import org.apache.cloudstack.vm.jobs.VmWorkJobVO;
import org.apache.cloudstack.vm.jobs.VmWorkJobVO.Step;
import com.cloud.api.ApiSerializerHelper;
import com.cloud.cluster.ClusterManager;
@ -45,14 +55,6 @@ import com.cloud.utils.LogUtils;
import com.cloud.utils.Predicate;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.db.Transaction;
import com.google.gson.Gson;
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
import org.apache.cloudstack.vm.jobs.VmWorkJobDao;
import org.apache.cloudstack.vm.jobs.VmWorkJobVO;
import org.apache.cloudstack.vm.jobs.VmWorkJobVO.Step;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:/VmWorkTestContext.xml")
@ -90,10 +92,11 @@ public class VmWorkTest extends TestCase {
}
}
@After
public void tearDown() {
Transaction.currentTxn().close();
}
@Override
@After
public void tearDown() {
Transaction.currentTxn().close();
}
@Test
public void testDeployPlanSerialization() {
@ -122,7 +125,7 @@ public class VmWorkTest extends TestCase {
}
public void testVmWorkDispatcher() {
VmWorkJobVO workJob = new VmWorkJobVO();
VmWorkJobVO workJob = new VmWorkJobVO(UUID.randomUUID().toString());
workJob.setDispatcher("VmWorkJobDispatcher");
workJob.setCmd("doVmWorkStart");
workJob.setAccountId(1L);

View File

@ -54,7 +54,7 @@ public class VmWorkTestApiJobDispatcher extends AdapterBase implements AsyncJobD
}
}
VmWorkJobVO workJob = new VmWorkJobVO();
VmWorkJobVO workJob = new VmWorkJobVO(job.getRelated());
workJob.setDispatcher("TestWorkJobDispatcher");
workJob.setCmd(VmWorkJobDispatcher.Start);

View File

@ -19,9 +19,13 @@ package com.cloud.vm.dao;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.UUID;
import javax.inject.Inject;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -38,9 +42,6 @@ import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import junit.framework.Assert;
import junit.framework.TestCase;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:/vmdaoTestContext.xml")
public class VmDaoTest extends TestCase {
@ -76,11 +77,11 @@ public class VmDaoTest extends TestCase {
@Test
public void testPowerStateUpdate() {
UserVmVO userVmInstance = new UserVmVO(1L, "Dummy", "DummyInstance",
UserVmVO userVmInstance = new UserVmVO(1L, "Dummy", "DummyInstance",
1L, HypervisorType.Any, 1L, true, false, 1L, 1L, 1L, null, null, null);
userVmDao.persist(userVmInstance);
userVmInstance = new UserVmVO(2L, "Dummy2", "DummyInstance2",
userVmInstance = new UserVmVO(2L, "Dummy2", "DummyInstance2",
1L, HypervisorType.Any, 1L, true, false, 1L, 1L, 1L, null, null, null);
userVmDao.persist(userVmInstance);
@ -147,7 +148,7 @@ public class VmDaoTest extends TestCase {
@Test
public void testVmWork() {
VmWorkJobVO workJob = new VmWorkJobVO();
VmWorkJobVO workJob = new VmWorkJobVO(UUID.randomUUID().toString());
workJob.setAccountId(1);
workJob.setUserId(1L);
workJob.setCmd("StartVM");
@ -158,7 +159,7 @@ public class VmDaoTest extends TestCase {
workJobDao.persist(workJob);
VmWorkJobVO workJob2 = new VmWorkJobVO();
VmWorkJobVO workJob2 = new VmWorkJobVO(UUID.randomUUID().toString());
workJob2.setAccountId(1);
workJob2.setUserId(1L);
workJob2.setCmd("StopVM");

View File

@ -83,6 +83,8 @@ CREATE TABLE `cloud`.`image_data_store` (
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`async_job` ADD COLUMN `related` CHAR(40) NOT NULL;
ALTER TABLE `cloud`.`vm_template` ADD COLUMN `image_data_store_id` bigint unsigned;
ALTER TABLE `cloud`.`service_offering` ADD COLUMN `is_volatile` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the vm needs to be volatile, i.e., on every reboot of vm from API root disk is discarded and creates a new root disk';

View File

@ -68,7 +68,6 @@ import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.ComponentLifecycle;
import com.cloud.utils.component.ComponentLifecycleBase;
import com.cloud.utils.component.ComponentMethodInterceptable;
@ -130,8 +129,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
protected Field[] _embeddedFields;
// This is private on purpose. Everyone should use createPartialSelectSql()
private Pair<StringBuilder, Attribute[]> _partialSelectSql;
private Pair<StringBuilder, Attribute[]> _partialQueryCacheSelectSql;
private final Pair<StringBuilder, Attribute[]> _partialSelectSql;
private final Pair<StringBuilder, Attribute[]> _partialQueryCacheSelectSql;
protected StringBuilder _discriminatorClause;
protected Map<String, Object> _discriminatorValues;
protected String _selectByIdSql;
@ -178,6 +177,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
return builder;
}
@Override
public Map<String, Attribute> getAllAttributes() {
return _allAttributes;
}
@ -351,7 +351,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
}
@Override
public List<T> searchIncludingRemoved(SearchCriteria<T> sc, final Filter filter, final Boolean lock,
public List<T> searchIncludingRemoved(SearchCriteria<T> sc, final Filter filter, final Boolean lock,
final boolean cache, final boolean enable_query_cache) {
String clause = sc != null ? sc.getWhereClause() : null;
if (clause != null && clause.length() == 0) {
@ -420,6 +420,9 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
@Override @SuppressWarnings("unchecked")
public <M> List<M> customSearchIncludingRemoved(SearchCriteria<M> sc, final Filter filter) {
if (sc.isSelectAll()) {
return (List<M>)searchIncludingRemoved((SearchCriteria<T>)sc, filter, null, false);
}
String clause = sc != null ? sc.getWhereClause() : null;
if (clause != null && clause.length() == 0) {
clause = null;