Skip to content

Commit 6474f1d

Browse files
committed
Add docstrings
1 parent 97faea1 commit 6474f1d

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

caso/extract/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def _get_keystone_users(self, ks_client):
9999
return {u.id: u.name for u in users}
100100

101101
def vm_status(self, status):
102+
"""Return the status corresponding to the OpenStack status.
103+
104+
:param status: OpenStack status.
105+
"""
102106
return openstack_vm_statuses.get(status.lower(), 'unknown')
103107

104108
@abc.abstractmethod

caso/extract/ceilometer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ def _fill_net_metric(self, metric_name, net_samples, records):
9393
unit_conv=lambda v: int(v / 2 ** 30))
9494

9595
def extract_for_tenant(self, tenant, lastrun):
96+
"""Extract records for a tenant from given date.
97+
98+
This method will get information from nova, and will enhance it with
99+
information from ceilometer.
100+
101+
:param tenant: Tenant to extract records for.
102+
:param extract_from: datetime.datetime object indicating the date to
103+
extract records from
104+
:returns: A dictionary of {"server_id": caso.record.Record"}
105+
"""
96106
records = super(CeilometerExtractor,
97107
self).extract_for_tenant(tenant, lastrun)
98108
# Try and except here

caso/extract/manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ def _extract(self, extract_from):
7575
self.records.update(records)
7676

7777
def get_records(self, lastrun="1970-01-01"):
78+
"""Get records from given date
79+
80+
:param lastrun: date to get records from (optional).
81+
82+
If CONF.extract_from is present, it will be used instead of the
83+
lastrun parameter.
84+
"""
7885
extract_from = CONF.extract_from or lastrun
7986

8087
if isinstance(extract_from, six.string_types):

caso/extract/nova.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def _get_conn(self, tenant):
4646
return conn
4747

4848
def extract_for_tenant(self, tenant, lastrun):
49+
"""Extract records for a tenant from given date querying nova.
50+
51+
This method will get information from nova.
52+
53+
:param tenant: Tenant to extract records for.
54+
:param extract_from: datetime.datetime object indicating the date to
55+
extract records from
56+
:returns: A dictionary of {"server_id": caso.record.Record"}
57+
"""
4958
# Some API calls do not expect a TZ, so we have to remove the timezone
5059
# from the dates. We assume that all dates coming from upstream are
5160
# in UTC TZ.

0 commit comments

Comments
 (0)