コード例 #1
0
ファイル: std_actions.py プロジェクト: ainkov/mistral
    def run(self):
        def raise_exc(parent_exc=None):
            message = ("Failed to execute ssh cmd "
                       "'%s' on %s" % (self.cmd, self.host))
            if parent_exc:
                message += "\nException: %s" % str(parent_exc)
            raise exc.ActionException(message)

        try:
            results = []

            if not isinstance(self.host, list):
                self.host = [self.host]

            for host_name in self.host:
                status_code, result = ssh_utils.execute_command(
                    self.cmd,
                    host_name,
                    self.username,
                    self.password)

                if status_code > 0:
                    return raise_exc()
                else:
                    results.append(result)

            if len(results) > 1:
                return results

            return result
        except Exception as e:
            return raise_exc(parent_exc=e)
コード例 #2
0
    def run(self):
        def raise_exc(parent_exc=None):
            message = ("Failed to execute ssh cmd "
                       "'%s' on %s" % (self.cmd, self.host))
            if parent_exc:
                message += "\nException: %s" % str(parent_exc)
            raise exc.ActionException(message)

        try:
            results = []

            if not isinstance(self.host, list):
                self.host = [self.host]

            for host_name in self.host:
                status_code, result = ssh_utils.execute_command(
                    self.cmd, host_name, self.username, self.password)

                if status_code > 0:
                    return raise_exc()
                else:
                    results.append(result)

            if len(results) > 1:
                return results

            return result
        except Exception as e:
            return raise_exc(parent_exc=e)
コード例 #3
0
    def _wait_until_server_up(cls, server_ip, timeout=120, delay=2):
        seconds_remain = timeout

        LOG.info("Waiting server SSH [IP=%s]..." % server_ip)

        while seconds_remain > 0:
            try:
                ssh_utils.execute_command('cd', server_ip, None)
            except ssh_exception.SSHException:
                LOG.info("Server %s: SSH service is ready.")
                return
            except Exception as e:
                LOG.info(str(e))
                seconds_remain -= delay
                time.sleep(delay)
            else:
                return

        raise Exception("Failed waiting until server's '%s' SSH is up." %
                        server_ip)
コード例 #4
0
    def _wait_until_server_up(cls, server_ip, timeout=120, delay=2):
        seconds_remain = timeout

        LOG.info("Waiting server SSH [IP=%s]..." % server_ip)

        while seconds_remain > 0:
            try:
                ssh_utils.execute_command('cd', server_ip, None)
            except ssh_exception.SSHException:
                LOG.info("Server %s: SSH service is ready.")
                return
            except Exception as e:
                LOG.info(str(e))
                seconds_remain -= delay
                time.sleep(delay)
            else:
                return

        raise Exception(
            "Failed waiting until server's '%s' SSH is up." % server_ip
        )
コード例 #5
0
    def run(self):
        def raise_exc(parent_exc=None):
            message = ("Failed to execute ssh cmd "
                       "'%s' on %s" % (self.cmd, self.host))
            if parent_exc:
                message += "\nException: %s" % str(parent_exc)
            raise exc.ActionException(message)

        try:
            status_code, result = ssh_utils.execute_command(
                self.cmd, self.host, self.username, self.password)
            if status_code > 0:
                return raise_exc()

            return result
        except Exception as e:
            return raise_exc(parent_exc=e)
コード例 #6
0
ファイル: std_actions.py プロジェクト: dshulyak/mistral
    def run(self):
        def raise_exc(parent_exc=None):
            message = ("Failed to execute ssh cmd "
                       "'%s' on %s" % (self.cmd, self.host))
            if parent_exc:
                message += "\nException: %s" % str(parent_exc)
            raise exc.ActionException(message)

        try:
            status_code, result = ssh_utils.execute_command(self.cmd,
                                                            self.host,
                                                            self.username,
                                                            self.password)
            if status_code > 0:
                return raise_exc()

            return result
        except Exception as e:
            return raise_exc(parent_exc=e)