@@ -718,10 +718,8 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept
718718
719719 String userSpecifiedName = getVolumeNameFromCommand (cmd );
720720
721- VolumeVO volume = commitVolume (cmd , caller , owner , displayVolume , zoneId , diskOfferingId , provisioningType , size , minIops , maxIops , parentVolume , userSpecifiedName ,
721+ return commitVolume (cmd , caller , owner , displayVolume , zoneId , diskOfferingId , provisioningType , size , minIops , maxIops , parentVolume , userSpecifiedName ,
722722 _uuidMgr .generateUuid (Volume .class , cmd .getCustomId ()));
723-
724- return volume ;
725723 }
726724
727725 private VolumeVO commitVolume (final CreateVolumeCmd cmd , final Account caller , final Account owner , final Boolean displayVolume , final Long zoneId , final Long diskOfferingId ,
@@ -1043,6 +1041,7 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10431041 // the requested change
10441042
10451043 /* If this volume has never been beyond allocated state, short circuit everything and simply update the database. */
1044+ // We need to publish this event to usage_volume table
10461045 if (volume .getState () == Volume .State .Allocated ) {
10471046 s_logger .debug ("Volume is in the allocated state, but has never been created. Simply updating database with new size and IOPS." );
10481047
@@ -1056,7 +1055,8 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10561055 }
10571056
10581057 _volsDao .update (volume .getId (), volume );
1059-
1058+ UsageEventUtils .publishUsageEvent (EventTypes .EVENT_VOLUME_RESIZE , volume .getAccountId (), volume .getDataCenterId (), volume .getId (), volume .getName (),
1059+ volume .getDiskOfferingId (), volume .getTemplateId (), volume .getSize (), Volume .class .getName (), volume .getUuid ());
10601060 return volume ;
10611061 }
10621062
@@ -1133,7 +1133,7 @@ private void validateIops(Long minIops, Long maxIops) {
11331133
11341134 private VolumeVO orchestrateResizeVolume (long volumeId , long currentSize , long newSize , Long newMinIops , Long newMaxIops , Integer newHypervisorSnapshotReserve , Long newDiskOfferingId ,
11351135 boolean shrinkOk ) {
1136- VolumeVO volume = _volsDao .findById (volumeId );
1136+ final VolumeVO volume = _volsDao .findById (volumeId );
11371137 UserVmVO userVm = _userVmDao .findById (volume .getInstanceId ());
11381138 StoragePoolVO storagePool = _storagePoolDao .findById (volume .getPoolId ());
11391139 boolean isManaged = storagePool .isManaged ();
@@ -1209,14 +1209,8 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n
12091209 volService .resizeVolumeOnHypervisor (volumeId , newSize , hosts [0 ], instanceName );
12101210 }
12111211 }
1212-
1213- volume .setSize (newSize );
1214-
1215- _volsDao .update (volume .getId (), volume );
12161212 }
12171213
1218- volume = _volsDao .findById (volume .getId ());
1219-
12201214 if (newDiskOfferingId != null ) {
12211215 volume .setDiskOfferingId (newDiskOfferingId );
12221216 }
@@ -1229,20 +1223,18 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n
12291223
12301224 /* Update resource count for the account on primary storage resource */
12311225 if (!shrinkOk ) {
1232- _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), new Long ( newSize - currentSize ) );
1226+ _resourceLimitMgr .incrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), newSize - currentSize );
12331227 } else {
1234- _resourceLimitMgr .decrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), new Long ( currentSize - newSize ) );
1228+ _resourceLimitMgr .decrementResourceCount (volume .getAccountId (), ResourceType .primary_storage , volume .isDisplayVolume (), currentSize - newSize );
12351229 }
1230+
1231+ UsageEventUtils .publishUsageEvent (EventTypes .EVENT_VOLUME_RESIZE , volume .getAccountId (), volume .getDataCenterId (), volume .getId (), volume .getName (),
1232+ volume .getDiskOfferingId (), volume .getTemplateId (), volume .getSize (), Volume .class .getName (), volume .getUuid ());
1233+
12361234 return volume ;
1237- } catch (InterruptedException e ) {
1238- s_logger .warn ("failed get resize volume result" , e );
1239- throw new CloudRuntimeException (e .getMessage ());
1240- } catch (ExecutionException e ) {
1241- s_logger .warn ("failed get resize volume result" , e );
1242- throw new CloudRuntimeException (e .getMessage ());
1235+
12431236 } catch (Exception e ) {
1244- s_logger .warn ("failed get resize volume result" , e );
1245- throw new CloudRuntimeException (e .getMessage ());
1237+ throw new CloudRuntimeException ("Exception caught during resize volume operation of volume UUID: " + volume .getUuid (), e );
12461238 }
12471239 }
12481240
0 commit comments