forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiskProfile.java
More file actions
260 lines (215 loc) · 6.97 KB
/
DiskProfile.java
File metadata and controls
260 lines (215 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.vm;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.offering.DiskOffering;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Volume;
/**
* DiskProfile describes a disk and what functionality is required from it.
* and resources to allocate and create disks. There object is immutable once
*/
public class DiskProfile {
private long size;
private String[] tags;
private Volume.Type type;
private String name;
private boolean useLocalStorage;
private boolean recreatable;
private long diskOfferingId;
private Long templateId;
private long volumeId;
private String path;
private ProvisioningType provisioningType;
private Long bytesReadRate;
private Long bytesWriteRate;
private Long iopsReadRate;
private Long iopsWriteRate;
private String cacheMode;
private Long minIops;
private Long maxIops;
private boolean requiresEncryption;
private HypervisorType hyperType;
protected DiskProfile() {
}
public DiskProfile(long volumeId, Volume.Type type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable,
Long templateId) {
this.type = type;
this.name = name;
this.size = size;
this.tags = tags;
this.useLocalStorage = useLocalStorage;
this.recreatable = recreatable;
this.diskOfferingId = diskOfferingId;
this.templateId = templateId;
this.volumeId = volumeId;
}
public DiskProfile(long volumeId, Volume.Type type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable,
Long templateId, boolean requiresEncryption) {
this(volumeId, type, name, diskOfferingId, size, tags, useLocalStorage, recreatable, templateId);
this.requiresEncryption = requiresEncryption;
}
public DiskProfile(Volume vol, DiskOffering offering, HypervisorType hyperType) {
this(vol.getId(),
vol.getVolumeType(),
vol.getName(),
offering.getId(),
vol.getSize(),
offering.getTagsArray(),
offering.isUseLocalStorage(),
offering.isCustomized(),
null);
this.hyperType = hyperType;
this.provisioningType = offering.getProvisioningType();
this.requiresEncryption = offering.getEncrypt() || vol.getPassphraseId() != null;
}
public DiskProfile(DiskProfile dp) {
}
/**
* @return size of the disk requested in bytes.
*/
public long getSize() {
return size;
}
/**
* @return id of the volume backing up this disk characteristics
*/
public long getVolumeId() {
return volumeId;
}
/**
* @return Unique name for the disk.
*/
public String getName() {
return name;
}
public void setTags(String[] tags) {
this.tags = tags;
}
/**
* @return tags for the disk. This can be used to match it to different storage pools.
*/
public String[] getTags() {
return tags;
}
/**
* @return type of volume.
*/
public Volume.Type getType() {
return type;
}
/**
* @return Does this volume require local storage?
*/
public boolean useLocalStorage() {
return useLocalStorage;
}
public void setUseLocalStorage(boolean useLocalStorage) {
this.useLocalStorage = useLocalStorage;
}
/**
* @return Is this volume recreatable? A volume is recreatable if the disk's content can be
* reconstructed from the template.
*/
public boolean isRecreatable() {
return recreatable;
}
/**
* @return template id the disk is based on. Can be null if it is not based on any templates.
*/
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
/**
* @return disk offering id that the disk is based on.
*/
public long getDiskOfferingId() {
return diskOfferingId;
}
@Override
public String toString() {
return new StringBuilder("DskChr[").append(type).append("|").append(size).append("|").append("]").toString();
}
public void setHyperType(HypervisorType hyperType) {
this.hyperType = hyperType;
}
public HypervisorType getHypervisorType() {
return this.hyperType;
}
public void setPath(String path) {
this.path = path;
}
public String getPath() {
return this.path;
}
public void setProvisioningType(ProvisioningType provisioningType){
this.provisioningType = provisioningType;
}
public ProvisioningType getProvisioningType(){
return this.provisioningType;
}
public void setSize(long size) {
this.size = size;
}
public void setBytesReadRate(Long bytesReadRate) {
this.bytesReadRate = bytesReadRate;
}
public Long getBytesReadRate() {
return bytesReadRate;
}
public void setBytesWriteRate(Long bytesWriteRate) {
this.bytesWriteRate = bytesWriteRate;
}
public Long getBytesWriteRate() {
return bytesWriteRate;
}
public void setIopsReadRate(Long iopsReadRate) {
this.iopsReadRate = iopsReadRate;
}
public Long getIopsReadRate() {
return iopsReadRate;
}
public void setIopsWriteRate(Long iopsWriteRate) {
this.iopsWriteRate = iopsWriteRate;
}
public Long getIopsWriteRate() {
return iopsWriteRate;
}
public void setCacheMode(String cacheMode) {
this.cacheMode = cacheMode;
}
public String getCacheMode() {
return cacheMode;
}
public Long getMinIops() {
return minIops;
}
public void setMinIops(Long minIops) {
this.minIops = minIops;
}
public Long getMaxIops() {
return maxIops;
}
public void setMaxIops(Long maxIops) {
this.maxIops = maxIops;
}
public boolean requiresEncryption() { return requiresEncryption; }
public void setEncryption(boolean encrypt) { this.requiresEncryption = encrypt; }
}