Commit d6d19b64 authored by Simon Leinen's avatar Simon Leinen

Mention AGPL

Convert header comment to documentation strings.
parent d6b2e6b9
#!/usr/bin/env python
###
### Extract utilization information from OpenStack
###
### We would like to know which tenants/organizations use (or have
### reserved) how many resources of the various types in the different
### regions of our OpenStack cloud.
###
### In order to map tenants to organizations, or "cost centers", we
### put the name of the cost center into tenants' description strings
### surrounded by brackets, e.g.:
###
### $ keystone tenant-get simon.leinen@switch.ch
### +-------------+------------------------------------------------+
### | Property | Value |
### +-------------+------------------------------------------------+
### | description | Project for simon.leinen@switch.ch [switch.ch] |
### | enabled | True |
### | id | 4aecd5c1599f4862960dbe808e56f403 |
### | name | simon.leinen@switch.ch |
### +-------------+------------------------------------------------+
###
### The script builds a map from tenants to cost centers.
###
### The script lists all VMs in the system, computes resource
### utilization (using flavor descriptions), and adds up utilization
### per tenant.
#
# Copyright (c) 2015 SWITCH
#
# Licensed under the GNU Affero General Public License
"""Extract utilization information from OpenStack"""
import os
import re
......@@ -38,6 +18,33 @@ from novaclient.exceptions import BadRequest, NotFound
from cinderclient.v2 import client as cinder_client
class UsageAnalyzer:
"""Analyze the current resource utilization of an OpenStack cluster.
We would like to know which tenants/organizations use (or have
reserved) how many resources of the various types in the different
regions of our OpenStack cloud.
In order to map tenants to organizations, or "cost centers", we
put the name of the cost center into tenants' description strings
surrounded by brackets, e.g.:
$ keystone tenant-get simon.leinen@switch.ch
+-------------+------------------------------------------------+
| Property | Value |
+-------------+------------------------------------------------+
| description | Project for simon.leinen@switch.ch [switch.ch] |
| enabled | True |
| id | 4aecd5c1599f4862960dbe808e56f403 |
| name | simon.leinen@switch.ch |
+-------------+------------------------------------------------+
The script builds a map from tenants to cost centers.
The script lists all VMs and volumes in the system, computes
resource utilization (using flavor descriptions), adds up
utilization per tenant, and provides reports.
"""
def __init__(self,
fine_grained=True,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment