Renamed current_audit_period function to last_completed_audit_period to clarify its purpose.

Change-Id: I7bcfbd1a0545f992b1deae54e4deb956ae33e15d
This commit is contained in:
Brian Elliott 2012-04-12 12:44:06 +00:00
parent 6d750971fd
commit d207b37fa6
5 changed files with 16 additions and 16 deletions

View File

@ -65,7 +65,7 @@ if __name__ == '__main__':
utils.default_flagfile() utils.default_flagfile()
flags.FLAGS(sys.argv) flags.FLAGS(sys.argv)
logging.setup() 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)) print "Creating usages for %s until %s" % (str(begin), str(end))
instances = db.instance_get_active_by_window_joined(admin_context, instances = db.instance_get_active_by_window_joined(admin_context,
begin, begin,

View File

@ -2253,7 +2253,7 @@ class ComputeManager(manager.SchedulerDependentManager):
@manager.periodic_task @manager.periodic_task
def _poll_bandwidth_usage(self, context, start_time=None, stop_time=None): def _poll_bandwidth_usage(self, context, start_time=None, stop_time=None):
if not start_time: if not start_time:
start_time = utils.current_audit_period()[1] start_time = utils.last_completed_audit_period()[1]
curr_time = time.time() curr_time = time.time()
if curr_time - self._last_bw_usage_poll > FLAGS.bandwith_poll_interval: if curr_time - self._last_bw_usage_poll > FLAGS.bandwith_poll_interval:

View File

@ -38,7 +38,7 @@ def notify_usage_exists(instance_ref, current_period=False):
Generates usage for last completed period, unless 'current_period' Generates usage for last completed period, unless 'current_period'
is True.""" is True."""
admin_context = context.get_admin_context(read_deleted='yes') admin_context = context.get_admin_context(read_deleted='yes')
begin, end = utils.current_audit_period() begin, end = utils.last_completed_audit_period()
bw = {} bw = {}
if current_period: if current_period:
audit_start = end audit_start = end

View File

@ -1042,7 +1042,7 @@ class AuditPeriodTest(test.TestCase):
super(AuditPeriodTest, self).tearDown() super(AuditPeriodTest, self).tearDown()
def test_hour(self): 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( self.assertEquals(begin, datetime.datetime(
hour=7, hour=7,
day=5, day=5,
@ -1055,7 +1055,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_hour_with_offset_before_current(self): 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( self.assertEquals(begin, datetime.datetime(
minute=10, minute=10,
hour=7, hour=7,
@ -1070,7 +1070,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_hour_with_offset_after_current(self): 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( self.assertEquals(begin, datetime.datetime(
minute=30, minute=30,
hour=6, hour=6,
@ -1085,7 +1085,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_day(self): 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( self.assertEquals(begin, datetime.datetime(
day=4, day=4,
month=3, month=3,
@ -1096,7 +1096,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_day_with_offset_before_current(self): 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( self.assertEquals(begin, datetime.datetime(
hour=6, hour=6,
day=4, day=4,
@ -1109,7 +1109,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_day_with_offset_after_current(self): 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( self.assertEquals(begin, datetime.datetime(
hour=10, hour=10,
day=3, day=3,
@ -1122,7 +1122,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_month(self): 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( self.assertEquals(begin, datetime.datetime(
day=1, day=1,
month=2, month=2,
@ -1133,7 +1133,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_month_with_offset_before_current(self): 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( self.assertEquals(begin, datetime.datetime(
day=2, day=2,
month=2, month=2,
@ -1144,7 +1144,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_month_with_offset_after_current(self): 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( self.assertEquals(begin, datetime.datetime(
day=15, day=15,
month=1, month=1,
@ -1155,7 +1155,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_year(self): 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( self.assertEquals(begin, datetime.datetime(
day=1, day=1,
month=1, month=1,
@ -1166,7 +1166,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_year_with_offset_before_current(self): 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( self.assertEquals(begin, datetime.datetime(
day=1, day=1,
month=2, month=2,
@ -1177,7 +1177,7 @@ class AuditPeriodTest(test.TestCase):
year=2012)) year=2012))
def test_year_with_offset_after_current(self): 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( self.assertEquals(begin, datetime.datetime(
day=1, day=1,
month=6, month=6,

View File

@ -371,7 +371,7 @@ EASIER_PASSWORD_SYMBOLS = ('23456789', # Removed: 0, 1
'ABCDEFGHJKLMNPQRSTUVWXYZ') # Removed: I, O '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. """This method gives you the most recently *completed* audit period.
arguments: arguments: