mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-3231: Update service offering Id of allocated Vm usage whem service offering changes for a Vm
This commit is contained in:
parent
3c0c6cb0b3
commit
f96442a45b
@ -104,6 +104,10 @@ public class UsageVMInstanceVO {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
public String getHypervisorType() {
|
||||
return hypervisorType;
|
||||
}
|
||||
@ -112,6 +116,10 @@ public class UsageVMInstanceVO {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
@ -988,7 +988,20 @@ 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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user