Merge branch 'master' into rbac

This commit is contained in:
Min Chen 2014-03-13 14:52:37 -07:00
commit 84a528fad6
31 changed files with 175 additions and 321 deletions

View File

@ -60,7 +60,4 @@ public interface Domain extends OwnedBy, Identity, InternalIdentity {
String getNetworkDomain();
@Override
public String getUuid();
}

View File

@ -59,7 +59,7 @@ public class ApiConstants {
public static final String CTX_ACCOUNT_ID = "ctxaccountid";
public static final String CTX_USER_ID = "ctxuserid";
public static final String CTXSTARTEVENTID = "ctxstarteventid";
public static final String CTX_START_EVENT_ID = "ctxStartEventId";
public static final String CTX_START_EVENT_ID = "ctxstarteventid";
public static final String CUSTOMIZED = "customized";
public static final String CUSTOMIZED_IOPS = "customizediops";
public static final String CUSTOM_ID = "customid";

View File

@ -24,7 +24,7 @@ import com.cloud.utils.exception.CSExceptionErrorCode;
public abstract class BaseListCmd extends BaseCmd {
private static Long s_maxPageSize = null;
public static Long s_pageSizeUnlimited = -1L;
public static final Long s_pageSizeUnlimited = -1L;
// ///////////////////////////////////////////////////
// ///////// BaseList API parameters /////////////////

View File

@ -181,6 +181,9 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.3", description = "used to specify the custom parameters.")
private Map details;
@Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4", authorized = { RoleType.Admin })
private String deploymentPlanner;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -196,6 +199,10 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
return diskOfferingId;
}
public String getDeploymentPlanner() {
return deploymentPlanner;
}
public String getDisplayName() {
return displayName;
}

View File

@ -16,16 +16,17 @@
// under the License.
package org.apache.cloudstack.api.command.user.vm;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncVMCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.ServerApiException;
@ -66,10 +67,14 @@ public class StartVMCmd extends BaseAsyncVMCmd {
since = "3.0.1")
private Long hostId;
@Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4", authorized = { RoleType.Admin })
private String deploymentPlanner;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public Long getId() {
return id;
}
@ -91,6 +96,10 @@ public class StartVMCmd extends BaseAsyncVMCmd {
return "virtualmachine";
}
public String getDeploymentPlanner() {
return deploymentPlanner;
}
@Override
public long getEntityOwnerId() {
UserVm vm = _responseGenerator.findUserVmById(getId());

View File

@ -85,7 +85,7 @@ public interface VirtualMachineManager extends Manager {
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params);
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy);
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner);
void stop(String vmUuid) throws ResourceUnavailableException;

View File

