def get_repos_from_cs(cs, skip_dot_version=False):
    p = Pulp(PULP_HOSTNAME, (PULP_USER, PULP_PWD), not PULP_SECURE)

    ret = p.do_request(
        'post', 'repositories/search/', {
            'criteria': {
                'filters': {
                    'notes.content_set': cs
                },
            },
            'distributors': False,
        })

    ret.raise_for_status()

    for item in ret.json():
        notes = item['notes']

        if skip_dot_version and '.' in notes['platform_full_version']:
            continue

        yield {
            'id': item['id'],
            'name': item['display_name'],
            'url': notes['relative_url'],
            'arch': notes['arch']
        }
def query_pulp_rpms(repo_id, name=None, arch=None):
    p = Pulp(PULP_HOSTNAME, (PULP_USER, PULP_PWD), not PULP_SECURE)

    url = 'repositories/{REPO_ID}/search/units/'.format(REPO_ID=repo_id)

    criteria = {'type_ids': ['rpm', 'srpm']}
    filters = {'filters': {'unit': {}}}

    if name:
        filters['filters']['unit']['name'] = name
        criteria.update(filters)

    if arch:
        filters['filters']['unit']['arch'] = arch
        criteria.update(filters)

    res = p.do_request('post', url, {'criteria': criteria})
    res.raise_for_status()
    rpms = []

    for item in res.json():
        metadata = item['metadata']
        rpms.append({
            'name': metadata['name'],
            'arch': metadata['arch'],
            'filename': metadata['filename'],
        })

    return rpms
 def __init__(self,
              pulp_hostname,
              pulp_auth,
              dry_run,
              ubiconfig_filename_list=None,
              ubiconfig_dir_or_url=None,
              insecure=False,
              workers_count=4,
              output_repos=None,
              **kwargs):
     # legacy client implemeted in this repo, it's expected to be replaced by pubtools.pulplib.Client
     self.pulp = Pulp(pulp_hostname, pulp_auth, insecure)
     self._pulp_hostname = pulp_hostname
     self._pulp_auth = pulp_auth
     self._insecure = insecure
     self._pulp_client = None
     self.dry_run = dry_run
     self.output_repos = output_repos
     self._executor = Executors.thread_pool(
         max_workers=workers_count).with_retry()
     self._ubiconfig_list = None
     self._ubiconfig_filename_list = ubiconfig_filename_list
     self._ubiconfig_dir_or_url = ubiconfig_dir_or_url
     self._content_sets = kwargs.get("content_sets", None)
     self._repo_ids = kwargs.get("repo_ids", None)
     self._version = kwargs.get("version", None)
     self._content_set_regex = kwargs.get("content_set_regex", None)
     self._ubiconfig_map = None
def query_pulp_modules(repo_id, name=None, stream=None):
    p = Pulp(PULP_HOSTNAME, (PULP_USER, PULP_PWD), not PULP_SECURE)

    url = 'repositories/{REPO_ID}/search/units/'.format(REPO_ID=repo_id)

    criteria = {'type_ids': ['modulemd']}

    if name and stream:
        criteria.update(
            {'filters': {
                'unit': {
                    'name': name,
                    'stream': stream
                }
            }})

    res = p.do_request('post', url, {'criteria': criteria})
    res.raise_for_status()
    modules = []

    for item in res.json():
        metadata = item['metadata']
        modules.append({
            'name': metadata['name'],
            'arch': metadata['arch'],
            'stream': metadata['stream'],
            'artifacts': metadata['artifacts'],
            'profiles': metadata['profiles'],
        })

    return modules
예제 #5
0
def query_pulp_rpms(repo_id, name=None, arch=None):
    p = Pulp(PULP_HOSTNAME, (PULP_USER, PULP_PWD), not PULP_SECURE)

    url = "repositories/{REPO_ID}/search/units/".format(REPO_ID=repo_id)

    criteria = {"type_ids": ["rpm", "srpm"]}
    filters = {"filters": {"unit": {}}}

    if name:
        filters["filters"]["unit"]["name"] = name
        criteria.update(filters)

    if arch:
        filters["filters"]["unit"]["arch"] = arch
        criteria.update(filters)

    res = p.do_request("post", url, {"criteria": criteria})
    res.raise_for_status()
    rpms = []

    for item in res.json():
        metadata = item["metadata"]
        rpms.append({
            "name": metadata["name"],
            "arch": metadata["arch"],
            "filename": metadata["filename"],
        })

    return rpms
예제 #6
0
def get_repos_from_cs(cs, skip_dot_version=False):
    p = Pulp(PULP_HOSTNAME, (PULP_USER, PULP_PWD), not PULP_SECURE)

    ret = p.do_request(
        "post",
        "repositories/search/",
        {
            "criteria": {
                "filters": {
                    "notes.content_set": cs
                },
            },
            "distributors": False,
        },
    )

    ret.raise_for_status()

    for item in ret.json():
        notes = item["notes"]

        if skip_dot_version and "." in notes["platform_full_version"]:
            continue

        yield {
            "id": item["id"],
            "name": item["display_name"],
            "url": notes["relative_url"],
            "arch": notes["arch"],
        }
예제 #7
0
def query_pulp_modules(repo_id, name=None, stream=None):
    p = Pulp(PULP_HOSTNAME, (PULP_USER, PULP_PWD), not PULP_SECURE)

    url = "repositories/{REPO_ID}/search/units/".format(REPO_ID=repo_id)

    criteria = {"type_ids": ["modulemd"]}

    if name and stream:
        criteria.update(
            {"filters": {
                "unit": {
                    "name": name,
                    "stream": stream
                }
            }})

    res = p.do_request("post", url, {"criteria": criteria})
    res.raise_for_status()
    modules = []

    for item in res.json():
        metadata = item["metadata"]
        modules.append({
            "name": metadata["name"],
            "arch": metadata["arch"],
            "stream": metadata["stream"],
            "artifacts": metadata["artifacts"],
            "profiles": metadata["profiles"],
        })

    return modules
예제 #8
0
    def __init__(self, pulp_hostname, pulp_auth, dry_run, ubiconfig_filename_list=None,
                 ubiconfig_dir_or_url=None, insecure=False, workers_count=4, output_repos=None,
                 **kwargs):

        self.pulp = Pulp(pulp_hostname, pulp_auth, insecure)
        self.dry_run = dry_run
        self.output_repos = output_repos
        self._executor = Executors.thread_pool(max_workers=workers_count).with_retry()
        self.ubiconfig_list = self._load_ubiconfig(ubiconfig_filename_list, ubiconfig_dir_or_url,
                                                   content_sets=kwargs.get('content_sets', None),
                                                   repo_ids=kwargs.get('repo_ids', None))
예제 #9
0
def test_insecure():
    with patch("urllib3.disable_warnings") as patched_warnings:
        Pulp('foo.host', ('fake', 'user'), insecure=True)
        patched_warnings.assert_called_once()
예제 #10
0
def fixture_mock_pulp():
    yield Pulp("foo.pulp.com", (None, ))
예제 #11
0
def test_insecure():
    with patch("urllib3.disable_warnings") as patched_warnings:
        Pulp("foo.host", ("fake", "user"), insecure=True)
        patched_warnings.assert_called_once()