示例#1
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     try:
         if settings.UPLOAD_MANIFESTS:
             logger.info(
                 "Uploading new manifests from "
                 "{:s}".format(settings.UPLOAD_MANIFESTS_PATH))
             environment = get_current_env(args)
             if not environment:
                 logger.warning("Can't upload manifests: method of "
                                "unexpected class is decorated.")
                 return result
             with environment.d_env.get_admin_remote() as remote:
                 remote.execute('rm -rf /etc/puppet/modules/*')
                 remote.upload(settings.UPLOAD_MANIFESTS_PATH,
                               '/etc/puppet/modules/')
                 logger.info(
                     "Copying new site.pp from "
                     "{:s}".format(settings.SITEPP_FOR_UPLOAD))
                 remote.execute("cp %s /etc/puppet/manifests" %
                                settings.SITEPP_FOR_UPLOAD)
                 if settings.SYNC_DEPL_TASKS:
                     remote.execute("fuel release --sync-deployment-tasks"
                                    " --dir /etc/puppet/")
     except Exception:
         logger.error("Could not upload manifests")
         raise
     return result
示例#2
0
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if settings.UPDATE_FUEL:
            logger.info("Update fuel's packages from directory {0}.".format(
                settings.UPDATE_FUEL_PATH))
            environment = get_current_env(args)
            if not environment:
                logger.warning("Decorator was triggered "
                               "from unexpected class.")
                return result

            centos_files_count, ubuntu_files_count = \
                environment.admin_actions.upload_packages(
                    local_packages_dir=settings.UPDATE_FUEL_PATH,
                    centos_repo_path=settings.LOCAL_MIRROR_CENTOS,
                    ubuntu_repo_path=settings.LOCAL_MIRROR_UBUNTU)

            cluster_id = environment.fuel_web.get_last_created_cluster()

            if centos_files_count > 0:
                environment.docker_actions.execute_in_containers(
                    cmd='yum -y install yum-plugin-priorities')

                # Update docker containers and restart them
                environment.docker_actions.execute_in_containers(
                    cmd='yum clean expire-cache; yum update -y')
                environment.docker_actions.restart_containers()

                with environment.d_env.get_admin_remote() as remote:
                    # Update packages on master node
                    remote.execute('yum -y install yum-plugin-priorities;'
                                   'yum clean expire-cache; yum update -y')

                # Add auxiliary repository to the cluster attributes
                if settings.OPENSTACK_RELEASE_UBUNTU not in \
                        settings.OPENSTACK_RELEASE:
                    environment.fuel_web.add_local_centos_mirror(
                        cluster_id,
                        name="Auxiliary",
                        path=settings.LOCAL_MIRROR_CENTOS,
                        priority=settings.AUX_RPM_REPO_PRIORITY)

            if ubuntu_files_count > 0:
                # Add auxiliary repository to the cluster attributes
                if settings.OPENSTACK_RELEASE_UBUNTU in \
                        settings.OPENSTACK_RELEASE:
                    environment.fuel_web.add_local_ubuntu_mirror(
                        cluster_id,
                        name="Auxiliary",
                        path=settings.LOCAL_MIRROR_UBUNTU,
                        priority=settings.AUX_DEB_REPO_PRIORITY)
                else:
                    logger.error("{0} .DEB files uploaded but won't be used"
                                 " because of deploying wrong release!".format(
                                     ubuntu_files_count))
            if settings.SYNC_DEPL_TASKS:
                with environment.d_env.get_admin_remote() as remote:
                    remote.execute("fuel release --sync-deployment-tasks"
                                   " --dir /etc/puppet/")
        return result
