1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 12:45:57 +01:00

271 Commits

Author SHA1 Message Date
Brent Baude
2b744bfdbb Honor proxy usage
If HTTP[S]_PROXY is defined, honor it in python requests usage
as well as pass it on to skopeo.

If http[s]_proxy is defined in atomic.conf, use it; however, environment
variables will override these if defined.

Added --insecure to Atomic push so the user can override the logic
(or lack thereof) around deducing if a registry is insecure.  Also
needed for integration tests.

Closes: #964
Approved by: rhatdan
2017-04-13 16:13:07 +00:00
Brent Baude
f836bf82c4 Re-add check latest
Prior to refactoring, we had a check_latest method that would check
to see if the image being used by container was the latest image
by simply comparing hash IDs.

Adding this back in and refactoring into docker.py.

Closes: #938
Approved by: rhatdan
2017-03-16 13:45:32 +00:00
Brent Baude
153f4b077f Atomic/storage.py: Reduce number of times NoDockerDaemon is called
Instead of calling the default_docker_lib function a bunch of times
in the arg parser, we call it one and use the result in the parser.

Also, tighten up some exit conditions where self.d.close() is being
called when dockerd is not running.

Closes: #921
Approved by: rhatdan
2017-03-01 16:22:03 +00:00
Brent Baude
8fafc5feeb Account for API Changes in docker-py-2
The new 2.x version of the docker python API has non-backward
compatible changes.  These changes are described here:

https://docker-py.readthedocs.io/en/stable/change-log.html#breaking-changes

We need to account for docker.Client and docker.APIClient as well
as changes in the way kwargs are handled.  Also, it appears the
AutoVersion method is deprecated.

Closes: #894
Approved by: rhatdan
2017-02-21 14:17:51 +00:00
Brent Baude
ed9eaf2e55 Fix Stop Regression: BZ #1422448
BZ #1422448 actually points out one regression and one
bug related to atomic stop. The BZ itself points out
a TypeError exception in the code when trying to glue
together a python list and str.

Then the atomic stop command was failling in the case where a
STOP label was defined and it uses the variable $NAME resulting
in a subprocess exception.

The self.name variable was not being set by set_args after
refactoring occured.  Ideally, this should all be moved
into the image|container object handling but for now we
just handle it in set_args.

Also added a test in test_display to catch any future
regressions.

Closes: #899
Approved by: rhatdan
2017-02-20 20:37:38 +00:00
Lars Karlitski
dd182c19cd atomic_dbus: fix VulnerableInfo method
As of ef984ed, atomic.get_all_vulnerable_info() sometimes returns a JSON
object instead of a string.

Make it always return an object and amend its documentation.

Closes: #817
Approved by: baude
2017-02-06 16:53:24 +00:00
Brent Baude
b564751c01 Atomic/pull.py: Pull by Digest
Users wish to be able to pull images by digest.  This can be
done by docker and therefore parity is preferred.  The request
is described in https://github.com/projectatomic/atomic/issues/691.

$ atomic pull busybox@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
Pulling docker.io/busybox@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912 ...
Copying blob sha256:56bec22e355981d8ba0878c6c2f23b21f422f30ab0aba188b54f1ffeff59c190
 495.23 KB / 652.49 KB [=========================================>-------------]
Copying config sha256:e02e811dd08fd49e7f6032625495118e63f597eb150403d02e3238af1df240ba
 0 B / 1.43 KB [---------------------------------------------------------------]
Writing manifest to image destination
Storing signatures
 1.43 KB / 1.43 KB [===========================================================]
$ docker images
REPOSITORY                         TAG                                                                IMAGE ID            CREATED             SIZE
docker.io/busybox                  29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912   e02e811dd08f        3 months ago        1.093 MB

Note how the tag is populated with the digest.  Docker's default behaviour is
to populate the tag with nothing.  We cannot currently replicate that exactly.

Closes: #856
Approved by: baude
2017-02-01 20:02:00 +00:00
Brent Baude
c7aafb3314 Refactor Pull, Update, Install, Run
Refactor several of the atomic verbs and subverbs to take advantage
of object refactoring.

Also, do not pull images with skopeo if the local image is already
at the latest.

$ sudo python ./atomic --debug pull busybox
Namespace(_class=<class 'Atomic.pull.Pull'>, assumeyes=False, debug=True, func='pull_image', image='busybox', reg_type=None, storage='docker')
Latest version of busybox already present.

