Hide Forgot
Created from redmine issue http://projects.theforeman.org/issues//9518
Need to be able to create containers from content views through the API
Moving to POST since upstream bug http://projects.theforeman.org/issues/9518 has been closed
This requires: https://github.com/theforeman/foreman-docker/pull/93 moving back to ASSIGNED
It is not possible to verify this until BZ #1217603 is resolved.
What fields should be passed in order to create a container from a content view or a repository? I should use "container[repository_name]" field in order to do that? An example should help a lot because the API docs are not clear enough.
Yes you need to use container repository name . $ hammer repository list --content-type=docker --organization-id=1 --content-view=cv --environment dev ---|------------------------------------------------------------|--------------------------|--------------|---- ID | NAME | PRODUCT | CONTENT TYPE | URL ---|------------------------------------------------------------|--------------------------|--------------|---- 8 | CENTOS | great | docker | ---|------------------------------------------------------------|--------------------------|--------------|---- $ hammer repository info --id=8 .... ID: 8 Name: CENTOS ... <snip>.... Container Repository Name: default_organization-dev-cv-centos-great-centos ...<snip>.... $ hammer docker tag list --repository-id=8 ---|-----|-------------- ID | TAG | REPOSITORY ID ---|---------|-------------- 51 | latest | 8 .....<snip>.... Finally :) .... $ hammer docker container create --name=fooo --repository-name="default_organization-dev-cv-centos-great-centos" --tag="latest" --compute-resource-id=3 --command="/bin/bash" Docker Container Created.
Verified on: S8C1 Steps to verify: 1) Created a Product, added and synced some docker repo 2) Create a Content View and added the docker repos created on step 1 and published a version 3) Promoted the content view to another environment 4) Then ran the commands: hammer> repository list --content-type docker --organization-id 1 --content-view DockerContentView --environment DEV ----|---------|---------------|--------------|---- ID | NAME | PRODUCT | CONTENT TYPE | URL ----|---------|---------------|--------------|---- 392 | busybox | DockerProduct | docker | 393 | centos | DockerProduct | docker | 394 | fedora | DockerProduct | docker | ----|---------|---------------|--------------|---- hammer> repository info --id 392 ID: 392 Name: busybox Label: busybox Organization: Default Organization Red Hat Repository: no Content Type: docker URL: Publish Via HTTP: yes Published At: qe-sat6-rhel71.example.com:5000/default_organization-dev-DockerContentView-DockerProduct-busybox Product: ID: 3778 Name: DockerProduct GPG Key: Sync: Status: Created: 2015/06/11 12:13:14 Updated: 2015/06/11 12:13:14 Content Counts: Docker Images: 9 Docker Tags: 5 hammer> docker container create --name busybox-cv --repository-name default_organization-dev-dockercontentview-dockerproduct-busybox --tag latest --compute-resource-id 55 --command top Docker container created Had to change the repository name to lowercase due to BZ #1230777
Reopening because is missing "Container Repository Name" on repository info. And that is part of the fix for this bug.
Verified on: S8C2 Steps to verify: 1) Ran the commands described on bug's description: hammer organization create --name "Container Org" hammer lifecycle-environment create --organization "Container Org" --name "DEV" --description "development" --prior "Library" hammer product create --name='containers' --organization="Container Org" hammer repository create --name='rhel' --organization="Container Org" --product='containers' --content-type='docker' --url='https://registry.access.redhat.com' --docker-upstream-name='rhel' --publish-via-http="true" hammer repository create --name='wordpress' --organization="Container Org" --product='containers' --content-type='docker' --url='https://registry.hub.docker.com' --docker-upstream-name='wordpress' --publish-via-http="true" hammer repository create --name='mysql' --organization="Container Org" --product='containers' --content-type='docker' --url='https://registry.hub.docker.com' --docker-upstream-name='mysql' --publish-via-http="true" hammer product synchronize --organization "Container Org" --name "containers" hammer content-view create --name "registry" --description "Sample Registry" --organization "Container Org" hammer content-view add-repository --organization "Container Org" --name "registry" --repository "rhel" --product "containers" hammer content-view add-repository --organization "Container Org" --name "registry" --repository "mysql" --product "containers" hammer content-view add-repository --organization "Container Org" --name "registry" --repository "wordpress" --product "containers" hammer content-view publish --organization "Container Org" --name "registry" 2) Searched for a repo id in order to pull images from and grabbed the published at info: hammer repository list --content-type docker --organization "Container Org" --content-view "registry" --lifecycle-environment "Library" hammer repository info --id 38 Published At: sat6server.com:5000/container_org-library-registry-containers-rhel 3) Installed the certificate RPM: [root@docker-host ~]# rpm -Uvh http://sat6server.com/pub/katello-ca-consumer-latest.noarch.rpm 4) Pulled the image: [root@docker-host ~]# docker pull sat6server.com:5000/container_org-library-registry-containers-rhel Trying to pull repository sat6server.com:5000/container_org-library-registry-containers-rhel ... 65de4a13fc7c: Download complete Status: Downloaded newer image for sat6server.com:5000/container_org-library-registry-containers-rhel:latest [root@docker-host ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE sat6server.com:5000/container_org-library-registry-containers-rhel latest 65de4a13fc7c 5 weeks ago 154.9 MB
Apologies I have miss verified this bug. Please not consider the Comment 17, as it was for verifying another bug. Changing back the state of the bug to Assigned in order to maintain the previous state.
Delivered in Snap10
# hammer -u admin -p changeme compute-resource list ---|---------------|--------- ID | NAME | PROVIDER ---|---------------|--------- 2 | local_docker | Docker 1 | local_libvirt | Libvirt ---|---------------|--------- # hammer -u admin -p changeme repository list --content-type docker --organization "Default Organization" ----|----------|---------|--------------|---------------------------------- ID | NAME | PRODUCT | CONTENT TYPE | URL ----|----------|---------|--------------|---------------------------------- 348 | CentOS | Docker | docker | https://registry.hub.docker.com 349 | RHEL 6.7 | Docker | docker | http://registry.access.redhat.com ----|----------|---------|--------------|---------------------------------- # hammer -u admin -p changeme repository info --id=349 ID: 349 Name: RHEL 6.7 Label: RHEL_6_7 Organization: Default Organization Red Hat Repository: no Content Type: docker URL: http://registry.access.redhat.com Publish Via HTTP: yes Published At: <EDITED>:5000/default_organization-docker-rhel_6_7 Upstream Repository Name: rhel6.7 Container Repository Name: default_organization-docker-rhel_6_7 Product: ID: 125 Name: Docker GPG Key: Sync: Status: Last Sync Date: 2015/07/23 16:39:56 Created: 2015/07/23 16:39:44 Updated: 2015/07/23 16:39:46 Content Counts: Docker Images: 1 Docker Tags: 2 # hammer -u admin -p changeme docker tag list --repository-id=349 ---|--------|-------------- ID | TAG | REPOSITORY ID ---|--------|-------------- 17 | latest | 349 16 | 6.7-2 | 349 ---|--------|-------------- # hammer -u admin -p changeme docker container create --name="BZ1199304" --repository-name="default_organization-docker-rhel_6_7" --tty=yes --command='top' --compute-resource="local_docker" --tag='latest' Docker container created # hammer -u admin -p changeme docker container list ------------------------|--------------------------------------|--------|------------|----------------- NAME | IMAGE REPOSITORY | TAG | COMMAND | COMPUTE RESOURCE ------------------------|--------------------------------------|--------|------------|----------------- docker-rhel-6-7-top | default_organization-docker-rhel_6_7 | latest | top | local_docker docker-fedora-latest-01 | fedora | latest | yum update | local_docker BZ1199304 | default_organization-docker-rhel_6_7 | latest | top | local_docker ------------------------|--------------------------------------|--------|------------|-----------------
OK, so to verify this issue, assuming that we have a Content View "docker cv" that is published to Lifecycle Environment "X", where X in my case is the lifecycle "Test", then: Get the Lifecycle ID: # hammer -u admin -p changeme lifecycle-environment list --organization="Default Organization" ---|---------|-------- ID | NAME | PRIOR ---|---------|-------- 4 | Test | Library 3 | QE | DEV 1 | Library | 2 | DEV | Library ---|---------|-------- Get the Content View ID: # hammer -u admin -p changeme content-view list --name="docker cv" --organization="Default Organization" ----------------|-----------|-----------|-----------|--------------- CONTENT VIEW ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS ----------------|-----------|-----------|-----------|--------------- 27 | docker cv | docker_cv | | 348, 349 ----------------|-----------|-----------|-----------|--------------- Get the ID(s) for the docker product(s) contained in the content view for lifecycle "Test": # hammer -u admin -p changeme repository list --organization="Default Organization" --content-view-id=27 --environment='Test' ----|----------|---------|--------------|---- ID | NAME | PRODUCT | CONTENT TYPE | URL ----|----------|---------|--------------|---- 354 | CentOS | Docker | docker | 355 | RHEL 6.7 | Docker | docker | ----|----------|---------|--------------|---- I chose the "RHEL 6.7" repository with ID=355: [root@ibm-x3250m4-06 ~]# hammer -u admin -p changeme repository info --id=355 ID: 355 Name: RHEL 6.7 Label: RHEL_6_7 Organization: Default Organization Red Hat Repository: no Content Type: docker URL: Publish Via HTTP: yes Published At: <EDITED>:5000/default_organization-test-docker_cv-docker-rhel_6_7 Container Repository Name: default_organization-test-docker_cv-docker-rhel_6_7 Product: ID: 125 Name: Docker GPG Key: Sync: Status: Created: 2015/07/23 18:27:48 Updated: 2015/07/23 18:27:48 Content Counts: Docker Images: 1 Docker Tags: 2 Now, use "Container Repository Name" of "default_organization-test-docker_cv-docker-rhel_6_7" create a new container using the docker image located in the content view published to the Test lifecycle: [root@ibm-x3250m4-06 ~]# hammer -u admin -p changeme docker container create --name="BZ1199304-part2" --repository-name="default_organization-test-docker_cv-docker-rhel_6_7" --tty=yes --command='top' --compute-resource="local_docker" --tag='latest' Docker container created Find it: [root@ibm-x3250m4-06 ~]# hammer -u admin -p changeme docker container list ------------------------|-----------------------------------------------------|--------|------------|----------------- NAME | IMAGE REPOSITORY | TAG | COMMAND | COMPUTE RESOURCE ------------------------|-----------------------------------------------------|--------|------------|----------------- docker-rhel-6-7-top | default_organization-docker-rhel_6_7 | latest | top | local_docker docker-fedora-latest-01 | fedora | latest | yum update | local_docker BZ1199304 | default_organization-docker-rhel_6_7 | latest | top | local_docker BZ1199304-part2 | default_organization-test-docker_cv-docker-rhel_6_7 | latest | top | local_docker ------------------------|-----------------------------------------------------|--------|------------|-----------------
Verified using Satellite 6.1.1 SNAP 13
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2015:1592