Bug 1199304 - [RFE] Need to be able to create containers from content views through the API
Summary: [RFE] Need to be able to create containers from content views through the API
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Content Management
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Partha Aji
QA Contact: Og Maciel
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On: 1217603
Blocks: 1190289
TreeView+ depends on / blocked
 
Reported: 2015-03-05 22:02 UTC by Partha Aji
Modified: 2017-02-23 20:22 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-12 05:29:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 9518 0 Normal Closed Need to be able to create containers from content views through the API 2020-06-26 02:06:35 UTC
Red Hat Product Errata RHSA-2015:1592 0 normal SHIPPED_LIVE Important: Red Hat Satellite 6.1.1 on RHEL 6 2015-08-12 09:04:35 UTC

Description Partha Aji 2015-03-05 22:02:08 UTC

Comment 1 Partha Aji 2015-03-05 22:02:09 UTC
Created from redmine issue http://projects.theforeman.org/issues//9518

Comment 2 Partha Aji 2015-03-05 22:03:44 UTC
Need to be able to create containers from content views through the API

Comment 4 Bryan Kearney 2015-03-17 14:05:44 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/9518 has been closed

Comment 7 Mike McCune 2015-03-20 16:19:34 UTC
This requires:

https://github.com/theforeman/foreman-docker/pull/93

moving back to ASSIGNED

Comment 11 Elyézer Rezende 2015-05-05 14:20:38 UTC
It is not possible to verify this until BZ #1217603 is resolved.

Comment 12 Elyézer Rezende 2015-06-11 17:04:23 UTC
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.

Comment 13 Partha Aji 2015-06-11 17:49:45 UTC
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.

Comment 14 Elyézer Rezende 2015-06-11 18:37:57 UTC
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

Comment 15 Elyézer Rezende 2015-06-11 19:41:13 UTC
Reopening because is missing "Container Repository Name" on repository info. And that is part of the fix for this bug.

Comment 17 Elyézer Rezende 2015-06-15 18:05:30 UTC
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

Comment 18 Elyézer Rezende 2015-06-15 18:12:32 UTC
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.

Comment 21 Bryan Kearney 2015-06-26 14:32:20 UTC
Delivered in Snap10

Comment 22 Og Maciel 2015-07-23 18:15:27 UTC
# 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
------------------------|--------------------------------------|--------|------------|-----------------

Comment 23 Og Maciel 2015-07-23 19:26:19 UTC
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
------------------------|-----------------------------------------------------|--------|------------|-----------------

Comment 24 Og Maciel 2015-07-23 19:29:58 UTC
Verified using Satellite 6.1.1 SNAP 13

Comment 26 errata-xmlrpc 2015-08-12 05:29:06 UTC
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


Note You need to log in before you can comment on or make changes to this bug.