示例#3
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     try:
         if settings.UPLOAD_MANIFESTS:
             logger.info("Uploading new manifests from %s" %
                         settings.UPLOAD_MANIFESTS_PATH)
             environment = get_current_env(args)
             if not environment:
                 logger.warning("Can't upload manifests: method of "
                                "unexpected class is decorated.")
                 return result
             with environment.d_env.get_admin_remote() as remote:
                 remote.execute('rm -rf /etc/puppet/modules/*')
                 remote.upload(settings.UPLOAD_MANIFESTS_PATH,
                               '/etc/puppet/modules/')
                 logger.info("Copying new site.pp from %s" %
                             settings.SITEPP_FOR_UPLOAD)
                 remote.execute("cp %s /etc/puppet/manifests" %
                                settings.SITEPP_FOR_UPLOAD)
                 if settings.SYNC_DEPL_TASKS:
                     remote.execute("fuel release --sync-deployment-tasks"
                                    " --dir /etc/puppet/")
     except Exception:
         logger.error("Could not upload manifests")
         raise
     return result
示例#4
0
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if not settings.UPDATE_FUEL:
                return result
        try:
            environment = get_current_env(args)
            if not environment:
                logger.warning("Can't update packages: method of "
                               "unexpected class is decorated.")
                return result

            if settings.UPDATE_FUEL_MIRROR:
                for url in settings.UPDATE_FUEL_MIRROR:
                    repo_url = urlparse(url)
                    cut_dirs = len(repo_url.path.strip('/').split('/'))
                    download_cmd = ('wget --recursive --no-parent'
                                    ' --no-verbose --reject "index'
                                    '.html*,*.gif" --exclude-directories'
                                    ' "{pwd}/repocache" '
                                    '--directory-prefix {path} -nH'
                                    ' --cut-dirs={cutd} {url}').\
                        format(pwd=repo_url.path.rstrip('/'),
                               path=settings.UPDATE_FUEL_PATH,
                               cutd=cut_dirs, url=repo_url.geturl())
                    return_code = call(download_cmd, shell=True)
                    assert_equal(return_code, 0, 'Mirroring of remote'
                                                 ' packages '
                                                 'repository failed')

            centos_files_count, ubuntu_files_count = \
                environment.admin_actions.upload_packages(
                    local_packages_dir=settings.UPDATE_FUEL_PATH,
                    centos_repo_path=settings.LOCAL_MIRROR_CENTOS,
                    ubuntu_repo_path=settings.LOCAL_MIRROR_UBUNTU)

            if centos_files_count == 0:
                return result

            # Add temporary repo with new packages to YUM configuration
            conf_file = '/etc/yum.repos.d/temporary.repo'
            cmd = ("echo -e '[temporary]\nname=temporary\nbaseurl=file://{0}/"
                   "\ngpgcheck=0\npriority=1' > {1}").format(
                settings.LOCAL_MIRROR_CENTOS, conf_file)
            with environment.d_env.get_admin_remote() as remote:
                environment.execute_remote_cmd(remote, cmd, exit_code=0)
                update_command = 'yum clean expire-cache; yum update -y -d3'
                result = remote.execute(update_command)
                logger.debug('Result of "yum update" command on master node: '
                             '{0}'.format(result))
                assert_equal(int(result['exit_code']), 0,
                             'Packages update failed, '
                             'inspect logs for details')
                environment.execute_remote_cmd(remote,
                                               cmd='rm -f {0}'
                                               .format(conf_file),
                                               exit_code=0)
        except Exception:
            logger.error("Could not update packages")
            raise
        return result
示例#5
0
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if settings.UPDATE_FUEL:
            logger.info("Update fuel's packages from directory {0}."
                        .format(settings.UPDATE_FUEL_PATH))
            environment = get_current_env(args)
            if not environment:
                logger.warning("Decorator was triggered "
                               "from unexpected class.")
                return result

            centos_files_count, ubuntu_files_count = \
                environment.admin_actions.upload_packages(
                    local_packages_dir=settings.UPDATE_FUEL_PATH,
                    centos_repo_path=settings.LOCAL_MIRROR_CENTOS,
                    ubuntu_repo_path=settings.LOCAL_MIRROR_UBUNTU)
            if not centos_files_count and not ubuntu_files_count:
                raise ConfigurationException('Nothing to update,'
                                             ' packages to update values is 0')
            cluster_id = environment.fuel_web.get_last_created_cluster()

            if centos_files_count > 0:
                environment.docker_actions.execute_in_containers(
                    cmd='yum -y install yum-plugin-priorities')

                # Update docker containers and restart them
                environment.docker_actions.execute_in_containers(
                    cmd='yum clean expire-cache; yum update -y')
                environment.docker_actions.restart_containers()

                with environment.d_env.get_admin_remote() as remote:
                    # Update packages on master node
                    remote.execute(
                        'yum -y install yum-plugin-priorities;'
                        'yum clean expire-cache; yum update -y')

                # Add auxiliary repository to the cluster attributes
                if settings.OPENSTACK_RELEASE_UBUNTU not in \
                        settings.OPENSTACK_RELEASE:
                    environment.fuel_web.add_local_centos_mirror(
                        cluster_id, path=settings.LOCAL_MIRROR_CENTOS,
                        priority=settings.AUX_RPM_REPO_PRIORITY)

            if ubuntu_files_count > 0:
                # Add auxiliary repository to the cluster attributes
                if settings.OPENSTACK_RELEASE_UBUNTU in \
                        settings.OPENSTACK_RELEASE:
                    environment.fuel_web.add_local_ubuntu_mirror(
                        cluster_id, name="Auxiliary",
                        path=settings.LOCAL_MIRROR_UBUNTU,
                        priority=settings.AUX_DEB_REPO_PRIORITY)
                else:
                    logger.error("{0} .DEB files uploaded but won't be used"
                                 " because of deploying wrong release!"
                                 .format(ubuntu_files_count))
            if settings.SYNC_DEPL_TASKS:
                with environment.d_env.get_admin_remote() as remote:
                    remote.execute("fuel release --sync-deployment-tasks"
                                   " --dir /etc/puppet/")
        return result
示例#6
0
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if not settings.UPDATE_FUEL:
            return result
        try:
            environment = get_current_env(args)
            if not environment:
                logger.warning("Can't update packages: method of "
                               "unexpected class is decorated.")
                return result

            if settings.UPDATE_FUEL_MIRROR:
                for url in settings.UPDATE_FUEL_MIRROR:
                    repo_url = urlparse(url)
                    cut_dirs = len(repo_url.path.strip('/').split('/'))
                    download_cmd = ('wget --recursive --no-parent'
                                    ' --no-verbose --reject "index'
                                    '.html*,*.gif" --exclude-directories'
                                    ' "{pwd}/repocache" '
                                    '--directory-prefix {path} -nH'
                                    ' --cut-dirs={cutd} {url}').\
                        format(pwd=repo_url.path.rstrip('/'),
                               path=settings.UPDATE_FUEL_PATH,
                               cutd=cut_dirs, url=repo_url.geturl())
                    return_code = call(download_cmd, shell=True)
                    assert_equal(
                        return_code, 0, 'Mirroring of remote'
                        ' packages '
                        'repository failed')

            centos_files_count, ubuntu_files_count = \
                environment.admin_actions.upload_packages(
                    local_packages_dir=settings.UPDATE_FUEL_PATH,
                    centos_repo_path=settings.LOCAL_MIRROR_CENTOS,
                    ubuntu_repo_path=settings.LOCAL_MIRROR_UBUNTU)

            if centos_files_count == 0:
                return result

            # Add temporary repo with new packages to YUM configuration
            conf_file = '/etc/yum.repos.d/temporary.repo'
            cmd = ("echo -e '[temporary]\nname=temporary\nbaseurl=file://{0}/"
                   "\ngpgcheck=0\npriority=1' > {1}").format(
                       settings.LOCAL_MIRROR_CENTOS, conf_file)
            with environment.d_env.get_admin_remote() as remote:
                environment.execute_remote_cmd(remote, cmd, exit_code=0)
                update_command = 'yum clean expire-cache; yum update -y -d3'
                result = remote.execute(update_command)
                logger.debug('Result of "yum update" command on master node: '
                             '{0}'.format(result))
                assert_equal(
                    int(result['exit_code']), 0, 'Packages update failed, '
                    'inspect logs for details')
                environment.execute_remote_cmd(
                    remote, cmd='rm -f {0}'.format(conf_file), exit_code=0)
        except Exception:
            logger.error("Could not update packages")
            raise
        return result
