3131import java .util .LinkedList ;
3232import java .util .List ;
3333import java .util .Map ;
34+ import java .util .Random ;
3435import java .util .Set ;
3536import java .util .UUID ;
3637import java .util .concurrent .Executors ;
112113import com .cloud .host .Host ;
113114import com .cloud .host .HostVO ;
114115import com .cloud .host .Status ;
115- import com .cloud .host .dao .HostDetailsDao ;
116116import com .cloud .host .dao .HostDao ;
117+ import com .cloud .host .dao .HostDetailsDao ;
117118import com .cloud .hypervisor .Hypervisor .HypervisorType ;
118119import com .cloud .hypervisor .HypervisorGuruManager ;
119120import com .cloud .network .NetworkManager ;
183184import com .cloud .vm .dao .UserVmDao ;
184185import com .cloud .vm .dao .VMInstanceDao ;
185186
186- import java .util .Random ;
187-
188187@ Local (value = { StorageManager .class , StorageService .class })
189188public class StorageManagerImpl implements StorageManager , StorageService , Manager , ClusterManagerListener {
190189 private static final Logger s_logger = Logger .getLogger (StorageManagerImpl .class );
@@ -1683,7 +1682,7 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept
16831682
16841683 if (diskOffering .getDiskSize () > 0 ) {
16851684 size = diskOffering .getDiskSize ();
1686- }
1685+ }
16871686
16881687 if (!validateVolumeSizeRange (size )) {// convert size from mb to gb for validation
16891688 throw new InvalidParameterValueException ("Invalid size for custom volume creation: " + size + " ,max volume size is:" + _maxVolumeSizeInGb );
@@ -1697,7 +1696,7 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept
16971696
16981697 if (snapshotCheck .getStatus () != Snapshot .Status .BackedUp ) {
16991698 throw new InvalidParameterValueException ("Snapshot id=" + snapshotId + " is not in " + Snapshot .Status .BackedUp + " state yet and can't be used for volume creation" );
1700- }
1699+ }
17011700
17021701 diskOfferingId = (cmd .getDiskOfferingId () != null ) ? cmd .getDiskOfferingId () : snapshotCheck .getDiskOfferingId ();
17031702 zoneId = snapshotCheck .getDataCenterId ();
@@ -2627,7 +2626,7 @@ public void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDe
26272626 }
26282627 if (assignedPool != null ) {
26292628 Volume .State state = vol .getState ();
2630- if (state == Volume .State .Allocated ) {
2629+ if (state == Volume .State .Allocated && state == Volume . State . Creating ) {
26312630 recreateVols .add (vol );
26322631 } else {
26332632 if (vol .isRecreatable ()) {
@@ -2649,7 +2648,7 @@ public void prepare(VirtualMachineProfile<? extends VirtualMachine> vm, DeployDe
26492648 }
26502649 if (s_logger .isDebugEnabled ()) {
26512650 s_logger .debug ("No need to recreate the volume: " +vol + ", since it already has a pool assigned: " +vol .getPoolId ()+", adding disk to VM" );
2652- }
2651+ }
26532652 StoragePoolVO pool = _storagePoolDao .findById (vol .getPoolId ());
26542653 vm .addDisk (new VolumeTO (vol , pool ));
26552654 }
@@ -2714,7 +2713,7 @@ protected VolumeVO switchVolume(VolumeVO existingVolume, VirtualMachineProfile<?
27142713 txn .start ();
27152714 _volsDao .update (existingVolume , Volume .Event .Destroy );
27162715
2717- Long templateIdToUse = null ;
2716+ Long templateIdToUse = null ;
27182717 Long volTemplateId = existingVolume .getTemplateId ();
27192718 long vmTemplateId = vm .getTemplateId ();
27202719 if (volTemplateId != null && volTemplateId .longValue () != vmTemplateId ) {
0 commit comments