Example #1
0
    def is_running(self, _silent=False):
        '''
        Determine wheather or not the cluster is currently running.

        Returns
        -------
        out : bool
            Weather the cluster is currently running

        See Also
        --------
        start, stop
        '''
        # See if the local cluster_controller handle is still good.
        if self.cluster_controller is not None:
            if _ec2_execution._is_host_pingable(self.cluster_controller):
                return True

        # Check S3 for possibly updated information.
        try:
            s3_copy = load(self.s3_state_path)
        except Exception as e:
            if not _silent:
                _log.warning('Exception trying to load updated configuration '
                             'from S3 path %s. Exception: %s' %
                             (self.s3_state_path, e))
            return False

        # Reconcile S3 info with our local info.
        if s3_copy.cluster_controller is None:
            self.cluster_controller = None
            return False
        elif self.cluster_controller == s3_copy.cluster_controller:
            return False

        # Use the update info from S3. Now check that.
        if not _silent:
            _log.info('Using updated state from S3.')
        self = s3_copy
        if _ec2_execution._is_host_pingable(self.cluster_controller):
            return True
        else:
            return False
    def is_running(self, _silent=False):
        '''
        Determine wheather or not the cluster is currently running.

        Returns
        -------
        out : bool
            Weather the cluster is currently running

        See Also
        --------
        start, stop
        '''
        # See if the local cluster_controller handle is still good.
        if self.cluster_controller is not None:
            if _ec2_execution._is_host_pingable(self.cluster_controller):
                return True

        # Check S3 for possibly updated information.
        try:
            s3_copy = load(self.s3_state_path)
        except Exception as e:
            if not _silent:
                _log.warning('Exception trying to load updated configuration '
                             'from S3 path %s. Exception: %s' % (self.s3_state_path, e))
            return False

        # Reconcile S3 info with our local info.
        if s3_copy.cluster_controller is None:
            self.cluster_controller = None
            return False
        elif self.cluster_controller == s3_copy.cluster_controller:
            return False

        # Use the update info from S3. Now check that.
        if not _silent:
            _log.info('Using updated state from S3.')
        self = s3_copy
        if _ec2_execution._is_host_pingable(self.cluster_controller):
            return True
        else:
            return False