File tree Expand file tree Collapse file tree
engine/schema/src/com/cloud/usage
usage/src/com/cloud/usage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public class UsageVMInstanceVO {
4747
4848 @ Column (name ="template_id" )
4949 private long templateId ;
50-
50+
5151 @ Column (name ="hypervisor_type" )
5252 private String hypervisorType ;
5353
@@ -104,6 +104,10 @@ public long getTemplateId() {
104104 return templateId ;
105105 }
106106
107+ public void setServiceOfferingId (long serviceOfferingId ) {
108+ this .serviceOfferingId = serviceOfferingId ;
109+ }
110+
107111 public String getHypervisorType () {
108112 return hypervisorType ;
109113 }
@@ -112,7 +116,11 @@ public Date getStartDate() {
112116 return startDate ;
113117 }
114118
115- public Date getEndDate () {
119+ public void setStartDate (Date startDate ) {
120+ this .startDate = startDate ;
121+ }
122+
123+ public Date getEndDate () {
116124 return endDate ;
117125 }
118126 public void setEndDate (Date endDate ) {
Original file line number Diff line number Diff line change @@ -988,8 +988,21 @@ private void createVMHelperEvent(UsageEventVO event) {
988988 usageInstances = m_usageInstanceDao .search (sc , null );
989989 if (usageInstances == null || (usageInstances .size () == 0 )) {
990990 s_logger .error ("Cannot find allocated vm entry for a vm running with id: " + vmId );
991+ } else if (usageInstances .size () == 1 ) {
992+ UsageVMInstanceVO usageInstance = usageInstances .get (0 );
993+ if (usageInstance .getSerivceOfferingId () != soId ){
994+ //Service Offering changed after Vm creation
995+ //End current Allocated usage and create new Allocated Vm entry with new soId
996+ usageInstance .setEndDate (event .getCreateDate ());
997+ m_usageInstanceDao .update (usageInstance );
998+ usageInstance .setServiceOfferingId (soId );
999+ usageInstance .setStartDate (event .getCreateDate ());
1000+ usageInstance .setEndDate (null );
1001+ m_usageInstanceDao .persist (usageInstance );
1002+ }
9911003 }
992-
1004+
1005+
9931006 Long templateId = event .getTemplateId ();
9941007 String hypervisorType = event .getResourceType ();
9951008
You can’t perform that action at this time.
0 commit comments