@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.CloudException;
@ -90,7 +91,7 @@ public interface VirtualMachineEntity extends CloudStackEntity {
* @param exclude list of areas to exclude
* @return a reservation id
*/
String reserve(String plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException,
String reserve(DeploymentPlanner plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException,
ResourceUnavailableException;
/**

View File

@ -43,8 +43,10 @@ public interface DeploymentPlanningManager extends Manager {
ExcludeList avoids, DeploymentPlanner planner) throws InsufficientServerCapacityException, AffinityConflictException;
String finalizeReservation(DeployDestination plannedDestination,
VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids)
VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids, DeploymentPlanner planner)
throws InsufficientServerCapacityException, AffinityConflictException;
void cleanupVMReservations();
DeploymentPlanner getDeploymentPlannerByName(String plannerName);
}

View File

@ -40,8 +40,6 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@ -70,6 +68,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.to.VolumeObjectTO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
@ -80,8 +79,8 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
import com.cloud.agent.api.CheckVirtualMachineCommand;
import com.cloud.agent.api.ClusterSyncAnswer;
import com.cloud.agent.api.ClusterSyncCommand;
import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer;
import com.cloud.agent.api.ClusterVMMetaDataSyncCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.MigrateAnswer;
import com.cloud.agent.api.MigrateCommand;
@ -608,13 +607,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
@Override
public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) {
start(vmUuid, params, null);
start(vmUuid, params, null, null);
}
@Override
public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) {
public void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy, DeploymentPlanner planner) {
try {
advanceStart(vmUuid, params, planToDeploy, null);
advanceStart(vmUuid, params, planToDeploy, planner);
} catch (ConcurrentOperationException e) {
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid);
} catch (InsufficientCapacityException e) {
@ -779,7 +778,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_workJobDao.expunge(placeHolder.getId());
}
} else {
Outcome<VirtualMachine> outcome = startVmThroughJobQueue(vmUuid, params, planToDeploy);
Outcome<VirtualMachine> outcome = startVmThroughJobQueue(vmUuid, params, planToDeploy, planner);
try {
VirtualMachine vm = outcome.get();
@ -4451,7 +4450,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
//
public Outcome<VirtualMachine> startVmThroughJobQueue(final String vmUuid,
final Map<VirtualMachineProfile.Param, Object> params,
final DeploymentPlan planToDeploy) {
final DeploymentPlan planToDeploy, final DeploymentPlanner planner) {
final CallContext context = CallContext.current();
final User callingUser = context.getCallingUser();
@ -4488,6 +4487,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
// save work context info (there are some duplications)
VmWorkStart workInfo = new VmWorkStart(callingUser.getId(), callingAccount.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER);
workInfo.setPlan(planToDeploy);
if (planner != null) {
workInfo.setDeploymentPlanner(planner.getName());
}
workInfo.setParams(params);
workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
@ -5123,7 +5125,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
assert (vm != null);
orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), null);
orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner()));
return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null);
}

View File

@ -21,10 +21,9 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper;
import org.apache.log4j.Logger;
import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeploymentPlan;
@ -46,6 +45,7 @@ public class VmWorkStart extends VmWork {
String reservationId;
String journalName;
String planner;
// use serialization friendly map
private Map<String, String> rawParams;
@ -91,6 +91,14 @@ public class VmWorkStart extends VmWork {
}
}
public void setDeploymentPlanner(String planner) {
this.planner = planner;
}
public String getDeploymentPlanner() {
return this.planner;
}
public Map<String, String> getRawParams() {
return rawParams;
}

View File

@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
@ -35,7 +36,7 @@ public interface VMEntityManager {
void saveVirtualMachine(VMEntityVO vmInstanceVO);
String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException,
String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException,
ResourceUnavailableException;
void deployVirtualMachine(String reservationId, VMEntityVO vmEntityVO, String caller, Map<VirtualMachineProfile.Param, Object> params)

View File

@ -22,9 +22,6 @@ import java.util.UUID;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO;
@ -32,6 +29,8 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao;
import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.dc.DataCenter;
import com.cloud.deploy.DataCenterDeployment;
@ -114,6 +113,8 @@ public class VMEntityManagerImpl implements VMEntityManager {
@Inject
protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
@Inject
DeploymentPlanningManager _planningMgr;
@Override
public VMEntityVO loadVirtualMachine(String vmId) {
@ -138,7 +139,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
}
@Override
public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude)
public String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude)
throws InsufficientCapacityException, ResourceUnavailableException {
//call planner and get the deployDestination.
@ -189,13 +190,13 @@ public class VMEntityManagerImpl implements VMEntityManager {
while (true) {
DeployDestination dest = null;
try {
dest = _dpMgr.planDeployment(vmProfile, plan, exclude, null);
dest = _dpMgr.planDeployment(vmProfile, plan, exclude, plannerToUse);
} catch (AffinityConflictException e) {
throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict");
}
if (dest != null) {
String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan, exclude);
String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan, exclude, plannerToUse);
if (reservationId != null) {
return reservationId;
} else {
@ -229,7 +230,7 @@ public class VMEntityManagerImpl implements VMEntityManager {
DataCenterDeployment reservedPlan =
new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(), vmReservation.getClusterId(), vmReservation.getHostId(), null, null);
try {
_itMgr.start(vm.getUuid(), params, reservedPlan);
_itMgr.start(vm.getUuid(), params, reservedPlan, _planningMgr.getDeploymentPlannerByName(vmReservation.getDeploymentPlanner()));
} catch (Exception ex) {
// Retry the deployment without using the reservation plan
DataCenterDeployment plan = new DataCenterDeployment(0, null, null, null, null, null);
@ -238,11 +239,11 @@ public class VMEntityManagerImpl implements VMEntityManager {
plan.setAvoids(reservedPlan.getAvoids());
}
_itMgr.start(vm.getUuid(), params, plan);
_itMgr.start(vm.getUuid(), params, plan, null);
}
} else {
// no reservation found. Let VirtualMachineManager retry
_itMgr.start(vm.getUuid(), params, null);
_itMgr.start(vm.getUuid(), params, null, null);
}
}

View File

@ -24,10 +24,10 @@ import java.util.Map;
import javax.inject.Inject;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
@ -195,7 +195,7 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity {
}
@Override
public String reserve(String plannerToUse, DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException,
public String reserve(DeploymentPlanner plannerToUse, DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException,
ResourceUnavailableException {
return manager.reserveVirtualMachine(this.vmEntityVO, plannerToUse, plan, exclude);
}

View File

@ -39,7 +39,7 @@ import com.cloud.utils.db.TransactionLegacy;
@Component
@Local(value = {VmRulesetLogDao.class})
public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> implements VmRulesetLogDao {
protected static Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class);
protected static final Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class);
private SearchBuilder<VmRulesetLogVO> VmIdSearch;
private String InsertOrUpdateSQl = "INSERT INTO op_vm_ruleset_log (instance_id, created, logsequence) "
+ " VALUES(?, now(), 1) ON DUPLICATE KEY UPDATE logsequence=logsequence+1";

View File

@ -31,6 +31,7 @@ import javax.persistence.Table;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.GenericDao;
@Entity
@ -161,4 +162,8 @@ public class ProjectVO implements Project, Identity, InternalIdentity {
this.uuid = uuid;
}
@Override
public int hashCode() {
return NumbersUtil.hash(id);
}
}

View File

@ -66,6 +66,9 @@ public class VMReservationVO implements Identity, InternalIdentity {
@Column(name = GenericDao.REMOVED_COLUMN)
private Date removed;
@Column(name = "deployment_planner")
private String deploymentPlanner;
// VolumeId -> poolId
@Transient
Map<Long, Long> volumeReservationMap;
@ -124,4 +127,12 @@ public class VMReservationVO implements Identity, InternalIdentity {
this.volumeReservationMap = volumeReservationMap;
}
public void setDeploymentPlanner(String planner) {
this.deploymentPlanner = planner;
}
public String getDeploymentPlanner() {
return this.deploymentPlanner;
}
}

View File

@ -29,6 +29,7 @@ import java.lang.reflect.Type;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import com.cloud.utils.exception.CloudRuntimeException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
@ -40,14 +41,12 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.cloud.utils.exception.CloudRuntimeException;
/**
* Note: toPairList and appendPairList only support simple POJO objects currently
*/
public class JobSerializerHelper {
private static final Logger s_logger = Logger.getLogger(JobSerializerHelper.class);
public static String token = "/";
public static final String token = "/";
private static Gson s_gson;
static {

View File

@ -30,8 +30,16 @@ import java.util.concurrent.Executors;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.framework.events.Event;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.cloudstack.framework.events.EventSubscriber;
import org.apache.cloudstack.framework.events.EventTopic;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import org.apache.log4j.Logger;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.AlreadyClosedException;
import com.rabbitmq.client.Channel;
@ -43,16 +51,6 @@ import com.rabbitmq.client.MessageProperties;
import com.rabbitmq.client.ShutdownListener;
import com.rabbitmq.client.ShutdownSignalException;
import org.apache.cloudstack.framework.events.Event;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.cloudstack.framework.events.EventSubscriber;
import org.apache.cloudstack.framework.events.EventTopic;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
@Local(value = EventBus.class)
public class RabbitMQEventBus extends ManagerBase implements EventBus {

View File

@ -805,7 +805,7 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller, long callerUserId, Map<Param, Object> params)
throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Starting Internal LB VM " + internalLbVm);
_itMgr.start(internalLbVm.getUuid(), params, null);
_itMgr.start(internalLbVm.getUuid(), params, null, null);
if (internalLbVm.isStopPending()) {
s_logger.info("Clear the stop pending flag of Internal LB VM " + internalLbVm.getHostName() + " after start router successfully!");
internalLbVm.setStopPending(false);

View File

@ -48,7 +48,6 @@ import com.cloud.offering.ServiceOffering;
import com.cloud.org.Cluster;
import com.cloud.resource.ResourceManager;
import com.cloud.service.ServiceOfferingDetailsVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.service.dao.ServiceOfferingDetailsDao;
import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.GuestOSVO;
@ -56,14 +55,9 @@ import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.dao.GuestOSCategoryDao;
import com.cloud.storage.dao.GuestOSDao;
import com.cloud.user.Account;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.SecondaryStorageVmDao;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
/**
@ -74,20 +68,10 @@ import com.cloud.vm.dao.VMInstanceDao;
public class FirstFitAllocator extends AdapterBase implements HostAllocator {
private static final Logger s_logger = Logger.getLogger(FirstFitAllocator.class);
@Inject
HostDao _hostDao = null;
protected HostDao _hostDao = null;
@Inject
HostDetailsDao _hostDetailsDao = null;
@Inject
UserVmDao _vmDao = null;
@Inject
ServiceOfferingDao _offeringDao = null;
@Inject
DomainRouterDao _routerDao = null;
@Inject
ConsoleProxyDao _consoleProxyDao = null;
@Inject
SecondaryStorageVmDao _secStorgaeVmDao = null;
@Inject
ConfigurationDao _configDao = null;
@Inject
GuestOSDao _guestOSDao = null;
@ -96,19 +80,20 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
@Inject
VMInstanceDao _vmInstanceDao = null;
@Inject
ResourceManager _resourceMgr;
protected ResourceManager _resourceMgr;
@Inject
ClusterDao _clusterDao;
@Inject
ClusterDetailsDao _clusterDetailsDao;
@Inject
ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
float _factor = 1;
boolean _checkHvm = true;
protected String _allocationAlgorithm = "random";
@Inject
CapacityManager _capacityMgr;
boolean _checkHvm = true;
protected String _allocationAlgorithm = "random";
@Override
public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan plan, Type type, ExcludeList avoid, int returnUpTo) {
return allocateTo(vmProfile, plan, type, avoid, returnUpTo, true);
@ -489,8 +474,6 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
if (_configDao != null) {
Map<String, String> configs = _configDao.getConfiguration(params);
String opFactor = configs.get("cpu.overprovisioning.factor");
_factor = NumbersUtil.parseFloat(opFactor, 1);
String allocationAlgorithm = configs.get("vm.allocation.algorithm");
if (allocationAlgorithm != null) {

View File

@ -42,6 +42,7 @@ public class ParamGenericValidationWorker implements DispatchWorker {
protected static final List<String> defaultParamNames = new ArrayList<String>();
static {
defaultParamNames.add(ApiConstants.ACCOUNT_ID);
defaultParamNames.add(ApiConstants.CTX_START_EVENT_ID);
defaultParamNames.add(ApiConstants.COMMAND);
defaultParamNames.add(ApiConstants.CMD_EVENT_TYPE);
@ -62,6 +63,8 @@ public class ParamGenericValidationWorker implements DispatchWorker {
defaultParamNames.add(ApiConstants.CTX_ACCOUNT_ID);
defaultParamNames.add(ApiConstants.CTX_START_EVENT_ID);
defaultParamNames.add(ApiConstants.CTX_USER_ID);
defaultParamNames.add(ApiConstants.UUID);
defaultParamNames.add(ApiConstants.ID);
defaultParamNames.add("_");
}

View File

@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.utils.NumbersUtil;
@Entity
@Table(name = "dedicated_resources")
public class DedicatedResourceVO implements DedicatedResources {
@ -163,4 +165,9 @@ public class DedicatedResourceVO implements DedicatedResources {
return false;
}
}
@Override
public int hashCode() {
return NumbersUtil.hash(id);
}
}

View File

@ -31,8 +31,6 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.affinity.AffinityGroupVMMapVO;
@ -51,6 +49,7 @@ import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
@ -284,12 +283,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key());
}
}
for (DeploymentPlanner plannerInList : _planners) {
if (plannerName.equals(plannerInList.getName())) {
planner = plannerInList;
break;
}
}
planner = getDeploymentPlannerByName(plannerName);
}
int cpu_requested = offering.getCpu() * offering.getSpeed();
@ -450,7 +444,6 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
if (planner != null && planner.canHandle(vmProfile, plan, avoids)) {
while (true) {
if (planner instanceof DeploymentClusterPlanner) {
ExcludeList plannerAvoidInput =
@ -502,6 +495,21 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
return dest;
}
@Override
public DeploymentPlanner getDeploymentPlannerByName(String plannerName) {
if (plannerName != null) {
for (DeploymentPlanner plannerInList : _planners) {
if (plannerName != null) {
}
if (plannerName.equalsIgnoreCase(plannerInList.getName())) {
return plannerInList;
}
}
}
return null;
}
private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) {
boolean isExplicit = false;
VirtualMachine vm = vmProfile.getVirtualMachine();
@ -1345,7 +1353,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
@DB
@Override
public String finalizeReservation(final DeployDestination plannedDestination, final VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids)
public String finalizeReservation(final DeployDestination plannedDestination, final VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids, final DeploymentPlanner planner)
throws InsufficientServerCapacityException, AffinityConflictException {
final VirtualMachine vm = vmProfile.getVirtualMachine();
@ -1374,6 +1382,9 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
VMReservationVO vmReservation =
new VMReservationVO(vm.getId(), plannedDestination.getDataCenter().getId(), plannedDestination.getPod().getId(), plannedDestination.getCluster()
.getId(), plannedDestination.getHost().getId());
if (planner != null) {
vmReservation.setDeploymentPlanner(planner.getName());
}
Map<Long, Long> volumeReservationMap = new HashMap<Long, Long>();
if (vm.getHypervisorType() != HypervisorType.BareMetal) {

View File

@ -25,13 +25,12 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.log4j.Logger;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityManager;

View File

@ -1346,7 +1346,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipToAssoc, _vlanDao.findById(ipToAssoc.getVlanId()));
ipList.add(publicIp);
Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(ipList, false, true);
if (ipToServices != null & !ipToServices.isEmpty()) {
if (!ipToServices.isEmpty()) {
Set<Service> services = ipToServices.get(publicIp);
if (services != null && !services.isEmpty()) {
throw new InvalidParameterValueException("IP " + ipToAssoc + " has services and rules associated in the network " + networkId);
@ -1387,7 +1387,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
ipList.add(publicIp);
Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(ipList, false, true);
if (ipToServices != null & !ipToServices.isEmpty()) {
if (!ipToServices.isEmpty()) {
Set<Service> ipServices = ipToServices.get(publicIp);
if (ipServices != null && !ipServices.isEmpty()) {
return false;

View File

@ -1378,8 +1378,8 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
private boolean startNewVM(long vmId) {
try {
CallContext.current().setEventDetails("Vm Id: " + vmId);
_userVmManager.startVirtualMachine(vmId, null, null);
} catch (ResourceUnavailableException ex) {
_userVmManager.startVirtualMachine(vmId, null, null, null);
} catch (final ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {

View File

@ -44,11 +44,9 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
import org.apache.cloudstack.api.command.admin.account.CreateAccountCmd;
import org.apache.cloudstack.api.command.admin.account.DeleteAccountCmd;
import org.apache.cloudstack.api.command.admin.account.DisableAccountCmd;
@ -557,18 +555,14 @@ import com.cloud.storage.GuestOSHypervisor;
import com.cloud.storage.GuestOSHypervisorVO;
import com.cloud.storage.GuestOSVO;
import com.cloud.storage.GuestOsCategory;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.GuestOSCategoryDao;
import com.cloud.storage.dao.GuestOSDao;
import com.cloud.storage.dao.GuestOSHypervisorDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.tags.ResourceTagVO;
@ -584,7 +578,6 @@ import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.SSHKeyPairDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.EnumUtils;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.PasswordGenerator;
@ -669,8 +662,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Inject
private DiskOfferingDao _diskOfferingDao;
@Inject
private VMTemplateDao _templateDao;
@Inject
private DomainDao _domainDao;
@Inject
private AccountDao _accountDao;
@ -738,12 +729,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private AccountService _accountService;
@Inject
private ServiceOfferingDao _offeringDao;
@Inject
private DeploymentPlanningManager _dpMgr;
private LockMasterListener _lockMasterListener;
private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("EventChecker"));
private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AlertChecker"));
@Inject
@ -1708,210 +1697,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return new Pair<List<? extends Configuration>, Integer>(result.first(), result.second());
}
/* TODO: this method should go away. Keep here just in case that our latest refactoring using template_store_ref missed anything
* in handling Swift or S3.
private Set<Pair<Long, Long>> listTemplates(Long templateId, String name, String keyword, TemplateFilter templateFilter, boolean isIso,
Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean showDomr, boolean onlyReady,
List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String> tags, String zoneType) {
VMTemplateVO template = null;
if (templateId != null) {
template = _templateDao.findById(templateId);
if (template == null) {
throw new InvalidParameterValueException("Please specify a valid template ID.");
}// If ISO requested then it should be ISO.
if (isIso && template.getFormat() != ImageFormat.ISO) {
s_logger.error("Template Id " + templateId + " is not an ISO");
InvalidParameterValueException ex = new InvalidParameterValueException("Specified Template Id is not an ISO");
ex.addProxyObject(template.getUuid(), "templateId");
throw ex;
}// If ISO not requested then it shouldn't be an ISO.
if (!isIso && template.getFormat() == ImageFormat.ISO) {
s_logger.error("Incorrect format of the template id " + templateId);
InvalidParameterValueException ex = new InvalidParameterValueException("Incorrect format " + template.getFormat()
+ " of the specified template id");
ex.addProxyObject(template.getUuid(), "templateId");
throw ex;
}
}
DomainVO domain = null;
if (!permittedAccounts.isEmpty()) {
domain = _domainDao.findById(permittedAccounts.get(0).getDomainId());
} else {
domain = _domainDao.findById(DomainVO.ROOT_DOMAIN);
}
List<HypervisorType> hypers = null;
if (!isIso) {
hypers = _resourceMgr.listAvailHypervisorInZone(null, null);
}
Set<Pair<Long, Long>> templateZonePairSet = new HashSet<Pair<Long, Long>>();
if (_swiftMgr.isSwiftEnabled()) {
if (template == null) {
templateZonePairSet = _templateDao.searchSwiftTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize,
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, tags);
Set<Pair<Long, Long>> templateZonePairSet2 = new HashSet<Pair<Long, Long>>();
templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize,
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
for (Pair<Long, Long> tmpltPair : templateZonePairSet2) {
if (!templateZonePairSet.contains(new Pair<Long, Long>(tmpltPair.first(), -1L))) {
templateZonePairSet.add(tmpltPair);
}
}
} else {
// if template is not public, perform permission check here
if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
Account owner = _accountMgr.getAccount(template.getAccountId());
_accountMgr.checkAccess(caller, null, true, owner);
}
templateZonePairSet.add(new Pair<Long, Long>(template.getId(), zoneId));
}
} else if (_s3Mgr.isS3Enabled()) {
if (template == null) {
templateZonePairSet = _templateDao.searchSwiftTemplates(name, keyword, templateFilter, isIso,
hypers, bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady, showDomr,
permittedAccounts, caller, tags);
Set<Pair<Long, Long>> templateZonePairSet2 = new HashSet<Pair<Long, Long>>();
templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers,
bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady, showDomr,
permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
for (Pair<Long, Long> tmpltPair : templateZonePairSet2) {
if (!templateZonePairSet.contains(new Pair<Long, Long>(tmpltPair.first(), -1L))) {
templateZonePairSet.add(tmpltPair);
}
}
} else {
// if template is not public, perform permission check here
if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
Account owner = _accountMgr.getAccount(template.getAccountId());
_accountMgr.checkAccess(caller, null, true, owner);
}
templateZonePairSet.add(new Pair<Long, Long>(template.getId(), zoneId));
}
} else {
if (template == null) {
templateZonePairSet = _templateDao.searchTemplates(name, keyword, templateFilter, isIso, hypers, bootable, domain, pageSize,
startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
} else {
// if template is not public, perform permission check here
if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
Account owner = _accountMgr.getAccount(template.getAccountId());
_accountMgr.checkAccess(caller, null, true, owner);
}
templateZonePairSet.add(new Pair<Long, Long>(template.getId(), zoneId));
}
}
return templateZonePairSet;
}
*/
private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
Long id = cmd.getId();
String name = cmd.getTemplateName();
String displayText = cmd.getDisplayText();
String format = cmd.getFormat();
Long guestOSId = cmd.getOsTypeId();
Boolean passwordEnabled = cmd.isPasswordEnabled();
Boolean bootable = cmd.isBootable();
Integer sortKey = cmd.getSortKey();
Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
Boolean isRoutingTemplate = cmd.isRoutingType();
Account account = CallContext.current().getCallingAccount();
// verify that template exists
VMTemplateVO template = _templateDao.findById(id);
if (template == null || template.getRemoved() != null) {
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find template/iso with specified id");
ex.addProxyObject(id.toString(), "templateId");
throw ex;
}
// Don't allow to modify system template
if (id.equals(Long.valueOf(1))) {
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id");
ex.addProxyObject(template.getUuid(), "templateId");
throw ex;
}
// do a permission check
_accountMgr.checkAccess(account, AccessType.OperateEntry, true, template);
if(cmd.isRoutingType() != null){
if (!_accountService.isRootAdmin(account.getId())) {
throw new PermissionDeniedException("Parameter isrouting can only be specified by a Root Admin, permission denied");
}
}
boolean updateNeeded = !(name == null && displayText == null && format == null && guestOSId == null && passwordEnabled == null && bootable == null && sortKey == null
&& isDynamicallyScalable == null && isRoutingTemplate == null);
if (!updateNeeded) {
return template;
}
template = _templateDao.createForUpdate(id);
if (name != null) {
template.setName(name);
}
if (displayText != null) {
template.setDisplayText(displayText);
}
if (sortKey != null) {
template.setSortKey(sortKey);
}
ImageFormat imageFormat = null;
if (format != null) {
try {
imageFormat = ImageFormat.valueOf(format.toUpperCase());
} catch (IllegalArgumentException e) {
throw new InvalidParameterValueException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values()));
}
template.setFormat(imageFormat);
}
if (guestOSId != null) {
GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
if (guestOS == null) {
throw new InvalidParameterValueException("Please specify a valid guest OS ID.");
} else {
template.setGuestOSId(guestOSId);
}
}
if (passwordEnabled != null) {
template.setEnablePassword(passwordEnabled);
}
if (bootable != null) {
template.setBootable(bootable);
}
if (isDynamicallyScalable != null) {
template.setDynamicallyScalable(isDynamicallyScalable);
}
if (isRoutingTemplate != null) {
if (isRoutingTemplate) {
template.setTemplateType(TemplateType.ROUTING);
} else {
template.setTemplateType(TemplateType.USER);
}
}
_templateDao.update(id, template);
return _templateDao.findById(id);
}
@Override
public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd cmd) {
Object keyword = cmd.getKeyword();
@ -3463,7 +3248,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
}
long diskOffMaxSize = _volumeMgr.CustomDiskOfferingMaxSize.value();
long diskOffMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
KVMSnapshotEnabled = Boolean.parseBoolean(_configDao.getValue("KVM.snapshot.enabled"));
boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId());

View File

@ -88,7 +88,7 @@ public interface UserVmManager extends UserVmService {
boolean expunge(UserVmVO vm, long callerUserId, Account caller);
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams)
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse)
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
boolean upgradeVirtualMachine(Long id, Long serviceOfferingId, Map<String, String> customParameters) throws ResourceUnavailableException,

