Bug 1571086

Summary: can't use hammer CLI to create a new host in VMware
Product: Red Hat Satellite Reporter: matt jia <mjia>
Component: HostsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3.1CC: akarsale, apatel, dhlavacd, inecas, kgaikwad, ktordeur, mhulan, mjia, mshira, rabajaj, sauchter, tbrisker, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-23 09:27:10 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:
Bug Depends On:    
Bug Blocks: 1316897    

Description matt jia 2018-04-24 05:48:14 UTC
Description of problem:

Can't create a new host by using hammer CLI with Vmware compute options.

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

6.3

How reproducible:

Normal

Steps to Reproduce:

use a hammer command like this 

hammer -d  host create \
  --name "lonlxt90014" \
  --organization "NOMURA" \
  --location "rnd" \
  --hostgroup-id 22 \
  --content-source-id 1 \
  --compute-resource-id 3 \
  --provision-method image \
  --image "RHEL7.4-16042018" \
  --ip xx.xx.xxx.xx
  --subnet-id 1 \
  --managed true \
  --interface="compute_type=VirtualVmxnet3, \
               compute_network=network-44"  \
  --compute-attributes="cpus=1, \
                        corespersocket=2, \
                        memory_mb=2048,
                        cluster='Woking RND', \
                        path='/Datacenters/Woking RND/vm/Discovered virtual machine',guest_id=rhel6_64Guest,hardware_version=vmx-08" \
  --volume="size_gb=60, \
            datastore=ESX_DataStore_ISO, \
            name='Hard disk 1', \
            thin=true, eager_zero=false,mode=persistent"

Actual results:

[ERROR 2018-04-20 07:26:04 Exception] Failed to create a compute lonwst90002.rndeurope.nom (VMware) instance lonlxt90014.nomura.com: undefined method `include?' for nil:NilClass


Expected results:

Creating a new host should see no errors.


Additional info:

If a compute profile is given, it works. UI also works.

Comment 2 matt jia 2018-04-24 07:05:29 UTC
After digging a little bit more, it seems like the image_id is not populated in the /usr/share/foreman/app/models/concerns/orchestration/compute.rb:77:in `setCompute'

As I understand, it should use the given image's id. 

On the other hand, the hammer CLI accepts --image-id. Will this be used as the image id of the compute attributes? SIt seems like the image id can be set with  --compute-attributes, but the doc doesn't mention it.

hammer host create --help

  VMWare:
    --compute-attributes:
      cpus                  Cpu count
      corespersocket        Number of cores per socket (applicable to hardware versions < 10 only)
      memory_mb             Integer number, amount of memory in MB
      cluster               Cluster id from VMware
      path                  Path to folder
      guest_id              Guest OS id form VMware
      scsi_controller_type  Id of the controller from VMware
      hardware_version      Hardware version id from VMware
      start

Comment 5 Marek Hulan 2018-04-26 06:33:24 UTC
I guess tha same would happen for other CRs as well. Matt, could you please try using --image-id as you suggest in comment 2? Also try it as an attribute of compute_attributes hash, I'd expect this should work. I haven't looked to API code yet, but perhaps it's just documentation issue.

Comment 6 matt jia 2018-04-26 07:01:10 UTC
Hi Marek,

Using --image-id gives me the same error. Using it as an attribute of compute_attributes hash works. It would make more sense that the API can
populate the image_id attribute of compute_attributes from the given --image/--image-id.

Comment 9 Shira Maximov 2018-12-05 13:31:23 UTC
I saw the same issue in 
https://bugzilla.redhat.com/show_bug.cgi?id=1633345
please try to add image_id under --compute-attributes section.

Comment 10 Shira Maximov 2018-12-23 09:27:10 UTC

*** This bug has been marked as a duplicate of bug 1529252 ***

Comment 11 Red Hat Bugzilla 2024-01-06 04:25:29 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days