Skip to content

Commit 52bf157

Browse files
committed
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
1 parent 7015138 commit 52bf157

10 files changed

Lines changed: 1004 additions & 1027 deletions

File tree

agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,8 @@ protected Answer execute(CreateCommand cmd) {
949949
disksize = dskch.getSize();
950950
vol = _storageResource.createVolume(conn, primaryPool, UUID.randomUUID().toString(), dskch.getSize(), volFormat.QCOW2);
951951
}
952-
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(), getStorageResourceType(), pool.getType(),
953-
pool.getUuid(), pool.getPath(), vol.getName(),vol.getKey(), disksize, null);
952+
VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(),
953+
pool.getPath(), vol.getName(), vol.getKey(),disksize, null);
954954
return new CreateAnswer(cmd, volume);
955955
} catch (LibvirtException e) {
956956

api/src/com/cloud/agent/api/storage/DestroyCommand.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.cloud.agent.api.storage;
1919

2020
import com.cloud.agent.api.to.VolumeTO;
21-
import com.cloud.storage.Storage;
2221
import com.cloud.storage.StoragePool;
2322
import com.cloud.storage.VMTemplateStorageResourceAssoc;
2423
import com.cloud.storage.Volume;
@@ -37,9 +36,9 @@ public DestroyCommand(StoragePool pool, Volume volume, String vmName) {
3736
}
3837

3938
public DestroyCommand(StoragePool pool, VMTemplateStorageResourceAssoc templatePoolRef) {
40-
volume = new VolumeTO(templatePoolRef.getId(), null, Storage.StorageResourceType.STORAGE_POOL, pool.getPoolType(),
41-
pool.getUuid(), null, pool.getPath(),
42-
templatePoolRef.getInstallPath(), templatePoolRef.getTemplateSize(), null);
39+
volume = new VolumeTO(templatePoolRef.getId(), null, pool.getPoolType(), pool.getUuid(),
40+
null, pool.getPath(), templatePoolRef.getInstallPath(),
41+
templatePoolRef.getTemplateSize(), null);
4342
}
4443

4544
public VolumeTO getVolume() {

api/src/com/cloud/agent/api/to/VolumeTO.java

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,84 +17,73 @@
1717
*/
1818
package com.cloud.agent.api.to;
1919

20-
import com.cloud.storage.Storage;
2120
import com.cloud.storage.Storage.StoragePoolType;
2221
import com.cloud.storage.StoragePool;
2322
import com.cloud.storage.Volume;
2423

2524
public class VolumeTO {
2625
protected VolumeTO() {
2726
}
28-
27+
2928
private long id;
3029
private String name;
3130
private String mountPoint;
3231
private String path;
3332
private long size;
3433
private Volume.Type type;
35-
private Storage.StorageResourceType resourceType;
3634
private StoragePoolType storagePoolType;
3735
private String storagePoolUuid;
3836
private long deviceId;
3937
private String chainInfo;
4038
private String guestOsType;
41-
42-
public VolumeTO(long id, Volume.Type type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
43-
String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
39+
40+
public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
41+
this.id = id;
42+
this.name = name;
43+
this.path = path;
44+
this.size = size;
45+
this.type = type;
46+
this.storagePoolType = poolType;
47+
this.storagePoolUuid = poolUuid;
48+
this.mountPoint = mountPoint;
49+
this.chainInfo = chainInfo;
50+
}
51+
52+
public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo, String guestOsType) {
4453
this.id = id;
45-
this.name= name;
54+
this.name = name;
4655
this.path = path;
4756
this.size = size;
4857
this.type = type;
49-
this.resourceType = resourceType;
5058
this.storagePoolType = poolType;
5159
this.storagePoolUuid = poolUuid;
5260
this.mountPoint = mountPoint;
5361
this.chainInfo = chainInfo;
62+
this.guestOsType = guestOsType;
5463
}
55-
56-
public VolumeTO(long id, Volume.Type type, Storage.StorageResourceType resourceType, StoragePoolType poolType,
57-
String poolUuid, String name, String mountPoint, String path, long size, String chainInfo, String guestOsType) {
58-
this.id = id;
59-
this.name= name;
60-
this.path = path;
61-
this.size = size;
62-
this.type = type;
63-
this.resourceType = resourceType;
64-
this.storagePoolType = poolType;
65-
this.storagePoolUuid = poolUuid;
66-
this.mountPoint = mountPoint;
67-
this.chainInfo = chainInfo;
68-
this.guestOsType = guestOsType;
69-
}
70-
64+
7165
public VolumeTO(Volume volume, StoragePool pool) {
7266
this.id = volume.getId();
7367
this.name = volume.getName();
7468
this.path = volume.getPath();
7569
this.size = volume.getSize();
7670
this.type = volume.getVolumeType();
77-
this.resourceType = volume.getStorageResourceType();
7871
this.storagePoolType = pool.getPoolType();
7972
this.storagePoolUuid = pool.getUuid();
8073
this.mountPoint = volume.getFolder();
8174
this.chainInfo = volume.getChainInfo();
8275
if (volume.getDeviceId() != null)
83-
this.deviceId = volume.getDeviceId();
76+
this.deviceId = volume.getDeviceId();
8477
}
85-
78+
8679
public long getDeviceId() {
8780
return deviceId;
8881
}
89-
82+
9083
public void setDeviceId(long id) {
91-
this.deviceId = id;
84+
this.deviceId = id;
9285
}
9386

94-
public Storage.StorageResourceType getResourceType() {
95-
return resourceType;
96-
}
97-
9887
public long getId() {
9988
return id;
10089
}
@@ -114,27 +103,27 @@ public Volume.Type getType() {
114103
public String getName() {
115104
return name;
116105
}
117-
106+
118107
public String getMountPoint() {
119108
return mountPoint;
120109
}
121-
110+
122111
public StoragePoolType getPoolType() {
123112
return storagePoolType;
124113
}
125-
114+
126115
public String getPoolUuid() {
127-
return storagePoolUuid;
116+
return storagePoolUuid;
128117
}
129-
118+
130119
public String getChainInfo() {
131-
return chainInfo;
120+
return chainInfo;
132121
}
133-
122+
134123
public String getOsType() {
135-
return guestOsType;
124+
return guestOsType;
136125
}
137-
126+
138127
@Override
139128
public String toString() {
140129
return new StringBuilder("Vol[").append(id).append("|").append(type).append("|").append(path).append("|").append(size).append("]").toString();

api/src/com/cloud/storage/Volume.java

Lines changed: 47 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@
2626
import com.cloud.utils.fsm.FiniteState;
2727
import com.cloud.utils.fsm.StateMachine;
2828

29-
3029
public interface Volume extends ControlledEntity, BasedOn {
31-
enum Type {UNKNOWN, ROOT, SWAP, DATADISK, ISO};
32-
33-
enum State implements FiniteState<State, Event> {
34-
Allocated("The volume is allocated but has not been created yet."),
35-
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
36-
Ready("The volume is ready to be used."),
37-
Destroy("The volume is set to be destroyed but can be recovered.");
38-
39-
String _description;
40-
41-
private State(String description) {
42-
_description = description;
43-
}
30+
enum Type {
31+
UNKNOWN, ROOT, SWAP, DATADISK, ISO
32+
};
33+
34+
enum State implements FiniteState<State, Event> {
35+
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(
36+
"The volume is ready to be used."), Destroy("The volume is set to be destroyed but can be recovered.");
37+
38+
String _description;
39+
40+
private State(String description) {
41+
_description = description;
42+
}
4443

4544
@Override
4645
public StateMachine<State, Event> getStateMachine() {
@@ -61,12 +60,12 @@ public List<State> getFromStates(Event event) {
6160
public Set<Event> getPossibleEvents() {
6261
return s_fsm.getPossibleEvents(this);
6362
}
64-
63+
6564
@Override
6665
public String getDescription() {
6766
return _description;
6867
}
69-
68+
7069
private final static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
7170
static {
7271
s_fsm.addTransition(Allocated, Event.Create, Creating);
@@ -78,63 +77,58 @@ public String getDescription() {
7877
s_fsm.addTransition(Creating, Event.Create, Creating);
7978
s_fsm.addTransition(Ready, Event.Destroy, Destroy);
8079
}
81-
}
82-
83-
enum Event {
84-
Create,
85-
OperationFailed,
86-
OperationSucceeded,
87-
OperationRetry,
88-
Destroy;
89-
}
90-
91-
long getId();
92-
/**
80+
}
81+
82+
enum Event {
83+
Create, OperationFailed, OperationSucceeded, OperationRetry, Destroy;
84+
}
85+
86+
long getId();
87+
88+
/**
9389
* @return the volume name
9490
*/
9591
String getName();
96-
92+
9793
/**
9894
* @return total size of the partition
9995
*/
10096
long getSize();
101-
97+
10298
/**
10399
* @return the vm instance id
104100
*/
105101
Long getInstanceId();
106-
102+
107103
/**
108104
* @return the folder of the volume
109105
*/
110106
String getFolder();
111-
107+
112108
/**
113109
* @return the path created.
114110
*/
115111
String getPath();
116-
112+
117113
Long getPodId();
118-
114+
119115
long getDataCenterId();
120-
116+
121117
Type getVolumeType();
122-
123-
Storage.StorageResourceType getStorageResourceType();
124-
125-
Long getPoolId();
126-
127-
State getState();
128-
129-
Date getAttached();
130-
131-
Long getDeviceId();
132-
133-
Date getCreated();
134-
135-
long getDiskOfferingId();
136-
137-
String getChainInfo();
138-
139-
boolean isRecreatable();
118+
119+
Long getPoolId();
120+
121+
State getState();
122+
123+
Date getAttached();
124+
125+
Long getDeviceId();
126+
127+
Date getCreated();
128+
129+
long getDiskOfferingId();
130+
131+
String getChainInfo();
132+
133+
boolean isRecreatable();
140134
}

core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,8 +4537,8 @@ public CreateAnswer execute(CreateCommand cmd) {
45374537
vdir = vdi.getRecord(conn);
45384538
s_logger.debug("Succesfully created VDI for " + cmd + ". Uuid = " + vdir.uuid);
45394539

4540-
VolumeTO vol = new VolumeTO(cmd.getVolumeId(), dskch.getType(), Storage.StorageResourceType.STORAGE_POOL, pool.getType(), pool.getUuid(),
4541-
vdir.nameLabel, pool.getPath(), vdir.uuid, vdir.virtualSize, null);
4540+
VolumeTO vol = new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), vdir.nameLabel,
4541+
pool.getPath(), vdir.uuid, vdir.virtualSize, null);
45424542
return new CreateAnswer(cmd, vol);
45434543
} catch (Exception e) {
45444544
s_logger.warn("Unable to create volume; Pool=" + pool + "; Disk: " + dskch, e);

0 commit comments

Comments
 (0)