def get_instances_data(self): self.date_range = self.date_range_class(self.request) from_until_ts = self.date_range.get_date_range() from_until_ts = ( self._make_aware_datetime(from_until_ts[0]), self._make_aware_datetime(from_until_ts[1])) return [usage_tables.InstanceUsageTableEntry(id='.'.join([stats['id'], str(day)]), name=stats['res_string'], hours=stats['hours'], price=stats['price']) for day in range((from_until_ts[1] - from_until_ts[0]).days) for stats in priced_usage.PricedUsageBase.get_meter_class( 'instance').get_priced_stats( CeilometerStats.get_stats( meter='instance', project_id=self.request.user.tenant_id, from_ts=from_until_ts[0] + datetime.timedelta( days=day), until_ts=from_until_ts[0] + datetime.timedelta( days=day + 1)), (from_until_ts[0] + datetime.timedelta(days=day), from_until_ts[0] + datetime.timedelta(days=day + 1)))]
def _fetch_from_cm(cls, index): return CeilometerStats.get_stats( meter=index.meter, project_id=index.project_id, from_ts=index.from_ts, until_ts=index.until_ts)