FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cloudstack/api/src/com/cloud/vm/UserVmService.java at vmsync · kwanggithub/cloudstack · GitHub
This repository was archived by the owner on Jan 15, 2020. It is now read-only.
kwanggithub
/
cloudstack
Public archive
forked from
apache/cloudstack
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cloudstack
/
api
/
src
/
com
/
cloud
/
vm
/
UserVmService.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
467 lines (430 loc) · 22 KB
Breadcrumbs
cloudstack
/
api
/
src
/
com
/
cloud
/
vm
/
UserVmService.java
Copy path
File metadata and controls
executable file
·
467 lines (430 loc) · 22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
// 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
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
javax
.
naming
.
InsufficientResourcesException
;
import
org
.
apache
.
cloudstack
.
api
.
BaseCmd
.
HTTPMethod
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
admin
.
vm
.
AssignVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
admin
.
vm
.
RecoverVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
AddNicToVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
DeployVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
DestroyVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
RebootVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
RemoveNicFromVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
ResetVMPasswordCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
ResetVMSSHKeyCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
RestoreVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
ScaleVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
StartVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
UpdateDefaultNicForVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
UpdateVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vm
.
UpgradeVMCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vmgroup
.
CreateVMGroupCmd
;
import
org
.
apache
.
cloudstack
.
api
.
command
.
user
.
vmgroup
.
DeleteVMGroupCmd
;
import
com
.
cloud
.
dc
.
DataCenter
;
import
com
.
cloud
.
exception
.
ConcurrentOperationException
;
import
com
.
cloud
.
exception
.
InsufficientCapacityException
;
import
com
.
cloud
.
exception
.
ManagementServerException
;
import
com
.
cloud
.
exception
.
ResourceAllocationException
;
import
com
.
cloud
.
exception
.
ResourceUnavailableException
;
import
com
.
cloud
.
exception
.
StorageUnavailableException
;
import
com
.
cloud
.
exception
.
VirtualMachineMigrationException
;
import
com
.
cloud
.
host
.
Host
;
import
com
.
cloud
.
hypervisor
.
Hypervisor
.
HypervisorType
;
import
com
.
cloud
.
network
.
Network
.
IpAddresses
;
import
com
.
cloud
.
offering
.
ServiceOffering
;
import
com
.
cloud
.
storage
.
StoragePool
;
import
com
.
cloud
.
template
.
VirtualMachineTemplate
;
import
com
.
cloud
.
user
.
Account
;
import
com
.
cloud
.
uservm
.
UserVm
;
import
com
.
cloud
.
utils
.
exception
.
ExecutionException
;
public
interface
UserVmService
{
/**
* Destroys one virtual machine
*
* @param userId
* the id of the user performing the action
* @param vmId
* the id of the virtual machine.
* @throws ConcurrentOperationException
* @throws ResourceUnavailableException
*/
UserVm
destroyVm
(
DestroyVMCmd
cmd
)
throws
ResourceUnavailableException
,
ConcurrentOperationException
;
/**
* Destroys one virtual machine
*
* @param userId
* the id of the user performing the action
* @param vmId
* the id of the virtual machine.
* @throws ConcurrentOperationException
* @throws ResourceUnavailableException
*/
UserVm
destroyVm
(
long
vmId
)
throws
ResourceUnavailableException
,
ConcurrentOperationException
;
/**
* Resets the password of a virtual machine.
*
* @param cmd
* - the command specifying vmId, password
* @return the VM if reset worked successfully, null otherwise
*/
UserVm
resetVMPassword
(
ResetVMPasswordCmd
cmd
,
String
password
)
throws
ResourceUnavailableException
,
InsufficientCapacityException
;
/**
* Resets the SSH Key of a virtual machine.
*
* @param cmd
* - the command specifying vmId, Keypair name
* @return the VM if reset worked successfully, null otherwise
*/
UserVm
resetVMSSHKey
(
ResetVMSSHKeyCmd
cmd
)
throws
ResourceUnavailableException
,
InsufficientCapacityException
;
UserVm
startVirtualMachine
(
StartVMCmd
cmd
)
throws
StorageUnavailableException
,
ExecutionException
,
ConcurrentOperationException
,
ResourceUnavailableException
,
InsufficientCapacityException
,
ResourceAllocationException
;
UserVm
rebootVirtualMachine
(
RebootVMCmd
cmd
)
throws
InsufficientCapacityException
,
ResourceUnavailableException
;
UserVm
updateVirtualMachine
(
UpdateVMCmd
cmd
)
throws
ResourceUnavailableException
,
InsufficientCapacityException
;
/**
* Adds a NIC on the given network to the virtual machine
* @param cmd the command object that defines the vm and the given network
* @return the vm object if successful, null otherwise
*/
UserVm
addNicToVirtualMachine
(
AddNicToVMCmd
cmd
);
/**
* Removes a NIC on the given network from the virtual machine
* @param cmd the command object that defines the vm and the given network
* @return the vm object if successful, null otherwise
*/
UserVm
removeNicFromVirtualMachine
(
RemoveNicFromVMCmd
cmd
);
/**
* Updates default Nic to the given network for given virtual machine
* @param cmd the command object that defines the vm and the given network
* @return the vm object if successful, null otherwise
*/
UserVm
updateDefaultNicForVirtualMachine
(
UpdateDefaultNicForVMCmd
cmd
);
UserVm
recoverVirtualMachine
(
RecoverVMCmd
cmd
)
throws
ResourceAllocationException
;
/**
* Creates a Basic Zone User VM in the database and returns the VM to the
* caller.
*
* @param zone
* - availability zone for the virtual machine
* @param serviceOffering
* - the service offering for the virtual machine
* @param template
* - the template for the virtual machine
* @param securityGroupIdList
* - comma separated list of security groups id that going to be
* applied to the virtual machine
* @param hostName
* - host name for the virtual machine
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
* - the ID of the disk offering for the virtual machine. If the
* template is of ISO format, the diskOfferingId is for the root
* disk volume. Otherwise this parameter is used to indicate the
* offering for the data disk volume. If the templateId parameter
* passed is from a Template object, the diskOfferingId refers to
* a DATA Disk Volume created. If the templateId parameter passed
* is from an ISO object, the diskOfferingId refers to a ROOT
* Disk Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually
* exclusive with diskOfferingId
* @param group
* - an optional group for the virtual machine
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
* - an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be
* base64 encoded before adding it to the request. Currently only
* HTTP GET is supported. Using HTTP GET (via querystring), you
* can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual
* machine
* @param requestedIps
* TODO
* @param defaultIp
* TODO
* @param displayVm
* - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
*
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
* @param domainId
* - an optional domainId for the virtual machine. If the account
* parameter is used, domainId must also be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM or in the
* same environment.
* @throws ResourceUnavailableException
* if the resources required to deploy the VM is not currently
* available.
* @throws InsufficientResourcesException
*/
UserVm
createBasicSecurityGroupVirtualMachine
(
DataCenter
zone
,
ServiceOffering
serviceOffering
,
VirtualMachineTemplate
template
,
List
<
Long
>
securityGroupIdList
,
Account
owner
,
String
hostName
,
String
displayName
,
Long
diskOfferingId
,
Long
diskSize
,
String
group
,
HypervisorType
hypervisor
,
HTTPMethod
httpmethod
,
String
userData
,
String
sshKeyPair
,
Map
<
Long
,
IpAddresses
>
requestedIps
,
IpAddresses
defaultIp
,
Boolean
displayVm
,
String
keyboard
,
List
<
Long
>
affinityGroupIdList
)
throws
InsufficientCapacityException
,
ConcurrentOperationException
,
ResourceUnavailableException
,
StorageUnavailableException
,
ResourceAllocationException
;
/**
* Creates a User VM in Advanced Zone (Security Group feature is enabled) in
* the database and returns the VM to the caller.
*
* @param zone
* - availability zone for the virtual machine
* @param serviceOffering
* - the service offering for the virtual machine
* @param template
* - the template for the virtual machine
* @param networkIdList
* - list of network ids used by virtual machine
* @param securityGroupIdList
* - comma separated list of security groups id that going to be
* applied to the virtual machine
* @param hostName
* - host name for the virtual machine
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
* - the ID of the disk offering for the virtual machine. If the
* template is of ISO format, the diskOfferingId is for the root
* disk volume. Otherwise this parameter is used to indicate the
* offering for the data disk volume. If the templateId parameter
* passed is from a Template object, the diskOfferingId refers to
* a DATA Disk Volume created. If the templateId parameter passed
* is from an ISO object, the diskOfferingId refers to a ROOT
* Disk Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually
* exclusive with diskOfferingId
* @param group
* - an optional group for the virtual machine
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
* - an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be
* base64 encoded before adding it to the request. Currently only
* HTTP GET is supported. Using HTTP GET (via querystring), you
* can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual
* machine
* @param requestedIps
* TODO
* @param defaultIps
* TODO
* @param displayVm
* - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
*
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
* @param domainId
* - an optional domainId for the virtual machine. If the account
* parameter is used, domainId must also be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM or in the
* same environment.
* @throws ResourceUnavailableException
* if the resources required to deploy the VM is not currently
* available.
* @throws InsufficientResourcesException
*/
UserVm
createAdvancedSecurityGroupVirtualMachine
(
DataCenter
zone
,
ServiceOffering
serviceOffering
,
VirtualMachineTemplate
template
,
List
<
Long
>
networkIdList
,
List
<
Long
>
securityGroupIdList
,
Account
owner
,
String
hostName
,
String
displayName
,
Long
diskOfferingId
,
Long
diskSize
,
String
group
,
HypervisorType
hypervisor
,
HTTPMethod
httpmethod
,
String
userData
,
String
sshKeyPair
,
Map
<
Long
,
IpAddresses
>
requestedIps
,
IpAddresses
defaultIps
,
Boolean
displayVm
,
String
keyboard
,
List
<
Long
>
affinityGroupIdList
)
throws
InsufficientCapacityException
,
ConcurrentOperationException
,
ResourceUnavailableException
,
StorageUnavailableException
,
ResourceAllocationException
;
/**
* Creates a User VM in Advanced Zone (Security Group feature is disabled)
* in the database and returns the VM to the caller.
*
* @param zone
* - availability zone for the virtual machine
* @param serviceOffering
* - the service offering for the virtual machine
* @param template
* - the template for the virtual machine
* @param networkIdList
* - list of network ids used by virtual machine
* @param hostName
* - host name for the virtual machine
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
* - the ID of the disk offering for the virtual machine. If the
* template is of ISO format, the diskOfferingId is for the root
* disk volume. Otherwise this parameter is used to indicate the
* offering for the data disk volume. If the templateId parameter
* passed is from a Template object, the diskOfferingId refers to
* a DATA Disk Volume created. If the templateId parameter passed
* is from an ISO object, the diskOfferingId refers to a ROOT
* Disk Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually
* exclusive with diskOfferingId
* @param group
* - an optional group for the virtual machine
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
* - an optional binary data that can be sent to the virtual
* machine upon a successful deployment. This binary data must be
* base64 encoded before adding it to the request. Currently only
* HTTP GET is supported. Using HTTP GET (via querystring), you
* can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual
* machine
* @param requestedIps
* TODO
* @param defaultIps
* TODO
* @param displayVm
* - Boolean flag whether to the display the vm to the end user or not
* @param affinityGroupIdList
*
* @param accountName
* - an optional account for the virtual machine. Must be used
* with domainId
* @param domainId
* - an optional domainId for the virtual machine. If the account
* parameter is used, domainId must also be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM or in the
* same environment.
* @throws ResourceUnavailableException
* if the resources required to deploy the VM is not currently
* available.
* @throws InsufficientResourcesException
*/
UserVm
createAdvancedVirtualMachine
(
DataCenter
zone
,
ServiceOffering
serviceOffering
,
VirtualMachineTemplate
template
,
List
<
Long
>
networkIdList
,
Account
owner
,
String
hostName
,
String
displayName
,
Long
diskOfferingId
,
Long
diskSize
,
String
group
,
HypervisorType
hypervisor
,
HTTPMethod
httpmethod
,
String
userData
,
String
sshKeyPair
,
Map
<
Long
,
IpAddresses
>
requestedIps
,
IpAddresses
defaultIps
,
Boolean
displayVm
,
String
keyboard
,
List
<
Long
>
affinityGroupIdList
)
throws
InsufficientCapacityException
,
ConcurrentOperationException
,
ResourceUnavailableException
,
StorageUnavailableException
,
ResourceAllocationException
;
/**
* Starts the virtual machine created from createVirtualMachine.
*
* @param cmd
* Command to deploy.
* @return UserVm object if successful.
* @throws InsufficientCapacityException
* if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM.
* @throws ResourceUnavailableException
* if the resources required the deploy the VM is not currently available.
*/
UserVm
startVirtualMachine
(
DeployVMCmd
cmd
)
throws
InsufficientCapacityException
,
ConcurrentOperationException
,
ResourceUnavailableException
;
/**
* Creates a vm group.
*
* @param name
* - name of the group
* @param accountId
* - accountId
*/
InstanceGroup
createVmGroup
(
CreateVMGroupCmd
cmd
);
boolean
deleteVmGroup
(
DeleteVMGroupCmd
cmd
);
/**
* upgrade the service offering of the virtual machine
*
* @param cmd
* - the command specifying vmId and new serviceOfferingId
* @return the vm
* @throws ResourceAllocationException
*/
UserVm
upgradeVirtualMachine
(
UpgradeVMCmd
cmd
)
throws
ResourceAllocationException
;
UserVm
stopVirtualMachine
(
long
vmId
,
boolean
forced
)
throws
ConcurrentOperationException
;
void
deletePrivateTemplateRecord
(
Long
templateId
);
HypervisorType
getHypervisorTypeOfUserVM
(
long
vmid
);
UserVm
createVirtualMachine
(
DeployVMCmd
cmd
)
throws
InsufficientCapacityException
,
ResourceUnavailableException
,
ConcurrentOperationException
,
StorageUnavailableException
,
ResourceAllocationException
;
UserVm
getUserVm
(
long
vmId
);
/**
* Migrate the given VM to the destination host provided. The API returns the migrated VM if migration succeeds.
* Only Root
* Admin can migrate a VM.
*
* @param destinationStorage
* TODO
* @param Long
* vmId
* vmId of The VM to migrate
* @param Host
* destinationHost to migrate the VM
*
* @return VirtualMachine migrated VM
* @throws ManagementServerException
* in case we get error finding the VM or host or access errors or other internal errors.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM.
* @throws ResourceUnavailableException
* if the destination host to migrate the VM is not currently available.
* @throws VirtualMachineMigrationException
* if the VM to be migrated is not in Running state
*/
VirtualMachine
migrateVirtualMachine
(
Long
vmId
,
Host
destinationHost
)
throws
ResourceUnavailableException
,
ConcurrentOperationException
,
ManagementServerException
,
VirtualMachineMigrationException
;
/**
* Migrate the given VM with its volumes to the destination host. The API returns the migrated VM if it succeeds.
* Only root admin can migrate a VM.
*
* @param destinationStorage
* TODO
* @param Long
* vmId of The VM to migrate
* @param Host
* destinationHost to migrate the VM
* @param Map
* A map of volume to which pool it should be migrated
*
* @return VirtualMachine migrated VM
* @throws ManagementServerException
* in case we get error finding the VM or host or access errors or other internal errors.
* @throws ConcurrentOperationException
* if there are multiple users working on the same VM.
* @throws ResourceUnavailableException
* if the destination host to migrate the VM is not currently available.
* @throws VirtualMachineMigrationException
* if the VM to be migrated is not in Running state
*/
VirtualMachine
migrateVirtualMachineWithVolume
(
Long
vmId
,
Host
destinationHost
,
Map
<
String
,
String
>
volumeToPool
)
throws
ResourceUnavailableException
,
ConcurrentOperationException
,
ManagementServerException
,
VirtualMachineMigrationException
;
UserVm
moveVMToUser
(
AssignVMCmd
moveUserVMCmd
)
throws
ResourceAllocationException
,
ConcurrentOperationException
,
ResourceUnavailableException
,
InsufficientCapacityException
;
VirtualMachine
vmStorageMigration
(
Long
vmId
,
StoragePool
destPool
);
UserVm
restoreVM
(
RestoreVMCmd
cmd
)
throws
InsufficientCapacityException
,
ResourceUnavailableException
;
UserVm
upgradeVirtualMachine
(
ScaleVMCmd
cmd
)
throws
ResourceUnavailableException
,
ConcurrentOperationException
,
ManagementServerException
,
VirtualMachineMigrationException
;
}
Back
|
FazBrowse Home
|
New Git URL