cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [42/50] [abbrv] git commit: updated refs/heads/vmsync to 3c2aa18
Date Thu, 27 Jun 2013 20:57:44 GMT
CLOUDSTACK-3231: Update service offering Id of allocated Vm usage whem service offering changes
for a Vm


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

Branch: refs/heads/vmsync
Commit: f96442a45b98c4bdc5cfec8535dbde06b0f4b799
Parents: 3c0c6cb
Author: Kishan Kavala <kishan@cloud.com>
Authored: Thu Jun 27 16:01:09 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Thu Jun 27 16:01:39 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/usage/UsageVMInstanceVO.java       | 12 ++++++++++--
 usage/src/com/cloud/usage/UsageManagerImpl.java      | 15 ++++++++++++++-
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f96442a4/engine/schema/src/com/cloud/usage/UsageVMInstanceVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/usage/UsageVMInstanceVO.java b/engine/schema/src/com/cloud/usage/UsageVMInstanceVO.java
index 6f40471..2fe346e 100644
--- a/engine/schema/src/com/cloud/usage/UsageVMInstanceVO.java
+++ b/engine/schema/src/com/cloud/usage/UsageVMInstanceVO.java
@@ -47,7 +47,7 @@ public class UsageVMInstanceVO {
 
     @Column(name="template_id")
     private long templateId;
-    
+
     @Column(name="hypervisor_type")
     private String hypervisorType;
 
@@ -104,6 +104,10 @@ public class UsageVMInstanceVO {
         return templateId;
     }
 
+    public void setServiceOfferingId(long serviceOfferingId) {
+        this.serviceOfferingId = serviceOfferingId;
+    }
+
     public String getHypervisorType() {
         return hypervisorType;
     }
@@ -112,7 +116,11 @@ public class UsageVMInstanceVO {
 		return startDate;
 	}
 
-	public Date getEndDate() {
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public Date getEndDate() {
 		return endDate;
 	}
 	public void setEndDate(Date endDate) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f96442a4/usage/src/com/cloud/usage/UsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java
index 65f354c..4901dd9 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -988,8 +988,21 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
                 usageInstances = m_usageInstanceDao.search(sc, null);
                 if (usageInstances == null || (usageInstances.size() == 0)) {
                     s_logger.error("Cannot find allocated vm entry for a vm running with
id: " + vmId);
+                } else if (usageInstances.size() == 1) {
+                    UsageVMInstanceVO usageInstance = usageInstances.get(0);
+                    if(usageInstance.getSerivceOfferingId() != soId){
+                        //Service Offering changed after Vm creation
+                        //End current Allocated usage and create new Allocated Vm entry with
new soId
+                        usageInstance.setEndDate(event.getCreateDate());
+                        m_usageInstanceDao.update(usageInstance);
+                        usageInstance.setServiceOfferingId(soId);
+                        usageInstance.setStartDate(event.getCreateDate());
+                        usageInstance.setEndDate(null);
+                        m_usageInstanceDao.persist(usageInstance);
+                    }
                 }
-                
+
+
                 Long templateId = event.getTemplateId();
                 String hypervisorType = event.getResourceType();
 


Mime
View raw message