removed override

This commit is contained in:
Alex Huang 2010-08-17 10:16:16 -07:00
parent 334b2f7d27
commit a89aad4d15
12 changed files with 131 additions and 91 deletions

View File

@ -34,11 +34,12 @@ public class DiskCharacteristics {
private boolean recreatable;
private long diskOfferingId;
private Long templateId;
private long volumeId;
protected DiskCharacteristics() {
}
public DiskCharacteristics(Volume.VolumeType type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable, Long templateId) {
public DiskCharacteristics(long volumeId, Volume.VolumeType type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable, Long templateId) {
this.type = type;
this.name = name;
this.size = size;
@ -47,6 +48,7 @@ public class DiskCharacteristics {
this.recreatable = recreatable;
this.diskOfferingId = diskOfferingId;
this.templateId = templateId;
this.volumeId = volumeId;
}
/**
@ -56,6 +58,13 @@ public class DiskCharacteristics {
return size;
}
/**
* @return id of the volume backing up this disk characteristics
*/
public long getVolumeId() {
return volumeId;
}
/**
* @return Unique name for the disk.
*/

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Aug 16 11:01:21 PDT 2010
build.number=31
#Mon Aug 16 18:14:16 PDT 2010
build.number=32

View File

@ -1,19 +0,0 @@
# This is a template file for defining properties needed by build-vmops.xml.
# If you need to add properties to be used in build-vmops.xml, then you should
# add it in this file. If all you need is to change the default values,
# you should "cp build-vmops.properties.template build-vmops.properties"
# and modify the values within build-vmops.properties.
debug=true
debuglevel=vars,lines,source
tomcat.home=/home/tomcat/current
debug.jvmarg=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
deprecation=off
meld.home=/usr/bin
target.compat.version=1.6
source.compat.version=1.6
assertion=-ea
branding.name=default
build.type=developer
premium.name=premium
#manual.build.number=8

View File

@ -1,7 +0,0 @@
DBUSER=cloud
DBROOTPW=
DBPW=cloud
MSLOG=.\/dist\/vmops.log
APISERVERLOG=.\/dist\/api.log
DBHOST=localhost

View File

@ -34,12 +34,39 @@ import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.vm.VMInstanceVO;
public interface StorageManager extends Manager {
/**
* Convenience method for creating a VM with a data disk based on a template.
* @param vm VM to create disks for.
* @param template Template to based the root disk on.
* @param rootOffering Disk offering for the root disk.
* @param dataOffering Disk offering for the data disk.
* @param size size of the data disk if the data disk offering has variable size.
* @param dc data center to deploy in.
* @param account owner.
* @return List<VolumeVO> where the first disk is the root disk.
*/
List<VolumeVO> allocateTemplatedVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, DiskOfferingVO dataOffering, Long size, DataCenterVO dc, AccountVO account);
/**
* Convenience method for allocating system VMs in the database.
* @param vm VM to create disks for.
* @param template template the root disk should be based on.
* @param rootOffering Disk offering for the root disk.
* @param dc data center to deploy in.
* @return VolumeVO volume allocated.
*/
VolumeVO allocateSystemVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, DataCenterVO dc);
VolumeVO allocateIsoInstalledVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, Long size, DataCenterVO dc, AccountVO account);
/**
* Calls the storage agent and makes the volumes sharable with this host.
*

View File

@ -27,6 +27,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -39,9 +40,10 @@ import com.google.gson.annotations.Expose;
@Table(name="volumes")
public class VolumeVO implements Volume {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@TableGenerator(name="volume_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="volume_seq", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name="id")
Long id;
long id;
@Expose
@Column(name="name")
@ -176,7 +178,8 @@ public class VolumeVO implements Volume {
}
// Real Constructor
public VolumeVO(VolumeType type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size) {
public VolumeVO(long id, VolumeType type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size) {
this.id = id;
this.volumeType = type;
this.name = name;
this.dataCenterId = dcId;
@ -233,7 +236,7 @@ public class VolumeVO implements Volume {
return iscsiName;
}
public Long getId() {
public long getId() {
return id;
}
@ -310,10 +313,6 @@ public class VolumeVO implements Volume {
return volumeType;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}

View File

@ -225,11 +225,6 @@ public class StorageManagerImpl implements StorageManager {
return true;
}
protected void setDeviceId(VolumeVO vol) {
//TODO: Need to figure out what to do here.
vol.setDeviceId(1l);
}
@DB
public List<VolumeVO> allocate(DiskCharacteristics rootDisk, List<DiskCharacteristics> dataDisks, VMInstanceVO vm, DataCenterVO dc, AccountVO account) {
ArrayList<VolumeVO> vols = new ArrayList<VolumeVO>(dataDisks.size() + 1);
@ -238,7 +233,7 @@ public class StorageManagerImpl implements StorageManager {
long deviceId = 0;
Transaction txn = Transaction.currentTxn();
txn.start();
rootVol = new VolumeVO(VolumeType.ROOT, rootDisk.getName(), dc.getId(), account.getDomainId(), account.getId(), rootDisk.getDiskOfferingId(), rootDisk.getSize());
rootVol = new VolumeVO(rootDisk.getVolumeId(), VolumeType.ROOT, rootDisk.getName(), dc.getId(), account.getDomainId(), account.getId(), rootDisk.getDiskOfferingId(), rootDisk.getSize());
if (rootDisk.getTemplateId() != null) {
rootVol.setTemplateId(rootDisk.getTemplateId());
}
@ -247,10 +242,10 @@ public class StorageManagerImpl implements StorageManager {
rootVol = _volsDao.persist(rootVol);
vols.add(rootVol);
for (DiskCharacteristics dataDisk : dataDisks) {
dataVol = new VolumeVO(VolumeType.DATADISK, dataDisk.getName(), dc.getId(), account.getDomainId(), account.getId(), dataDisk.getDiskOfferingId(), dataDisk.getSize());
dataVol = new VolumeVO(dataDisk.getVolumeId(), VolumeType.DATADISK, dataDisk.getName(), dc.getId(), account.getDomainId(), account.getId(), dataDisk.getDiskOfferingId(), dataDisk.getSize());
dataVol.setDeviceId(deviceId++);
dataVol = _volsDao.persist(dataVol);
dataVol.setInstanceId(vm.getId());
dataVol = _volsDao.persist(dataVol);
vols.add(dataVol);
}
txn.commit();
@ -258,6 +253,41 @@ public class StorageManagerImpl implements StorageManager {
return vols;
}
@Override
public List<VolumeVO> allocateTemplatedVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, DiskOfferingVO diskOffering, Long size, DataCenterVO dc, AccountVO account) {
assert (template.getFormat() != ImageFormat.ISO) : "You can't create user vm based on ISO with this format";
DiskCharacteristics rootDisk = null;
List<DiskCharacteristics> dataDisks = new ArrayList<DiskCharacteristics>(diskOffering != null ? 1 : 0);
long rootId = _volsDao.getNextInSequence(Long.class, "volume_seq");
rootDisk = new DiskCharacteristics(rootId, VolumeType.ROOT, "ROOT-" + vm.getId() + " rootId", rootOffering.getId(), 0, rootOffering.getTagsArray(), rootOffering.getUseLocalStorage(), rootOffering.isRecreatable(), template.getId());
if (diskOffering != null) {
long dataId = _volsDao.getNextInSequence(Long.class, "volume_seq");
dataDisks.add(new DiskCharacteristics(dataId, VolumeType.DATADISK, "DATA-" + vm.getId() + "-" + dataId, diskOffering.getId(), size != null ? size : diskOffering.getDiskSizeInBytes(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), null));
}
return allocate(rootDisk, dataDisks, vm, dc, account);
}
@Override
public VolumeVO allocateIsoInstalledVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, Long size, DataCenterVO dc, AccountVO account) {
assert (template.getFormat() == ImageFormat.ISO) : "The template has to be ISO";
long rootId = _volsDao.getNextInSequence(Long.class, "volume_seq");
DiskCharacteristics rootDisk = new DiskCharacteristics(rootId, VolumeType.ROOT, "ROOT-" + vm.getId() + "-" + rootId, rootOffering.getId(), size != null ? size : rootOffering.getDiskSizeInBytes(), rootOffering.getTagsArray(), rootOffering.getUseLocalStorage(), rootOffering.isRecreatable(), null);
List<VolumeVO> vols = allocate(rootDisk, null, vm, dc, account);
return vols.get(0);
}
@Override
public VolumeVO allocateSystemVm(VMInstanceVO vm, VMTemplateVO template, DiskOfferingVO rootOffering, DataCenterVO dc) {
List<VolumeVO> vols = allocateTemplatedVm(vm, template, rootOffering, null, null, dc, _accountMgr.getSystemAccount());
return vols.get(0);
}
public List<VolumeVO> prepare(VMInstanceVO vm, HostVO host) {
List<VolumeVO> vols = _volsDao.findCreatedByInstance(vm.getId());
List<VolumeVO> recreateVols = new ArrayList<VolumeVO>(vols.size());
@ -427,9 +457,9 @@ public class StorageManagerImpl implements StorageManager {
}
VMTemplateHostVO ss = sss.get(0);
return new DiskCharacteristics(volume.getVolumeType(), volume.getName(), diskOffering.getId(), ss.getSize(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), Storage.ImageFormat.ISO != template.getFormat() ? template.getId() : null);
return new DiskCharacteristics(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), ss.getSize(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), Storage.ImageFormat.ISO != template.getFormat() ? template.getId() : null);
} else {
return new DiskCharacteristics(volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSizeInBytes(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), null);
return new DiskCharacteristics(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSizeInBytes(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), null);
}
}
@ -1466,7 +1496,7 @@ public class StorageManagerImpl implements StorageManager {
public VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId) throws InternalErrorException {
// Find a destination storage pool with the specified criteria
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
DiskCharacteristics dskCh = new DiskCharacteristics(volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSizeInBytes(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), null);
DiskCharacteristics dskCh = new DiskCharacteristics(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSizeInBytes(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), null);
DataCenterVO destPoolDataCenter = _dcDao.findById(destPoolDcId);
HostPodVO destPoolPod = _podDao.findById(destPoolPodId);
StoragePoolVO destPool = findStoragePool(dskCh, destPoolDataCenter, destPoolPod, destPoolClusterId, null, null, null, new HashSet<StoragePool>());

View File

@ -100,4 +100,6 @@ public interface AccountManager extends Manager {
*/
public ResourceLimitVO updateResourceLimit(Long domainId, Long accountId, ResourceType type, Long max) throws InvalidParameterValueException;
AccountVO getSystemAccount();
}

