Bug 1260697

Summary: [RFE] As a CLI user, I should be able to set the Content Source for a host and hostgroup.
Product: Red Hat Satellite Reporter: Bryan Kearney <bkearney>
Component: Content ManagementAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED ERRATA QA Contact: Martin Korbel <mkorbel>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.4CC: abalakht, ahumbe, anerurka, bbuckingham, carlospec, csulekha, frank.reimer, jbhatia, jentrena, john.thiesfeld, katello-bugs, kbidarka, ktordeur, mhulan, mkorbel, mmithaiw, msomasun, pdwyer, rankumar, rjain, sauchter, sjr, sraut, sthirugn, tomckay, tstrachota, vedprakash.nimbalkar, xdmoon
Target Milestone: UnspecifiedKeywords: FutureFeature, PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/7597
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 12:30:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1316897    
Bug Blocks: 1115190, 1122832    

Description Bryan Kearney 2015-09-07 13:14:18 UTC
Currently in Satellite6, the hammer tool cant be used to set the "Katello - Content Source" and I have to use the WebUI. This is currently the only element that I need to use the WebUI for, hammer can do the rest

Comment 1 Bryan Kearney 2015-09-07 13:14:21 UTC
Created from redmine issue http://projects.theforeman.org/issues/7597

Comment 3 Tom McKay 2016-04-07 13:33:18 UTC
My comment from redmine: I see that --content-source-id is available to both hammer host and hostgroup update, is this issue resolved?

Comment 4 Bryan Kearney 2016-04-10 22:02:57 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7597 has been closed

Comment 5 Bryan Kearney 2016-04-12 18:15:26 UTC
I show it for hostgroup in 6.2, but not host

[root@sat-test-rhel7 scenarios.d]# hammer hostgroup update --help | grep content
 --content-source-id CONTENT_SOURCE_ID                
 --content-view CONTENT_VIEW_NAME                    Name to search by
 --content-view-id CONTENT_VIEW_ID                   content view numeric identifier
[root@sat-test-rhel7 scenarios.d]# hammer host update --help | grep content
[root@sat-test-rhel7 scenarios.d]# 



Moving this to POST in 6.3 to get caught int he next rebase from upstream.

Comment 6 Julio Entrena Perez 2016-05-24 14:17:05 UTC
http://projects.theforeman.org/issues/14762 ?

Comment 8 Martin Korbel 2016-10-18 12:55:36 UTC
FAILQA on version tfm-rubygem-hammer_cli-0.8.0-1

Hammer return error for this case, the variant with id works well.

> hammer hostgroup update --content-view "test view" --id 1 
Could not update the hostgroup:
  Error: Missing options to search organization


The note for parameter "--content-source-id". It works well but we cannot get status via hammer.

> hammer hostgroup info --id 1
Id:                     1
Name:                   Test Group
Title:                  Test Group
Puppet CA Proxy Id:     
Puppet Master Proxy Id: 
Puppetclasses:          

Parameters:             

Locations:              
    Default Location
Organizations:          
    Default Organization
Parent Id:              
Content View:           Default Organization View
Lifecycle Environment:  Library



Other options look good, it works as we expect.

> hammer hostgroup update --content-view-id 2 --id 1
> hammer hostgroup info --id 1
...
  Content View:           test view
...


> hammer host update --content-view "test view" --id 2
> hammer host info --id 2
...
  Content View:          test view
...
> hammer host update --content-view-id 1 --id 2
  Content View:          Default Organization View



DOC:

> hammer hostgroup update --help | grep content
 --content-source-id CONTENT_SOURCE_ID               Content source ID
 --content-view CONTENT_VIEW_NAME                    Name to search by
 --content-view-id CONTENT_VIEW_ID                   content view numeric identifier


> hammer host update --help | grep content
 --content-view CONTENT_VIEW_NAME                    Name to search by
 --content-view-id CONTENT_VIEW_ID                   content view numeric identifier

Comment 9 Bryan Kearney 2016-10-18 14:04:04 UTC
Upstream bug component is Hammer - Content

Comment 11 Stuart Auchterlonie 2016-10-28 11:02:56 UTC
Is https://bugzilla.redhat.com/show_bug.cgi?id=1332908 a DUP of this bugzilla?

Comment 12 Marek Hulan 2016-10-31 08:58:20 UTC
*** Bug 1332908 has been marked as a duplicate of this bug. ***

Comment 13 Bryan Kearney 2016-11-03 15:00:00 UTC
*** Bug 1351773 has been marked as a duplicate of this bug. ***

Comment 14 Marek Hulan 2016-11-14 07:15:57 UTC
Update: Host part seems to be fixed by bz 1390153, host group will take more time, since host group does not support facets. Further progress is blocked on following upstream issue http://projects.theforeman.org/issues/16630

