Skip to content

Commit a22403e

Browse files
Edison Susudison
authored andcommitted
squash changes into one giant patch
1 parent d812092 commit a22403e

212 files changed

Lines changed: 9893 additions & 7776 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/com/cloud/agent/api/CreateVolumeFromSnapshotCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.cloud.storage.StoragePool;
2020

21+
2122
/**
2223
* This currently assumes that both primary and secondary storage are mounted on the XenServer.
2324
*/

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ public interface StoragePool extends Identity, InternalIdentity {
9999
/**
100100
* @return
101101
*/
102-
String getStorageProvider();
103-
104-
/**
105-
* @return
106-
*/
107-
String getStorageType();
102+
Long getStorageProviderId();
103+
104+
boolean isInMaintenance();
108105
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
package com.cloud.storage;
1818

1919
public enum StoragePoolStatus {
20-
Creating,
21-
Up,
22-
PrepareForMaintenance,
23-
ErrorInMaintenance,
24-
CancelMaintenance,
25-
Maintenance,
26-
Removed;
20+
Initial, Initialized, Creating, Attaching, Up, PrepareForMaintenance,
21+
ErrorInMaintenance, CancelMaintenance, Maintenance, Removed;
2722
}

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

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@
2222
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
2323
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
2424
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
25-
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
26-
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
27-
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
2825

29-
import com.cloud.exception.ConcurrentOperationException;
3026
import com.cloud.exception.InsufficientCapacityException;
31-
import com.cloud.exception.PermissionDeniedException;
32-
import com.cloud.exception.ResourceAllocationException;
3327
import com.cloud.exception.ResourceInUseException;
3428
import com.cloud.exception.ResourceUnavailableException;
35-
import com.cloud.user.Account;
3629

3730
public interface StorageService{
3831
/**
@@ -51,37 +44,6 @@ public interface StorageService{
5144
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException,
5245
UnknownHostException, ResourceUnavailableException;
5346

54-
/**
55-
* Creates the database object for a volume based on the given criteria
56-
*
57-
* @param cmd
58-
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
59-
* name)
60-
* @return the volume object
61-
* @throws PermissionDeniedException
62-
*/
63-
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
64-
65-
/**
66-
* Creates the volume based on the given criteria
67-
*
68-
* @param cmd
69-
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
70-
* name)
71-
* @return the volume object
72-
*/
73-
Volume createVolume(CreateVolumeCmd cmd);
74-
75-
76-
/**
77-
* Resizes the volume based on the given criteria
78-
*
79-
* @param cmd
80-
* the API command wrapping the criteria
81-
* @return the volume object
82-
*/
83-
Volume resizeVolume(ResizeVolumeCmd cmd);
84-
8547
/**
8648
* Delete the storage pool
8749
*
@@ -120,19 +82,4 @@ public StoragePool cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMainte
12082
public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
12183

12284
public StoragePool getStoragePool(long id);
123-
124-
Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
125-
126-
127-
/**
128-
* Uploads the volume to secondary storage
129-
*
130-
* @param UploadVolumeCmd cmd
131-
*
132-
* @return Volume object
133-
*/
134-
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
135-
136-
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
137-
13885
}

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ enum State {
3939
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
4040
Resizing("The volume is being resized"),
4141
Expunging("The volume is being expunging"),
42+
Expunged("The volume is being expunging"),
4243
Destroy("The volume is destroyed, and can't be recovered."),
4344
Destroying("The volume is destroying, and can't be recovered."),
44-
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
45+
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage"),
46+
Uploading("volume is uploading"),
47+
Uploaded("volume is uploaded");
4548

4649
String _description;
4750

@@ -70,19 +73,25 @@ public String getDescription() {
7073
s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);
7174
s_fsm.addTransition(Resizing, Event.OperationFailed, Ready);
7275
s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
73-
s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
76+
s_fsm.addTransition(Uploaded, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
7477
s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
75-
s_fsm.addTransition(Creating, Event.CopyFailed, UploadOp);// Copying volume from sec to primary failed.
78+
s_fsm.addTransition(Creating, Event.CopyFailed, Uploaded);// Copying volume from sec to primary failed.
7679
s_fsm.addTransition(UploadOp, Event.DestroyRequested, Destroy);
7780
s_fsm.addTransition(Ready, Event.DestroyRequested, Destroy);
7881
s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging);
82+
s_fsm.addTransition(Expunging, Event.ExpungingRequested, Expunging);
83+
s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
84+
s_fsm.addTransition(Expunging, Event.OperationFailed, Expunging);
7985
s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
8086
s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
8187
s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
8288
s_fsm.addTransition(Ready, Event.MigrationRequested, Migrating);
8389
s_fsm.addTransition(Migrating, Event.OperationSucceeded, Ready);
8490
s_fsm.addTransition(Migrating, Event.OperationFailed, Ready);
8591
s_fsm.addTransition(Destroy, Event.OperationSucceeded, Destroy);
92+
s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded);
93+
s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated);
94+
s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy);
8695
}
8796
}
8897

