Commit Graph

2495 Commits

Author SHA1 Message Date
Brian C. Lane
3fdc783850 docs: Fix Sphinx errors in docstrings 2019-10-16 13:52:54 -07:00
Brian C. Lane
a02538fdc3 vm.install: Turn on verbose output
Helps debug mock rebuild errors for the .src.rpm
2019-10-16 09:17:54 -07:00
Brian C. Lane
0eb01b84a8 tests: Switch the azure examples used in the lifted tests to use aws 2019-10-16 09:17:54 -07:00
Brian C. Lane
6f0473c742 Remove lifted azure support
The python modules that Ansible depends on for Azure support are old,
and incompatible with Fedora. Drop support until the azure playbook is
supported with Fedora packages.
2019-10-16 09:17:54 -07:00
Brian C. Lane
2fdcfc2e4c composer-cli: Add providers info <PROVIDER> command
This will print details about the settings for the provider, as well as
the supported image types.
2019-10-16 09:17:54 -07:00
Brian C. Lane
63816d9764 composer-cli: Fix error handling in providers push 2019-10-16 09:17:54 -07:00
Brian C. Lane
4256a1d4f2 composer-cli: Fix upload log output 2019-10-16 09:17:54 -07:00
Brian C. Lane
2a2313151b Add list to bash completion for composer-cli upload 2019-10-16 09:17:54 -07:00
Brian C. Lane
eee7a3e47d Update composer-cli documentation
Add documentation for the new upload and providers commands.
2019-10-16 09:17:54 -07:00
Brian C. Lane
b5df65f658 Add composer and lifted to coverage report 2019-10-16 09:17:54 -07:00
Brian C. Lane
3e9b56e66d composer-cli: Add starting an upload to compose start
This allows starting an upload once the image has been built.
2019-10-16 09:17:54 -07:00
Brian C. Lane
6a2f465217 composer-cli: Add providers template command
This outputs a TOML template of the settings needed for setting the
upload credentials. It can be passed to 'upload start' and to 'compose
start', as well as used to set the profile for 'providers push'
2019-10-16 09:17:54 -07:00
Brian C. Lane
1969711d8c bash_completion: Add support for new composer-cli commands 2019-10-16 09:17:54 -07:00
Brian C. Lane
4276a68cf3 composer-cli: Add support for providers command
Add commands for listing, saving, and adding new provider profiles.
Also adds a list command to upload.
2019-10-16 09:17:54 -07:00
Brian C. Lane
a414988ee8 composer-cli: Add support for upload command
This allows the user to start an upload, get info about a specific
upload, and to cancel, reset, or delete an upload.
2019-10-16 09:17:54 -07:00
Brian C. Lane
27a4165089 Increase ansible verbosity to 2 2019-10-16 09:17:54 -07:00
Brian C. Lane
c2620b0c85 lifted: Add support for AWS upload
This uses a new Ansible module, ec2_snapshot_import, which is included
here until it is available from upstream.

It will upload the AMI to s3, convert it to a snapshot, and then
register the snapshot as an AMI. The s3 object is deleted when it has
been successfully uploaded.
2019-10-16 09:17:54 -07:00
Brian C. Lane
a59c0241c4 lifted: Improve logging for upload playbooks
playbook errors are now logged, as well as errors encountered while
executing the playbook.
2019-10-16 09:17:53 -07:00
Brian C. Lane
146560b959 Add upload status examples to compose route docstrings 2019-10-16 09:17:53 -07:00
Brian C. Lane
b91d742ecb tests: Add tests for deleting unknown upload and profile 2019-10-16 09:17:53 -07:00
Brian C. Lane
b23c73e52c Add docstrings to the new upload functions in pylorax.api.queue 2019-10-16 09:17:53 -07:00
Brian C. Lane
d16e8f5bfc Change /compose/uploads/delete to /upload/delete
Remove the requirement to pass the compose uuid and the upload uuid --
only the upload uuid is needed.
2019-10-16 09:17:53 -07:00
Brian C. Lane
577c56ebaa tests: Add test for /compose/uploads/delete
Test deleting an upload from a compose.
2019-10-16 09:17:53 -07:00
Brian C. Lane
b307ff0430 tests: Add tests for /compose/uploads/schedule
Test it with a profile, and with one-time use settings. It does not
actually upload anything, it only tests that the upload is scheduled.
2019-10-16 09:17:53 -07:00
Brian C. Lane
0eda252d61 Add profile support to /uploads/schedule/
Pass in the name of a profile in the `profile` field, or pass in
one-time use settings in the `settings` object.
2019-10-16 09:17:53 -07:00
Brian C. Lane
fd2330c4b7 tests: Fix comments about V1 API results including uploads data 2019-10-16 09:17:53 -07:00
Brian C. Lane
acbf63013a lifted: Make sure inputs cannot have path elements
This processes the inputs with os.path.basename to strip off any path
elements and prevent potential path traversal attacks. Also adds a test.
2019-10-16 09:17:53 -07:00
Brian C. Lane
7396c272b2 Use consistent naming for upload uuids
Since we have both compose uuids and upload uuids they need to be
clearly named. This updates the upload naming to use 'upload_uuid' in
the inputs, and 'upload_id' in the output (_id instead of _uuid for
consistency with build_id naming in the status responses).

This also adds 'upload_id' to the /upload/log response.
2019-10-16 09:17:53 -07:00
Brian C. Lane
ade8945da3 tests: Add tests for new upload routes
This tests the routes for saving a profile, listing profiles, deleting
profiles, as well as composing with upload.

The composes run fake composes with upload data, one selects a profile
the other passes in the settings. No actual upload is done, but it tests
that the info, log, and cancel routes work.

