Beispiel #1
0
 def get_stats(cls, **kwargs):
     stats = CeilometerClient().statistics.list(
         kwargs['meter'],
         **PricedUsageBase.get_meter_class(
             kwargs['meter']).meter_specific_criterias(
                 cls._get_stats_query(**kwargs)))
     return StatsContainer([{
         'stats':
         stat.to_dict(),
         'resource':
         CeilometerClient().resources.get(
             stat.groupby['resource_id']).to_dict()
     } for stat in stats])
Beispiel #2
0
 def get_stats(cls, **kwargs):
     stats = CeilometerClient().statistics.list(
         kwargs["meter"],
         **PricedUsageBase.get_meter_class(kwargs["meter"]).meter_specific_criterias(cls._get_stats_query(**kwargs))
     )
     return StatsContainer(
         [
             {
                 "stats": stat.to_dict(),
                 "resource": CeilometerClient().resources.get(stat.groupby["resource_id"]).to_dict(),
             }
             for stat in stats
         ]
     )
Beispiel #3
0
 def bill_projects(cls, dry_run=False):
     ut = UserTransactions()
     for stat in cls._get_unbilled_statistics():
         for data in cls._get_raw_data(stat.id):
             for priced_usage in PricedUsageBase.get_meter_class(
                     stat.meter).get_priced_stats(
                         data, (stat.from_ts, stat.until_ts)):
                 if not dry_run:
                     ut.consume_user_money(
                         stat.project_id, priced_usage['price'],
                         cls._get_transaction_message(priced_usage))
                     stat.billed = True
                     stat.save()
                 cls._print_info(stat.project_id, priced_usage, dry_run)
Beispiel #4
0
 def bill_projects(cls, dry_run=False):
     ut = UserTransactions()
     for stat in cls._get_unbilled_statistics():
         for data in cls._get_raw_data(stat.id):
             for priced_usage in PricedUsageBase.get_meter_class(
                     stat.meter).get_priced_stats(
                         data,
                         (stat.from_ts,
                          stat.until_ts)):
                 if not dry_run:
                     ut.consume_user_money(
                         stat.project_id,
                         priced_usage['price'],
                         cls._get_transaction_message(
                             priced_usage))
                     stat.billed = True
                     stat.save()
                 cls._print_info(stat.project_id, priced_usage, dry_run)