Ejemplo n.º 1
0
	def rendezvous(self, wait_for_all=not ONLY_WAIT_FOR_CRITICAL): # Rendez-vous for processes
		"""
		wait for all process in the list to complette
		New version, replaces the 08/09/2015 one, better use of OOP
		:type wait_for_all: bool
		"""
		offset = len(PRE_BOOT_CHECK_LIST)
		for each in self[:]:
			assert isinstance(each, SysCheckUnit) and each.has_proc
			# Only wait for mandatory checks
			if wait_for_all or each.mandatory:
				each.block()
				self._results[each.url] = each.exitcode == 0
				if self.FAIL_ON_CRITICAL_MISSING and each.exitcode != 0 and each.mandatory:
					print Bcolors.fail('BREEZE INIT FAILED ( %s )' % repr(each.ex()))
					# raise each.ex()
					import sys
					sys.exit(2)
				each.terminate()
				self.remove(each)

		# print self._results
		for each in self:
			self._results[each.url] = each.exitcode == 0

		success_text = 'successful : %s/%s' % (len(self.succeeded) + offset, len(self.boot_tests) + offset)

		if not self.any_running:
			print Bcolors.ok_green('System is up and running, All checks done ! (%s)' % success_text)
		else:
			print Bcolors.ok_green('System is up and running, %s, ') % success_text + \
				Bcolors.warning('but %s (non critical) check%s %s still running %s') % \
				(self.running_count, 's' if self.running_count > 1 else '', self.article,
				self.still_running)
Ejemplo n.º 2
0
# import breeze.auxiliary as aux


DEBUG = True
SKIP_SYSTEM_CHECK = False
# FAIL_ON_CRITICAL_MISSING = True
# RAISE_EXCEPTION = False
# ONLY_WAIT_FOR_CRITICAL = True # if checker should also wait for non-critical

if DEBUG:
	# quick fix to solve PyCharm Django console environment issue
	from breeze.process import MyProcess as Process
else:
	from multiprocessing import Process

OK = '[' + Bcolors.ok_green('OK') + ']'
BAD = '[' + Bcolors.fail('NO') + ']'
WARN = '[' + Bcolors.warning('NO') + ']'


# clem 25/09/2015
class CheckerList(list):
	""" list of SysCheckUnit with filtering properties """
	FAIL_ON_CRITICAL_MISSING = True
	ONLY_WAIT_FOR_CRITICAL = True # if checker should also wait for non-critical

	def __init__(self, check_list):
		self._list_to_check = check_list
		self._results = dict()
		super(CheckerList, self).__init__()