Exemplo n.º 1
0
def main():
    settings = get_settings(sys_args=sys.argv[1:],
                            env_variables=dict(os.environ))
    exit_if_settings_invalid(settings)
    keys = get_keys(settings["remoteci_id"])
    if keys is None:
        print("Can't get certificate's keys, contact DCI administrator")
        sys.exit(0)
    cert = create_temp_file(keys["cert"]).name
    key = create_temp_file(keys["key"]).name
    return_code = 0

    for topic_settings in settings["topics"]:
        topic_name = topic_settings["name"]
        job = None
        try:
            topic = api.get_topic(topic_name)
            if topic is None:
                raise ("Topic name %s not found" % topic_name)
            job = create_job(topic["id"])
            create_tag(job["id"], "download")
            download_components(topic_settings, api, downloader, cert, key)
            create_jobstate(job["id"], "success")
        except Exception:
            print("Exception when downloading components for %s" % topic_name)
            if job is not None:
                create_jobstate(job["id"], "failure")
            traceback.print_exc()
            return_code = 1
    os.unlink(cert)
    os.unlink(key)
    sys.exit(return_code)
Exemplo n.º 2
0
def main():
    api.check_repo_is_accessible()
    settings = get_settings(sys_args=sys.argv[1:],
                            env_variables=dict(os.environ))
    exit_if_settings_invalid(settings)
    configure_ssl_certificates(settings)
    for topic_settings in settings["topics"]:
        download_topic(topic_settings)
Exemplo n.º 3
0
def test_exit_if_architecture_in_settings_invalid_for_rhel_7():
    with pytest.raises(SystemExit):
        exit_if_settings_invalid(
            get_settings(
                sys_args=["RHEL-7", "/tmp/repo7", "--arch", "aarch64"],
                env_variables={
                    "DCI_CLIENT_ID":
                    "remoteci/9dd94b70-1707-46c5-a2bb-661e8d5d4212",
                    "DCI_API_SECRET":
                    "jSbJwfCdIfq12gwHAAtg5JXSBTO3wj0xkG7oW3DlqyM7bXahPRrfZlqmSv3BhmAy",
                    "DCI_CS_URL": "https://distributed-ci.io",
                },
            ))
Exemplo n.º 4
0
def test_exit_if_settings_invalid_without_download_folder():
    with pytest.raises(SystemExit):
        test_dir = os.path.dirname(os.path.abspath(__file__))
        settings_file_path = os.path.join(test_dir, "data", "settings_v2.yml")
        exit_if_settings_invalid(
            get_settings(
                sys_args=["--settings", settings_file_path],
                env_variables={
                    "DCI_CLIENT_ID":
                    "remoteci/66194b70-46c5-1707-a2bb-9dde8d5d4212",
                    "DCI_API_SECRET": "",
                    "DCI_CS_URL": "",
                },
            ))
Exemplo n.º 5
0
def test_exit_if_settings_invalid():
    try:
        exit_if_settings_invalid(
            get_settings(
                sys_args=["RHEL-8", "/tmp/repo7", "--variant", "BaseOS"],
                env_variables={
                    "DCI_CLIENT_ID":
                    "remoteci/9dd94b70-1707-46c5-a2bb-661e8d5d4212",
                    "DCI_API_SECRET":
                    "jSbJwfCdIfq12gwHAAtg5JXSBTO3wj0xkG7oW3DlqyM7bXahPRrfZlqmSv3BhmAy",
                    "DCI_CS_URL": "https://distributed-ci.io",
                },
            ))
    except SystemExit:
        pytest.fail("exit_if_settings_invalid raise SystemExit but should not")
Exemplo n.º 6
0
def test_with_registry_and_skopeo(has_skopeo_command_mock):
    has_skopeo_command_mock.return_value = True
    exit_if_settings_invalid(
        get_settings(
            sys_args=[
                "OSP16.2", "/tmp/repoOSP16.2", "--registry", "localhost:5000"
            ],
            env_variables={
                "DCI_CLIENT_ID":
                "remoteci/9dd94b70-1707-46c5-a2bb-661e8d5d4212",
                "DCI_API_SECRET":
                "jSbJwfCdIfq12gwHAAtg5JXSBTO3wj0xkG7oW3DlqyM7bXahPRrfZlqmSv3BhmAy",
                "DCI_CS_URL": "https://distributed-ci.io",
            },
        ))
Exemplo n.º 7
0
def test_exit_if_settings_invalid_with_bad_variants():
    with pytest.raises(SystemExit):
        exit_if_settings_invalid(
            get_settings(
                sys_args=[
                    "RHEL-8",
                    "/tmp/repo9",
                    "--variant",
                    "AppStream",
                    "--variant",
                    "Server",
                ],
                env_variables={
                    "DCI_CLIENT_ID": "",
                    "DCI_API_SECRET": "",
                    "DCI_CS_URL": "",
                },
            ))
Exemplo n.º 8
0
def test_exit_if_settings_invalid_with_empty_env_variables():
    with pytest.raises(SystemExit):
        exit_if_settings_invalid(
            get_settings(sys_args=["RHEL-8", "/tmp/repo8"], env_variables={}))