def test_can_filter_commands_by_finish_time(self): with session.begin(): self.system.command_queue.extend([ Command(action=u'interrupt', service=u'testdata', status=CommandStatus.running, start_time=datetime.datetime(2015, 12, 7, 0, 0, 0)), Command(action=u'off', service=u'testdata', status=CommandStatus.completed, start_time=datetime.datetime(2015, 12, 6, 0, 0, 2), finish_time=datetime.datetime(2015, 12, 7, 0, 0, 0)), Command(action=u'on', service=u'testdata', status=CommandStatus.completed, start_time=datetime.datetime(2015, 12, 6, 0, 0, 1), finish_time=datetime.datetime(2015, 12, 6, 0, 0, 2)), ]) b = self.browser self.go_to_commands_tab(self.system) pane = b.find_element_by_id('power') pane.find_element_by_xpath('.//input[@type="search"]')\ .send_keys('finish_time:2015-12-06') pane.find_element_by_xpath( './/table[' 'not(tbody/tr/td[6]/text()="interrupt") and ' 'not(tbody/tr/td[6]/text()="off") and ' 'tbody/tr/td[6]/text()="on"]')
def add_completed_command(self, fqdn, action): # Reports completion of a command that was executed # synchronously by the lab controller user = identity.current.user system = System.by_fqdn(fqdn, user) cmd = Command(user=user, service=u"XMLRPC", action=action, status=CommandStatus.completed) cmd.start_time = cmd.finish_time = datetime.utcnow() system.command_queue.append(cmd) session.flush() # Populates cmd.system (needed for next call) cmd.log_to_system_history() return True
def _system_command_metrics_for_query_grouped(name, grouping, query): group_counts = Command.get_queue_stats_by_group(grouping, query) for group, counts in group_counts.iteritems(): for status, count in counts.iteritems(): metrics.measure( 'gauges.system_commands_%s.%s.%s' % (status, name, group.replace('.', '_')), count)
def _system_command_metrics_for_query(name, query): for status, count in Command.get_queue_stats(query).items(): metrics.measure('gauges.system_commands_%s.%s' % (status, name), count)
def _system_command_metrics_for_query_grouped(name, grouping, query): group_counts = Command.get_queue_stats_by_group(grouping, query) for group, counts in group_counts.iteritems(): for status, count in counts.iteritems(): metrics.measure('gauges.system_commands_%s.%s.%s' % (status, name, group.replace('.', '_')), count)