Skip to content

Commit be6bc2b

Browse files
author
Mike Tutkowski
committed
Changes related to Review Board comments
1 parent a3792fd commit be6bc2b

11 files changed

Lines changed: 897 additions & 861 deletions

File tree

core/src/com/cloud/agent/api/AttachVolumeAnswer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ public AttachVolumeAnswer(AttachVolumeCommand cmd, String result) {
2727
this.deviceId = null;
2828
}
2929

30+
public AttachVolumeAnswer(AttachVolumeCommand cmd, Long deviceId) {
31+
super(cmd);
32+
this.deviceId = deviceId;
33+
this.vdiUuid = "";
34+
}
35+
3036
public AttachVolumeAnswer(AttachVolumeCommand cmd, Long deviceId, String vdiUuid) {
3137
super(cmd);
3238
this.deviceId = deviceId;

core/src/com/cloud/agent/api/AttachVolumeCommand.java

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -19,71 +19,71 @@
1919
import com.cloud.storage.Storage.StoragePoolType;
2020

2121
public class AttachVolumeCommand extends Command {
22-
private boolean attach;
23-
private boolean _managed;
24-
private String vmName;
25-
private StoragePoolType pooltype;
26-
private String volumePath;
27-
private String volumeName;
28-
private Long deviceId;
29-
private String chainInfo;
30-
private String poolUuid;
31-
private String _storageHost;
32-
private int _storagePort;
33-
private String _iScsiName;
34-
private String _chapInitiatorUsername;
35-
private String _chapInitiatorPassword;
36-
private String _chapTargetUsername;
37-
private String _chapTargetPassword;
38-
private Long bytesReadRate;
39-
private Long bytesWriteRate;
40-
private Long iopsReadRate;
41-
private Long iopsWriteRate;
42-
43-
protected AttachVolumeCommand() {
44-
}
22+
private boolean attach;
23+
private boolean _managed;
24+
private String vmName;
25+
private StoragePoolType pooltype;
26+
private String volumePath;
27+
private String volumeName;
28+
private Long deviceId;
29+
private String chainInfo;
30+
private String poolUuid;
31+
private String _storageHost;
32+
private int _storagePort;
33+
private String _iScsiName;
34+
private String _chapInitiatorUsername;
35+
private String _chapInitiatorPassword;
36+
private String _chapTargetUsername;
37+
private String _chapTargetPassword;
38+
private Long bytesReadRate;
39+
private Long bytesWriteRate;
40+
private Long iopsReadRate;
41+
private Long iopsWriteRate;
42+
43+
protected AttachVolumeCommand() {
44+
}
4545

4646
public AttachVolumeCommand(boolean attach, boolean managed, String vmName,
4747
StoragePoolType pooltype, String volumePath, String volumeName,
4848
Long deviceId, String chainInfo) {
49-
this.attach = attach;
50-
this._managed = managed;
51-
this.vmName = vmName;
52-
this.pooltype = pooltype;
53-
this.volumePath = volumePath;
54-
this.volumeName = volumeName;
55-
this.deviceId = deviceId;
56-
this.chainInfo = chainInfo;
57-
}
58-
59-
@Override
49+
this.attach = attach;
50+
this._managed = managed;
51+
this.vmName = vmName;
52+
this.pooltype = pooltype;
53+
this.volumePath = volumePath;
54+
this.volumeName = volumeName;
55+
this.deviceId = deviceId;
56+
this.chainInfo = chainInfo;
57+
}
58+
59+
@Override
6060
public boolean executeInSequence() {
6161
return true;
6262
}
6363

64-
public boolean getAttach() {
65-
return attach;
66-
}
64+
public boolean getAttach() {
65+
return attach;
66+
}
6767

68-
public String getVmName() {
69-
return vmName;
70-
}
68+
public String getVmName() {
69+
return vmName;
70+
}
7171

72-
public StoragePoolType getPooltype() {
72+
public StoragePoolType getPooltype() {
7373
return pooltype;
7474
}
7575

7676
public void setPooltype(StoragePoolType pooltype) {
7777
this.pooltype = pooltype;
7878
}
7979

80-
public String getVolumePath() {
81-
return volumePath;
82-
}
80+
public String getVolumePath() {
81+
return volumePath;
82+
}
8383

84-
public String getVolumeName() {
84+
public String getVolumeName() {
8585
return volumeName;
86-
}
86+
}
8787

8888
public Long getDeviceId() {
8989
return deviceId;
@@ -109,61 +109,61 @@ public void setStorageHost(String storageHost) {
109109
_storageHost = storageHost;
110110
}
111111

112-
public String getStorageHost() {
113-
return _storageHost;
114-
}
112+
public String getStorageHost() {
113+
return _storageHost;
114+
}
115115

116-
public void setStoragePort(int storagePort) {
117-
_storagePort = storagePort;
118-
}
116+
public void setStoragePort(int storagePort) {
117+
_storagePort = storagePort;
118+
}
119119

120-
public int getStoragePort() {
121-
return _storagePort;
122-
}
120+
public int getStoragePort() {
121+
return _storagePort;
122+
}
123123

124-
public boolean isManaged() {
124+
public boolean isManaged() {
125125
return _managed;
126126
}
127127

128-
public void set_iScsiName(String iScsiName) {
129-
this._iScsiName = iScsiName;
130-
}
128+
public void set_iScsiName(String iScsiName) {
129+
this._iScsiName = iScsiName;
130+
}
131131

132-
public String get_iScsiName() {
133-
return _iScsiName;
134-
}
132+
public String get_iScsiName() {
133+
return _iScsiName;
134+
}
135135

136-
public void setChapInitiatorUsername(String chapInitiatorUsername) {
137-
_chapInitiatorUsername = chapInitiatorUsername;
138-
}
136+
public void setChapInitiatorUsername(String chapInitiatorUsername) {
137+
_chapInitiatorUsername = chapInitiatorUsername;
138+
}
139139

140-
public String getChapInitiatorUsername() {
141-
return _chapInitiatorUsername;
142-
}
140+
public String getChapInitiatorUsername() {
141+
return _chapInitiatorUsername;
142+
}
143143

144-
public void setChapInitiatorPassword(String chapInitiatorPassword) {
145-
_chapInitiatorPassword = chapInitiatorPassword;
146-
}
144+
public void setChapInitiatorPassword(String chapInitiatorPassword) {
145+
_chapInitiatorPassword = chapInitiatorPassword;
146+
}
147147

148-
public String getChapInitiatorPassword() {
149-
return _chapInitiatorPassword;
150-
}
148+
public String getChapInitiatorPassword() {
149+
return _chapInitiatorPassword;
150+
}
151151

152-
public void setChapTargetUsername(String chapTargetUsername) {
153-
_chapTargetUsername = chapTargetUsername;
154-
}
152+
public void setChapTargetUsername(String chapTargetUsername) {
153+
_chapTargetUsername = chapTargetUsername;
154+
}
155155

156-
public String getChapTargetUsername() {
157-
return _chapTargetUsername;
158-
}
156+
public String getChapTargetUsername() {
157+
return _chapTargetUsername;
158+
}
159159

160-
public void setChapTargetPassword(String chapTargetPassword) {
161-
_chapTargetPassword = chapTargetPassword;
162-
}
160+
public void setChapTargetPassword(String chapTargetPassword) {
161+
_chapTargetPassword = chapTargetPassword;
162+
}
163163

164-
public String getChapTargetPassword() {
165-
return _chapTargetPassword;
166-
}
164+
public String getChapTargetPassword() {
165+
return _chapTargetPassword;
166+
}
167167

168168
public void setBytesReadRate(Long bytesReadRate) {
169169
this.bytesReadRate = bytesReadRate;

core/test/org/apache/cloudstack/api/agent/test/AttachVolumeAnswerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class AttachVolumeAnswerTest {
3333
String results = "";
3434
AttachVolumeAnswer ava2 = new AttachVolumeAnswer(avc, results);
3535
Long deviceId = 10L;
36-
AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId, "");
36+
AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId);
3737

3838
@Test
3939
public void testGetDeviceId() {

engine/schema/src/com/cloud/storage/DiskOfferingVO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ public enum Type {
9898
private Boolean customizedIops;
9999

100100
@Column(name="min_iops")
101-
Long minIops;
101+
private Long minIops;
102102

103103
@Column(name="max_iops")
104-
Long maxIops;
104+
private Long maxIops;
105105

106106
@Column(name = "sort_key")
107107
int sortKey;

engine/schema/src/com/cloud/storage/VolumeVO.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public class VolumeVO implements Volume {
7171
Long size;
7272

7373
@Column(name = "min_iops")
74-
Long minIops;
74+
private Long minIops;
7575

7676
@Column(name = "max_iops")
77-
Long maxIops;
77+
private Long maxIops;
7878

7979
@Column(name = "folder")
8080
String folder;
@@ -155,8 +155,9 @@ public class VolumeVO implements Volume {
155155
String reservationId;
156156

157157
// Real Constructor
158-
public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size,
159-
Long minIops, Long maxIops, String iScsiName) {
158+
public VolumeVO(Type type, String name, long dcId, long domainId,
159+
long accountId, long diskOfferingId, long size,
160+
Long minIops, Long maxIops, String iScsiName) {
160161
this.volumeType = type;
161162
this.name = name;
162163
this.dataCenterId = dcId;
@@ -171,8 +172,10 @@ public VolumeVO(Type type, String name, long dcId, long domainId, long accountId
171172
this.uuid = UUID.randomUUID().toString();
172173
}
173174

174-
public VolumeVO(String name, long dcId, long podId, long accountId, long domainId, Long instanceId, String folder, String path,
175-
long size, Long minIops, Long maxIops, String iScsiName, Volume.Type vType) {
175+
public VolumeVO(String name, long dcId, long podId, long accountId,
176+
long domainId, Long instanceId, String folder, String path,
177+
long size, Long minIops, Long maxIops, String iScsiName,
178+
Volume.Type vType) {
176179
this.name = name;
177180
this.accountId = accountId;
178181
this.domainId = domainId;
@@ -191,6 +194,27 @@ public VolumeVO(String name, long dcId, long podId, long accountId, long domainI
191194
this.uuid = UUID.randomUUID().toString();
192195
}
193196

197+
public VolumeVO(String name, long dcId, long podId, long accountId,
198+
long domainId, Long instanceId, String folder, String path,
199+
long size, Volume.Type vType) {
200+
this.name = name;
201+
this.accountId = accountId;
202+
this.domainId = domainId;
203+
this.instanceId = instanceId;
204+
this.folder = folder;
205+
this.path = path;
206+
this.size = size;
207+
this.minIops = null;
208+
this.maxIops = null;
209+
this._iScsiName = null;
210+
this.podId = podId;
211+
this.dataCenterId = dcId;
212+
this.volumeType = vType;
213+
this.state = Volume.State.Allocated;
214+
this.recreatable = false;
215+
this.uuid = UUID.randomUUID().toString();
216+
}
217+
194218
// Copy Constructor
195219
public VolumeVO(Volume that) {
196220
this(that.getName(), that.getDataCenterId(), that.getPodId(), that.getAccountId(), that.getDomainId(), that.getInstanceId(),

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,7 +3972,7 @@ protected ManagedObjectReference handleDatastoreAndVmdk(AttachVolumeCommand cmd)
39723972
throw new Exception("Unable to create a dummy VM for volume creation");
39733973
}
39743974

3975-
vmMo.createDisk(volumeDatastorePath, (int)(dsMo.getSummary().getFreeSpace() / (1024L * 1024L)),
3975+
vmMo.createDisk(volumeDatastorePath, getMBsFromBytes(dsMo.getSummary().getFreeSpace()),
39763976
morDs, vmMo.getScsiDeviceControllerKey());
39773977
vmMo.detachDisk(volumeDatastorePath, false);
39783978
}
@@ -5052,7 +5052,7 @@ public synchronized CreateAnswer execute(CreateCommand cmd) {
50525052
synchronized (this) {
50535053
s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath);
50545054
VmwareHelper.deleteVolumeVmdkFiles(dsMo, vmdkName, dcMo);
5055-
vmMo.createDisk(volumeDatastorePath, (int) (dskch.getSize() / (1024L * 1024L)), morDatastore, -1);
5055+
vmMo.createDisk(volumeDatastorePath, getMBsFromBytes(dskch.getSize()), morDatastore, -1);
50565056
vmMo.detachDisk(volumeDatastorePath, false);
50575057
}
50585058

@@ -5111,7 +5111,7 @@ public synchronized CreateAnswer execute(CreateCommand cmd) {
51115111
// s_logger.info("Delete file if exists in datastore to clear the way for creating the volume. file: " + volumeDatastorePath);
51125112
VmwareHelper.deleteVolumeVmdkFiles(dsMo, volumeUuid.toString(), dcMo);
51135113

5114-
vmMo.createDisk(volumeDatastorePath, (int) (dskch.getSize() / (1024L * 1024L)), morDatastore, vmMo.getScsiDeviceControllerKey());
5114+
vmMo.createDisk(volumeDatastorePath, getMBsFromBytes(dskch.getSize()), morDatastore, vmMo.getScsiDeviceControllerKey());
51155115
vmMo.detachDisk(volumeDatastorePath, false);
51165116
}
51175117

@@ -5135,6 +5135,10 @@ public synchronized CreateAnswer execute(CreateCommand cmd) {
51355135
}
51365136
}
51375137

5138+
private static int getMBsFromBytes(long bytes) {
5139+
return (int)(bytes / (1024L * 1024L));
5140+
}
5141+
51385142
protected VirtualMachineMO prepareVolumeHostDummyVm(VmwareHypervisorHost hyperHost, DatastoreMO dsMo, String vmName) throws Exception {
51395143
assert (hyperHost != null);
51405144

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6627,7 +6627,7 @@ private long getMetadata(long physicalSize) {
66276627
}
66286628

66296629
protected VDI handleSrAndVdiAttach(String iqn, String storageHostName,
6630-
String chapInitiatorName, String chapInitiatorPassword) throws Exception {
6630+
String chapInitiatorName, String chapInitiatorPassword) throws Types.XenAPIException, XmlRpcException, CloudRuntimeException {
66316631
VDI vdi = null;
66326632

66336633
Connection conn = getConnection();
@@ -6648,7 +6648,7 @@ protected VDI handleSrAndVdiAttach(String iqn, String storageHostName,
66486648
vdir.virtualSize = sr.getPhysicalSize(conn) - sr.getPhysicalUtilisation(conn) - getMetadata(sr.getPhysicalSize(conn));
66496649

66506650
if (vdir.virtualSize < 0) {
6651-
throw new Exception("VDI virtual size cannot be less than 0.");
6651+
throw new CloudRuntimeException("VDI virtual size cannot be less than 0.");
66526652
}
66536653

66546654
vdi = VDI.create(conn, vdir);

0 commit comments

Comments
 (0)