Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Commit

Permalink
iQIcBAABAgAGBQJXl4HqAAoJECY9bfLhY+HqrLwP/R4HjkMURTKdkMVqfPFklTQd
Browse files Browse the repository at this point in the history
 DhhPRwdholRaXs192P0FFFPmLjNGB2VZzsNRpWhhNMt27Bkt8ivkxlcFW8OJoCmE
 3Fs/l9hAYgf5NvIUISIVNUxoN2vd5gIczgm5FH7ZNN4J4a3j9PX8dpzmz+kjzfUL
 ZZjhZdcfDnd/4rb4pDrZ248wprUlzLu0mLpm9qeUgnRZqSHfx1zvPu9VgIPMq+jK
 Bta7NVC4uVWv9tLd74KmTeGT/hfzbjfsmjutw+qdIsnp80xJ6jhvQx+VMhF6C/cN
 4f4GTV5B0t1i0Jc1vrgyfqyqCN5XpqTS1dgp8Bx80Pa36Eok1JmzGw0gsgJ/tpEE
 TiZTVe83EGDF/esZy2KfpnvAqIjoBRm/SuDMOHhQ8RnTfOmqY1eV0hQ1ZsfKyDUs
 6gHmYgOEv+EWUM0PqyZ3UfgbOjSS626u3JGPxBwVVdDbeeW3ptsST8FlEhB+6MXf
 +g0W8ho44NL7j/PN6c5mdIEIFvjwphQ8PCPKtGA2Uc489RMaHME1miMd4rl5hyBO
 ed5fKB4qp9DeC8VWIQEz0ALtj3u0UvSGYAXMlSlnvSnwl5tu8dw7xpGqiNJQEDni
 +FnBNuBwcn/6HsDDoBP6eeiMkA4uFUnsa50bJsUKiuTQM0DF7nc8Y6lrLVmK8Iur
 X0Q8d1mZ8psYHLzSh/bQ
 =blTC
 -----END PGP SIGNATURE-----

delete: support images from the OSTree repository

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

Closes: #497
Approved by: jlebon
  • Loading branch information
giuseppe authored and rh-atomic-bot committed Jul 26, 2016
1 parent 08f833d commit f4282f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
19 changes: 11 additions & 8 deletions Atomic/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ def _delete_remote(self, targets):
def _delete_local(self, targets):
results = 0
for target in targets:
try:
self.d.remove_image(target)
except NotFound as e:
util.write_err("Failed to delete Image {}: {}".format(target, e))
results = 2
except APIError as e:
util.write_err("Failed operation for delete Image {}: {}".format(target, e))
results = 2
if self.syscontainers.has_system_container_image(target):
self.syscontainers.delete_image(target)
else:
try:
self.d.remove_image(target)
except NotFound as e:
util.write_err("Failed to delete Image {}: {}".format(target, e))
results = 2
except APIError as e:
util.write_err("Failed operation for delete Image {}: {}".format(target, e))
results = 2
return results
11 changes: 11 additions & 0 deletions Atomic/syscontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,17 @@ def get_system_containers(self):
ret.append(container)
return ret

def delete_image(self, image):
repo = self._get_ostree_repo()
if not repo:
return
imagebranch = SystemContainers._get_ostree_image_branch(image)
commit_rev = repo.resolve_rev(imagebranch, True)
if not commit_rev[1]:
return
ref = OSTree.parse_refspec(imagebranch)
repo.set_ref_immediate(ref[1], ref[2], None)

def get_system_images(self, repo=None):
if repo is None:
repo = self._get_ostree_repo()
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_system_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.0
test \! -e ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.1

# check that there are not any "ociimage/" prefixed branch left after images prune
ostree --repo=${ATOMIC_OSTREE_REPO} refs --delete "ociimage/atomic-test-system-latest"
ostree --repo=${ATOMIC_OSTREE_REPO} refs --delete "ociimage/busybox-latest"
${ATOMIC} images delete -f atomic-test-system
${ATOMIC} images delete -f busybox
${ATOMIC} images prune
OUTPUT=$(! ostree --repo=${ATOMIC_OSTREE_REPO} refs | grep -c ociimage)
if test $OUTPUT \!= 0; then
Expand Down

0 comments on commit f4282f0

Please sign in to comment.