Bug 1416376 - hammer host create fails with a lot of required option if NO hostgroup is used
Summary: hammer host create fails with a lot of required option if NO hostgroup is used
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.2.6
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: Unspecified
Assignee: Tomas Strachota
QA Contact: Marek Hulan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-25 11:37 UTC by Peter Tselios
Modified: 2019-08-12 16:36 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:49:54 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 18339 0 Normal Closed hammer host create require -id version of options when name is used 2021-01-22 06:14:55 UTC

Description Peter Tselios 2017-01-25 11:37:39 UTC
Description of problem:

I want to build a VM via the Hammer CLI without using a hostgroup. 
I used this command:
hammer host create --compute-resource="Local KVM" --compute-profile="02-vm" --location="Lab" --lifecycle-environment="Library" --domain="testenv" --location="Lab"  --operatingsystem-id=2 --partition-table-id=189 --provision-method=build --root-pass="changeme" --subnet-id=1 --environment-id=0 --architecture-id=1 --puppet-proxy-id=0  --name="basic73"

It fails with the following error
Could not create the host:
  Error: Options --environment-id, --architecture-id, --domain-id, --puppet-proxy-id, --operatingsystem-id, --partition-table-id are required


Version-Release number of selected component (if applicable):
6.2.6

How reproducible:
100% when hostgroup is not used. 

Steps to Reproduce:
1. Execute the above command

Actual results:
host creation fails

Expected results:
Host created

Additional info:

Comment 1 Marek Hulan 2017-01-26 08:44:56 UTC
I don't think this is a bug. If you're creating a managed host, parameters such as architecture-id, --operatingsystem-id are required. When you used host group, values were inherited from there but if you don't use it, all required parameters must be specified. Also looking at parameters like --puppet-proxy-id=0 or --environment-id=0, values do not look correct, no resource can have id 0.

If you want to create unmanaged host (no provisioning) you can pass --managed=false. For more information about parameters, please take a look at product documentation available at https://access.redhat.com/documentation/en/red-hat-satellite/6.2/paged/hammer-cli-guide/chapter-5-managing-hosts (chapter 5.2 in particular)

I'm closing this as not a bug, please let me know if I misunderstood or there's something that I missed, I'd reopen in such case.

Comment 2 Peter Tselios 2017-01-26 09:28:30 UTC
I will insist, that this is not normal.

I hadn't a puppet environment, so I created one:

hammer environment list
---|----------
ID | NAME     
---|----------
2  | LabPuppet
---|----------

So, I replaced all names with ids (basically, the domain with the domain-id). 
Then the error message changed to the missing medium and missing content view, which was specific enough. 
Passing those arguments, the host was created. 

So, it **IS** a bug because:
a. It REQUIRES the usage of IDs instead of names
b. The error message is very generic and it's not specific; In my case it should say "domain-id is missing". (I guess the code is a simple if with a lot of OR )
c. The --help is not saying that you HAVE to use IDs.

Comment 3 Marek Hulan 2017-01-30 10:48:47 UTC
> a. It REQUIRES the usage of IDs instead of names

I'm sorry if I misunderstand, but I think --domain="testenv" would normally work, could you double check that domain with such name exists (e.g. hammer domain list), normally domain is something like testenv.com. If it exists and you can't swap in working command --domain-id 1 with --domain testenv.com then I agree it's a bug. Would you mind uploading a production.log and output of the hammer command ran with "-d -v" to here so we could investigate it?

> b. The error message is very generic and it's not specific; In my case it should say "domain-id is missing". (I guess the code is a simple if with a lot of OR )

You uploaded the error message which says what arguments are missing. It might be that if the domain was not found, hammer suggests to use --domain-id (listed below). It could say one of --domain-id or --domain is required but that would make the error message much longs, in case you sent it would list 12 arguments instead of 6.

Could not create the host:
  Error: Options --environment-id, --architecture-id, --domain-id, --puppet-proxy-id, --operatingsystem-id, --partition-table-id are required

> c. The --help is not saying that you HAVE to use IDs.

I still don't think it's required to use --domain-id instead --domain. If we find out it's the case and --domain argument does not work, I'm happy to reopen and we'll make --domain argument working. I was not able to reproduce in my environment and in fact it works for me.

