def _create_task_log(self, host, num_instances):
     task_log = objects.TaskLog(context.get_admin_context())
     task_log.task_name = 'instance_usage_audit'
     task_log.period_beginning = '2012-06-01 00:00:00'
     task_log.period_ending = '2012-07-01 00:00:00'
     task_log.host = host
     task_log.task_items = num_instances
     task_log.message = ('Instance usage audit ran for host %s, %s '
                         'instances in 0.01 seconds.' %
                         (host, num_instances))
     task_log.begin_task()
     task_log.errors = 1
     task_log.end_task()
Ejemplo n.º 2
0
 def test_end_task(self, mock_end_task):
     task_log = objects.TaskLog(self.context)
     task_log.task_name = fake_task_log['task_name']
     task_log.period_beginning = fake_task_log['period_beginning']
     task_log.period_ending = fake_task_log['period_ending']
     task_log.host = fake_task_log['host']
     task_log.errors = fake_task_log['errors']
     task_log.message = fake_task_log['message']
     task_log.end_task()
     mock_end_task.assert_called_once_with(
         self.context,
         fake_task_log['task_name'],
         fake_task_log['period_beginning'].replace(tzinfo=iso8601.UTC),
         fake_task_log['period_ending'].replace(tzinfo=iso8601.UTC),
         fake_task_log['host'],
         errors=fake_task_log['errors'],
         message=fake_task_log['message'])