View File

@ -26,8 +26,8 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.configuration.ResourceLimitVO;
import com.cloud.configuration.ResourceCount.ResourceType;
import com.cloud.configuration.ResourceLimitVO;
import com.cloud.configuration.dao.ResourceCountDao;
import com.cloud.configuration.dao.ResourceLimitDao;
import com.cloud.domain.DomainVO;
@ -36,7 +36,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.SearchCriteria;
@ -46,49 +46,24 @@ public class AccountManagerImpl implements AccountManager {
public static final Logger s_logger = Logger.getLogger(AccountManagerImpl.class.getName());
private String _name;
private AccountDao _accountDao;
private DomainDao _domainDao;
private UserDao _userDao;
private VMTemplateDao _templateDao;
private ResourceLimitDao _resourceLimitDao;
private ResourceCountDao _resourceCountDao;
private final GlobalLock m_resourceCountLock = GlobalLock.getInternLock("resource.count");
@Inject private AccountDao _accountDao;
@Inject private DomainDao _domainDao;
@Inject private UserDao _userDao;
@Inject private VMTemplateDao _templateDao;
@Inject private ResourceLimitDao _resourceLimitDao;
@Inject private ResourceCountDao _resourceCountDao;
@Inject private final GlobalLock m_resourceCountLock = GlobalLock.getInternLock("resource.count");
AccountVO _systemAccount;
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
_name = name;
final ComponentLocator locator = ComponentLocator.getCurrentLocator();
_accountDao = locator.getDao(AccountDao.class);
if (_accountDao == null) {
throw new ConfigurationException("Unable to get the account dao.");
}
_domainDao = locator.getDao(DomainDao.class);
if (_domainDao == null) {
throw new ConfigurationException("Unable to get the domain dao.");
}
_userDao = locator.getDao(UserDao.class);
if (_userDao == null) {
throw new ConfigurationException("Unable to get the user dao.");
}
_templateDao = locator.getDao(VMTemplateDao.class);
if (_templateDao == null) {
throw new ConfigurationException("Unable to get the template dao.");
}
_resourceLimitDao = locator.getDao(ResourceLimitDao.class);
if (_resourceLimitDao == null) {
throw new ConfigurationException("Unable to get " + ResourceLimitDao.class.getName());
}
_resourceCountDao = locator.getDao(ResourceCountDao.class);
if (_resourceCountDao == null) {
throw new ConfigurationException("Unable to get " + ResourceCountDao.class.getName());
}
_systemAccount = _accountDao.findById(AccountVO.ACCOUNT_ID_SYSTEM);
if (_systemAccount == null) {
throw new ConfigurationException("Unable to find the system account using " + AccountVO.ACCOUNT_ID_SYSTEM);
}
return true;
}
@ -328,5 +303,10 @@ public class AccountManagerImpl implements AccountManager {
return _resourceLimitDao.persist(new ResourceLimitVO(domainId, accountId, type, max));
}
}
@Override
public AccountVO getSystemAccount() {
return _systemAccount;
}
}

