Renamed current_audit_period function to last_completed_audit_period to clarify its purpose.
Change-Id: I7bcfbd1a0545f992b1deae54e4deb956ae33e15d
This commit is contained in:
parent
6d750971fd
commit
d207b37fa6
@ -65,7 +65,7 @@ if __name__ == '__main__':
|
||||
utils.default_flagfile()
|
||||
flags.FLAGS(sys.argv)
|
||||
logging.setup()
|
||||
begin, end = utils.current_audit_period()
|
||||
begin, end = utils.last_completed_audit_period()
|
||||
print "Creating usages for %s until %s" % (str(begin), str(end))
|
||||
instances = db.instance_get_active_by_window_joined(admin_context,
|
||||
begin,
|
||||
|
@ -2253,7 +2253,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
@manager.periodic_task
|
||||
def _poll_bandwidth_usage(self, context, start_time=None, stop_time=None):
|
||||
if not start_time:
|
||||
start_time = utils.current_audit_period()[1]
|
||||
start_time = utils.last_completed_audit_period()[1]
|
||||
|
||||
curr_time = time.time()
|
||||
if curr_time - self._last_bw_usage_poll > FLAGS.bandwith_poll_interval:
|
||||
|
@ -38,7 +38,7 @@ def notify_usage_exists(instance_ref, current_period=False):
|
||||
Generates usage for last completed period, unless 'current_period'
|
||||
is True."""
|
||||
admin_context = context.get_admin_context(read_deleted='yes')
|
||||
begin, end = utils.current_audit_period()
|
||||
begin, end = utils.last_completed_audit_period()
|
||||
bw = {}
|
||||
if current_period:
|
||||
audit_start = end
|
||||
|
@ -1042,7 +1042,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
super(AuditPeriodTest, self).tearDown()
|
||||
|
||||
def test_hour(self):
|
||||
begin, end = utils.current_audit_period(unit='hour')
|
||||
begin, end = utils.last_completed_audit_period(unit='hour')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
hour=7,
|
||||
day=5,
|
||||
@ -1055,7 +1055,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_hour_with_offset_before_current(self):
|
||||
begin, end = utils.current_audit_period(unit='hour@10')
|
||||
begin, end = utils.last_completed_audit_period(unit='hour@10')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
minute=10,
|
||||
hour=7,
|
||||
@ -1070,7 +1070,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_hour_with_offset_after_current(self):
|
||||
begin, end = utils.current_audit_period(unit='hour@30')
|
||||
begin, end = utils.last_completed_audit_period(unit='hour@30')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
minute=30,
|
||||
hour=6,
|
||||
@ -1085,7 +1085,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_day(self):
|
||||
begin, end = utils.current_audit_period(unit='day')
|
||||
begin, end = utils.last_completed_audit_period(unit='day')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=4,
|
||||
month=3,
|
||||
@ -1096,7 +1096,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_day_with_offset_before_current(self):
|
||||
begin, end = utils.current_audit_period(unit='day@6')
|
||||
begin, end = utils.last_completed_audit_period(unit='day@6')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
hour=6,
|
||||
day=4,
|
||||
@ -1109,7 +1109,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_day_with_offset_after_current(self):
|
||||
begin, end = utils.current_audit_period(unit='day@10')
|
||||
begin, end = utils.last_completed_audit_period(unit='day@10')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
hour=10,
|
||||
day=3,
|
||||
@ -1122,7 +1122,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_month(self):
|
||||
begin, end = utils.current_audit_period(unit='month')
|
||||
begin, end = utils.last_completed_audit_period(unit='month')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=1,
|
||||
month=2,
|
||||
@ -1133,7 +1133,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_month_with_offset_before_current(self):
|
||||
begin, end = utils.current_audit_period(unit='month@2')
|
||||
begin, end = utils.last_completed_audit_period(unit='month@2')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=2,
|
||||
month=2,
|
||||
@ -1144,7 +1144,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_month_with_offset_after_current(self):
|
||||
begin, end = utils.current_audit_period(unit='month@15')
|
||||
begin, end = utils.last_completed_audit_period(unit='month@15')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=15,
|
||||
month=1,
|
||||
@ -1155,7 +1155,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_year(self):
|
||||
begin, end = utils.current_audit_period(unit='year')
|
||||
begin, end = utils.last_completed_audit_period(unit='year')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=1,
|
||||
month=1,
|
||||
@ -1166,7 +1166,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_year_with_offset_before_current(self):
|
||||
begin, end = utils.current_audit_period(unit='year@2')
|
||||
begin, end = utils.last_completed_audit_period(unit='year@2')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=1,
|
||||
month=2,
|
||||
@ -1177,7 +1177,7 @@ class AuditPeriodTest(test.TestCase):
|
||||
year=2012))
|
||||
|
||||
def test_year_with_offset_after_current(self):
|
||||
begin, end = utils.current_audit_period(unit='year@6')
|
||||
begin, end = utils.last_completed_audit_period(unit='year@6')
|
||||
self.assertEquals(begin, datetime.datetime(
|
||||
day=1,
|
||||
month=6,
|
||||
|
@ -371,7 +371,7 @@ EASIER_PASSWORD_SYMBOLS = ('23456789', # Removed: 0, 1
|
||||
'ABCDEFGHJKLMNPQRSTUVWXYZ') # Removed: I, O
|
||||
|
||||
|
||||
def current_audit_period(unit=None):
|
||||
def last_completed_audit_period(unit=None):
|
||||
"""This method gives you the most recently *completed* audit period.
|
||||
|
||||
arguments:
|
||||
|
Loading…
Reference in New Issue
Block a user