Closes: #825
Approved by: baude
2017-01-17 22:16:36 +00:00
yuqi-zhang
5cea34fc4a update: refactor into non-base verbs
Refactor:
  `atomic update`
  `atomic update --container`
  `atomic update --container --rollback`

To:
  `atomic images update`
  `atomic containers update`
  `atomic containers rollback`

And update corresponding tests, docs and auto-complete. Much like
other image commands (info, verify), the base verb is hidden but
still available for use.

Move update functionality from atomic.py to update.py, and use
new backendutils to abstract.

Signed-off-by: Yu Qi Zhang <jerzhang@redhat.com>

Closes: #773
Approved by: rhatdan
2016-12-12 21:56:55 +00:00
Antonio Murdaca
ff65a1e7d2 fix get auth from docker.io
Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Closes: #790
Approved by: rhatdan
2016-12-07 14:31:37 +00:00
Brent Baude
ef984ed066 Refactor images
Covers all but verify and generate.  This is a refactoring of the
images subverbs (i.e. info, version, delete, ...)

Added in a unittest for list and info.

Closes: #771
Approved by: baude
2016-11-29 21:47:05 +00:00
Dan Walsh
580bc2e460 Add substitutions for Opt variables
Closes: #734
Approved by: rhatdan
2016-11-26 12:04:34 +00:00
Brent Baude
a60a3fedad Atomic/atomic.py: Explore RepoTags for Fq name
In cases where the input name is not fully-qualified and
the local image is tagged more than once, we iterate repotags
in an attempt to figure out the fq name.  If this fails, we
raise a ValueError like before.

Closes: #718
Approved by: rhatdan
2016-10-24 14:56:28 +00:00
yuqi-zhang
fb3779349e Add --storage option to image-related commands
Add an optional --storage flag to the following commands:
 - images delete
 - info
 - mount
 - verify
 - version

If specified, the command will only look at the specified storage
(ostree/docker) for the image to perform the action. If not
specified, the command will look through both ostree/docker for
the image (as it was before). However, if the storage is not
specified and the image exists in both ostree and docker, the
command will error and prompt the user to specify. Image inspection
also no longer forces the user to delete/rename one or the other.

This is meant to address the duplicate naming issue (where a user
can have an image in both ostree and docker with the same name).

Signed-off-by: Yu Qi Zhang <jerzhang@redhat.com>

Closes: #720
Approved by: giuseppe
2016-10-24 09:27:00 +00:00
Brent Baude
9a0114c284 Atomic: Prune unused methods
Removing unused methods to reduce our code counts which will
come in handy when refactoring occurs.

Closes: #717
Approved by: rhatdan
2016-10-21 15:37:27 +00:00
Giuseppe Scrivano
41cc884b62 syscontainers: fix version
also now "version" returns None instead of raising an exception when
the Docker daemon cannot be reached.  This is needed so that atomic
can work without a docker daemon as well.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #711
Approved by: rhatdan
2016-10-18 12:16:57 +00:00
Brent Baude
112abcf2ac Atomic/info.py: Fix info and version
The atomic image version subcommand was broken.  Among the issues
was it called the wrong method, attempted to obtain the image
if not locally present, and outputted incorrect information. Some
of the problems were described in:

     https://github.com/projectatomic/atomic/issues/708

The version method has been redone to obtain the correct information.  It
no longer attempts to obtain the image if not present. It raises an
error.

Also, moved the version method into info and performed a pep8 clean up.

Example output now appears like:

```
atomic --debug version -r docker.io/busybox

IMAGE NAME                                     VERSION   IMAGE ID
10.3.11.254:5000/baude/busybox:latest          None      e02e811dd08f
  Tag: docker.io/busybox:latest
  Tag: localhost:5000/busybox:latest

atomic --debug version -r registry.access.redhat.com/rhel7/rsyslog

IMAGE NAME                                               VERSION                IMAGE ID
registry.access.redhat.com/rhel7/rsyslog:latest          rhel7/rsyslog-7.2-21   53f20e902da7
registry.access.redhat.com/rhel7.2:7.2-56                rhel7/rhel-7.2-56      1a9b3357bac5

```

Closes: #710
Approved by: baude
2016-10-14 19:53:03 +00:00
Brent Baude
4aa4318c29 decompose: Add ability to decompose image w/digest
Adding the ability to decompose an input image "name" that
includes a digest. For example:

