Code Monkey home page Code Monkey logo

pulp-cli's Introduction

Pulp command line interface

This is a command line interface for Pulp 3.

This software is in beta and future releases may include backwards incompatible changes.

Check out our docs and the quickstart guide to get started.

pulp-cli's People

Contributors

bmbouter avatar daviddavis avatar decko avatar dependabot[bot] avatar dkliban avatar dralley avatar evgeni avatar fao89 avatar gerrod3 avatar ggainey avatar goosemania avatar ipanova avatar jaskarannarula avatar lubosmj avatar manisha15 avatar mdellweg avatar michalpysik avatar mkot02 avatar pavelpicka avatar pedro-psb avatar pulpbot avatar quartsize avatar quba42 avatar thmo avatar tjev avatar tjmullicani avatar vonsch avatar wbclark avatar zapp42 avatar ziegenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulp-cli's Issues

Make initial config file creation easier

Ok so the config file is already pretty easy to make: https://github.com/pulp/pulp-cli#configuration It would be easier still though if the user didn't have to make the dir and then then the config file. If they could just have to edit it to customize it instead of the default that would be easier.

Does it make any sense to do any of the following?

a) have the config file created by default on installation.

b) have a CLI command that would populate the config file (kind of like pulp smash has).

What do you think?

Add new python remote options

Pulp python 3.2 adding three new options to the remote: keep_latest_packages, exclude_platforms, and package_types

Make export/import process simpler for CLI

Users should be able to export the repositories they want in one command and shouldn't need to know the difference between 'export' and 'exporter'. I propose we remove the 'export' commands and re-brand them under 'exporter'. Exporter should get two new subcommands: 'export' and 'history'.

The 'history' command would get three subcommands from the original 'export' command: 'list', 'show', and 'delete'. Export objects are basically history records of previous exports and thus would fit nicely under this context. If a user doesn't specify a subcommand when using 'history' the default behaviour should be 'list' so they can see all the export objects aka the history.

The new 'export' sub command will take over the original export's 'run' command. This command will have extra functionality to allow for the creation of an exporter so the whole process can be done in one command.

Examples:

with Exporter named foo:

$pulp exporter pulp export --name foo [export options]
Started export task. Task href: ...

with no Exporter:

$pulp exporter pulp export --base-path tmp/exports/ --repository file_repo file --repository rpm_repo rpm [export options]
Would you like to save these configurations? [y/n]
$y
Please give a name to the exporter config options:
$bar
Config options saved in exporter object bar
Started export task. Task href: ...

If the user would specify 'no' on saving the config options, the command would give the created exporter a default name. The other commands under 'exporter' should have their help descriptions updated to reflect the exporter's role as a config object.

A similar process should be applied to the 'importer' commands so that the experience is consistent.

As a user I want to be able to specify types of RPMs to skip during a repository sync

The REST API for the Pulp RPM Plugin documents a parameter for "skip_types" that is not available via the pulp-cli wrapper. This is a very valuable filter because it allows skipping source RPMs in dnf repositories. Source RPMs tend to be many times larger than their respective compiled RPMs and take up significant space with very little return. When using Pulp to fully mirror a repository, the sync process often times out due to a default timeout of 5 minutes for any given operation. A single source RPM, for example, in the Appstream subscription for Oracle Linux 8 can be as large as 5 GBs.

Allow to specify plugin and type along with the name for a dependent resource

The referencing schema for resources (like remote on repositories) should follow the pattern: [[app_label:]type:]name

Given that "file" is the default type, all those should be equivalent:
pulp file repository update --name "test" --remote "test_remote"
pulp file repository update --name "test" --remote "file:test_remote"
pulp file repository update --name "test" --remote "file:file:test_remote"

If the name has colons: ::name:with:colons

Allow the fixture base url to be configurable for tests

We're running the CLI tests in various other repo CIs that use the docker_fixtures setting in plugin_template. The CLI does not honor this setting though and uses fixtures.pulpproject.org. We should make fixutre base url configurable and update the CLI code in plugin_template to configure it.

As a user I want to be able to pass a path to a YAML file with a list of Ansible Collections I wish to be represented by a Ansible Remote in the Ansible plugin

When creating or updating a remote Collection for the Ansible plugin the REST API documents a parameter, "requirements_file." This parameter is currently exposed via the pulp CLI tool. However, it only accepts a string directly. When you instead pass a file path to a YAML file it fails to serialize the YAML file correctly to JSON and throws an exception. My YAML file looked similar to the following:

---
collections:
  - testing.ansible_testing_content
  - pulp.squeezer

Misleading error message: 'core>=3.10.dev is not available

Edit: The described behavior is "as designed", but we should rephrase the error message to point to user to the real issue, a server side version mismatch for a particular command.

Hello,