Comment 15 Tomas Strachota 2017-03-01 11:00:56 UTC
Displaying the content source in info action is tracked here:
https://bugzilla.redhat.com/show_bug.cgi?id=1313056

Usage of --content-view was fixed by (requires --query-organization now):
https://bugzilla.redhat.com/show_bug.cgi?id=1416862

--content-source-id is present in both host and hostgroup create and update in upstream so I'm switching this to ON_QA for verification.

Comment 18 Kedar Bidarkar 2017-08-18 13:46:07 UTC
[root@qe-rhel7 ~]# hammer -u admin -p changeme host create --help | grep -i content-source
 --content-source-id CONTENT_SOURCE_ID                
[root@qe-hel7 ~]# hammer -u admin -p changeme host update  --help | grep -i content-source
 --content-source-id CONTENT_SOURCE_ID                
[root@qe-rhel7 ~]# hammer -u admin -p changeme hostgroup create  --help | grep -i content-source
 --content-source-id CONTENT_SOURCE_ID               Content source ID
[root@qe-rhel7 ~]# hammer -u admin -p changeme hostgroup update  --help | grep -i content-source
 --content-source-id CONTENT_SOURCE_ID               Content source ID

[root@qe-rhel7 ~]# hammer -u admin -p changeme hostgroup info --id 2 | grep -i "content source"
Content Source:         sat6-hostname.redhat.com


VERIFIED with Sat6.3.0-snap11.0

Comment 19 Kedar Bidarkar 2017-08-18 15:01:45 UTC
hammer -u admin -p changeme hostgroup create --name='RHEL 7 Server 64-bit HG' --content-view='RHEL 7 CV' --environment-id=1 --lifecycle-environment='DEV' --content-source-id="1" --puppet-proxy="$(hostname)" --puppet-ca-proxy="$(hostname)" --query-organization-id="1" --puppet-classes='access_insights_client,foreman_scap_client' --domain-id="1" --subnet="katello_latest" --architecture='x86_64' --operatingsystem-id="3" --partition-table='Kickstart default' --location-ids="2"
Hostgroup created

--------------------------------

hammer -u admin -p changeme  host create --name='rhel-7-libvirt2' --root-password='changeme' --organization-id="1" --location-id="2" --hostgroup="RHEL 7 Server 64-bit HG" --compute-resource="libvirt" --compute-attributes="cpus=1, memory=1073741824, start=1" --interface="primary=true, compute_type=bridge, compute_bridge=katello_latest, compute_model=virtio" --volume="capacity=10G,format_type=qcow2" --operatingsystem-id "2" --pxe-loader 'PXELinux BIOS' --provision-method build
Host created

After creating the HOST, checked whether the content-source was set from the UI and it was indeed set. Will upload a screenshot shortly.

-------------------------------

# hammer -u admin -p changeme hostgroup info --id 2
Id:                     2
Name:                   RHEL 7 Server 64-bit HG
Title:                  RHEL 7 Server 64-bit HG
Operating System:       RedHat 7.3
Environment:            production
Subnet:                 katello_latest
Domain:                 sat6-domainname.redhat.com
Architecture:           x86_64
Partition Table:        Kickstart default
Puppet CA Proxy Id:     1
Puppet Master Proxy Id: 1
Puppetclasses:          
    access_insights_client
    foreman_scap_client
Parameters:             

Locations:              
    Default Location
Organizations:          
    Default Organization
Parent Id:              
Content View:           RHEL 7 CV
Lifecycle Environment:  DEV
Content Source:         sat6-hostname.redhat.com

Comment 20 Kedar Bidarkar 2017-08-18 15:02:54 UTC
currently there is no "content source" information available from "host info --id <id>"

Comment 28 Ashish Humbe 2017-10-31 06:00:58 UTC
As per discussion with Partha on this issue.

On Satellite v 6.2.12 using below API command, we can set the content source ID successfully 

# curl -H "Content-Type:application/json" -X PUT -u 'username:password' -k -d '{"host":{"content_source_id": "2"}}'  https://satellite.example.com/api/v2/hosts/123

Replace below values appropriately: 

123 : with the host ID for which content source ID needs to be updated.
satellite.example.com : with FADN of the satellite server
username:password   : with appropriate admin user credentials 
"2" (content_source_id) : with appropriate capsule server ID 

To get the host ID and content source ID one can use below commands 

# hammer host list      << To get host ID

# hammer capsule list   << To get content source ID

This can be used as a workaround for now.

Comment 31 errata-xmlrpc 2018-02-21 12:30:53 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-2018:0336