docker.io/library/fedora@sha256:64a02df6aac27d1200c2572fe4b9949f1970d05f74d367ce4af994ba5dc3669e

Also, reword the decompose method in a Decompose class.  This simplifies the use of
decomposition and allows for growth.

Example usage:
   registry, repo, image, tag, digest = Decompose("docker.io/library/busybox:latest").all
   repo = Decompose("docker.io/library/busybox:latest").repo
   digest = Decompose("docker.io/fedora@sha256:64a02df6aac27d1200c2...67ce4af994ba5dc3669e").digest

Closes: #701
Approved by: rhatdan
2016-10-13 12:23:37 +00:00
yuqi-zhang
8bf20755dd version: fix atomic version error
Add extra check to prevent errors for image IDs without repo name.
Before, when a user invokes "atomic version" on such an ID, it
returns "List index out of range" instead of label information
that exists.

Signed-off-by: Yu Qi Zhang <jerzhang@redhat.com>

Closes: #696
Approved by: rhatdan
2016-10-11 20:14:00 +00:00
Brent Baude
adc8956f50 Allow pull from registry not in docker conf
We now allow pulls from registries that are not in
the docker configuration file.  This altered our
decompose method a bit.  We now check the registry
in decompose to see if it resolves on the network.
If so, then we use it.

Closes: #693
Approved by: baude
2016-10-11 13:23:58 +00:00
Brent Baude
aa59a5e285 Introduce registry inspect methods
Add two classes and several new methods for inspecting
registries and images.  These methods are helpful
for:

* taking user input (i.e. image names, partial image names) and determining
the fully qualified names.
* determining the fq name when the registry is omitted by the user.
* obtaining image manifests
* mimicing skopeo inspect

Closes: #687
Approved by: baude
2016-10-07 19:54:35 +00:00
Giuseppe Scrivano
f596f1205a syscontainers: rename some functions
they are part of the class SystemContainers, do not repeat
system_container in the name.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #683
Approved by: rhatdan
2016-10-06 11:07:34 +00:00
Brent Baude
e83c2c5dd8 Atomic.util: More robust decompose
Colleagues asked for decompose to be improved to where it took
an image name and broke it into registry, repo, image, and tag.
It also should mimic docker's implementation where 'library' is a known
exception

Also added unittests for decompose.  Removed a singular glob  test
as it is no longer valid

Closes: #677
Approved by: rhatdan
2016-10-05 17:00:11 +00:00
Brent Baude
18f499df51 Atomic/push.py: Don't prompt for password if token found
If the user has a token for the registry, we assume the token
is good and do not prompt for a username or password.

Closes: #675
Approved by: rhatdan
2016-10-04 14:54:53 +00:00
Brent Baude
d7af4a1307 Atomic update and install: Use skopeo for pulling
Atomic update and install now use skopeo for pulling images
from registries.  This allows us to enforce signature policies
as part of pull and update operations.

Closes: #672
Approved by: rhatdan
2016-10-03 12:06:22 +00:00
Dan Walsh
83d87d55c9 cmd_env() should not modify the current process environ
Create a copy of os.environ and then modify the copy.
Also add a new function expandvars to util.  This function is a
copy of os.path.expandvars but takes an optional parameter of the
environment to expand.

Closes: #521
Approved by: cgwalters
2016-09-05 12:56:55 +00:00
Brent Baude
683c0fac9b Introduce signing
Allow atomic users to sign an images that has been pulled
from a repository.  This uses GPG, skopeo, and friends and
creates a local signature file for a image that has been
pulled locally.  Signatures are stored in the dir:

/var/lib/atomic/containers/registry/image_name@sha256:image_id/

Individual signature files are then stored as:

  ../signature-(INTEGER)

where INTEGER is incremented each time a signature
is added.