Comment 4 Peter Tselios 2017-01-30 13:29:40 UTC
(In reply to Marek Hulan from comment #3)
> > a. It REQUIRES the usage of IDs instead of names
> 
> I'm sorry if I misunderstand, but I think --domain="testenv" would normally
> work, could you double check that domain with such name exists (e.g. hammer
> domain list), normally domain is something like testenv.com. If it exists
> and you can't swap in working command --domain-id 1 with --domain
> testenv.com then I agree it's a bug. Would you mind uploading a
> production.log and output of the hammer command ran with "-d -v" to here so
> we could investigate it?

So, what is working:
=============================================================================
hammer  host create --compute-resource="Local KVM" --compute-profile="02-vm" --location="Lab" --lifecycle-environment="Library" --domain-id=1 --location="Lab"  --operatingsystem-id=2 --partition-table-id=189 --provision-method=build --root-pass="changeme" --subnet-id=1 --environment-id=1 --architecture-id=1 --puppet-proxy-id=1  --name="basic73" --medium="ITCultus_LTD/Library/Red_Hat_Server/Red_Hat_Enterprise_Linux_7_Server_Kickstart_x86_64_7_2" --content-view="RHEL 7 Latest"
Host created
=============================================================================

The domain DOES exist.

hammer domain list
---|--------
ID | NAME   
---|--------
1  | testenv
---|--------

So, as far as I understand, it should work, but it's not:

hammer  host create --compute-resource="Local KVM" --compute-profile="02-vm" --location="Lab" --lifecycle-environment="Library" --domain="testenv" --location="Lab"  --operatingsystem-id=2 --partition-table-id=189 --provision-method=build --root-pass="changeme" --subnet-id=1 --environment-id=1 --architecture-id=1 --puppet-proxy-id=1  --name="basic73" --medium="ITCultus_LTD/Library/Red_Hat_Server/Red_Hat_Enterprise_Linux_7_Server_Kickstart_x86_64_7_2" --content-view="RHEL 7 Latest"
Could not create the host:
  Error: Options --environment-id, --architecture-id, --domain-id, --puppet-proxy-id, --operatingsystem-id, --partition-table-id are required
  
  See: 'hammer host create --help'


Also, it seems that it's a general issue with ID/names.

I replaced architecture_id with architecture; same error:

hammer architecture list
---|-------
ID | NAME  
---|-------
2  | i386  
1  | x86_64
---|-------

hammer  host create --compute-resource="Local KVM" --compute-profile="02-vm" --location="Lab" --lifecycle-environment="Library" --domain-id=1 --location="Lab"  --operatingsystem-id=2 --partition-table-id=189 --provision-method=build --root-pass="changeme" --subnet-id=1 --environment-id=1 --architecture="x86_64" --puppet-proxy-id=1  --name="basic73" --medium="ITCultus_LTD/Library/Red_Hat_Server/Red_Hat_Enterprise_Linux_7_Server_Kickstart_x86_64_7_2" --content-view="RHEL 7 Latest"


Just to clarify something. I have provisioned hosts using hostgroups. 

  
 
> You uploaded the error message which says what arguments are missing. It
> might be that if the domain was not found, hammer suggests to use
> --domain-id (listed below). It could say one of --domain-id or --domain is
> required but that would make the error message much longs, in case you sent
> it would list 12 arguments instead of 6.

Yes. It should be 24 arguments long, as long as the error message is specific and accurate!
 
> Could not create the host:
>   Error: Options --environment-id, --architecture-id, --domain-id,
> --puppet-proxy-id, --operatingsystem-id, --partition-table-id are required
> 
> > c. The --help is not saying that you HAVE to use IDs.

Comment 5 Peter Tselios 2017-01-30 13:31:24 UTC
Created attachment 1245891 [details]
Production.log

Comment 6 Peter Tselios 2017-01-30 13:32:42 UTC
Created attachment 1245892 [details]
hammer host create command with -d -v

Comment 7 Peter Tselios 2017-01-30 13:33:55 UTC
I would be grateful if the production.log is not downloadable by non-related to this bug people.

Comment 8 Marek Hulan 2017-01-30 13:54:22 UTC
Thank you, I've made them private. One thing I can tell from the log is that the domain "testenv" was identified as domain with ID 1, which according to the output you provided is the right domain. The server responded back with information that only Medium and Content view can't be blank, so I'm not sure why hammer lists --domain-id missing as well. Anyway outputs you provided should help us reproduce it.

I'm reopening to investigate further. Could you please additionally verify whether this domain is assigned to organization with id 1 and location with id 2 as well? But I doubt that would be the cause, since as you said, with hostgroup it works.

Comment 9 Peter Tselios 2017-01-31 10:38:36 UTC
Hi Marek,
Thank you for the private.
Yes, associations are just fine.

Comment 10 Tomas Strachota 2017-02-01 11:43:17 UTC
Created redmine issue http://projects.theforeman.org/issues/18339 from this bug

Comment 11 pm-sat@redhat.com 2017-02-01 13:06:12 UTC
Upstream bug assigned to tstrachota@redhat.com

Comment 12 pm-sat@redhat.com 2017-02-01 13:06:15 UTC
Upstream bug assigned to tstrachota@redhat.com

Comment 14 pm-sat@redhat.com 2017-02-21 11:06:03 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/18339 has been resolved.

Comment 17 pm-sat@redhat.com 2018-02-21 16:49:54 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


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