summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* sources: Set default format with a constantRadostin Stoyanov2017-08-032-2/+4
|
* tests: Add unit tests for the "utils" moduleRadostin Stoyanov2017-07-241-0/+699
|
* tests: Add unit tests for "progress" moduleRadostin Stoyanov2017-07-241-0/+112
|
* tests: Add unit tests for FileSourceRadostin Stoyanov2017-07-241-0/+171
|
* tests: Add unit tests for DockerSourceRadostin Stoyanov2017-07-241-0/+602
|
* tests: Add unit tests for 'virt_bootstrap' moduleRadostin Stoyanov2017-07-242-0/+503
|
* Use tox to test against multiple Python versionsRadostin Stoyanov2017-07-243-0/+25
| | | | | 'Tox' is tool that will check if the package installs correctly and all unit tests pass with different Python versions.
* Add support for setting root passowrd in qcow2Radostin Stoyanov2017-07-242-9/+32
| | | | | For containers bootstrapped in qcow2 format use the tool 'virt-edit' to insert the hashed root password in the shadow file of the last layer
* DockerSource: Show correct err msg on skopeo failRadostin Stoyanov2017-07-241-1/+1
| | | | | The first argument of CalledProcessError() must be the returncode not the command.
* DockerSource: Fix formula of download progressRadostin Stoyanov2017-07-241-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | When downloading image with multiple layers, the download progress value of every following layer should not start from 0. If we have 10 layers, downloading each of them should increase the total download progress by 10%. Assuming that the download and extraction are 50/50 of the total work. Then, downloading each of 10 layers will increase the progress value with 5% of the total work. When all layers are downloaded the progress value should be 50%. However, with the current formula the progress value of each layer starts from 0%. (E.g. when downloading 2nd layer of 10 the download progress starts from 0% instead of 5%.) This bug can be seen when downloading images with multiple layers of large size. Example: virt-bootstrap docker://rails /tmp/foo --status-only
* tests: Add test suiteRadostin Stoyanov2017-07-243-1/+16
|
* Add remapping ownership of files in rootfsRadostin Stoyanov2017-07-241-5/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Libvirt creates LXC container with enabled user namespace the ownership of files in the container should be mapped to the specified target UID/GID. The implementation of the mapping is inspired by the tool uidmapshift: http://bazaar.launchpad.net/%7Eserge-hallyn/+junk/nsexec/view/head:/uidmapshift.c Mapping values can be specified with the flags: --idmap Map both UIDs/GIDs --uidmap Map UIDs --gidmap Map GIDs Each of these flags can be specified multiple times. Example: virt-bootstrap docker://fedora /tmp/foo --uidmap 0:1000:10 --gidmap 0:1000:10 Will map the ownership of files with UIDs/GIDs: 0-9 to 1000-1009 The same result can be achived with: virt-bootstrap docker://fedora /tmp/foo --idmap 0:1000:10 Multiple mapping values can be specified as follows: virt_bootstrap.py docker://ubuntu /tmp/foo --idmap 0:1000:10 --idmap 500:1500:10 This will map the UID/GIDs: 0-9 to 1000-1009 and 500-509 to 1500-1509
* Update argument helpersRadostin Stoyanov2017-07-211-7/+4
|
* Specify logger name when executed directlyRadostin Stoyanov2017-07-211-1/+1
|
* readme: Fix typoRadostin Stoyanov2017-07-211-1/+1
|
* Drop need of root privileges to set root passwordRadostin Stoyanov2017-07-213-15/+41
| | | | | | | | | | | | | | These changes aim to avoid the requirement for root privileges when setting the password of root user on root file system. The "-R, --root" flag of chpasswd is using chroot to apply changes in root file system and this requires root privileges. [1] Instead compute hash of the root password using passlib [2] and insert the value in the /etc/shadow file in the rootfs. [1] https://en.wikipedia.org/wiki/Chroot#Limitations [2] http://passlib.readthedocs.io/en/stable/lib/passlib.hosts.html
* DockerSource: Add support for Manifest version 1Radostin Stoyanov2017-07-212-5/+20
| | | | | | | | | | | | | | | | Handle differences between version 1 and 2 of the Manifest file for Docker registry. Layers' blob sums in v1 are stored in a list "fsLayers" and the digest is stored in following filed with name "blobSum". [1] In v2 the layer list is stored in field with name "layers" and ordered starting from the base image (opposite order of v1). The digest is stored under a following field with name "digest". The size in bytes is included in a field with name "size". [2] [1] https://docs.docker.com/registry/spec/manifest-v2-1/#manifest-field-descriptions [2] https://docs.docker.com/registry/spec/manifest-v2-2/#image-manifest-field-descriptions
* Python 3/2 compatibility: Convert Byte-str to StrRadostin Stoyanov2017-07-212-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Encoded Unicode in Python 3 is represented as binary data. The difference with Python2 is that any attempt to mix text and data in Python 3.0 raises TypeError, whereas if you were to mix Unicode and 8-bit strings in Python 2.x, it would work if the 8-bit string happened to contain only 7-bit (ASCII) bytes, but you would get UnicodeDecodeError if it contained non-ASCII values. Reference: https://docs.python.org/release/3.0.1/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit Example: Python 2: >>> b'foo.bar'.split('.') ['foo', 'bar'] Python 3: >>> b'foo.bar'.split('.') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: a bytes-like object is required, not 'str' >>> b'foo.bar'.split(b'.') [b'foo', b'bar']
* DockerSource: Don't calc progress on short linesRadostin Stoyanov2017-07-181-0/+3
| | | | | Perform additional check of the input to avoid unexpected behaviour when string is passed instead of list or a list with short length.
* DockerSource: Remove '/' at the end of URIRadostin Stoyanov2017-07-181-1/+1
| | | | | | | | | This change aims to convert URI: docker:///repository/my_image/ to: docker://repository/my_image
* DockerSource: Encapsulate URI generationRadostin Stoyanov2017-07-181-14/+19
| | | | This change makes it easier to test the code.
* DockerSource: Encapsulate layers' info retrievalRadostin Stoyanov2017-07-181-3/+9
| | | | This change makes it easier to test the code.
* sources: Update doc stringsRadostin Stoyanov2017-07-181-2/+9
|
* utils: bytes_to_size remove trailing spaceRadostin Stoyanov2017-07-181-1/+1
| | | | | Remove traling space which occurs when the number is smaller than kibibyte.
* utils: size_to_bytes convert from intRadostin Stoyanov2017-07-181-2/+2
| | | | | | | | | | | | When converting 0 KB with string input the result will be string with zeroes. >>> print(size_to_bytes('0', 'KB')) 000000... Instead convert the string input to integer and then perform the conversion. Rename the variable from "string" to "number" to avoid confusion.
* Add script to run virt-bootstrap for hackersCédric Bosdonnat2017-07-182-0/+29
| | | | | | | run script takes care of setting the environment variables (only PYTHONPATH so far) needed to run virt-bootstrap without installing it. This wrapper script works in the same fashion than the ones in virt-manager or libvirt projects for consistency.
* DockerSource: Ignore short lines from skopeoRadostin Stoyanov2017-07-051-2/+2
| | | | | Avoid parsing short lines when detecting download progress from skopeo's output.
* Rename format_number() into bytes_to_size()Cédric Bosdonnat2017-07-051-2/+2
| | | | rename the function to match its counterpart size_to_bytes().
* Gather common utility functions in "utils" moduleRadostin Stoyanov2017-07-053-334/+369
| | | | | | Add new module to collect utility functions used in virt-bootstrap. Move the function definitions from "sources" and "virt_bootstrap" to the new module.
* get_image_details: Use connection optionsRadostin Stoyanov2017-07-051-4/+13
| | | | | Pass the "not_secure", "username" and "password" values to "skopeo inspect" when manifest is retrieved.
* Detect and log download progress of layersRadostin Stoyanov2017-07-051-1/+136
| | | | | | | | | | Parse skopeo's output messages to detect and log the donwload progress for each layer and update the progress of virt-bootstrap. Example: virt-bootstrap docker://ubuntu /tmp/foo --status-only Status: Downloading layer (2/5), Progress: 25.30%
* Add --status-only flagRadostin Stoyanov2017-07-051-3/+29
| | | | | When this flag is passed only the current state of virt-bootstrap will be shown along with the total bootstrap progress.
* Add new module to store the progressRadostin Stoyanov2017-07-053-21/+108
| | | | | | | | | | | | | | | | | | | | This module is used to store the progress of the bootstrap process and could be used by other applications to get status of virt-bootstrap as well as percentage of completion. Convert some info messages to use this new system for a clean reporting in client applications. Example usage: import virtBootstrap def show_progress(data): print("Status: %s, Progress: %.2f" % (data['status'], data['value'])) virtBootstrap.bootstrap(uri='docker://ubuntu', dest="/tmp/test1", progress_cb=show_progress)
* checksum: Log failuresRadostin Stoyanov2017-07-051-2/+8
|
* Remove redundant checksum verificationRadostin Stoyanov2017-07-051-10/+2
| | | | | | | | The checksum verification of downloaded layers is already done in the method validate_image_layers() or "skopeo copy" [1] [2]. [1] https://github.com/containers/image/blob/master/copy/copy.go#L352 [2] https://github.com/containers/image/blob/master/copy/copy.go#L358
* DockerSource: Use downloaded layersRadostin Stoyanov2017-07-051-1/+23
| | | | | | | | Do not call "skopeo copy" if layers were downloaded and have valid hash sum. Although, "skopeo copy" already does such check for us this change allow us to control the output and avoids spawning a binary.
* DockerSource: Encapsulate skopeo copy in a methodRadostin Stoyanov2017-07-051-19/+25
|
* Compact layers' details passed to extract methodsRadostin Stoyanov2017-07-051-24/+25
| | | | | | | | | Improve maintainability by putting layers' digest, sum_type, size and file_path in a list which is then passed to extract methods. This change replaces the function get_layer_info(). Reduce the amount of duplicated code by taking out the logging calls in a method.
* Log the size of layers when extractingRadostin Stoyanov2017-07-051-2/+26
|
* DockerSource: Retrieve manifest before downloadRadostin Stoyanov2017-07-041-6/+21
| | | | | | | | | | | | | Get manifest of Docker image before the calling "skopeo copy" command. The aim of this change is to: - Make available method get_image_details() which could be used to get information about Docker image or detect whether Docker URI is valid and accessible. - Get information about the layers before the download process (skopeo copy) is called.
* DockerSource: Use getter for image directoryRadostin Stoyanov2017-07-041-15/+23
| | | | | Make the method for getting image directory reusable and use instance variable to store the path where image layers will be stored.
* Improve URI parse of DockerSourceRadostin Stoyanov2017-07-041-7/+12
| | | | | | | | | | | Decrease the number of instance attributes of class DockerSource. Since variables "image" and "registry" are only used to create valid Docker URI they could be used as local variables instead of instance attributes to improve encapsulation. Add comments to improve readability. Fix problem with invalid docker URLs
* bootstrap: Use explicit argumentsRadostin Stoyanov2017-07-042-34/+48
| | | | | | | | | | | | | Specify explicitly the arguments of bootstrap method. This change allows to easily bootstrap a container from another python application when the module virtBootstrap is imported. Example: import virtBootstrap virtBootstrap.bootstrap(uri="docker://fedora", dest="/tmp/foo")
* Expose bootstrap method from virtBootstrap moduleRadostin Stoyanov2017-07-041-0/+26
| | | | | | | | | This allows other python applications to import the virtBootstrap module and call the bootstrap() method. Example: >>> import virtBootstrap >>> virtBootstrap.bootstrap()
* Improve help menuRadostin Stoyanov2017-07-011-4/+2
|
* Set logger name/format/levelRadostin Stoyanov2017-07-012-28/+60
| | | | | | This patch aims to set logger name for the virtBootstrap module. Set logging format to: %(levelname)s: %(message)s and use an elegant way of setting log level.
* Check for write permissions on destination pathRadostin Stoyanov2017-07-011-0/+3
|
* Auto-correct docker source URIRadostin Stoyanov2017-06-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | Skopeo does not accept "docker:///" as valid URI format. [1] However, driver URIs within the Libvirt project and virtualization tools such as libvirt-sandbox use three slashes after URI scheme. [2] Make virt-bootstrap auto-correct the source URI for consistency with other tools. Following the syntax specifications in RFC 1808, "urlparse" recognizes a netloc only if it is properly introduced by ‘//’. [3] Otherwise the input is presumed to be a relative URL and thus to start with a path component. [4] - "self.image" is the path component - "self.registry" is the netloc component [1] https://github.com/projectatomic/skopeo/blob/master/docs/skopeo.1.md#skopeo-copy-1 [2] http://libvirt.org/uri.html [3] https://docs.python.org/2/library/urlparse.html [4] https://hg.python.org/cpython/file/2.7/Lib/urlparse.py#l187
* Resolve pylint issuesRadostin Stoyanov2017-06-282-3/+6
|
* Refactor info messagesRadostin Stoyanov2017-06-281-6/+12
| | | | | | | Update logged messages to provide information about the current state of virt-bootstrap. E.g "Downloading container image" or "Extracting layer (1/5)"