1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 03:45:28 +01:00
Files
atomic/Atomic/uninstall.py
Yu Qi Zhang 14e878dbfc Fix tests for f26
Fix test failures after updating papr to test with f26 atomic/cloud
images instead of f25, with the following changes:

1. Remove dependency on docker hub tester image. Instead, mimic
what ostree/rpm-ostree does and use a recursive .papr.sh script
to install the necessary packages to the base f26 image in the
fedora registry. This fixes tests on the atomic host since python3.6
is being used, and prevents future tests from testing the wrong
version. (Note this is slightly slower due to having to install
packages during the test rather than using a pre-built image).

2. Fix some pylint errors, and mask others for now

3. Fix failing integration tests due to inter-test interference

4. Remove unnecessary deepcopy in container filter

5. Add compatibility for both c-s-s and d-s-s in storage

6. Update expected sha256 values for dockertar test

Remaining issues:

1. test_storage should possibly be reworked. The current test
setup is conflicting with the new default of overlay as a driver.
For now, the test for generated d-s-s is disabled.

2. some storage commands are still using "docker-storage-setup"
instead of "container-storage-setup". There is a backward
compatible check in place that should be reworked in the future

3. some masked pylint errors should be further investigated

4. keep the dockerfile for the project atomic tester image for now
(bump to 26), since its a little easier and faster to set up with

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

Closes: #1076
Approved by: baude
2017-08-23 18:33:48 +00:00

70 lines
3.0 KiB
Python

import argparse
from . import util
from .util import add_opt
from .install import INSTALL_ARGS
from Atomic.backendutils import BackendUtils
import sys
from Atomic.backends._ostree import OSTreeBackend
try:
from . import Atomic
except ImportError:
from atomic import Atomic # pylint: disable=relative-import
ATOMIC_CONFIG = util.get_atomic_config()
_storage = ATOMIC_CONFIG.get('default_storage', "docker")
def cli(subparser):
# atomic uninstall
uninstallp = subparser.add_parser(
"uninstall", help=_("execute container image uninstall method"),
epilog="atomic uninstall attempts to read the LABEL UNINSTALL "
"field in the image, if it does not exist atomic will "
"remove the image from your machine. You could add a "
"LABEL UNINSTALL command to your Dockerfile like: 'LABEL "
"UNINSTALL %s'" % Uninstall.print_uninstall())
uninstallp.set_defaults(_class=Uninstall, func='uninstall')
add_opt(uninstallp)
uninstallp.add_argument("-n", "--name", dest="name", default=None,
help=_("name of container"))
uninstallp.add_argument("-f", "--force", default=False, dest="force",
action="store_true",
help=_("remove all containers based on this "
"image"))
uninstallp.add_argument("--display", default=False, action="store_true",
help=_("preview the command that %s would execute") % sys.argv[0])
uninstallp.add_argument("image", help=_("container image"))
uninstallp.add_argument("--storage", dest="storage", default=None,
help=_("Specify the storage. Default is currently '%s'. You can change the default "
"by editing /etc/atomic.conf and changing the 'default_storage' field." % _storage))
uninstallp.add_argument("args", nargs=argparse.REMAINDER,
help=_("Additional arguments appended to the "
"image uninstall method"))
class Uninstall(Atomic):
def __init__(self): # pylint: disable=useless-super-delegation
super(Uninstall, self).__init__()
def uninstall(self):
if self.args.debug:
util.write_out(str(self.args))
beu = BackendUtils()
try:
be, img_obj = beu.get_backend_and_image_obj(self.args.image, str_preferred_backend=self.args.storage)
except ValueError as e:
if 'ostree' in [x().backend for x in beu.available_backends]:
ost = OSTreeBackend()
img_obj = ost.has_container(self.args.image)
if not img_obj:
raise ValueError(e)
be = ost
be.uninstall(img_obj, name=self.args.name, atomic=self, ignore=self.args.ignore)
return 0
@staticmethod
def print_uninstall():
return "%s %s %s" % (util.default_docker(), " ".join(INSTALL_ARGS), "/usr/bin/UNINSTALLCMD")