~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to nova/db/api.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:
496
496
    return IMPL.instance_get_all_by_filters(context, filters)
497
497
 
498
498
 
499
 
def instance_get_active_by_window(context, begin, end=None):
500
 
    """Get instances active during a certain time window."""
501
 
    return IMPL.instance_get_active_by_window(context, begin, end)
 
499
def instance_get_active_by_window(context, begin, end=None, project_id=None):
 
500
    """Get instances active during a certain time window.
 
501
 
 
502
    Specifying a project_id will filter for a certain project."""
 
503
    return IMPL.instance_get_active_by_window(context, begin, end, project_id)
 
504
 
 
505
 
 
506
def instance_get_active_by_window_joined(context, begin, end=None,
 
507
                                         project_id=None):
 
508
    """Get instances and joins active during a certain time window.
 
509
 
 
510
    Specifying a project_id will filter for a certain project."""
 
511
    return IMPL.instance_get_active_by_window_joined(context, begin, end,
 
512
                                              project_id)
502
513
 
503
514
 
504
515
def instance_get_all_by_user(context, user_id):