当前位置: 首页>>代码示例>>Python>>正文


Python paramiko.ssh_exception方法代码示例

本文整理汇总了Python中paramiko.ssh_exception方法的典型用法代码示例。如果您正苦于以下问题:Python paramiko.ssh_exception方法的具体用法?Python paramiko.ssh_exception怎么用?Python paramiko.ssh_exception使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paramiko的用法示例。


在下文中一共展示了paramiko.ssh_exception方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import ssh_exception [as 别名]
def run(self, command, *args, **kwargs):
        command = self.get_command(command, *args)
        command = self.encode(command)
        try:
            rc, stdout, stderr = self._exec_command(command)
        except paramiko.ssh_exception.SSHException:
            if not self.client.get_transport().is_active():
                # try to reinit connection (once)
                del self.client
                rc, stdout, stderr = self._exec_command(command)
            else:
                raise

        return self.result(rc, command, stdout, stderr) 
开发者ID:philpep,项目名称:testinfra,代码行数:16,代码来源:paramiko.py

示例2: _get_pkey_object

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import ssh_exception [as 别名]
def _get_pkey_object(self, key_material, passphrase):
        """
        Try to detect private key type and return paramiko.PKey object.
        """

        for cls in [paramiko.RSAKey, paramiko.DSSKey, paramiko.ECDSAKey]:
            try:
                key = cls.from_private_key(StringIO(key_material), password=passphrase)
            except paramiko.ssh_exception.SSHException:
                # Invalid key, try other key type
                pass
            else:
                return key

        # If a user passes in something which looks like file path we throw a more friendly
        # exception letting the user know we expect the contents a not a path.
        # Note: We do it here and not up the stack to avoid false positives.
        contains_header = REMOTE_RUNNER_PRIVATE_KEY_HEADER in key_material.lower()
        if not contains_header and (key_material.count('/') >= 1 or key_material.count('\\') >= 1):
            msg = ('"private_key" parameter needs to contain private key data / content and not '
                   'a path')
        elif passphrase:
            msg = 'Invalid passphrase or invalid/unsupported key type'
        else:
            msg = 'Invalid or unsupported key type'

        raise paramiko.ssh_exception.SSHException(msg) 
开发者ID:StackStorm,项目名称:st2,代码行数:29,代码来源:paramiko_ssh.py

示例3: _is_key_file_needs_passphrase

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import ssh_exception [as 别名]
def _is_key_file_needs_passphrase(file):
        for cls in [paramiko.RSAKey, paramiko.DSSKey, paramiko.ECDSAKey]:
            try:
                cls.from_private_key_file(file, password=None)
            except paramiko.ssh_exception.PasswordRequiredException:
                return True
            except paramiko.ssh_exception.SSHException:
                continue

        return False 
开发者ID:StackStorm,项目名称:st2,代码行数:12,代码来源:paramiko_ssh.py

示例4: cleanup

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import ssh_exception [as 别名]
def cleanup(self, jsonpath=None, vm=None, name_path=None, result_filter=None, collect_logs=True):
        """Collect all data and cleanup VM's and images

        Example:
            ci = CI('/data/shared/marvin/marvin.json')
            ci.cleanup(config=config, jsonpath='zones[*].pods[*].clusters[*].hosts[*]', namepath='url',
                filter=lambda x: x.split('/')[::-1][0])

        :param jsonpath: JSONPath to filter out JSON
        :param vm: Name of the instance to remove
        :param name_path: Optional parameter to filter out json
        :param result_filter: Optional lambda to use on filtered result
        :param collect_logs: Collect logs and coverage files
        """
        for i in parse(jsonpath).find(self.config):
            properties = i.value
            username = properties.get('username', properties.get('user', 'root'))
            password = properties.get('password', properties.get('passwd', 'password'))

            if name_path:
                vm = parse(name_path).find(properties)[0].value
            if result_filter:
                vm = result_filter(vm)
            if collect_logs:
                print("==> Collecting Logs and Code Coverage Report from %s" % vm)
                # TODO: Copy logs and coverage reports from HV and SCP them
                # collect_files_from_vm ${csip} ${csuser} ${cspass} "/var/log/cosmic/management/*.log*" "cs${i}-management-logs/"
                if vm.startswith('cs'):
                    src = "/var/log/cosmic/management/*.log*"
                    dstdir = "%s-management-logs" % vm
                    hostname = properties['mgtSvrIp']
                else:
                    src = "/var/log/cosmic/agent/*.log*"
                    dstdir = "%s-agent-logs" % vm
                    hostname = vm
                if not os.path.exists(dstdir):
                    os.makedirs(dstdir)
                try:
                    self.collect_files_from_vm(hostname=hostname, username=username, password=password,
                                               src=src, dst="%s" % dstdir)
                except (scp.SCPException, paramiko.ssh_exception) as e:
                    print("ERROR: %s" % e.message)

            print("==> Destroying VM %s" % vm)
            # FIXME: Create library for this instead of a subprocess
            subprocess.call(['/data/shared/deploy/kvm_local_deploy.py', '-x', vm]) 
开发者ID:MissionCriticalCloud,项目名称:bubble-toolkit,代码行数:48,代码来源:CI.py


注:本文中的paramiko.ssh_exception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。