Bug 1468906

Summary: [RFE] [6.3] Creating hostgroups script
Product: Red Hat Satellite Reporter: Shadd <shadd>
Component: Docs Hammer CLI GuideAssignee: Sergei Petrosian <spetrosi>
Status: CLOSED NOTABUG QA Contact: Stephen Wadeley <swadeley>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.10CC: adahms, sbream, shadd
Target Milestone: UnspecifiedKeywords: FutureFeature
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-31 13:21:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Example on Creating Multiple Host Groups none

Description Shadd 2017-07-09 16:55:20 UTC
Document URL: 
https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html-single/hammer_cli_guide/#sect-CLI_Guide-Creating_a_Host_Group

Section Number and Name: 
6.1. Creating a Host Group

Describe the issue:
Only useful if a customer wants a single Environment 
If ran as is Parent_ID and HgID can provide multiple ids and the script is not in a loop  so it fails with to many variables 

Suggestions for improvement: 
Verify correct variables are in /root/.bashrc or add them into script
ARCH=
DOMAIN=
PROXYID=
NETNAME=
CAID=
MEDID=
ORGID=
LOCID=
OSID=
PARTTABLEID=

source /root/.bashrc

Set variables for loop

ENVIROMENT=$(hammer environment list |awk -F "|" {'print $2'}|grep -v -|grep -v NAME |sed 's/ //g' |grep -v production)
LEL=$(hammer lifecycle-environment list --organization $ORG |awk -F "|" {'print $2'}|grep -v - |grep -v NAME)

for loop to add hostgroups
for i in $ENVIROMENT; do for j in $(hammer --csv environment list |awk -F "," {'print $2'}| awk -F "_" {'print $3'}); do hammer hostgroup create --name rhel-7-"$j" --environment "$i" --architecture "$ARCH" --domain "$DOMAIN" --subnet "$NETNAME" --puppet-proxy-id "$PROXYID" --puppet-ca-proxy-id "$CAID" --medium-id "$MEDID" --organization-ids "$ORGID" --location-ids "$LOCID" --operatingsystem-id "$OSID" --partition-table-id $PARTTABLEID ; done; done


Additional information:

Comment 1 Andrew Dahms 2017-07-13 05:37:40 UTC
Assigning to Sergei for review.

Comment 4 Shadd 2017-08-30 17:43:42 UTC
What info can I provide to close this ticket?

Comment 7 Sergei Petrosian 2017-08-31 14:14:25 UTC
Created attachment 1320608 [details]
Example on Creating Multiple Host Groups

Find working document with the example of script on creating multiple host groups in the attachment.