コード例 #1
0
 def verify(secs, func, step='', msg='', action='', duration=1000,
            sleep_for=10, *args, **kwargs):
     """Arguments:
     :secs: timeout time;
     :func: function to be verified;
     :step: number of test step;
     :msg: message that will be displayed if an exception occurs;
     :action: action that is performed by the method.
     """
     logger.info("STEP:{0}, verify action: '{1}'".format(step, action))
     now = time.time()
     time_out = now + duration
     try:
         with timeout(secs, action):
             while now < time_out:
                 result = func(*args, **kwargs)
                 if result or result is None:
                     return result
                 logger.info(
                     "{} is failed. Will try again".
                     format(action)
                 )
                 time.sleep(sleep_for)
                 now = time.time()
     except Exception as exc:
         logger.exception(exc)
         if type(exc) is AssertionError:
             msg = str(exc)
         raise AssertionError(
             "Step {} failed: {} Please refer to OpenStack logs for more "
             "details.".format(step, msg)
         )
     else:
         return result
コード例 #2
0
ファイル: base_test_case.py プロジェクト: dtsapikov/fuel-qa
    def centos_setup_fuel(self, hostname):
        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)

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

        logger.debug("Update host information")
        cmd = "echo HOSTNAME={} >> /etc/sysconfig/network".format(hostname)
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        cmd = "echo {0} {1} {2} >> /etc/hosts".format(
            ssh.admin_ip,
            hostname,
            settings.FUEL_MASTER_HOSTNAME)

        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        cmd = "hostname {}".format(hostname)
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        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)

        cmd = "yum install -y screen"
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        logger.info("Install Fuel services")

        cmd = "screen -dm bash -c 'showmenu=no wait_for_external_config=yes " \
              "bootstrap_admin_node.sh'"
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        self.env.wait_for_external_config()
        self.env.admin_actions.modify_configs(self.env.d_env.router())
        self.env.kill_wait_for_external_config()

        self.env.wait_bootstrap()

        logger.debug("Check Fuel services")
        self.env.admin_actions.wait_for_fuel_ready()

        logger.debug("post-installation configuration of Fuel services")
        self.fuel_post_install_actions()
コード例 #3
0
ファイル: base_test_case.py プロジェクト: dtsapikov/fuel-qa
    def centos_setup_fuel(self, hostname):
        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)

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

        logger.debug("Update host information")
        cmd = "echo HOSTNAME={} >> /etc/sysconfig/network".format(hostname)
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        cmd = "echo {0} {1} {2} >> /etc/hosts".format(
            ssh.admin_ip, hostname, settings.FUEL_MASTER_HOSTNAME)

        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        cmd = "hostname {}".format(hostname)
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        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)

        cmd = "yum install -y screen"
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        logger.info("Install Fuel services")

        cmd = "screen -dm bash -c 'showmenu=no wait_for_external_config=yes " \
              "bootstrap_admin_node.sh'"
        ssh.execute_on_remote(ssh.admin_ip, cmd=cmd)

        self.env.wait_for_external_config()
        self.env.admin_actions.modify_configs(self.env.d_env.router())
        self.env.kill_wait_for_external_config()

        self.env.wait_bootstrap()

        logger.debug("Check Fuel services")
        self.env.admin_actions.wait_for_fuel_ready()

        logger.debug("post-installation configuration of Fuel services")
        self.fuel_post_install_actions()