Closes: #539
Approved by: baude
2016-09-02 17:11:28 +00:00
Dan Walsh
9d34ff22ec This function is only used by images so moving to images.py
Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
ab97c274dc Move SPC_ARGS and RUNC_ARGS to run.py
Want to consoldate constants to module that they are used in.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
e32d8692ad Split out atomic pull functions into their own source file.
Create a Pull class as a subclass of Atomic and move all of the
functions and CLI to this file.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
36a919e0d5 Split out atomic push functions into their own source file.
Create a Push class as a subclass of Atomic and move all of the
functions and CLI to this file.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
3475042c3e Move atomic version handling to the info.py file
Since this is just a fancy way of doing info, it should be handled in
info.py.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
dcbb737a18 Split out atomic uninstall functions into their own source file.
Create a Uninstall class as a subclass of Atomic and move all of the
functions and CLI to this file.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
b0e76bdc32 Split out atomic install functions into their own source file.
Create a Install class as a subclass of Atomic and move all of the
functions and CLI to this file.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
b7807eb6ff Split out atomic info functions into their own source file.
Create a Info class as a subclass of Atomic and move all of the
functions and CLI to this file.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Dan Walsh
936ccb170f Split out atomic host functions into their own source file.
Create a Host class as a subclass of Atomic and move all of the
functions and CLI to this file.

Closes: #570
Approved by: baude
2016-09-01 19:02:07 +00:00
Giuseppe Scrivano
5fec4354e1 syscontainers: generate the same name for user containers
and use only the last name component:

i.e. previously installing the image "gscrivano/etcd used by default the
name "gscrivano-etcd".  Change it to be "etcd" by default.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #559
Approved by: rhatdan
2016-08-30 11:28:22 +00:00
Giuseppe Scrivano
39c347f825 images: add an image_id field to JSON output
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #549
Approved by: cgwalters
2016-08-22 17:52:32 +00:00
Jan Pazdziora
f97e97f172 Add support for LABEL RUN_OPTS_FILE and ${RUN_OPTS}
Closes: #541
Approved by: rhatdan
2016-08-19 13:02:26 +00:00
Dan Walsh
45ec779178 Move generate from atomic verify to atomic images
Also breakout images handling into a separate python file.

Atomic/images.py

I have switched atomic images generate to generate an images
mtree file for each image in the system.

Closes: #534
Approved by: giuseppe
2016-08-16 08:03:19 +00:00
Giuseppe Scrivano
ecec183c81 install: block NoDockerDaemon exception
_inspect_container and _inspect_image do not raise an exception
if they cannot connect to Docker.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #524
Approved by: rhatdan
2016-08-09 17:00:29 +00:00
Giuseppe Scrivano
56b59573ab atomic: add support for user containers
Support containers that are stored an OSTree repository and executed
using bubblewrap.  bwrap-oci is used to convert the OCI configuration
file to the bubblewrap command line.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #524
Approved by: rhatdan
2016-08-09 17:00:29 +00:00
Giuseppe Scrivano
1d987bfda0 images: system images honor --all
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #514
Approved by: rhatdan
2016-08-04 11:50:09 +00:00
Giuseppe Scrivano
c367f7d9d7 syscontainers: use the ID from Docker instead of the OSTree rev
To find the ID for an image, try in order:

1) Digest from the docker.manifest metadata
2) $SHA if $SHA in ociimage/$SHA is a valid checksum
3) OSTree commit

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #506
Approved by: rhatdan
2016-08-04 10:03:20 +00:00
Giuseppe Scrivano
c45fdb6d1a systemcontainers: add functions for image inspection
It returns the information in a similar way to the Docker inspect
format.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #506
Approved by: rhatdan
2016-08-04 10:03:20 +00:00
yuqi-zhang
24f79bb5cc images: fix missing --all support
Closes: #511
Approved by: cgwalters
2016-08-03 18:45:31 +00:00
AmartC
14f613eb23 DBus API to retrieve images data and vulnerability information
images now either print to tty or return json data via dbus

Make encoding and decoding work properly for both Python2 and Python3

Create Cockpit JavaScript test client that will call the DBus API
and receive information.

Closes: #494
Approved by: rhatdan
2016-07-29 19:08:27 +00:00
yuqi-zhang
6fcfea443d images: add more sub-commands to images
Add the following sub-commands to "atomic images list"

  --all: show all images, including intermediate images

  --filter: filter output based on given filters

  --quiet: only display image IDs

and corresponding bash auto-complete, tests, and documentation.

Closes: #502
Approved by: rhatdan
2016-07-29 12:19:21 +00:00
Giuseppe Scrivano
896b90d08c atomic: fix a few file descriptors leaks
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #503
Approved by: cgwalters
2016-07-29 10:50:54 +00:00
Daniel J Walsh
3d1835044c Merge pull request #483 from mtohmaz/master
Atomic now has --user flag.
2016-07-26 10:47:23 -04:00