def shutdown_resources(self):
        JobDeploymentBase.shutdown_resources(self)
        # Here we terminate the running resources for this job and
        # wait until they have been shut down.
        res_ids = [node.id for node in self.nodes]
        LOG.debug('About to shut down the following nodes: %s' % res_ids)

        LOG.debug('Shutdown resources...')
        for node in self.nodes:
            self.driver.destroy_node(node)

        while res_ids:
            nodes_to_wait_for = self.driver.list_nodes(res_ids)
            still_running = [node.id for node in nodes_to_wait_for]
            new_res_ids = []
            # Now go through res_ids and delete the nodes that don't appear
            # in still_running.
            for res_id in res_ids:
                if res_id not in still_running:
                    LOG.debug('Resource <%s> has terminated...' % res_id)
                else:
                    new_res_ids.append(res_id)
            res_ids = new_res_ids
            if res_ids:
                LOG.debug('Still waiting for termination of resources %s...' %
                          res_ids)
                time.sleep(2)

        LOG.debug('All resources terminated.')
    def shutdown_resources(self):
        JobDeploymentBase.shutdown_resources(self)

        # Number of seconds between chceking for shutdown of resources.
        SHUTDOWN_POLL_DELAY = 4

        # Here we terminate the running resources for this job and
        # wait until they have been shut down.
        res_ids = [node.id for node in self.nodes]
        LOG.debug('About to shut down the following nodes: %s' % res_ids)

        LOG.debug('Shutdown resources...')
        for node in self.nodes:
            self.driver.destroy_node(node)

        while res_ids:
            # TODO: Find a better approach to remove nodes that have vanished
            # from the system, at present we need to manually go through each
            # node to identify individual nodes that are no longer accessible.
            try:
                nodes_to_wait_for = self._get_node_list(res_ids)
            except Exception as e:
                LOG.debug('Exception <%s> getting node list, getting node info'
                          ' individually.' % str(e))
                nodes_to_wait_for = self._get_node_list(res_ids, manual=True)
            still_running = []
            for node_info in nodes_to_wait_for:
                if node_info.state != NodeState.TERMINATED:
                    still_running.append(node_info.id)

            new_res_ids = []
            # Now go through res_ids and delete the nodes that don't appear
            # in still_running.
            for res_id in res_ids:
                if res_id not in still_running:
                    LOG.debug('Resource <%s> has terminated...' % res_id)
                else:
                    new_res_ids.append(res_id)
            res_ids = new_res_ids
            if res_ids:
                LOG.debug('Still waiting for termination of resources %s...' %
                          res_ids)
                time.sleep(SHUTDOWN_POLL_DELAY)

        LOG.debug('All resources terminated.')
예제 #3
0
 def shutdown_resources(self):
     JobDeploymentBase.shutdown_resources(self)
     # Here we collect terminate the running resources for this job and
     # wait until they have been shut down.
     LOG.debug('SSH Deployer: Shutdown resources - nothing to do here.')