There is an error while running pulp repository list on latest stable pulp-cli version:

# /usr/local/bin/pulp rpm repository list
[
  {
    "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/b1dc7dc8-b540-496f-a8be-bf5b8aae3f5a/",
    "pulp_created": "2021-03-22T07:14:29.138535Z",
    "versions_href": "/pulp/api/v3/repositories/rpm/rpm/b1dc7dc8-b540-496f-a8be-bf5b8aae3f5a/versions/",
    "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/b1dc7dc8-b540-496f-a8be-bf5b8aae3f5a/versions/0/",
    "name": "infra_8",
    "description": null,
    "remote": null,
    "metadata_signing_service": null,
    "retain_package_versions": 0
  },
  {
    "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/54f63365-dd05-4b6f-9fca-a447f0ef3491/",
    "pulp_created": "2021-03-22T07:14:20.466037Z",
    "versions_href": "/pulp/api/v3/repositories/rpm/rpm/54f63365-dd05-4b6f-9fca-a447f0ef3491/versions/",
    "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/54f63365-dd05-4b6f-9fca-a447f0ef3491/versions/0/",
    "name": "centos_8_3_base",
    "description": null,
    "remote": null,
    "metadata_signing_service": null,
    "retain_package_versions": 0
  }
]

# /usr/local/bin/pulp repository list
Error: 'core>=3.10.dev is not available

# pip3 list installed | grep pulp-cli
pulp-cli (0.7.0)

Error: no such option: --base_url

pulp-cli-0.7.0

$ pulp config create --base_url "http://localhost"
Usage: pulp config create [OPTIONS]
Try 'pulp config create --help' for help.

Error: no such option: --base_url

It works if I specify some other option, e.g. --username.
pulp config create --base_url "http://localhost" is an example specified in docs.

pulp config refuses to work in case the config file is not valid

When the existing config file is not valid, not even editing the config file works:

$ pulp config edit              
Usage: pulp [OPTIONS] COMMAND [ARGS]...
Try 'pulp --help' for help.

Error: Invalid value for '--format': invalid choice: jsonn. (choose from json, yaml, none)

In this special case, pulp --format=json config edit helps.

In general though, if the config file fails to parse, it would be nice to get a warning and still be able to run the pulp config ... commands.

Autopublish support - file plugin

Support should be added for

  • setting the "repository" field on distributions (all of them, after the new distribution models are rolled out)
  • setting the "manifest" field on file repositories
  • setting the "autopublish" field on file repositories

pulp/pulp_file#492 (comment)

Show distribution information by base_path

I think it would be useful to be able to lookup a yum distribution by its base path, something like:

pulp rpm distribution list --base-path=FOO
or
pulp rpm distribution show --base-path=FOO

Repository version url is malformed

Run these commands:

pulp file repository create --name cli_test_file_repository
pulp file repository version show --repository cli_test_file_repository --version 0

You'll see for the repository version show command, there are 3 requests to the server:

[05/May/2021 13:59:38] "GET /pulp/api/v3/repositories/file/file/?name=cli_test_file_repository&offset=0&limit=1 HTTP/1.0" 200 552
[05/May/2021 13:59:38] "GET /pulp/api/v3/repositories/file/file/346223ec-10f3-414c-b9e6-e0bd777a7402/versions/0 HTTP/1.0" 301 0
[05/May/2021 13:59:39] "GET /pulp/api/v3/repositories/file/file/346223ec-10f3-414c-b9e6-e0bd777a7402/versions/0/ HTTP/1.0" 200 322

The first and third I expect. The second one I do not. Looks like the CLI is forming the href without the slash at the end.

`pulp <plugin> remote show --name β€œname”` fails with error

(.venv) vagrant@some-computer ~/pulp-cli $ pulp rpm remote show --name "Red_Hat_Enterprise_Linux_7_Server_-_Extras_RPMs_x86_64-32327"
Traceback (most recent call last):
  File "/home/vagrant/pulp-cli/.venv/bin/pulp", line 33, in <module>
    sys.exit(load_entry_point('pulp-cli', 'console_scripts', 'pulp')())
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/vagrant/pulp-cli/.venv/lib64/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/vagrant/pulp-cli/pulpcore/cli/common/generic.py", line 311, in show_by_name
    entity = entity_ctx.show(href)
  File "/home/vagrant/pulp-cli/pulpcore/cli/common/context.py", line 308, in show
    return self.pulp_ctx.call(self.READ_ID, parameters={self.HREF: href})
AttributeError: 'PulpRpmRemoteContext' object has no attribute 'READ_ID'

AttributeError: 'PulpFileRemoteContext' object has no attribute 'READ_ID'

I'm hitting this on 0.2.0:

