def run_checks(self):
came_up = set()<EOL>went_down = set()<EOL>for port in self.ports:<EOL><INDENT>checks = self.checks[port].values()<EOL>if not checks:<EOL><INDENT>logger.warn("<STR_LIT>", self.name)<EOL><DEDENT>for check in checks:<EOL><INDENT>check.run()<EOL><DEDENT>checks_pass = all([check.passing for check in checks])<EOL>if self.is_up[port] in (False, None) and checks_pass:<EOL><INDENT>came_up.add(port)<EOL>self.is_up[port] = True<EOL><DEDENT>elif self.is_up[port] in (True, None) and not checks_pass:<EOL><INDENT>went_down.add(port)<EOL>self.is_up[port] = False<EOL><DEDENT><DEDENT>for unused_port in set(self.checks.keys()) - self.ports:<EOL><INDENT>went_down.add(unused_port)<EOL>del self.checks[unused_port]<EOL><DEDENT>return came_up, went_down<EOL>
Iterates over the configured ports and runs the checks on each one.

Returns a two-element tuple: the first is the set of ports that
transitioned from down to up, the second is the set of ports that
transitioned from up to down.

Also handles the case where a check for a since-removed port is run,
marking the port as down regardless of the check's result and removing
the check(s) for the port.