removed service offering from storageallocator

This commit is contained in:
Alex Huang 2010-09-24 09:59:01 -07:00
parent e6c2f7fa0b
commit 42986f43ba
14 changed files with 146 additions and 66 deletions

View File

@ -140,7 +140,7 @@
</path>
<path id="thirdparty.classpath">
<filelist files="${thirdparty.classpath}" />
<!--filelist files="${thirdparty.classpath}" /-->
<fileset dir="${thirdparty.dir}" erroronmissingdir="false">
<include name="*.jar" />
</fileset>

View File

@ -48,7 +48,7 @@
<javac srcdir="@{top.dir}/src" debug="${debug}" debuglevel="${debuglevel}" deprecation="${deprecation}" destdir="${classes.dir}/@{jar.name}" source="${source.compat.version}" target="${target.compat.version}" includeantruntime="false" compiler="javac1.6">
<!-- compilerarg line="-processor com.cloud.annotation.LocalProcessor -processorpath ${base.dir}/tools/src -Xlint:all"/ -->
<!-- compilerarg line="-processor com.cloud.utils.LocalProcessor -processorpath ${base.dir}/utils/src -Xlint:all"/ -->
<compilerarg line="-Xlint:all"/>
<compilerarg line="-Xlint:-path"/>
<classpath refid="@{classpath}" />
<exclude-files/>
</javac>

View File

