forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorageManager.java
More file actions
executable file
·240 lines (192 loc) · 8.88 KB
/
StorageManager.java
File metadata and controls
executable file
·240 lines (192 loc) · 8.88 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
// 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.storage;
import java.util.List;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.manager.Commands;
import com.cloud.capacity.CapacityVO;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Volume.Event;
import com.cloud.storage.Volume.Type;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager;
import com.cloud.utils.fsm.NoTransitionException;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
public interface StorageManager extends StorageService, Manager {
boolean canVmRestartOnAnotherServer(long vmId);
/** Returns the absolute path of the specified ISO
* @param templateId - the ID of the template that represents the ISO
* @param datacenterId
* @return absolute ISO path
*/
public Pair<String, String> getAbsoluteIsoPath(long templateId, long dataCenterId);
/**
* Returns the URL of the secondary storage host
* @param zoneId
* @return URL
*/
public String getSecondaryStorageURL(long zoneId);
/**
* Returns a comma separated list of tags for the specified storage pool
* @param poolId
* @return comma separated list of tags
*/
public String getStoragePoolTags(long poolId);
/**
* Returns the secondary storage host
* @param zoneId
* @return secondary storage host
*/
public HostVO getSecondaryStorageHost(long zoneId);
/**
* Returns the secondary storage host
* @param zoneId
* @return secondary storage host
*/
public VMTemplateHostVO findVmTemplateHost(long templateId, StoragePool pool);
/**
* Moves a volume from its current storage pool to a storage pool with enough capacity in the specified zone, pod, or cluster
* @param volume
* @param destPoolDcId
* @param destPoolPodId
* @param destPoolClusterId
* @return VolumeVO
* @throws ConcurrentOperationException
*/
VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException;
/**
* Create a volume based on the given criteria
* @param volume
* @param vm
* @param template
* @param dc
* @param pod
* @param clusterId
* @param offering
* @param diskOffering
* @param avoids
* @param size
* @param hyperType
* @return volume VO if success, null otherwise
*/
VolumeVO createVolume(VolumeVO volume, VMInstanceVO vm, VMTemplateVO template, DataCenterVO dc, HostPodVO pod, Long clusterId,
ServiceOfferingVO offering, DiskOfferingVO diskOffering, List<StoragePoolVO> avoids, long size, HypervisorType hyperType);
/**
* Marks the specified volume as destroyed in the management server database. The expunge thread will delete the volume from its storage pool.
* @param volume
* @return
*/
boolean destroyVolume(VolumeVO volume) throws ConcurrentOperationException;
/** Create capacity entries in the op capacity table
* @param storagePool
*/
public void createCapacityEntry(StoragePoolVO storagePool);
/**
* Checks that the volume is stored on a shared storage pool
* @param volume
* @return true if the volume is on a shared storage pool, false otherwise
*/
boolean volumeOnSharedStoragePool(VolumeVO volume);
Answer sendToPool(long poolId, Command cmd) throws StorageUnavailableException;
Answer sendToPool(StoragePool pool, Command cmd) throws StorageUnavailableException;
Answer[] sendToPool(long poolId, Commands cmd) throws StorageUnavailableException;
Answer[] sendToPool(StoragePool pool, Commands cmds) throws StorageUnavailableException;
Pair<Long, Answer[]> sendToPool(StoragePool pool, long[] hostIdsToTryFirst, List<Long> hostIdsToAvoid, Commands cmds) throws StorageUnavailableException;
Pair<Long, Answer> sendToPool(StoragePool pool, long[] hostIdsToTryFirst, List<Long> hostIdsToAvoid, Command cmd) throws StorageUnavailableException;
/**
* Checks that one of the following is true:
* 1. The volume is not attached to any VM
* 2. The volume is attached to a VM that is running on a host with the KVM hypervisor, and the VM is stopped
* 3. The volume is attached to a VM that is running on a host with the XenServer hypervisor (the VM can be stopped or running)
* @return true if one of the above conditions is true
*/
boolean volumeInactive(VolumeVO volume);
String getVmNameOnVolume(VolumeVO volume);
/**
* Checks if a host has running VMs that are using its local storage pool.
* @return true if local storage is active on the host
*/
boolean isLocalStorageActiveOnHost(Host host);
/**
* Cleans up storage pools by removing unused templates.
* @param recurring - true if this cleanup is part of a recurring garbage collection thread
*/
void cleanupStorage(boolean recurring);
String getPrimaryStorageNameLabel(VolumeVO volume);
/**
* Allocates one volume.
* @param <T>
* @param type
* @param offering
* @param name
* @param size
* @param template
* @param vm
* @param account
* @return VolumeVO a persisted volume.
*/
<T extends VMInstanceVO> DiskProfile allocateRawVolume(Type type, String name, DiskOfferingVO offering, Long size, T vm, Account owner);
<T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(Type type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, Account owner);
void createCapacityEntry(StoragePoolVO storagePool, short capacityType, long allocated);
void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException;
void release(VirtualMachineProfile<? extends VMInstanceVO> profile);
void cleanupVolumes(long vmId) throws ConcurrentOperationException;
void prepareForMigration(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest);
Answer sendToPool(StoragePool pool, long[] hostIdsToTryFirst, Command cmd) throws StorageUnavailableException;
CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId);
CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId);
boolean createStoragePool(long hostId, StoragePoolVO pool);
boolean delPoolFromHost(long hostId);
HostVO getSecondaryStorageHost(long zoneId, long tmpltId);
List<HostVO> getSecondaryStorageHosts(long zoneId);
List<StoragePoolVO> ListByDataCenterHypervisor(long datacenterId, HypervisorType type);
List<VMInstanceVO> listByStoragePool(long storagePoolId);
StoragePoolVO findLocalStorageOnHost(long hostId);
VMTemplateHostVO getTemplateHostRef(long zoneId, long tmpltId, boolean readyOnly);
boolean StorageMigration(
VirtualMachineProfile<? extends VirtualMachine> vm,
StoragePool destPool) throws ConcurrentOperationException;
boolean stateTransitTo(Volume vol, Event event)
throws NoTransitionException;
VolumeVO allocateDuplicateVolume(VolumeVO oldVol, Long templateId);
Host updateSecondaryStorage(long secStorageId, String newUrl);
List<Long> getUpHostsInPool(long poolId);
void cleanupSecondaryStorage(boolean recurring);
VolumeVO copyVolumeFromSecToPrimary(VolumeVO volume, VMInstanceVO vm,
VMTemplateVO template, DataCenterVO dc, HostPodVO pod,
Long clusterId, ServiceOfferingVO offering,
DiskOfferingVO diskOffering, List<StoragePoolVO> avoids, long size,
HypervisorType hyperType) throws NoTransitionException;
String getSupportedImageFormatForCluster(Long clusterId);
HypervisorType getHypervisorTypeFromFormat(ImageFormat format);
boolean storagePoolHasEnoughSpace(List<Volume> volume, StoragePool pool);
}