bug 9398: removed resource_type from volumes table as we no longer use it. Corresponding db upgrade scripts are updated

status 9398: resolved fixed

Conflicts:

	server/src/com/cloud/storage/StorageManagerImpl.java
This commit is contained in:
alena 2011-04-11 18:14:35 -07:00
parent 70151389d1
commit 52bf157387
10 changed files with 993 additions and 1016 deletions

View File

@ -949,8 +949,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
disksize = dskch.getSize();
vol = _storageResource.createVolume(conn, primaryPool, UUID.randomUUID().toString(), dskch.getSize(), volFormat.QCOW2);
}
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(), getStorageResourceType(), pool.getType(),
pool.getUuid(), pool.getPath(), vol.getName(),vol.getKey(), disksize, null);
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(),
pool.getPath(), vol.getName(), vol.getKey(),disksize, null);
return new CreateAnswer(cmd, volume);
} catch (LibvirtException e) {

View File

@ -18,7 +18,6 @@
package com.cloud.agent.api.storage;
import com.cloud.agent.api.to.VolumeTO;
import com.cloud.storage.Storage;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.Volume;
@ -37,9 +36,9 @@ public class DestroyCommand extends StorageCommand {
}
public DestroyCommand(StoragePool pool, VMTemplateStorageResourceAssoc templatePoolRef) {
volume = new VolumeTO(templatePoolRef.getId(), null, Storage.StorageResourceType.STORAGE_POOL, pool.getPoolType(),
pool.getUuid(), null, pool.getPath(),
templatePoolRef.getInstallPath(), templatePoolRef.getTemplateSize(), null);
volume = new VolumeTO(templatePoolRef.getId(), null, pool.getPoolType(), pool.getUuid(),
null, pool.getPath(), templatePoolRef.getInstallPath(),
templatePoolRef.getTemplateSize(), null);
}
public VolumeTO getVolume() {

View File

@ -17,7 +17,6 @@
*/
package com.cloud.agent.api.to;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Volume;
@ -25,76 +24,66 @@ import com.cloud.storage.Volume;
public class VolumeTO {
protected VolumeTO() {
}
private long id;
private String name;
private String mountPoint;
private String path;
private long size;
private Volume.Type type;
private Storage.StorageResourceType resourceType;
private StoragePoolType storagePoolType;
private String storagePoolUuid;
private long deviceId;
private String chainInfo;
private String guestOsType;
public VolumeTO(long id, Volume.Type type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
this.id = id;
this.name= name;
this.name = name;
this.path = path;
this.size = size;
this.type = type;
this.resourceType = resourceType;
this.storagePoolType = poolType;
this.storagePoolUuid = poolUuid;
this.mountPoint = mountPoint;
this.chainInfo = chainInfo;
}
public VolumeTO(long id, Volume.Type type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
String poolUuid, String name, String mountPoint, String path, long size, String chainInfo, String guestOsType) {
this.id = id;
this.name= name;
this.path = path;
this.size = size;
this.type = type;
this.resourceType = resourceType;
this.storagePoolType = poolType;
this.storagePoolUuid = poolUuid;
this.mountPoint = mountPoint;
this.chainInfo = chainInfo;
this.guestOsType = guestOsType;
}
public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo, String guestOsType) {
this.id = id;
this.name = name;
this.path = path;
this.size = size;
this.type = type;
this.storagePoolType = poolType;
this.storagePoolUuid = poolUuid;
this.mountPoint = mountPoint;
this.chainInfo = chainInfo;
this.guestOsType = guestOsType;
}
public VolumeTO(Volume volume, StoragePool pool) {
this.id = volume.getId();
this.name = volume.getName();
this.path = volume.getPath();
this.size = volume.getSize();
this.type = volume.getVolumeType();
this.resourceType = volume.getStorageResourceType();
this.storagePoolType = pool.getPoolType();
this.storagePoolUuid = pool.getUuid();
this.mountPoint = volume.getFolder();
this.chainInfo = volume.getChainInfo();
if (volume.getDeviceId() != null)
this.deviceId = volume.getDeviceId();
this.deviceId = volume.getDeviceId();
}
public long getDeviceId() {
return deviceId;
}
public void setDeviceId(long id) {
this.deviceId = id;
this.deviceId = id;
}
public Storage.StorageResourceType getResourceType() {
return resourceType;
}
public long getId() {
return id;
}
@ -114,27 +103,27 @@ public class VolumeTO {
public String getName() {
return name;
}
public String getMountPoint() {
return mountPoint;
}
public StoragePoolType getPoolType() {
return storagePoolType;
}
public String getPoolUuid() {
return storagePoolUuid;
return storagePoolUuid;
}
public String getChainInfo() {
return chainInfo;
return chainInfo;
}
public String getOsType() {
return guestOsType;
return guestOsType;
}
@Override
public String toString() {
return new StringBuilder("Vol[").append(id).append("|").append(type).append("|").append(path).append("|").append(size).append("]").toString();

View File

@ -26,21 +26,20 @@ import com.cloud.template.BasedOn;
import com.cloud.utils.fsm.FiniteState;
import com.cloud.utils.fsm.StateMachine;
public interface Volume extends ControlledEntity, BasedOn {
enum Type {UNKNOWN, ROOT, SWAP, DATADISK, ISO};
enum State implements FiniteState<State, Event> {
Allocated("The volume is allocated but has not been created yet."),
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
Ready("The volume is ready to be used."),
Destroy("The volume is set to be destroyed but can be recovered.");
String _description;
private State(String description) {
_description = description;
}
enum Type {
UNKNOWN, ROOT, SWAP, DATADISK, ISO
};
enum State implements FiniteState<State, Event> {
Allocated("The volume is allocated but has not been created yet."), Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."), Ready(
"The volume is ready to be used."), Destroy("The volume is set to be destroyed but can be recovered.");
String _description;
private State(String description) {
_description = description;
}
@Override
public StateMachine<State, Event> getStateMachine() {
@ -61,12 +60,12 @@ public interface Volume extends ControlledEntity, BasedOn {
public Set<Event> getPossibleEvents() {
return s_fsm.getPossibleEvents(this);
}
@Override
public String getDescription() {
return _description;
}
private final static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
static {
s_fsm.addTransition(Allocated, Event.Create, Creating);
@ -78,63 +77,58 @@ public interface Volume extends ControlledEntity, BasedOn {
s_fsm.addTransition(Creating, Event.Create, Creating);
s_fsm.addTransition(Ready, Event.Destroy, Destroy);
}
}
enum Event {
Create,
OperationFailed,
OperationSucceeded,
OperationRetry,
Destroy;
}
long getId();
/**
}
enum Event {
Create, OperationFailed, OperationSucceeded, OperationRetry, Destroy;
}
long getId();
/**
* @return the volume name
*/
String getName();
/**
* @return total size of the partition
*/
long getSize();
/**
* @return the vm instance id
*/
Long getInstanceId();
/**
* @return the folder of the volume
*/
String getFolder();
/**
* @return the path created.
*/
String getPath();
Long getPodId();
long getDataCenterId();
Type getVolumeType();
Storage.StorageResourceType getStorageResourceType();
Long getPoolId();
State getState();
Date getAttached();
Long getDeviceId();
Date getCreated();
long getDiskOfferingId();
String getChainInfo();
boolean isRecreatable();
Long getPodId();
long getDataCenterId();
Type getVolumeType();
Long getPoolId();
State getState();
Date getAttached();
Long getDeviceId();
Date getCreated();
long getDiskOfferingId();
String getChainInfo();
boolean isRecreatable();
}

View File

@ -4537,8 +4537,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
vdir = vdi.getRecord(conn);
s_logger.debug("Succesfully created VDI for " + cmd + ". Uuid = " + vdir.uuid);
VolumeTO vol = new VolumeTO(cmd.getVolumeId(), dskch.getType(), Storage.StorageResourceType.STORAGE_POOL, pool.getType(), pool.getUuid(),
vdir.nameLabel, pool.getPath(), vdir.uuid, vdir.virtualSize, null);
VolumeTO vol = new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), vdir.nameLabel,
pool.getPath(), vdir.uuid, vdir.virtualSize, null);
return new CreateAnswer(cmd, vol);
} catch (Exception e) {
s_logger.warn("Unable to create volume; Pool=" + pool + "; Disk: " + dskch, e);

View File

@ -36,95 +36,91 @@ import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.GenericDao;
@Entity
@Table(name="volumes")
@Table(name = "volumes")
public class VolumeVO implements Volume {
@Id
@TableGenerator(name="volume_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="volume_seq", allocationSize=1)
@GeneratedValue(strategy=GenerationType.TABLE)
@Column(name="id")
@TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "id")
long id;
@Column(name="name")
@Column(name = "name")
String name;
@Column(name="pool_id")
@Column(name = "pool_id")
Long poolId;
@Column(name="account_id")
@Column(name = "account_id")
long accountId;
@Column(name="domain_id")
@Column(name = "domain_id")
long domainId;
@Column(name="instance_id")
@Column(name = "instance_id")
Long instanceId = null;
@Column(name="device_id")
@Column(name = "device_id")
Long deviceId = null;
@Column(name="size")
@Column(name = "size")
long size;
@Column(name="folder")
@Column(name = "folder")
String folder;
@Column(name="path")
@Column(name = "path")
String path;
@Column(name="pod_id")
@Column(name = "pod_id")
Long podId;
@Column(name="created")
@Column(name = "created")
Date created;
@Column(name="attached")
@Temporal(value=TemporalType.TIMESTAMP)
@Column(name = "attached")
@Temporal(value = TemporalType.TIMESTAMP)
Date attached;
@Column(name="data_center_id")
@Column(name = "data_center_id")
long dataCenterId;
@Column(name="host_ip")
@Column(name = "host_ip")
String hostip;
@Column(name="disk_offering_id")
@Column(name = "disk_offering_id")
long diskOfferingId;
@Column(name="template_id")
@Column(name = "template_id")
Long templateId;
@Column(name="first_snapshot_backup_uuid")
@Column(name = "first_snapshot_backup_uuid")
String firstSnapshotBackupUuid;
@Column(name="volume_type")
@Column(name = "volume_type")
@Enumerated(EnumType.STRING)
Type volumeType = Volume.Type.UNKNOWN;
Type volumeType = Volume.Type.UNKNOWN;
@Column(name="pool_type")
@Column(name = "pool_type")
@Enumerated(EnumType.STRING)
StoragePoolType poolType;
@Column(name=GenericDao.REMOVED_COLUMN)
@Column(name = GenericDao.REMOVED_COLUMN)
Date removed;
@Column(name="resource_type")
@Enumerated(EnumType.STRING)
Storage.StorageResourceType storageResourceType;
@Column(name="updated")
@Temporal(value=TemporalType.TIMESTAMP)
@Column(name = "updated")
@Temporal(value = TemporalType.TIMESTAMP)
Date updated;
@Column(name="recreatable")
@Column(name = "recreatable")
boolean recreatable;
@Column(name="state")
@Enumerated(value=EnumType.STRING)
@Column(name = "state")
@Enumerated(value = EnumType.STRING)
private State state;
@Column(name="chain_info")
@Column(name = "chain_info")
String chainInfo;
// Real Constructor
public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size) {
this.volumeType = type;
@ -153,33 +149,33 @@ public class VolumeVO implements Volume {
// Copy Constructor
public VolumeVO(Volume that) {
this(that.getName(), that.getDataCenterId(), that.getPodId(), that.getAccountId(), that.getDomainId(), that.getInstanceId(), that.getFolder(), that.getPath(), that.getSize(), that.getVolumeType());
this(that.getName(), that.getDataCenterId(), that.getPodId(), that.getAccountId(), that.getDomainId(), that.getInstanceId(), that.getFolder(), that.getPath(), that.getSize(), that
.getVolumeType());
this.recreatable = that.isRecreatable();
this.state = that.getState();
this.size = that.getSize();
this.diskOfferingId = that.getDiskOfferingId();
this.poolId = that.getPoolId();
this.storageResourceType = that.getStorageResourceType();
this.attached = that.getAttached();
this.chainInfo = that.getChainInfo();
this.templateId = that.getTemplateId();
this.deviceId = that.getDeviceId();
}
@Override
public boolean isRecreatable() {
return recreatable;
}
public void setRecreatable(boolean recreatable) {
this.recreatable = recreatable;
}
@Override
@Override
public long getId() {
return id;
}
}
@Override
public Long getPodId() {
return podId;
@ -189,21 +185,21 @@ public class VolumeVO implements Volume {
public long getDataCenterId() {
return dataCenterId;
}
@Override
public String getName() {
return name;
}
@Override
public long getAccountId() {
return accountId;
}
public void setPoolType(StoragePoolType poolType) {
this.poolType = poolType;
}
public StoragePoolType getPoolType() {
return poolType;
}
@ -212,35 +208,35 @@ public class VolumeVO implements Volume {
public long getDomainId() {
return domainId;
}
@Override
public String getFolder() {
return folder;
return folder;
}
@Override
public String getPath() {
return path;
}
protected VolumeVO() {
}
@Override
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
this.size = size;
}
@Override
public Long getInstanceId() {
return instanceId;
return instanceId;
}
@Override
@Override
public Long getDeviceId() {
return deviceId;
}
@ -250,121 +246,112 @@ public class VolumeVO implements Volume {
}
@Override
public Type getVolumeType() {
return volumeType;
}
public void setName(String name) {
this.name = name;
}
public void setFolder(String folder) {
this.folder = folder;
}
public Type getVolumeType() {
return volumeType;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
public void setName(String name) {
this.name = name;
}
public void setFolder(String folder) {
this.folder = folder;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
public void setDomainId(long domainId) {
this.domainId = domainId;
}
public void setInstanceId(Long instanceId) {
this.instanceId = instanceId;
}
public void setPath(String path) {
this.path = path;
}
public void setInstanceId(Long instanceId) {
this.instanceId = instanceId;
}
public String getHostIp() {
return hostip;
}
public void setPath(String path) {
this.path = path;
}
public void setHostIp(String hostip) {
this.hostip = hostip;
}
public String getHostIp() {
return hostip;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public void setHostIp(String hostip) {
this.hostip = hostip;
}
public void setDataCenterId(long dataCenterId) {
this.dataCenterId = dataCenterId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public void setVolumeType(Type type) {
volumeType = type;
}
@Override
public void setDataCenterId(long dataCenterId) {
this.dataCenterId = dataCenterId;
}
public void setVolumeType(Type type) {
volumeType = type;
}
@Override
public Date getCreated() {
return created;
}
public Date getRemoved() {
return removed;
}
public void setRemoved(Date removed) {
this.removed = removed;
}
return created;
}
@Override
public Date getRemoved() {
return removed;
}
public void setRemoved(Date removed) {
this.removed = removed;
}
@Override
public long getDiskOfferingId() {
return diskOfferingId;
}
return diskOfferingId;
}
public void setDiskOfferingId(long diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
public void setDiskOfferingId(long diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
@Override
@Override
public Long getTemplateId() {
return templateId;
}
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public String getFirstSnapshotBackupUuid() {
return firstSnapshotBackupUuid;
}
public void setFirstSnapshotBackupUuid(String firstSnapshotBackupUuid) {
this.firstSnapshotBackupUuid = firstSnapshotBackupUuid;
}
@Override
public Storage.StorageResourceType getStorageResourceType() {
return storageResourceType;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public void setStorageResourceType(Storage.StorageResourceType storageResourceType2) {
this.storageResourceType = storageResourceType2;
}
public String getFirstSnapshotBackupUuid() {
return firstSnapshotBackupUuid;
}
@Override
public void setFirstSnapshotBackupUuid(String firstSnapshotBackupUuid) {
this.firstSnapshotBackupUuid = firstSnapshotBackupUuid;
}
@Override
public Long getPoolId() {
return poolId;
}
public void setPoolId(Long poolId) {
this.poolId = poolId;
}
public Date getUpdated() {
return poolId;
}
public void setPoolId(Long poolId) {
this.poolId = poolId;
}
public Date getUpdated() {
return updated;
}
@Override
@Override
public State getState() {
return state;
}
public void setState(State state) {
return state;
}
public void setState(State state) {
this.state = state;
}
@ -372,40 +359,40 @@ public class VolumeVO implements Volume {
this.updated = updated;
}
@Override
@Override
public String toString() {
return new StringBuilder("Vol[").append(id).append("|vm=").append(instanceId).append("|").append(volumeType).append("]").toString();
}
return new StringBuilder("Vol[").append(id).append("|vm=").append(instanceId).append("|").append(volumeType).append("]").toString();
}
@Override
public Date getAttached(){
return this.attached;
}
public void setAttached(Date attached){
this.attached = attached;
}
@Override
public String getChainInfo() {
return this.chainInfo;
}
public void setChainInfo(String chainInfo) {
this.chainInfo = chainInfo;
}
@Override
@Override
public Date getAttached() {
return this.attached;
}
public void setAttached(Date attached) {
this.attached = attached;
}
@Override
public String getChainInfo() {
return this.chainInfo;
}
public void setChainInfo(String chainInfo) {
this.chainInfo = chainInfo;
}
@Override
public int hashCode() {
return NumbersUtil.hash(id);
}
@Override
return NumbersUtil.hash(id);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof VolumeVO) {
return id == ((VolumeVO)obj).id;
} else {
return false;
}
}
if (obj instanceof VolumeVO) {
return id == ((VolumeVO) obj).id;
} else {
return false;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -139,7 +139,6 @@ import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.StorageResourceType;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolStatus;
@ -2436,15 +2435,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
if (guestOS != null) {
displayName = guestOS.getDisplayName();
}
VolumeTO iso = new VolumeTO(profile.getId(), Volume.Type.ISO, StorageResourceType.STORAGE_POOL, StoragePoolType.ISO, null, template.getName(), null, isoPath,
0, null, displayName);
VolumeTO iso = new VolumeTO(profile.getId(), Volume.Type.ISO, StoragePoolType.ISO, null, template.getName(), null, isoPath, 0,
null, displayName);
iso.setDeviceId(3);
profile.addDisk(iso);
} else {
/*create a iso placeholder*/
VolumeTO iso = new VolumeTO(profile.getId(), Volume.Type.ISO, StorageResourceType.STORAGE_POOL, StoragePoolType.ISO, null, template.getName(), null, null,
0, null);
VolumeTO iso = new VolumeTO(profile.getId(), Volume.Type.ISO, StoragePoolType.ISO, null, template.getName(), null, null, 0,
null);
iso.setDeviceId(3);
profile.addDisk(iso);
}

View File

@ -380,7 +380,6 @@ CREATE TABLE `cloud`.`volumes` (
`iscsi_name` varchar(255) COMMENT 'iscsi target name',
`host_ip` char(40) COMMENT 'host ip address for convenience',
`volume_type` varchar(64) NOT NULL COMMENT 'root, swap or data',
`resource_type` varchar(64) COMMENT 'pool-based or host-based',
`pool_type` varchar(64) COMMENT 'type of the pool',
`disk_offering_id` bigint unsigned NOT NULL COMMENT 'can be null for system VMs',
`template_id` bigint unsigned COMMENT 'fk to vm_template.id',

View File

@ -6,6 +6,7 @@ ALTER TABLE `cloud`.`host_pod_ref` DROP COLUMN `enabled`;
DELETE FROM `cloud`.`configuration` WHERE name in ('direct.attach.security.groups.enabled', 'direct.attach.untagged.vlan.enabled', 'hypervisor.type', 'management-server', 'max.volume.size.gb', 'multicast.throttling.rate', 'network.type', 'xen.preallocated.lun.size.range');
ALTER TABLE `cloud`.`volumes` DROP COLUMN `status`;
ALTER TABLE `cloud`.`volumes` DROP COLUMN `resource_type`;
ALTER TABLE `cloud`.`user_vm` DROP COLUMN guest_ip_address;
ALTER TABLE `cloud`.`user_vm` DROP COLUMN guest_mac_address;