~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/contrib/test_createserverext.py

  • Committer: Tarmac
  • Author(s): Vishvananda Ishaya, Anthony Young
  • Date: 2011-09-01 00:16:34 UTC
  • mfrom: (1468.3.13 os-simple-usage)
  • Revision ID: tarmac-20110901001634-bb3whyoipqxc60k5
Simple usage extension for nova.  Uses db to calculate tenant_usage for specified time periods.

Methods:
    * index: return a list of tenant_usages, with option of incuding detailed server_usage
    * show: returns a specific tenant_usage object

tenant_usage object:
    * tenant_usage.total_memory_mb_usage: sum of memory_mb * hours for all instances in tenant for this period
    * tenant_usage.total_local_gb_usage: sum of local_gb * hours for all instances in tenant for this period
    * tenant_usage.total_vcpus_usage: sum of vcpus * hours for all instances in tenant for this period
    * tenant_usage.total_hours: sum of all instance hours for this period
    * tenant_usage.server_usages: A detailed list of server_usages, which describe the usage of a specific server

For larger instances db tables, indexes on instance.launched_at and instance.terminated_at should significantly help performance.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import stubout
24
24
import webob
25
25
 
 
26
from nova import db
26
27
from nova import exception
27
28
from nova import flags
28
29
from nova import test
77
78
                self.injected_files = None
78
79
                self.networks = None
79
80
                self.user_data = None
 
81
                self.db = db
80
82
 
81
83
            def create(self, *args, **kwargs):
82
84
                if 'injected_files' in kwargs: