Example #1
0
def prepare_paagent_rpm_url(platform, binfo, config):
    uLogging.debug("Building pa-agent upgrade kit for platform {platform}".format(platform=platform))
    agent_rpm_path = get_paagent_rpm_path(binfo, platform)

    if not agent_rpm_path:
        uLogging.debug("Agent for platform {platform} not found".format(platform=platform))
        return None

    corerpms_path = "corerpms/{distrib}{osver}".format(distrib=Const.getDistribLinDir(), osver=platform.osver)
    rpm_in_corerpms_path = posixpath.join(corerpms_path, os.path.basename(agent_rpm_path))

    # Here we could get URL to our RPM, but we need to prepare archive because 'fetch' HCL method can not recognize
    # something except gzip/bzip/exe. Need to simplify this after improving install.cpp from pa-agent project.
    # We need 'fetch' method as the unified transport for agents.

    local_path = uPackaging.getMainMirror().localpath  # /usr/local/pem/install/tarballs
    kit_dir_name = 'linux_agent_upgrade_kit'
    upd_path = os.path.join(local_path, kit_dir_name, config.update_name)
    kit_tarball_filename = '{platform}_{build_name}.tgz'.format(platform=platform, build_name=config.update_name)
    kit_tarball_full_path = os.path.join(upd_path, kit_tarball_filename)

    if not os.path.exists(upd_path):
        os.makedirs(upd_path)

    tgz = tarfile.open(kit_tarball_full_path, "w:gz")
    tgz.debug = 1
    tgz.add(os.path.join(local_path, rpm_in_corerpms_path), PAAGENT_RPM_NAME)
    tgz.close()
    uLogging.debug("pa-agent upgrade kit for platform {platform} has been built: {kit_tarball_full_path}".format(
        platform=platform, kit_tarball_full_path=kit_tarball_full_path))
    return 'http://{comm_ip}/tarballs/{kit_dir_name}/{update_name}/{kit_tarball_filename}'.format(
        comm_ip=config.communication_ip, kit_dir_name=kit_dir_name,
        update_name=config.update_name, kit_tarball_filename=kit_tarball_filename
    )
Example #2
0
def prepare_request_for_repourl_updating(request, config):
    """Filling the request object with corresponding commands for updating yum repourl

    :param request - uHCL.Request() object
    :param config

    :return request
    """
    uLogging.debug("Preparing request for updating pa-central repo")
    yum_repo_url = posixpath.join(config.yum_repo_url, Const.getDistribLinDir(), "$releasever/")
    proxy = "proxy=%s" % config.yum_repo_proxy_url if config.yum_repo_proxy_url else ""
    contents = config.PA_YUM_REPO_CONF_TEMPLATE % {"url": yum_repo_url, "proxy": proxy}
    request.rm("/etc/yum.repos.d/poa.repo")  # remove old poa.repo config file
    request.mkfile(config.PA_YUM_REPO_FILE, contents, owner="root", group="root", perm="0600", overwrite=True)
    request.command("yum clean all --disablerepo=* --enablerepo=pa-central-repo")
    request.command("yum makecache --disablerepo=* --enablerepo=pa-central-repo")
    request.command("yum -q check-update", valid_exit_codes=[0, 100])
    return request