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
@ -47,7 +47,7 @@ public class UsageVMInstanceVO {
|
|||||||
|
|
||||||
@Column(name="template_id")
|
@Column(name="template_id")
|
||||||
private long templateId;
|
private long templateId;
|
||||||
|
|
||||||
@Column(name="hypervisor_type")
|
@Column(name="hypervisor_type")
|
||||||
private String hypervisorType;
|
private String hypervisorType;
|
||||||
|
|
||||||
@ -104,6 +104,10 @@ public class UsageVMInstanceVO {
|
|||||||
return templateId;
|
return templateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setServiceOfferingId(long serviceOfferingId) {
|
||||||
|
this.serviceOfferingId = serviceOfferingId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getHypervisorType() {
|
public String getHypervisorType() {
|
||||||
return hypervisorType;
|
return hypervisorType;
|
||||||
}
|
}
|
||||||
@ -112,7 +116,11 @@ public class UsageVMInstanceVO {
|
|||||||
return startDate;
|
return startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getEndDate() {
|
public void setStartDate(Date startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
return endDate;
|
return endDate;
|
||||||
}
|
}
|
||||||
public void setEndDate(Date endDate) {
|
public void setEndDate(Date endDate) {
|
||||||
|
|||||||
@ -988,8 +988,21 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
|
|||||||
usageInstances = m_usageInstanceDao.search(sc, null);
|
usageInstances = m_usageInstanceDao.search(sc, null);
|
||||||
if (usageInstances == null || (usageInstances.size() == 0)) {
|
if (usageInstances == null || (usageInstances.size() == 0)) {
|
||||||
s_logger.error("Cannot find allocated vm entry for a vm running with id: " + vmId);
|
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();
|
Long templateId = event.getTemplateId();
|
||||||
String hypervisorType = event.getResourceType();
|
String hypervisorType = event.getResourceType();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user