This also updates the test setup to copy over the share/lifted directory
so that the providers are available to the tests.
2019-10-16 09:17:53 -07:00
Brian C. Lane
f8f06ccd23 Fix some docstrings in the v1 API 2019-10-16 09:17:53 -07:00
Brian C. Lane
fd55bee85d lifted: Make sure providers list is always sorted 2019-10-16 09:17:53 -07:00
Brian C. Lane
c384b687ba Add /upload/providers/delete route
This allows deleting a provider's profile. Pass the provider and profile
name like:

/api/v1/upload/providers/delete/azure/test-settings

A standard json response will be returned.
2019-10-16 09:17:53 -07:00
Brian C. Lane
b2fc391677 lifted: Add delete_profile function and tests
Also adds a helper to providers, _get_profile_path, so that the code
doesn't need to be repeated in all the functions.
2019-10-16 09:17:53 -07:00
Brian C. Lane
5d7aa95f2f Add support for starting a compose upload with the profile
This extends the /compose/ route to support uploading with either an
existing profile, or with one-time use settings passed in the POST.

To select a profile include the provider and profile, as returned by
`/uploads/providers`:

    "upload": {
      "image_name": "My Image",
      "provider": "azure",
      "profile": "production-azure-settings"
    }
2019-10-16 09:17:53 -07:00
Brian C. Lane
bc06abceab lifted: Add a function to load the settings for a provider's profile
This returns the settings after loading them and running verify_settings
on them.
2019-10-16 09:17:53 -07:00
Brian C. Lane
1030dd083c Fix pylint errors in lifted.upload 2019-10-16 09:17:53 -07:00
Brian C. Lane
de314a0046 tests: Add yamllint of the lifted playbooks 2019-10-16 09:17:53 -07:00
Brian C. Lane
4da569442c tests: Add tests for the new lifted module
These tests cover most of the module's functions, except for the queue
monitor, and the actual execution of the playbooks.
2019-10-16 09:17:53 -07:00
Brian C. Lane
45498f2b93 All providers should have 'supported_types'
even if it is empty.
2019-10-16 09:17:53 -07:00
Brian C. Lane
1b84f90963 lifted directories should be under share_dir and lib_dir
Otherwise passing --sharedir pointed to some other path will not use the
correct providers.
2019-10-16 09:17:53 -07:00
Brian C. Lane
1a6bc098d9 tests: Add tests for API v1
Output from some of these are different from API v0. Instead of mixing
the two this moved v1 tests into a new class - ServerAPIV1TestCase to
make them easier to maintain, and removes the v1 tests from
ServerAPIV0TestCase
2019-10-16 09:17:53 -07:00
Brian C. Lane
3a453eaad7 Make sure V0 API doesn't return uploads information
uploads should only be included in the V1 API routes, add `api`
selection to the relevant helper functions and calls to them from v0.py

Add new V1 routes with api=1 to include the uploads information in the
results.

Also add tests to ensure that V0 requests do not include uploads.
2019-10-16 09:17:53 -07:00
Evan Goode
2692e8138c Automatically upload composed images to the cloud
Currently, Azure, vSphere, and OpenStack are supported. See
https://github.com/weldr/lorax/pull/826 for more details about this new
feature.

I've called the upload library "lifted" as a reference to Seuss'
The Lorax -- in the book, the Lorax lifts himself up by the seat of his
pants through a hole in the smog clouds, and they start calling him the
"Lifted Lorax."

This adds new features to the /compose route under API v1
2019-10-16 09:17:53 -07:00
Evan Goode
584a2d2076 Add load and dump to pylorax.api.toml 2019-10-16 09:17:53 -07:00
Martin Pitt
a2c67385e4 Support CI testing against a bots project PR
* If `$COCKPIT_BOTS_REF` is set, check out that bots version instead of
   master.

 * Use git cache in $XDG_CACHE_HOME if available. Our CI uses that to
   save downloads, and it does not get in the way for local developers.

Adapted from https://github.com/cockpit-project/starter-kit/pull/233
2019-10-14 20:57:25 +02:00
Martin Pitt
29c308ae73 Makefile: Don't clobber an existing bots checkout
Commit 4643afa58 was a thinko -- for our CI we *don't* want our test to
clobber a pre-existing bots/ checkout, as we often use this to run tests
against an updated image or to validate a changes to the bots project.

On developer machines, bots may also be a symlink to an actual bots
directory in development, so don't clobber that.

Stop making "bots" a phony target, and drop the now unnecessary
`[ -d bots ]` check.

Adapted from https://github.com/cockpit-project/starter-kit/pull/232
2019-10-14 20:57:25 +02:00
Brian C. Lane
697233c14a lorax-composer: Handle RecipeError in commit_recipe_directory
A recipe that is valid TOML can still be an invalid recipe (eg. missing
the 'name' field) so this should also catch RecipeError.

Also added tests for this, as well as making sure commit_recipe_file()
raises the correct errors.

Resolves: rhbz#1755068
2019-10-04 08:07:36 -07:00
Brian C. Lane
3aac31482c test: Disable pylint subprocess check check
The return value for subprocess is already being checked, no need to use
check=True.
2019-09-30 18:11:46 -07:00
Brian C. Lane
6cebc3da88 Automatic commit of package [lorax] release [32.0-1].
Created by command:

/bin/tito tag --keep-version
2019-09-30 16:56:49 -07:00
Brian C. Lane
5efaa876e1 aarch64: Fix live-iso creation on aarch64
Drop unneeded uboot-tools, and remove iso-graft from the aarch64.tmpl

Related: rhbz#1752002
2019-09-25 11:07:20 -07:00