Skip to content

Commit a9efec6

Browse files
committed
CLOUDSTACK-3949:[Object_Store_Refactor][Usage] No usage event is
generated for registered ISO.
1 parent 2d87e64 commit a9efec6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎server/src/com/cloud/template/HypervisorTemplateAdapter.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ protected Void createTemplateAsyncCallBack(AsyncCallbackDispatcher<HypervisorTem
214214
long accountId = tmplt.getAccountId();
215215
if (template.getSize() != null) {
216216
// publish usage event
217+
String etype = EventTypes.EVENT_TEMPLATE_CREATE;
218+
if (tmplt.getFormat() == ImageFormat.ISO) {
219+
etype = EventTypes.EVENT_ISO_CREATE;
220+
}
217221
// get physical size from template_store_ref table
218222
long physicalSize = 0;
219223
DataStore ds = template.getDataStore();
@@ -227,15 +231,15 @@ protected Void createTemplateAsyncCallBack(AsyncCallbackDispatcher<HypervisorTem
227231
Scope dsScope = ds.getScope();
228232
if (dsScope.getScopeType() == ScopeType.ZONE) {
229233
if (dsScope.getScopeId() != null) {
230-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_TEMPLATE_CREATE, template.getAccountId(), dsScope.getScopeId(), template.getId(), template.getName(), null,
234+
UsageEventUtils.publishUsageEvent(etype, template.getAccountId(), dsScope.getScopeId(), template.getId(), template.getName(), null,
231235
null, physicalSize, template.getSize(), VirtualMachineTemplate.class.getName(), template.getUuid());
232236
}
233237
else{
234238
s_logger.warn("Zone scope image store " + ds.getId() + " has a null scope id");
235239
}
236240
} else if (dsScope.getScopeType() == ScopeType.REGION) {
237241
// publish usage event for region-wide image store using a -1 zoneId for 4.2, need to revisit post-4.2
238-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_TEMPLATE_CREATE, template.getAccountId(), -1, template.getId(), template.getName(), null, null,
242+
UsageEventUtils.publishUsageEvent(etype, template.getAccountId(), -1, template.getId(), template.getName(), null, null,
239243
physicalSize, template.getSize(), VirtualMachineTemplate.class.getName(), template.getUuid());
240244
}
241245
_resourceLimitMgr.incrementResourceCount(accountId, ResourceType.secondary_storage, template.getSize());

0 commit comments

Comments
 (0)