@@ -86,10 +86,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
8686 Long doId = usageVol .getDiskOfferingId ();
8787 long zoneId = usageVol .getZoneId ();
8888 Long templateId = usageVol .getTemplateId ();
89+ Long instanceId = usageVol .getVmInstanceId ();
8990 long size = usageVol .getSize ();
9091 String key = volId + "-" + doId + "-" + size ;
9192
92- diskOfferingMap .put (key , new VolInfo (volId , zoneId , doId , templateId , size ));
93+ diskOfferingMap .put (key , new VolInfo (volId , zoneId , doId , templateId , instanceId , size ));
9394
9495 Date volCreateDate = usageVol .getCreated ();
9596 Date volDeleteDate = usageVol .getDeleted ();
@@ -120,8 +121,8 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
120121 // Only create a usage record if we have a runningTime of bigger than zero.
121122 if (useTime > 0L ) {
122123 VolInfo info = diskOfferingMap .get (volIdKey );
123- createUsageRecord (UsageTypes .VOLUME , useTime , startDate , endDate , account , info .getVolumeId (), info . getZoneId (), info . getDiskOfferingId (),
124- info .getTemplateId (), info .getSize ());
124+ createUsageRecord (UsageTypes .VOLUME , useTime , startDate , endDate , account , info .getVolumeId (),
125+ info .getZoneId (), info . getDiskOfferingId (), info . getTemplateId (), info . getInstanceId (), info .getSize ());
125126 }
126127 }
127128
@@ -140,8 +141,8 @@ private static void updateVolUsageData(Map<String, Pair<Long, Long>> usageDataMa
140141 usageDataMap .put (key , volUsageInfo );
141142 }
142143
143- private static void createUsageRecord (int type , long runningTime , Date startDate , Date endDate , AccountVO account , long volId , long zoneId , Long doId ,
144- Long templateId , long size ) {
144+ private static void createUsageRecord (int type , long runningTime , Date startDate , Date endDate , AccountVO account ,
145+ long volId , long zoneId , Long doId , Long templateId , Long instanceId , long size ) {
145146 // Our smallest increment is hourly for now
146147 if (s_logger .isDebugEnabled ()) {
147148 s_logger .debug ("Total running time " + runningTime + "ms" );
@@ -165,9 +166,8 @@ private static void createUsageRecord(int type, long runningTime, Date startDate
165166 } else if (doId != null ) {
166167 usageDesc += " (DiskOffering: " + doId + ")" ;
167168 }
168-
169- UsageVO usageRecord = new UsageVO (zoneId , account .getId (), account .getDomainId (), usageDesc , usageDisplay + " Hrs" , type , new Double (usage ), null , null , doId , templateId , volId ,
170- size , startDate , endDate );
169+ UsageVO usageRecord = new UsageVO (zoneId , account .getId (), account .getDomainId (), usageDesc ,usageDisplay + " Hrs" ,
170+ type , new Double (usage ), instanceId ,null , doId , templateId , volId , size , startDate , endDate );
171171 s_usageDao .persist (usageRecord );
172172 }
173173
@@ -176,13 +176,15 @@ private static class VolInfo {
176176 private long zoneId ;
177177 private Long diskOfferingId ;
178178 private Long templateId ;
179+ private Long instanceId ;
179180 private long size ;
180181
181- public VolInfo (long volId , long zoneId , Long diskOfferingId , Long templateId , long size ) {
182+ public VolInfo (long volId , long zoneId , Long diskOfferingId , Long templateId , Long instanceId , long size ) {
182183 this .volId = volId ;
183184 this .zoneId = zoneId ;
184185 this .diskOfferingId = diskOfferingId ;
185186 this .templateId = templateId ;
187+ this .instanceId = instanceId ;
186188 this .size = size ;
187189 }
188190
@@ -202,6 +204,10 @@ public Long getTemplateId() {
202204 return templateId ;
203205 }
204206
207+ public Long getInstanceId () {
208+ return instanceId ;
209+ }
210+
205211 public long getSize () {
206212 return size ;
207213 }
0 commit comments