Esempio n. 1
0
 def unstandby_all(self, timeout: int = 120) -> None:
     self.connector.unstandby_all()
     waiter = Waiter(title='no standby nodes in cluster',
                     timeout_seconds=timeout,
                     provider_fn=self.connector.get_nodes,
                     predicate=non_standby_nodes)
     waiter.wait()
Esempio n. 2
0
 def standby_all(self, timeout: int = 120) -> None:
     self.connector.standby_all()
     waiter = Waiter(title='no running resources',
                     timeout_seconds=timeout,
                     provider_fn=self.connector.get_resources,
                     predicate=all_stopped)
     waiter.wait()
Esempio n. 3
0
    def disable_stonith(self, timeout: int = 120) -> None:
        resources = self.connector.get_stonith_resources()
        for r in resources:
            self.connector.disable_resource(r)

        waiter = Waiter(title='stonith resources are disabled',
                        timeout_seconds=timeout,
                        provider_fn=self.connector.get_stonith_resources,
                        predicate=all_stopped)
        waiter.wait()
Esempio n. 4
0
    def enable_stonith(self, timeout: int = 120) -> None:
        resources = self.connector.get_stonith_resources()
        for r in resources:
            self.connector.enable_resource(r)

        def all_started(resource_list: List[Resource]) -> bool:
            logging.debug('The following resources are found: %s',
                          resource_list)
            return all(r.active for r in resource_list)

        waiter = Waiter(title='stonith resources are enabled',
                        timeout_seconds=timeout,
                        provider_fn=self.connector.get_stonith_resources,
                        predicate=all_started)
        waiter.wait()
Esempio n. 5
0
    def shutdown_node(self, node_name: str, timeout: int = 120) -> None:
        last_node = self._is_last_online_node(node_name)
        logging.debug(
            'Checking whether it is possible to shutdown the node %s',
            node_name)
        self.connector.ensure_shutdown_possible(node_name)

        self.connector.standby_node(node_name)
        waiter = Waiter(title=f'resources are stopped at node {node_name}',
                        timeout_seconds=timeout,
                        provider_fn=self.connector.get_nodes,
                        predicate=has_no_resources(node_name))
        waiter.wait()
        if not last_node:
            self.connector.shutdown_node(node_name)
        else:
            logging.info(
                'Node %s is the last alive node in the cluster. '
                'It will be powered off by means of direct IPMI signal '
                'without involving Pacemaker', node_name)
            self.connector.manual_shutdown_node(node_name)