コード例 #4
0
ファイル: utils.py プロジェクト: jvalinas/fuel-qa
def check_package_version_injected_in_bootstraps(package,
                                                 cluster_id=None,
                                                 ironic=None):

    ssh = SSHManager()
    try:
        pack_path = '/var/www/nailgun/{}/'.format(package)
        ssh.upload_to_remote(ip=ssh.admin_ip,
                             source=settings.UPDATE_FUEL_PATH.rstrip('/'),
                             target=pack_path)
    except Exception:
        logger.exception("Could not upload package")
        raise

    # Step 1 - unpack active bootstrap
    logger.info("unpack active bootstrap")

    if ironic:
        bootstrap = "/var/www/nailgun/bootstrap/ironic/{}".format(cluster_id)
    else:
        bootstrap = "/var/www/nailgun/bootstraps/active_bootstrap"
    bootstrap_var = "/var/root.squashfs"

    cmd = "unsquashfs -d {} {}/root.squashfs".format(bootstrap_var, bootstrap)
    ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)

    # Step 2 - check package version
    logger.info("check package {} version injected in ubuntu bootstrap".format(
        package))

    cmd = "ls {}|grep {} |grep deb |cut -f 2 -d '_'".format(pack_path, package)

    package_from_review = ssh.execute_on_remote(ip=ssh.admin_ip,
                                                cmd=cmd)['stdout_str']

    logger.info("package from review is {}".format(package_from_review))

    awk_pattern = "awk '{print $2}'"
    cmd = "chroot {}/ /bin/bash -c \"dpkg -s {}\"|grep Version|{}".format(
        bootstrap_var, package, awk_pattern)
    installed_package = ssh.execute_on_remote(ip=ssh.admin_ip,
                                              cmd=cmd)['stdout_str']
    logger.info("injected package is {}".format(installed_package))

    assert_equal(
        installed_package, package_from_review,
        "The new package {0} wasn't injected in bootstrap".format(
            package_from_review))

    # Step 3 - remove unpacked bootstrap
    cmd = "rm -rf {}".format(bootstrap_var)
    ssh.execute_on_remote(ip=ssh.admin_ip, cmd=cmd)
コード例 #5
0
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)
コード例 #6
0
    def execute_task_on_node(self, task, node, cluster_id):
        """Execute deployment task against the corresponding node

        :param task: a string of task name
        :param node: a dictionary with node description
        :param cluster_id: an integer, number of cluster id
        :return: None
        """
        try:
            logger.info("Trying to execute {!r} task on node {!r}"
                        .format(task, node['id']))
            tsk = self.fuel_web.client.put_deployment_tasks_for_cluster(
                cluster_id=cluster_id,
                data=[task],
                node_id=node['id'])
            self.fuel_web.assert_task_success(tsk, timeout=30 * 60)
        except (AssertionError, TimeoutError) as e:
            logger.exception("Failed to run task {!r}\n"
                             "Exception:\n{}".format(task, e))
コード例 #7
0
ファイル: utils.py プロジェクト: mmalchuk/openstack-fuel-qa
def check_package_version_injected_in_bootstraps(
        package,
        cluster_id=None,
        ironic=None):

    ssh = SSHManager()
    try:
        pack_path = '/var/www/nailgun/{}/'.format(package)
        ssh.upload_to_remote(
            ip=ssh.admin_ip,
            source=settings.UPDATE_FUEL_PATH.rstrip('/'),
            target=pack_path)
    except Exception:
        logger.exception("Could not upload package")
        raise

    # Step 1 - unpack active bootstrap
    logger.info("unpack active bootstrap")

    if ironic:
        bootstrap = "/var/www/nailgun/bootstrap/ironic/{}".format(cluster_id)
    else:
        bootstrap = "/var/www/nailgun/bootstraps/active_bootstrap"
    bootstrap_var = "/var/root.squashfs"

    cmd = "unsquashfs -d {} {}/root.squashfs".format(
        bootstrap_var, bootstrap)
    ssh.execute_on_remote(
        ip=ssh.admin_ip,
        cmd=cmd)

    # Step 2 - check package version
    logger.info(
        "check package {} version injected in ubuntu bootstrap".format(
            package))

    cmd = "ls {}|grep {} |grep deb |cut -f 2 -d '_'".format(
        pack_path, package)

    package_from_review = ssh.execute_on_remote(
        ip=ssh.admin_ip,
        cmd=cmd)['stdout_str']

    logger.info("package from review is {}".format(package_from_review))

    awk_pattern = "awk '{print $2}'"
    cmd = "chroot {}/ /bin/bash -c \"dpkg -s {}\"|grep Version|{}".format(
        bootstrap_var, package, awk_pattern)
    installed_package = ssh.execute_on_remote(
        ip=ssh.admin_ip,
        cmd=cmd)['stdout_str']
    logger.info("injected package is {}".format(installed_package))

    assert_equal(installed_package, package_from_review,
                 "The new package {0} wasn't injected in bootstrap".format(
                     package_from_review))

    # Step 3 - remove unpacked bootstrap
    cmd = "rm -rf {}".format(bootstrap_var)
    ssh.execute_on_remote(
        ip=ssh.admin_ip,
        cmd=cmd)