示例#7
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     environment = get_current_env(args)
     if environment:
         store_packages_json(environment)
     else:
         logger.warning("Can't collect packages: " "Unexpected class is decorated.")
     return result
示例#8
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     environment = get_current_env(args)
     if environment:
         store_packages_json(environment)
     else:
         logger.warning("Can't collect packages: "
                        "Unexpected class is decorated.")
     return result
示例#9
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     if settings.STORE_ASTUTE_YAML:
         environment = get_current_env(args)
         if environment:
             store_astute_yaml(environment)
         else:
             logger.warning("Can't download astute.yaml: " "Unexpected class is decorated.")
     return result
示例#10
0
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if not settings.UPDATE_FUEL:
            return result
        try:
            environment = get_current_env(args)
            if not environment:
                logger.warning("Can't update packages: method of " "unexpected class is decorated.")
                return result

            if settings.UPDATE_FUEL_MIRROR:
                for url in settings.UPDATE_FUEL_MIRROR:
                    repo_url = urllib.parse.urlparse(url)
                    cut_dirs = len(repo_url.path.strip("/").split("/"))
                    download_cmd = (
                        "wget --recursive --no-parent"
                        ' --no-verbose --reject "index'
                        '.html*,*.gif" --exclude-directories'
                        ' "{pwd}/repocache" '
                        "--directory-prefix {path} -nH"
                        " --cut-dirs={cutd} {url}"
                    ).format(
                        pwd=repo_url.path.rstrip("/"),
                        path=settings.UPDATE_FUEL_PATH,
                        cutd=cut_dirs,
                        url=repo_url.geturl(),
                    )
                    return_code = call(download_cmd, shell=True)
                    assert_equal(return_code, 0, "Mirroring of remote" " packages " "repository failed")

            centos_files_count, _ = environment.admin_actions.upload_packages(
                local_packages_dir=settings.UPDATE_FUEL_PATH,
                centos_repo_path=settings.LOCAL_MIRROR_CENTOS,
                ubuntu_repo_path=None,
            )

            if centos_files_count == 0:
                return result

            # Add temporary repo with new packages to YUM configuration
            conf_file = "/etc/yum.repos.d/temporary.repo"
            cmd = (
                "echo -e '[temporary]\nname=temporary\nbaseurl=file://{0}/" "\ngpgcheck=0\npriority=1' > {1}"
            ).format(settings.LOCAL_MIRROR_CENTOS, conf_file)

            SSHManager().execute_on_remote(ip=SSHManager().admin_ip, cmd=cmd)
            update_command = "yum clean expire-cache; yum update -y -d3 " "2>>/var/log/yum-update-error.log"
            cmd_result = SSHManager().execute(ip=SSHManager().admin_ip, cmd=update_command)
            logger.debug('Result of "yum update" command on master node: ' "{0}".format(cmd_result))
            assert_equal(int(cmd_result["exit_code"]), 0, "Packages update failed, " "inspect logs for details")

            SSHManager().execute_on_remote(ip=SSHManager().admin_ip, cmd="rm -f {0}".format(conf_file))
        except Exception:
            logger.error("Could not update packages")
            raise
        return result
示例#11
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     if settings.STORE_ASTUTE_YAML:
         environment = get_current_env(args)
         if environment:
             store_astute_yaml(environment)
         else:
             logger.warning("Can't download astute.yaml: "
                            "Unexpected class is decorated.")
     return result