View File

@ -19,16 +19,28 @@ package com.cloud.vm;
import java.util.List;
import javax.ejb.Local;
import com.cloud.dc.DataCenterVO;
import com.cloud.network.NetworkManager;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.StorageManager;
import com.cloud.user.AccountVO;
import com.cloud.utils.component.Inject;
@Local(value=VmManager.class)
public class MauriceMoss implements VmManager {
@Inject private StorageManager _storageMgr;
@Inject private NetworkManager _networkMgr;
@Override
public VMInstanceVO allocate(VMInstanceVO vm, ServiceOfferingVO serviceOffering, NetworkOfferingVO[] networkOfferings, DiskOfferingVO[] diskOffering) {
public VMInstanceVO allocate(VMInstanceVO vm, ServiceOfferingVO serviceOffering, List<NetworkOfferingVO> networkOfferings, List<DiskOfferingVO> diskOffering, DataCenterVO dc, AccountVO account) {
_storageMgr.allocateTemplatedVm(vm, template, rootOffering, dataOffering, size, dc, account)
return null;
}
@Override
public void create(VmCharacteristics vm, List<DiskCharacteristics> disks, List<NetworkCharacteristics> networks) {
// TODO Auto-generated method stub
@ -51,5 +63,7 @@ public class MauriceMoss implements VmManager {
public void stop() {
// TODO Auto-generated method stub
}
protected MauriceMoss() {
}
}

View File

@ -19,9 +19,11 @@ package com.cloud.vm;
import java.util.List;
import com.cloud.dc.DataCenterVO;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.user.AccountVO;
/**
* Manages allocating resources to vms.
@ -31,7 +33,9 @@ public interface VmManager {
VMInstanceVO allocate(VMInstanceVO vm,
ServiceOfferingVO serviceOffering,
NetworkOfferingVO[] networkOfferings,
DiskOfferingVO[] diskOffering);
DiskOfferingVO[] diskOffering,
DataCenterVO dc,
AccountVO account);
void create(VmCharacteristics vm, List<DiskCharacteristics> disks, List<NetworkCharacteristics> networks);

View File

@ -193,6 +193,7 @@ INSERT INTO `cloud`.`sequence` (name, value) VALUES ('vm_template_seq', 200);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('public_mac_address_seq', 1);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('private_mac_address_seq', 1);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('storage_pool_seq', 200);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('volume_seq', 1);
CREATE TABLE `cloud`.`disk_template_ref` (
`id` bigint unsigned NOT NULL auto_increment,