@@ -110,7 +119,7 @@ enum Event {
110119
/**
111120
* @return total size of the partition
112121
*/
113-
long getSize();
122+
Long getSize();
114123

115124
/**
116125
* @return the vm instance id
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.cloud.storage;
20+
21+
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
22+
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
23+
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
24+
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
25+
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
26+
27+
import com.cloud.exception.ConcurrentOperationException;
28+
import com.cloud.exception.PermissionDeniedException;
29+
import com.cloud.exception.ResourceAllocationException;
30+
import com.cloud.user.Account;
31+
32+
public interface VolumeApiService {
33+
/**
34+
* Creates the database object for a volume based on the given criteria
35+
*
36+
* @param cmd
37+
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
38+
* name)
39+
* @return the volume object
40+
* @throws PermissionDeniedException
41+
*/
42+
Volume allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
43+
44+
/**
45+
* Creates the volume based on the given criteria
46+
*
47+
* @param cmd
48+
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
49+
* name)
50+
* @return the volume object
51+
*/
52+
Volume createVolume(CreateVolumeCmd cmd);
53+
54+
55+
/**
56+
* Resizes the volume based on the given criteria
57+
*
58+
* @param cmd
59+
* the API command wrapping the criteria
60+
* @return the volume object
61+
*/
62+
Volume resizeVolume(ResizeVolumeCmd cmd);
63+
64+
Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
65+
66+
/**
67+
* Uploads the volume to secondary storage
68+
*
69+
* @param UploadVolumeCmd cmd
70+
*
71+
* @return Volume object
72+
*/
73+
Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException;
74+
75+
boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException;
76+
77+
Volume attachVolumeToVM(AttachVolumeCmd command);
78+
79+
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
80+
}

api/src/com/cloud/template/TemplateService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@
2525
import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
2626
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
2727
import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
28+
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
2829
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
2930
import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
3031
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
3132

3233
import com.cloud.exception.InternalErrorException;
3334
import com.cloud.exception.ResourceAllocationException;
3435
import com.cloud.exception.StorageUnavailableException;
36+
import com.cloud.user.Account;
37+
import com.cloud.utils.exception.CloudRuntimeException;
3538

3639
public interface TemplateService {
3740

@@ -87,4 +90,11 @@ public interface TemplateService {
8790
List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
8891

8992
boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
93+
94+
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd,
95+
Account templateOwner) throws ResourceAllocationException;
96+
97+
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command)
98+
throws CloudRuntimeException;
99+
90100
}

api/src/com/cloud/vm/UserVmService.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
2525
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
26-
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
2726
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
2827
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
2928
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
@@ -103,24 +102,6 @@ public interface UserVmService {
103102
*/
104103
UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
105104

106-
/**
107-
* Attaches the specified volume to the specified VM
108-
*
109-
* @param cmd
110-
* - the command specifying volumeId and vmId
111-
* @return the Volume object if attach worked successfully.
112-
*/
113-
Volume attachVolumeToVM(AttachVolumeCmd cmd);
114-
115-
/**
116-
* Detaches the specified volume from the VM it is currently attached to.
117-
*
118-
* @param cmd
119-
* - the command specifying volumeId
120-
* @return the Volume object if detach worked successfully.
121-
*/
122-
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
123-
124105
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException,
125106
ResourceAllocationException;
126107

@@ -151,28 +132,6 @@ UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, E
151132

152133
UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
153134

154-
/**
155-
* Create a template database record in preparation for creating a private template.
156-
*
157-
* @param cmd
158-
* the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
159-
* for the
160-
* private template
161-
* @param templateOwner
162-
* TODO
163-
* @return the vm template object if successful, null otherwise
164-
* @throws ResourceAllocationException
165-
*/
166-
VirtualMachineTemplate createPrivateTemplateRecord(CreateTemplateCmd cmd, Account templateOwner) throws ResourceAllocationException;
167-
168-
/**
169-
* Creates a private template from a snapshot of a VM
170-
*
171-
* @param cmd
172-
* - the command specifying snapshotId, name, description
173-
* @return a template if successfully created, null otherwise
174-
*/
175-
VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd cmd);
176135

177136
/**
178137
* Creates a Basic Zone User VM in the database and returns the VM to the caller.

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ public class ApiConstants {
444444
public static final String VM_SNAPSHOT_ID = "vmsnapshotid";
445445
public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids";
446446
public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory";
447+
public static final String IMAGE_STORE_UUID = "imagestoreuuid";
447448

448449
public enum HostDetails {
449450
all, capacity, events, stats, min;

api/src/org/apache/cloudstack/api/BaseCmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@
6262
import com.cloud.server.ManagementService;
6363
import com.cloud.server.TaggedResourceService;
6464
import com.cloud.storage.StorageService;
65+
import com.cloud.storage.VolumeApiService;
6566
import com.cloud.storage.snapshot.SnapshotService;
6667
import com.cloud.template.TemplateService;
6768
import com.cloud.user.Account;
6869
import com.cloud.user.AccountService;
6970
import com.cloud.user.DomainService;
7071
import com.cloud.user.ResourceLimitService;
7172
import com.cloud.utils.Pair;
72-
import com.cloud.vm.BareMetalVmService;
7373
import com.cloud.vm.UserVmService;
7474
import com.cloud.vm.snapshot.VMSnapshotService;
7575

@@ -102,6 +102,7 @@ public enum CommandType {
102102
@Inject public UserVmService _userVmService;
103103
@Inject public ManagementService _mgr;
104104
@Inject public StorageService _storageService;
105+
@Inject public VolumeApiService _volumeService;
105106
@Inject public ResourceService _resourceService;
106107
@Inject public NetworkService _networkService;
107108
@Inject public TemplateService _templateService;

0 commit comments

Comments
 (0)