$ git checkout 0.2.0
$ pulp file remote create --name test --url test
$ pulp file remote show --name test
Traceback (most recent call last):
  File "/usr/local/lib/pulp/bin/pulp", line 11, in <module>
    load_entry_point('pulp-cli', 'console_scripts', 'pulp')()
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/vagrant/devel/pulp-cli/pulpcore/cli/common/generic.py", line 57, in show_by_name
    entity = entity_ctx.show(href)
  File "/home/vagrant/devel/pulp-cli/pulpcore/cli/common/context.py", line 302, in show
    return self.pulp_ctx.call(self.READ_ID, parameters={self.HREF: href})
AttributeError: 'PulpFileRemoteContext' object has no attribute 'READ_ID'

Have json options accept json or a file

Provide a generic way to have json options accept json or a file.

We did this for file repository modify:

def _load_json_from_option(
ctx: click.Context,
option_name: Any,
option_value: str,
) -> List[Dict[str, str]]:
"""Load JSON from input string or from file if string starts with @."""
json_object: List[Dict[str, str]]
json_string: Union[str, bytes]
if option_value.startswith("@"):
json_file = option_value[1:]
try:
with click.open_file(json_file, "rb") as fp:
json_string = fp.read()
except OSError:
raise click.ClickException(f"Failed to load content from {json_file}")
else:
json_string = option_value
try:
json_object = json.loads(json_string)
except json.decoder.JSONDecodeError:
raise click.ClickException("Failed to decode JSON")
else:
return json_object

Feature: list objects by their associations and/or see "deeper" associations

It would be nice to see object associations without having to search around.

Example: See publications and distributions associated with a repo. For now you have to list the distributions, see what publications are associated, then look at the publication to see what repositories are associated.

Another example in a different direction: list repositories from a publication.

From a Katello developer's perspective, we do this all the time from the Rails console. Pretty much all of the associations you could wish for are there and it really helps with debugging.

`pulp <plugin> remote/distribution show --href` does not exist

It would be nice to view a remote or a distribution by the href, not just the name.

(.venv) vagrant@some-computer ~/pulp-cli $ pulp --client-cert /etc/pki/katello/certs/pulp-client.crt --client-key /etc/pki/katello/private/pulp-client.key rpm distribution show --help
Usage: pulp rpm distribution show [OPTIONS]

  Shows details of an entry

Options:
  --name TEXT  Name of the entry  [required]
  --help       Show this message and exit.

Misleading/unhelpful error message when requests are redirected

I spent quite some time this afternoon helping bmbouter debug a problem with his CLI. Basically, his CLI was pointing to http://localhost and whenever he submitted a POST request, he got a KeyError: '200'.

The issue turned out to be that his webserver was redirecting requests from http to https and thus POST :/pulp/api/v3/remotes/file/file was being turned into GET :/pulp/api/v3/remotes/file/file/ which returned a 200 response the cli didn't understand because it expected a 201 response.

Traceback (most recent call last):
  File "/usr/local/lib/pulp/bin/pulp", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/pulpcore/cli/common/generic.py", line 397, in callback
    result = entity_ctx.create(body=body)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/pulpcore/cli/common/context.py", line 389, in create
    result = self.pulp_ctx.call(
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/pulpcore/cli/common/context.py", line 137, in call
    result = self.api.call(operation_id, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/pulpcore/cli/common/openapi.py", line 284, in call
    return self.parse_response(method_spec, response)
  File "/usr/local/lib/pulp/lib64/python3.9/site-packages/pulpcore/cli/common/openapi.py", line 222, in parse_response
    response_spec = method_spec["responses"][str(100 * int(response.status_code / 100))]
KeyError: '200'

`

Need some docs on how The Magic works for a command-author

We've done a lot to make writing commands declarative and with as little boiler-plate as possible. This is great - but it can make writing new commands/changing existing ones, challenging for someone new to the codebase. It would be great if there were a short overview doc on "How It All Works", for would-be command-writers.

Using -b with async ansible commands errors or gives incorrect results

The '-b' or '--background' option runs commands without waiting for any tasks generated by the commands to complete. Some of the async ansible commands show the results of the tasks expecting them to be finished. Using the '-b' option skips the waiting causing them to error or show an incorrect result. The commands currently affected are:

  • distribution create & update
  • remote update
  • repository update

Solution:
Use the passed pulp_context to check if the '-b' option is set and then appropriately show the results of the task or not.

Intuitive workflow for adding content to repositories

The command repository add --name foo --filename "shelf-reader-0.1.tar.gz" is a little unintuitive, because you might think it's adding a repository, but it's adding content to a repository.

Would a reverse order work? pulp python repository --foo add --filename "shelf-reader-0.1.tar.gz"

Or maybe the names could be changed slightly?

pulp python repository add-content --repo-name foo --filename "shelf-reader-0.1.tar.gz"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.