Beispiel #1
0
	def test_scheduleDowntime_none(self):
		"""scheduleDowntime: do not generate any commands"""

		nagctl.conf["host"] = "worker0"
		nagctl.conf["service"] = "queue1"
		commands = nagctl.scheduleDowntime(["schedule", "downtime", "3600", "comment"], "all")

		expected = []
		self.assertEqual(commands, expected)
Beispiel #2
0
	def test_scheduleDowntime_service(self):
		"""scheduleDowntime: generate commands to schedule service downtime"""

		nagctl.conf["service"] = "load"
		commands = nagctl.scheduleDowntime(["schedule", "downtime", "3600", "comment"], "service")
		for i in range (0, len(commands)):
			commands[i] = commands[i].split(";")
			# Check if timestamps set proper duration.
			self.assertEqual(int(commands[i][-6]) - int(commands[i][-7]), 3600)
			# Remove timestamps from command list before comparing commands.
			commands[i] = commands[i][:-7] + commands[i][-5:]

		expected = [["SCHEDULE_SVC_DOWNTIME", "worker0", "load", "1", "0", "3600", "nagctl", "comment"], ["SCHEDULE_SVC_DOWNTIME", "worker1", "load", "1", "0", "3600", "nagctl", "comment"], ["SCHEDULE_SVC_DOWNTIME", "database", "load", "1", "0", "3600", "nagctl", "comment"]]
		self.assertEqual(commands, expected)