cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/master to a8b89be
Date Mon, 10 Nov 2014 07:01:39 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 1e1cc11d9 -> a8b89bea4


CLOUDSTACK-7870: When Vm deployments fail and end in error state volume count should be decremented


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a8b89bea
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a8b89bea
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a8b89bea

Branch: refs/heads/master
Commit: a8b89bea4f37a54267694b9a49be6b5bec91f0b0
Parents: 1e1cc11
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Sun Nov 9 23:01:28 2014 -0800
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Sun Nov 9 23:01:28 2014 -0800

----------------------------------------------------------------------
 .../cloudstack/engine/orchestration/VolumeOrchestrator.java     | 4 ++++
 server/src/com/cloud/vm/UserVmManagerImpl.java                  | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a8b89bea/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 4b40d5a..826e2ee 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -1380,9 +1380,13 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
             } else {
                 volService.destroyVolume(volume.getId());
             }
+            // FIXME - All this is boiler plate code and should be done as part of state
transition. This shouldn't be part of orchestrator.
             // publish usage event for the volume
             UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(),
volume.getDataCenterId(), volume.getId(), volume.getName(),
                     Volume.class.getName(), volume.getUuid(), volume.isDisplayVolume());
+            _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.volume,
volume.isDisplay());
+            //FIXME - why recalculate and not decrement
+            _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(),
ResourceType.primary_storage.getOrdinal());
         } catch (Exception e) {
             s_logger.debug("Failed to destroy volume" + volume.getId(), e);
             throw new CloudRuntimeException("Failed to destroy volume" + volume.getId(),
e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a8b89bea/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index ba07211..8096841 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4785,7 +4785,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
                 newVol = volumeMgr.allocateDuplicateVolume(root, null);
             }
 
-            // Create Usage event for the newly created volume
+            // 1. Save usage event and update resource count for user vm volumes
+            _resourceLimitMgr.incrementResourceCount(newVol.getAccountId(), ResourceType.volume,
newVol.isDisplay());
+            _resourceLimitMgr.incrementResourceCount(newVol.getAccountId(), ResourceType.primary_storage,
newVol.isDisplay(), new Long(newVol.getSize()));
+            // 2. Create Usage event for the newly created volume
             UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(),
newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), template.getId(),
newVol.getSize());
             _usageEventDao.persist(usageEvent);
 


Mime
View raw message