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


Python SSHManager.open_on_remote方法代码示例

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


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

示例1: get_puppet_report

# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import open_on_remote [as 别名]
    def get_puppet_report(node):
        """Get puppet run report from corresponding node

        :param node: a dictionary with node description
        :return: a dictionary with puppet report data
        """
        ssh = SSHManager()
        ip = node['ip']
        report_file = "/var/lib/puppet/state/last_run_report.yaml"
        asserts.assert_true(ssh.isfile_on_remote(ip, report_file),
                            'File {!r} not found on node {!r}'
                            .format(report_file, node['id']))
        with ssh.open_on_remote(ip, report_file) as f:
            data = yaml.load(f)
        ssh.rm_rf_on_remote(ip, report_file)
        return data
开发者ID:avgoor,项目名称:fuel-qa,代码行数:18,代码来源:base_lcm_test.py

示例2: install_mos_repos

# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import open_on_remote [as 别名]
def install_mos_repos():
    """
    Upload and install fuel-release packet with mos-repo description
    and install necessary packets for packetary Fuel installation
    :return: nothing
    """
    logger.info("upload fuel-release packet")
    if not settings.FUEL_RELEASE_PATH:
        raise exceptions.FuelQAVariableNotSet('FUEL_RELEASE_PATH', '/path')
    try:
        ssh = SSHManager()
        pack_path = '/tmp/'
        full_pack_path = os.path.join(pack_path,
                                      'fuel-release*.noarch.rpm')
        ssh.upload_to_remote(
            ip=ssh.admin_ip,
            source=settings.FUEL_RELEASE_PATH.rstrip('/'),
            target=pack_path)

        if settings.RPM_REPOS_YAML:
            with ssh.open_on_remote(
                    ip=ssh.admin_ip,
                    path='/etc/yum.repos.d/custom.repo',
                    mode="w") as f:
                f.write(generate_yum_repos_config(settings.RPM_REPOS_YAML))

        if settings.DEB_REPOS_YAML:
            ssh = SSHManager()
            pack_path = "/root/default_deb_repos.yaml"
            ssh.upload_to_remote(
                ip=ssh.admin_ip,
                source=settings.DEB_REPOS_YAML,
                target=pack_path)

    except Exception:
        logger.exception("Could not upload package")
        raise

    logger.debug("setup MOS repositories")
    cmd = "rpm -ivh {}".format(full_pack_path)
    ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

    cmd = "yum install -y fuel-setup"
    ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)
开发者ID:mmalchuk,项目名称:openstack-fuel-qa,代码行数:46,代码来源:fuel_release_hacks.py

示例3: EnvironmentModel

# 需要导入模块: from fuelweb_test.helpers.ssh_manager import SSHManager [as 别名]
# 或者: from fuelweb_test.helpers.ssh_manager.SSHManager import open_on_remote [as 别名]

#.........这里部分代码省略.........
        if match_no_updates or not match_complete_message \
                or not (match_updated_count or match_installed_count):
            logger.warning('No updates were found or update was incomplete.')
            return

        updates_count = 0

        if match_updated_count:
            updates_count += int(match_updated_count.group(1))

        if match_installed_count:
            updates_count += int(match_installed_count.group(1))

        logger.info('{0} package(s) were updated'.format(updates_count))

        logger.info('Applying updates via update-master-node.sh')
        cmd = '/usr/share/fuel-utils/update-master-node.sh'

        self.ssh_manager.execute_on_remote(
            ip=self.ssh_manager.admin_ip,
            cmd=cmd,
            err_msg='Update failed, inspect logs for details',
        )
        logger.info('Update successful')

    # Modifies a resolv.conf on the Fuel master node and returns
    # its original content.
    # * adds 'nameservers' at start of resolv.conf if merge=True
    # * replaces resolv.conf with 'nameservers' if merge=False
    def modify_resolv_conf(self, nameservers=None, merge=True):
        if nameservers is None:
            nameservers = []

        with self.ssh_manager.open_on_remote(
                ip=self.ssh_manager.admin_ip,
                path='/etc/resolv.conf',
        ) as f:
            resolv_conf = f.readlines()

        if merge:
            nameservers.extend(resolv_conf)
        resolv_keys = ['search', 'domain', 'nameserver']
        resolv_new = "".join(
            '{0}\n'.format(ns) for ns in nameservers
            if any(x in ns for x in resolv_keys))
        with self.ssh_manager.open_on_remote(
                ip=self.ssh_manager.admin_ip,
                path='/etc/resolv.conf',
                mode='w'
        ) as f:
            f.write(resolv_new)

        return resolv_conf

    @logwrap
    def describe_other_admin_interfaces(self, admin):
        admin_networks = [iface.network.name for iface in admin.interfaces]
        iface_name = None
        for i, network_name in enumerate(admin_networks):
            if 'admin' in network_name and 'admin' != network_name:
                # This will be replaced with actual interface labels
                # form fuel-devops
                iface_name = 'enp0s' + str(i + 3)
                logger.info("Describe Fuel admin node interface {0} for "
                            "network {1}".format(iface_name, network_name))
                self.describe_admin_interface(iface_name, network_name)
开发者ID:SmartInfrastructures,项目名称:fuel-qa,代码行数:70,代码来源:environment.py


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