@ -24,8 +24,10 @@ import java.util.Map;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
@ -41,6 +43,7 @@ import com.cloud.utils.component.Manager;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachineProfile;
public interface StorageManager extends Manager {
@ -314,4 +317,6 @@ public interface StorageManager extends Manager {
Long findHostIdForStoragePool(StoragePoolVO pool);
void createCapacityEntry(StoragePoolVO storagePool, long allocated);
VolumeTO[] prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException;
}

View File

@ -516,7 +516,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
@Override
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
try {
return start(proxyVmId, startEventId);
return start2(proxyVmId, startEventId);
} catch (StorageUnavailableException e) {
s_logger.warn("Exception while trying to start console proxy", e);
return null;
@ -852,7 +852,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled())
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
Map<String, Object> context = createProxyInstance(dataCenterId);
Map<String, Object> context = createProxyInstance2(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {
@ -892,7 +892,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled())
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
Map<String, Object> context = createProxyInstance(dataCenterId);
Map<String, Object> context = createProxyInstance2(dataCenterId);
long proxyVmId = (Long) context.get("proxyVmId");
if (proxyVmId == 0) {
@ -1417,7 +1417,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
try {
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
try {
readyProxy = start(readyProxy.getId(), 0);
readyProxy = start2(readyProxy.getId(), 0);
} finally {
proxyLock.unlock();
}

View File

@ -228,7 +228,7 @@ public interface NetworkManager extends Manager {
List<NicProfile> allocate(VirtualMachineProfile vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
List<NicTO> prepare(VirtualMachineProfile profile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
NicTO[] prepare(VirtualMachineProfile profile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
<K extends VMInstanceVO> void create(K vm);

View File

@ -2478,12 +2478,12 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
@Override
public List<NicTO> prepare(VirtualMachineProfile vmProfile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException {
public NicTO[] prepare(VirtualMachineProfile vmProfile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException {
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
List<NicTO> nicTos = new ArrayList<NicTO>(nics.size());
NicTO[] nicTos = new NicTO[nics.size()];
int i = 0;
for (NicVO nic : nics) {
NetworkConfigurationVO config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
nic.setState(Resource.State.Reserving);
@ -2510,7 +2510,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
}
}
nicTos.add(toNicTO(nic, config));
nicTos[i++] = toNicTO(nic, config);
}
return nicTos;

View File

@ -26,6 +26,7 @@ import java.util.Enumeration;
import java.util.Formatter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -74,6 +75,7 @@ import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.event.EventState;
import com.cloud.event.EventTypes;
import com.cloud.event.EventVO;
@ -145,6 +147,7 @@ import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@ -170,7 +173,9 @@ public class StorageManagerImpl implements StorageManager {
@Inject protected ConsoleProxyDao _consoleProxyDao;
@Inject protected DetailsDao _detailsDao;
@Inject protected SnapshotDao _snapshotDao;
@Inject(adapter=StoragePoolAllocator.class)
protected Adapters<StoragePoolAllocator> _storagePoolAllocators;
@Inject(adapter=StoragePoolDiscoverer.class)
protected Adapters<StoragePoolDiscoverer> _discoverers;
@Inject protected StoragePoolHostDao _storagePoolHostDao;
@Inject protected AlertManager _alertMgr;
@ -267,6 +272,87 @@ public class StorageManagerImpl implements StorageManager {
return vols.get(0);
}
@Override
public VolumeTO[] prepare(VirtualMachineProfile vm, DeployDestination dest) {
List<VolumeVO> vols = _volsDao.findCreatedByInstance(vm.getId());
List<VolumeVO> recreateVols = new ArrayList<VolumeVO>(vols.size());
Host host = dest.getHost();
VolumeTO[] disks = new VolumeTO[vols.size()];
int i = 0;
Iterator<VolumeVO> it = vols.iterator();
while (it.hasNext()) {
VolumeVO vol = it.next();
if (vol.isRecreatable()) {
it.remove();
//if we have a system vm
//get the storage pool
//if pool is in maintenance
//add to recreate vols, and continue
if(vm.getType().equals(VirtualMachine.Type.ConsoleProxy) || vm.getType().equals(VirtualMachine.Type.DomainRouter) || vm.getType().equals(VirtualMachine.Type.SecondaryStorageVm))
{
StoragePoolVO sp = _storagePoolDao.findById(vol.getPoolId());
if(sp!=null && sp.getStatus().equals(Status.PrepareForMaintenance))
{
recreateVols.add(vol);
continue;
}
}
StoragePoolHostVO ph = _storagePoolHostDao.findByPoolHost(vol.getPoolId(), host.getId());
if (ph == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Must recreate " + vol + " since " + vol.getPoolId() + " has is not hooked up with host " + host.getId());
}
recreateVols.add(vol);
}
}
}
for (VolumeVO vol : recreateVols) {
VolumeVO create = allocateDuplicateVolume(vol);
vols.add(vol);
}
/*
create.setDiskOfferingId(vol.getDiskOfferingId());
create.setDeviceId(vol.getDeviceId());
create = _volsDao.persist(create);
VMTemplateVO template = _templateDao.findById(create.getTemplateId());
DataCenterVO dc = _dcDao.findById(create.getDataCenterId());
HostPodVO pod = _podDao.findById(host.getPodId());
DiskOfferingVO diskOffering = null;
diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
ServiceOfferingVO offering;
if (vm instanceof UserVmVO) {
offering = _offeringDao.findById(((UserVmVO)vm).getServiceOfferingId());
} else {
offering = _offeringDao.findById(vol.getDiskOfferingId());
}
VolumeVO created = createVolume(create, vm, template, dc, pod, host.getClusterId(), offering, diskOffering, new ArrayList<StoragePoolVO>(),0);
if (created == null) {
break;
}
createds.add(created);
for (VolumeVO vol : recreateVols) {
_volsDao.remove(vol.getId());
}
disks[i++] = null;
}
*/
return disks;
}
VolumeVO allocateDuplicateVolume(VolumeVO oldVol) {
VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(), oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(), oldVol.getSize());
newVol.setTemplateId(oldVol.getTemplateId());
newVol.setDeviceId(oldVol.getDeviceId());
newVol.setInstanceId(oldVol.getInstanceId());
return _volsDao.persist(newVol);
}
@Override
public List<VolumeVO> prepare(VMInstanceVO vm, HostVO host) {
@ -392,7 +478,7 @@ public class StorageManagerImpl implements StorageManager {
Enumeration<StoragePoolAllocator> en = _storagePoolAllocators.enumeration();
while (en.hasMoreElements()) {
final StoragePoolAllocator allocator = en.nextElement();
final StoragePool pool = allocator.allocateToPool(dskCh, offering, dc, pod, clusterId, vm, template, avoid);
final StoragePool pool = allocator.allocateToPool(dskCh, dc, pod, clusterId, vm, template, avoid);
if (pool != null) {
return (StoragePoolVO) pool;
}
@ -1056,13 +1142,6 @@ public class StorageManagerImpl implements StorageManager {
return false;
}
_storagePoolAllocators = locator.getAdapters(StoragePoolAllocator.class);
if (!_storagePoolAllocators.isSet()) {
throw new ConfigurationException("Unable to get any storage pool allocators.");
}
_discoverers = locator.getAdapters(StoragePoolDiscoverer.class);
Map<String, String> configs = configDao.getConfiguration("management-server", params);

View File

@ -28,9 +28,9 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.StatsCollector;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageManager;
@ -42,6 +42,7 @@ import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.Volume.VolumeType;
import com.cloud.storage.dao.StoragePoolDao;
import com.cloud.storage.dao.StoragePoolHostDao;
@ -58,6 +59,7 @@ import com.cloud.utils.component.Inject;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
public abstract class AbstractStoragePoolAllocator extends AdapterBase implements StoragePoolAllocator {
private static final Logger s_logger = Logger.getLogger(FirstFitStoragePoolAllocator.class);
@ -100,7 +102,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
return true;
}
abstract boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering);
abstract boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm);
protected boolean templateAvailable(long templateId, long poolId) {
VMTemplateStorageResourceAssoc thvo = _templatePoolDao.findByPoolTemplate(poolId, templateId);
@ -114,26 +116,16 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
}
}
protected boolean localStorageAllocationNeeded(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering) {
if (vm == null) {
// We are finding a pool for a volume, so we need a shared storage allocator
return false;
} else if (vm.getType() == VirtualMachine.Type.User) {
// We are finding a pool for a UserVM, so check the service offering to see if we should use local storage
return offering.getUseLocalStorage();
} else {
// We are finding a pool for a DomR or ConsoleProxy, so check the configuration table to see if we should use local storage
String configValue = _configDao.getValue("system.vm.use.local.storage");
return Boolean.parseBoolean(configValue);
}
protected boolean localStorageAllocationNeeded(DiskProfile dskCh, VMInstanceVO vm) {
return dskCh.useLocalStorage();
}
protected boolean poolIsCorrectType(DiskProfile dskCh, StoragePool pool, VMInstanceVO vm, ServiceOffering offering) {
boolean localStorageAllocationNeeded = localStorageAllocationNeeded(dskCh, vm, offering);
protected boolean poolIsCorrectType(DiskProfile dskCh, StoragePool pool, VMInstanceVO vm) {
boolean localStorageAllocationNeeded = localStorageAllocationNeeded(dskCh, vm);
return ((!localStorageAllocationNeeded && pool.getPoolType().isShared()) || (localStorageAllocationNeeded && !pool.getPoolType().isShared()));
}
protected boolean checkPool(Set<? extends StoragePool> avoid, StoragePoolVO pool, DiskProfile dskCh, VMTemplateVO template, List<VMTemplateStoragePoolVO> templatesInPool, ServiceOffering offering,
protected boolean checkPool(Set<? extends StoragePool> avoid, StoragePoolVO pool, DiskProfile dskCh, VMTemplateVO template, List<VMTemplateStoragePoolVO> templatesInPool,
VMInstanceVO vm, StatsCollector sc) {
if (avoid.contains(pool)) {
return false;
@ -144,7 +136,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
// Check that the pool type is correct
if (!poolIsCorrectType(dskCh, pool, vm, offering)) {
if (!poolIsCorrectType(dskCh, pool, vm)) {
return false;
}
@ -235,4 +227,10 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
public String chooseStorageIp(VirtualMachine vm, Host host, Host storage) {
return storage.getStorageIpAddress();
}
@Override
public StoragePool allocateTo(DiskProfile dskCh, VirtualMachineProfile vm, DeployDestination dest, List<Volume> disks, Set<StoragePool> avoids) {
return null;
}
}

View File

@ -27,7 +27,6 @@ import org.apache.log4j.Logger;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.StatsCollector;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolVO;
@ -40,15 +39,15 @@ public class FirstFitStoragePoolAllocator extends AbstractStoragePoolAllocator {
private static final Logger s_logger = Logger.getLogger(FirstFitStoragePoolAllocator.class);
@Override
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering) {
return !localStorageAllocationNeeded(dskCh, vm, offering);
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm) {
return !localStorageAllocationNeeded(dskCh, vm);
}
@Override
public StoragePool allocateToPool(DiskProfile dskCh, ServiceOffering offering, DataCenterVO dc, HostPodVO pod, Long clusterId,
public StoragePool allocateToPool(DiskProfile dskCh, DataCenterVO dc, HostPodVO pod, Long clusterId,
VMInstanceVO vm, VMTemplateVO template, Set<? extends StoragePool> avoid) {
// Check that the allocator type is correct
if (!allocatorIsCorrectType(dskCh, vm, offering)) {
if (!allocatorIsCorrectType(dskCh, vm)) {
return null;
}
@ -65,7 +64,7 @@ public class FirstFitStoragePoolAllocator extends AbstractStoragePoolAllocator {
Collections.shuffle(pools);
for (StoragePoolVO pool: pools) {
if (checkPool(avoid, pool, dskCh, template, null, offering, vm, sc)) {
if (checkPool(avoid, pool, dskCh, template, null, vm, sc)) {
return pool;
}
}

View File

@ -29,7 +29,6 @@ import org.apache.log4j.Logger;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.offering.ServiceOffering;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO;
@ -48,7 +47,7 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl
boolean _storagePoolCleanupEnabled;
@Override
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering) {
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm) {
return true;
}
@ -62,7 +61,6 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl
@Override
public StoragePool allocateToPool(DiskProfile dskCh,
ServiceOffering offering,
DataCenterVO dc,
HostPodVO pod,
Long clusterId,
@ -80,7 +78,7 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl
// Determine what allocator to use
StoragePoolAllocator allocator;
if (localStorageAllocationNeeded(dskCh, vm, offering)) {
if (localStorageAllocationNeeded(dskCh, vm)) {
allocator = _localStoragePoolAllocator;
} else {
allocator = _firstFitStoragePoolAllocator;
@ -92,7 +90,7 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl
myAvoids.add(pool);
}
return allocator.allocateToPool(dskCh, offering, dc, pod, clusterId, vm, template, myAvoids);
return allocator.allocateToPool(dskCh, dc, pod, clusterId, vm, template, myAvoids);
}
@Override

View File

@ -33,7 +33,6 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.offering.ServiceOffering;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
@ -85,13 +84,12 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
@Override
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering) {
return localStorageAllocationNeeded(dskCh, vm, offering);
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm) {
return localStorageAllocationNeeded(dskCh, vm);
}
@Override
public StoragePool allocateToPool(DiskProfile dskCh,
ServiceOffering offering,
DataCenterVO dc,
HostPodVO pod,
Long clusterId,
@ -100,14 +98,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
Set<? extends StoragePool> avoid) {
// Check that the allocator type is correct
if (!allocatorIsCorrectType(dskCh, vm, offering)) {
if (!allocatorIsCorrectType(dskCh, vm)) {
return null;
}
Set<StoragePool> myAvoids = new HashSet<StoragePool>(avoid);
VirtualMachineProfile vmc = new VirtualMachineProfile(vm.getType());
StoragePool pool = null;
while ((pool = super.allocateToPool(dskCh, offering, dc, pod, clusterId, vm, template, myAvoids)) != null) {
while ((pool = super.allocateToPool(dskCh, dc, pod, clusterId, vm, template, myAvoids)) != null) {
myAvoids.add(pool);
if (pool.getPoolType().isShared()) {
return pool;

View File

@ -27,7 +27,6 @@ import org.apache.log4j.Logger;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.StatsCollector;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolVO;
@ -40,17 +39,17 @@ public class RandomStoragePoolAllocator extends AbstractStoragePoolAllocator {
private static final Logger s_logger = Logger.getLogger(RandomStoragePoolAllocator.class);
@Override
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering) {
public boolean allocatorIsCorrectType(DiskProfile dskCh, VMInstanceVO vm) {
return true;
}
@Override
public StoragePool allocateToPool(DiskProfile dskCh, ServiceOffering offering,
public StoragePool allocateToPool(DiskProfile dskCh,
DataCenterVO dc, HostPodVO pod, Long clusterId, VMInstanceVO vm,
VMTemplateVO template, Set<? extends StoragePool> avoid) {
// Check that the allocator type is correct
if (!allocatorIsCorrectType(dskCh, vm, offering)) {
if (!allocatorIsCorrectType(dskCh, vm)) {
return null;
}
@ -67,7 +66,7 @@ public class RandomStoragePoolAllocator extends AbstractStoragePoolAllocator {
Collections.shuffle(pools);
for (StoragePoolVO pool: pools) {
if (checkPool(avoid, pool, dskCh, template, null, offering, vm, sc)) {
if (checkPool(avoid, pool, dskCh, template, null, vm, sc)) {
return pool;
}
}

View File

@ -17,18 +17,21 @@
*/
package com.cloud.storage.allocator;
import java.util.List;
import java.util.Set;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.host.Host;
import com.cloud.offering.ServiceOffering;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.utils.component.Adapter;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
/**
* Allocator for a disk. This determines which StoragePool should
@ -36,7 +39,9 @@ import com.cloud.vm.VirtualMachine;
*/
public interface StoragePoolAllocator extends Adapter {
StoragePool allocateToPool(DiskProfile dskCh, ServiceOffering offering, DataCenterVO dc, HostPodVO pod, Long cluster, VMInstanceVO vm, VMTemplateVO template, Set<? extends StoragePool> avoids);
StoragePool allocateToPool(DiskProfile dskCh, DataCenterVO dc, HostPodVO pod, Long cluster, VMInstanceVO vm, VMTemplateVO template, Set<? extends StoragePool> avoids);
String chooseStorageIp(VirtualMachine vm, Host host, Host storage);
StoragePool allocateTo(DiskProfile dskCh, VirtualMachineProfile vm, DeployDestination dest, List<Volume> disks, Set<StoragePool> avoids);
}

View File

@ -28,7 +28,6 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.host.Host;
import com.cloud.offering.ServiceOffering;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume.VolumeType;
@ -42,12 +41,12 @@ public class UseLocalForRootAllocator extends LocalStoragePoolAllocator implemen
boolean _useLocalStorage;
@Override
public StoragePool allocateToPool(DiskProfile dskCh, ServiceOffering offering, DataCenterVO dc, HostPodVO pod, Long clusterId, VMInstanceVO vm, VMTemplateVO template, Set<? extends StoragePool> avoids) {
public StoragePool allocateToPool(DiskProfile dskCh, DataCenterVO dc, HostPodVO pod, Long clusterId, VMInstanceVO vm, VMTemplateVO template, Set<? extends StoragePool> avoids) {
if (!_useLocalStorage) {
return null;
}
return super.allocateToPool(dskCh, offering, dc, pod, clusterId, vm, template, avoids);
return super.allocateToPool(dskCh, dc, pod, clusterId, vm, template, avoids);
}
@Override
@ -69,13 +68,13 @@ public class UseLocalForRootAllocator extends LocalStoragePoolAllocator implemen
}
@Override
protected boolean localStorageAllocationNeeded(DiskProfile dskCh, VMInstanceVO vm, ServiceOffering offering) {
protected boolean localStorageAllocationNeeded(DiskProfile dskCh, VMInstanceVO vm) {
if (dskCh.getType() == VolumeType.ROOT) {
return true;
} else if (dskCh.getType() == VolumeType.DATADISK) {
return false;
} else {
return super.localStorageAllocationNeeded(dskCh, vm, offering);
return super.localStorageAllocationNeeded(dskCh, vm);
}
}