示例#12
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     # FIXME: Enable me for all release after fix #1403088 and #1448114
     if settings.OPENSTACK_RELEASE == settings.OPENSTACK_RELEASE_UBUNTU:
         env = get_current_env(args)
         nailgun_nodes = env.fuel_web.client.list_cluster_nodes(
             env.fuel_web.get_last_created_cluster())
         for n in nailgun_nodes:
             with env.d_env.get_ssh_to_remote(n['ip']) as node_ssh:
                 check_repo_managment(node_ssh)
     return result
示例#13
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     # FIXME: Enable me for all release after fix #1403088 and #1448114
     if settings.OPENSTACK_RELEASE == settings.OPENSTACK_RELEASE_UBUNTU:
         env = get_current_env(args)
         nailgun_nodes = env.fuel_web.client.list_cluster_nodes(
             env.fuel_web.get_last_created_cluster())
         for n in nailgun_nodes:
             with env.d_env.get_ssh_to_remote(n['ip']) as node_ssh:
                 check_repo_managment(node_ssh)
     return result
示例#14
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     # FIXME: Enable me for all release after fix #1403088 and #1448114
     if settings.OPENSTACK_RELEASE_UBUNTU in settings.OPENSTACK_RELEASE:
         try:
             env = get_current_env(args)
             nailgun_nodes = env.fuel_web.client.list_cluster_nodes(env.fuel_web.get_last_created_cluster())
             for n in nailgun_nodes:
                 logger.debug("Check repository management on {0}".format(n["ip"]))
                 check_repo_managment(n["ip"])
         except Exception:
             logger.error(
                 "An error happened during check repositories " "management on nodes. Please see the debug log."
             )
     return result
示例#15
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     # FIXME: Enable me for all release after fix #1403088 and #1448114
     if settings.OPENSTACK_RELEASE_UBUNTU in settings.OPENSTACK_RELEASE:
         try:
             env = get_current_env(args)
             nailgun_nodes = env.fuel_web.client.list_cluster_nodes(
                 env.fuel_web.get_last_created_cluster())
             for n in nailgun_nodes:
                 logger.debug("Check repository management on {0}"
                              .format(n['ip']))
                 check_repo_managment(n['ip'])
         except Exception:
             logger.error("An error happened during check repositories "
                          "management on nodes. Please see the debug log.")
     return result
示例#16
0
    def wrapper(*args, **kwargs):
        result = func(*args, **kwargs)
        if not settings.UPDATE_FUEL:
                return result
        try:
            environment = get_current_env(args)
            if not environment:
                logger.warning("Can't update packages: method of "
                               "unexpected class is decorated.")
                return result

            remote = environment.d_env.get_admin_remote()

            centos_files_count, ubuntu_files_count = \
                environment.admin_actions.upload_packages(
                    local_packages_dir=settings.UPDATE_FUEL_PATH,
                    centos_repo_path=settings.LOCAL_MIRROR_CENTOS,
                    ubuntu_repo_path=settings.LOCAL_MIRROR_UBUNTU)

            if centos_files_count == 0:
                return result

            # Add temporary repo with new packages to YUM configuration
            conf_file = '/etc/yum.repos.d/temporary.repo'
            cmd = ("echo -e '[temporary]\nname=temporary\nbaseurl=file://{0}/"
                   "\ngpgcheck=0\npriority=1' > {1}").format(
                settings.LOCAL_MIRROR_CENTOS, conf_file)
            environment.execute_remote_cmd(remote, cmd, exit_code=0)
            update_command = 'yum clean expire-cache; yum update -y -d3'
            result = remote.execute(update_command)
            logger.debug('Result of "yum update" command on master node: '
                         '{0}'.format(result))
            assert_equal(int(result['exit_code']), 0,
                         'Packages update failed, '
                         'inspect logs for details')
            environment.execute_remote_cmd(remote,
                                           cmd='rm -f {0}'.format(conf_file),
                                           exit_code=0)
        except Exception:
            logger.error("Could not update packages")
            raise
        return result