View File

@ -115,7 +115,9 @@ import com.cloud.dc.dao.DedicatedResourceDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.deploy.DeploymentPlanningManager;
import com.cloud.deploy.PlannerHostReservationVO;
import com.cloud.deploy.dao.PlannerHostReservationDao;
import com.cloud.domain.DomainVO;
@ -391,7 +393,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
protected ProjectManager _projectMgr;
@Inject
protected ResourceManager _resourceMgr;
@Inject
protected NetworkServiceMapDao _ntwkSrvcDao;
@Inject
@ -410,17 +411,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
protected GuestOSCategoryDao _guestOSCategoryDao;
@Inject
UsageEventDao _usageEventDao;
@Inject
SecondaryStorageVmDao _secondaryDao;
@Inject
VmDiskStatisticsDao _vmDiskStatsDao;
@Inject
protected VMSnapshotDao _vmSnapshotDao;
@Inject
protected VMSnapshotManager _vmSnapshotMgr;
@Inject
AffinityGroupVMMapDao _affinityGroupVMMapDao;
@Inject
@ -445,6 +443,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
UserVmDetailsDao _uservmDetailsDao;
@Inject
UUIDManager _uuidMgr;
@Inject
DeploymentPlanningManager _planningMgr;
protected ScheduledExecutorService _executor = null;
protected int _expungeInterval;
@ -1970,7 +1970,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Override
@ActionEvent(eventType = EventTypes.EVENT_VM_START, eventDescription = "starting Vm", async = true)
public UserVm startVirtualMachine(StartVMCmd cmd) throws ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
return startVirtualMachine(cmd.getId(), cmd.getHostId(), null).first();
return startVirtualMachine(cmd.getId(), cmd.getHostId(), null, cmd.getDeploymentPlanner()).first();
}
@Override
@ -2972,10 +2972,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Override
@ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "starting Vm", async = true)
public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
return startVirtualMachine(cmd, null);
return startVirtualMachine(cmd, null, cmd.getDeploymentPlanner());
}
protected UserVm startVirtualMachine(DeployVMCmd cmd, Map<VirtualMachineProfile.Param, Object> additonalParams) throws ResourceUnavailableException,
protected UserVm startVirtualMachine(DeployVMCmd cmd, Map<VirtualMachineProfile.Param, Object> additonalParams, String deploymentPlannerToUse) throws ResourceUnavailableException,
InsufficientCapacityException, ConcurrentOperationException {
long vmId = cmd.getEntityId();
@ -2984,7 +2984,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = null;
try {
vmParamPair = startVirtualMachine(vmId, hostId, additonalParams);
vmParamPair = startVirtualMachine(vmId, hostId, additonalParams, deploymentPlannerToUse);
vm = vmParamPair.first();
} finally {
updateVmStateForFailedVmCreation(vm.getId(), hostId);
@ -3230,7 +3230,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
@Override
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams)
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse)
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
// Input validation
Account callerAccount = CallContext.current().getCallingAccount();
@ -3323,18 +3323,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
// Get serviceOffering for Virtual Machine
ServiceOfferingVO offering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId());
String plannerName = offering.getDeploymentPlanner();
if (plannerName == null) {
if (vm.getHypervisorType() == HypervisorType.BareMetal) {
plannerName = "BareMetalPlanner";
} else {
plannerName = _configDao.getValue(Config.VmDeploymentPlanner.key());
DeploymentPlanner planner = null;
if (deploymentPlannerToUse != null) {
// if set to null, the deployment planner would be later figured out either from global config var, or from
// the service offering
planner = _planningMgr.getDeploymentPlannerByName(deploymentPlannerToUse);
if (planner == null) {
throw new InvalidParameterValueException("Can't find a planner by name " + deploymentPlannerToUse);
}
}
String reservationId = vmEntity.reserve(plannerName, plan, new ExcludeList(), Long.toString(callerUser.getId()));
String reservationId = vmEntity.reserve(planner, plan, new ExcludeList(), Long.toString(callerUser.getId()));
vmEntity.deploy(reservationId, Long.toString(callerUser.getId()), params);
Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = new Pair(vm, params);

View File

@ -75,6 +75,30 @@ public class ParamGenericValidationWorkerTest {
final BaseCmd cmd = new FakeCmd();
final Map<String, String> params = new HashMap<String, String>();
params.put(ApiConstants.COMMAND, "");
params.put(ApiConstants.ACCOUNT_ID, "");
params.put(ApiConstants.CTX_START_EVENT_ID, "");
params.put(ApiConstants.COMMAND, "");
params.put(ApiConstants.CMD_EVENT_TYPE, "");
params.put(ApiConstants.USERNAME, "");
params.put(ApiConstants.USER_ID, "");
params.put(ApiConstants.PASSWORD, "");
params.put(ApiConstants.DOMAIN, "");
params.put(ApiConstants.DOMAIN_ID, "");
params.put(ApiConstants.DOMAIN__ID, "");
params.put(ApiConstants.SESSIONKEY, "");
params.put(ApiConstants.RESPONSE, "");
params.put(ApiConstants.PAGE, "");
params.put(ApiConstants.USER_API_KEY, "");
params.put(ApiConstants.API_KEY, "");
params.put(ApiConstants.PAGE_SIZE, "");
params.put(ApiConstants.HTTPMETHOD, "");
params.put(ApiConstants.SIGNATURE, "");
params.put(ApiConstants.CTX_ACCOUNT_ID, "");
params.put(ApiConstants.CTX_START_EVENT_ID, "");
params.put(ApiConstants.CTX_USER_ID, "");
params.put(ApiConstants.UUID, "");
params.put(ApiConstants.ID, "");
params.put("_", "");
params.put("addedParam", "");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");

View File

@ -730,3 +730,5 @@ UPDATE `cloud`.`guest_os_hypervisor` SET `created` = now();
ALTER TABLE `cloud`.`guest_os` ADD COLUMN `created` datetime COMMENT 'Time when Guest OS was created in system';
ALTER TABLE `cloud`.`guest_os` ADD COLUMN `removed` datetime COMMENT 'Time when Guest OS was removed if deleted, else NULL';
UPDATE `cloud`.`guest_os` SET `created` = now();
ALTER TABLE `cloud`.`vm_reservation` ADD COLUMN `deployment_planner` varchar(40) DEFAULT NULL COMMENT 'Preferred deployment planner for the vm';