pulp/pulp — pull request #400 by jdob (2013-03-21 19:57:51+00:00)
Title: Updated the copy command to support polling the task

Comments in order not by importance but rather how the files appear in the Files Changes tab...

The bindings change is because recursive doesn't belong in there, it's a yum importer only concept. Expect to find that in the associated pulp_rpm PR.

The changes to the super calls in various __init__ implementations is because I needed to have a command with both criteria and polling capabilities and the super calls were making python angry.

The copy command changed less than the diff makes it appear. The idea is consistent with recent trends in these reusable commands. The run method provides hooks (described later) but otherwise should suffice for most uses. It will automatically poll the created task using the functionality in PollingCommand (which means it accounts for rejected, postponed, etc.)

There are three ways to customize the copy command. As I write this, I realize this should be in the docstring for the class and will put it there after I submit this:
* Upon instantiation, the command can be scoped to a particular type ID. This is used in the RPM commands for things like "copy rpm" v. "copy errata".
* The modify_user_input is the way of introducing things into the criteria. This looks a bit odd because the criteria generation isn't done until inside of the bindings, so without changing that, the way to influence it is to affect the user arguments. All of the standard criteria arguments will be in the user input and then parsed in the bindings, so this method lets you manipulate them. Let me know if that's not clear, I don't think I described it right.
* The generate_override_config method is a more typical hook. The user input is provided and can be used to take any extra options added by the subclass and turn them into the override config the importer will act on. The easiest example here is that the RPM commands add a --recursive flag that an overridden implementation of this method will convert into the options the yum importer will look at to know if it should be recursive.

I'm hoping the docstrings for those last two methods are clear enough, but I'm open to suggestions.

This isn't the complete copy command changes. I still need to add a --bg option to not poll, ways to list the existing tasks, etc. Right now this change will remove the lame "Please go follow the task to see what happened" with our standard polling approach, so scope your expectations accordingly.

The last few files are the unit tests for the copy command and a small addition/test to the task simulator.

There will be corresponding PRs in both pulp_rpm and pulp_puppet to deal with the changes.