Bug 1595120 - `hammer host create ...` fails with "undefined method `name' for nil:NilClass"
Summary: `hammer host create ...` fails with "undefined method `name' for nil:NilClass"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Compute Resources - libvirt
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
low vote
Target Milestone: 6.4.0
Assignee: Ondřej Pražák
QA Contact: Stephen Benjamin
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-06-26 07:57 UTC by Jan Hutař
Modified: 2019-11-05 23:25 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-16 18:58:19 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 24125 'Normal' 'Closed' 'Creating host on libvirt with hammer fails with fails with "undefined method `name'' for nil:NilClass"' 2019-11-25 15:12:25 UTC

Description Jan Hutař 2018-06-26 07:57:00 UTC
Description of problem:
`hammer host create ...` fails with "undefined method `name' for nil:NilClass"


Version-Release number of selected component (if applicable):
satellite-6.4.0-9.beta.el7sat.noarch


How reproducible:
always


Steps to Reproduce:
1. # hammer -u admin -p changeme host create --architecture-id="3" --compute-resource-id="2" --domain-id="3" --environment-id="5" --ip="148.172.224.43" --location-id="5" --mac="94:e3:d9:06:72:48" --medium-id="10" --name="jhutar$RANDOM" --operatingsystem-id="3" --organization-id="6" --partition-table-id="141" --puppet-proxy-id="1" --root-password="\xea\xae\x8f\xf0\x98\x87\x8a\xe9\xb5\xa8\xd0\x9e\xec\x8b\xa4\xe6\xa9\x88\xe0\xae\x88\xe1\x8b\xb8\xe5\x83\x95\xf0\x97\xbf\xa3\xe7\x87\x93\xf0\x96\xa6\x9e\xeb\xa9\x83\xe7\x88\x8a\xe6\x88\x8f\xe7\x9d\x8d\xea\x85\xa0\xef\xac\x85"


Actual results:
[ERROR 2018-06-26T03:45:55 API] 422 Unprocessable Entity
[ERROR 2018-06-26T03:45:55 Exception] Failed to create a compute 9zZ6tf (Libvirt) instance jhutar7545.xl2ppkfyft: undefined method `name' for nil:NilClass
 
Could not create the host:
  Failed to create a compute 9zZ6tf (Libvirt) instance jhutar7545.xl2ppkfyft: undefined method `name' for nil:NilClass


Expected results:
Should work


Additional info:
I think, all the entities used in the command should be in correct Org/Loc:

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme architecture info --id 3
Id:                3
Name:              aRjWRdClvy
Operating systems: 
    wanWtbXH 1263
Created at:        2018/06/26 07:36:10
Updated at:        2018/06/26 07:36:10

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme compute-resource info --id 2
Id:            2
Name:          9zZ6tf
Provider:      Libvirt
Url:           qemu+ssh://root@<libvirt>/system
Description:   
User:          
Locations:     
    Default Location
    tQvGVGLW
Organizations: 
    bRbHbc
    Default Organization
Created at:    2018/06/26 07:36:02
Updated at:    2018/06/26 07:39:19

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme domain info --id 3
Id:            3
Name:          xl2ppkfyft
Description:   
DNS Id:        
Subnets:       

Locations:     
    Default Location
    tQvGVGLW
Organizations: 
    bRbHbc
    Default Organization
Parameters:    

Created at:    2018/06/26 07:36:08
Updated at:    2018/06/26 07:40:17

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme environment info --id 5
Id:            5
Name:          6K752d7gzGN
Puppetclasses: 

Locations:     
    Default Location
    tQvGVGLW
Organizations: 
    bRbHbc
    Default Organization
Created at:    2018/06/26 07:36:09
Updated at:    2018/06/26 07:36:09

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme location info --id 5
\Id:                 5
Title:              tQvGVGLW
Name:               tQvGVGLW
Description:        
Users:              

Smart proxies:      
    <fqdn>
Subnets:            

Compute resources:  
    9zZ6tf
Installation media: 
    HooetO
Templates:          
    Alterator default (provision)
    Alterator default finish (finish)
    Alterator default PXELinux (PXELinux)
    alterator_pkglist ()
    ansible_provisioning_callback ()
    ansible_tower_callback_script ()
    ansible_tower_callback_service ()
    Atomic Kickstart default (provision)
    AutoYaST default (provision)
    AutoYaST default iPXE (iPXE)
    AutoYaST default PXELinux (PXELinux)
    AutoYaST default user data (user_data)
    AutoYaST SLES default (provision)
    bmc_nic_setup ()
    Boot disk iPXE - generic host (Bootdisk)
    Boot disk iPXE - host (Bootdisk)
    chef_client ()
    coreos_cloudconfig ()
    CoreOS provision (provision)
    CoreOS PXELinux (PXELinux)
    create_users ()
    Discovery Debian kexec (kexec)
    Discovery Red Hat kexec (kexec)
    epel ()
    fix_hosts ()
    FreeBSD (mfsBSD) finish (finish)
    FreeBSD (mfsBSD) provision (provision)
    FreeBSD (mfsBSD) PXELinux (PXELinux)
    freeipa_register ()
    Grubby default (script)
    http_proxy ()
    idm_register ()
    Jumpstart default (provision)
    Jumpstart default finish (finish)
    Jumpstart default PXEGrub (PXEGrub)
    Junos default finish (finish)
    Junos default SLAX (provision)
    Junos default ZTP config (ZTP)
    Kickstart default finish (finish)
    Kickstart default iPXE (iPXE)
    Kickstart default PXEGrub (PXEGrub)
    Kickstart default PXEGrub2 (PXEGrub2)
    Kickstart default PXELinux (PXELinux)
    Kickstart default user data (user_data)
    kickstart_ifcfg_bonded_interface ()
    kickstart_ifcfg_bond_interface ()
    kickstart_ifcfg_generic_interface ()
    kickstart_ifcfg_get_identifier_names ()
    kickstart_networking_setup ()
    Kickstart oVirt-RHVH (provision)
    Kickstart oVirt-RHVH PXELinux (PXELinux)
    NX-OS default POAP setup (POAP)
    Preseed default (provision)
    Preseed default finish (finish)
    Preseed default iPXE (iPXE)
    Preseed default PXEGrub2 (PXEGrub2)
    Preseed default PXELinux (PXELinux)
    Preseed default user data (user_data)
    preseed_networking_setup ()
    puppet.conf ()
    puppetlabs_repo ()
    puppet_setup ()
    pxegrub2_chainload ()
    PXEGrub2 default local boot (PXEGrub2)
    pxegrub2_discovery ()
    PXEGrub2 global default (PXEGrub2)
    pxegrub_chainload ()
    PXEGrub default local boot (PXEGrub)
    pxegrub_discovery ()
    PXEGrub global default (PXEGrub)
    PXELinux chain iPXE (PXELinux)
    PXELinux chain iPXE UNDI (PXELinux)
    pxelinux_chainload ()
    PXELinux default local boot (PXELinux)
    PXELinux default memdisk (PXELinux)
    pxelinux_discovery ()
    PXELinux global default (PXELinux)
    rancheros_cloudconfig ()
    RancherOS provision (provision)
    RancherOS PXELinux (PXELinux)
    redhat_register ()
    remote_execution_ssh_keys ()
    saltstack_minion ()
    saltstack_setup ()
    Satellite Atomic Kickstart Default (provision)
    Satellite Kickstart Default (provision)
    Satellite Kickstart Default Finish (finish)
    Satellite Kickstart Default User Data (user_data)
    UserData default (user_data)
    WAIK default PXELinux (PXELinux)
    XenServer default answerfile (provision)
    XenServer default finish (finish)
    XenServer default PXELinux (PXELinux)
Domains:            
    xl2ppkfyft
Environments:       
    6K752d7gzGN
Hostgroups:         

Parameters:         

Created at:         2018/06/26 07:36:03
Updated at:         2018/06/26 07:36:03

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme medium info --id 10
Id:                10
Name:              HooetO
Path:              https://OCLIzpNukd.org
OS Family:         
Operating systems: 
    wanWtbXH 1263
Locations:         
    Default Location
    tQvGVGLW
Organizations:     
    bRbHbc
    Default Organization
Created at:        2018/06/26 07:36:12
Updated at:        2018/06/26 07:43:55

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme os info --id 3
Id:                 3
Title:              wanWtbXH 1263
Release name:       
Family:             
Name:               wanWtbXH
Major version:      1263
Minor version:      
Partition tables:   
    ktDcyNBnmVbzjKYuuZD
Default templates:  

Architectures:      
    aRjWRdClvy
Installation media: 
    HooetO
Templates:          

Parameters:

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme organization info --id 6
Id:                     6
Title:                  bRbHbc
Name:                   bRbHbc
Description:            
Users:                  

Smart proxies:          
    <fqdn>
Subnets:                

Compute resources:      
    9zZ6tf
Installation media:     
    HooetO
Templates:              
    Alterator default (provision)
    Alterator default finish (finish)
    Alterator default PXELinux (PXELinux)
    alterator_pkglist ()
    ansible_provisioning_callback ()
    ansible_tower_callback_script ()
    ansible_tower_callback_service ()
    Atomic Kickstart default (provision)
    AutoYaST default (provision)
    AutoYaST default iPXE (iPXE)
    AutoYaST default PXELinux (PXELinux)
    AutoYaST default user data (user_data)
    AutoYaST SLES default (provision)
    bmc_nic_setup ()
    Boot disk iPXE - generic host (Bootdisk)
    Boot disk iPXE - host (Bootdisk)
    chef_client ()
    coreos_cloudconfig ()
    CoreOS provision (provision)
    CoreOS PXELinux (PXELinux)
    create_users ()
    Discovery Debian kexec (kexec)
    Discovery Red Hat kexec (kexec)
    epel ()
    fix_hosts ()
    FreeBSD (mfsBSD) finish (finish)
    FreeBSD (mfsBSD) provision (provision)
    FreeBSD (mfsBSD) PXELinux (PXELinux)
    freeipa_register ()
    Grubby default (script)
    http_proxy ()
    idm_register ()
    Jumpstart default (provision)
    Jumpstart default finish (finish)
    Jumpstart default PXEGrub (PXEGrub)
    Junos default finish (finish)
    Junos default SLAX (provision)
    Junos default ZTP config (ZTP)
    Kickstart default finish (finish)
    Kickstart default iPXE (iPXE)
    Kickstart default PXEGrub (PXEGrub)
    Kickstart default PXEGrub2 (PXEGrub2)
    Kickstart default PXELinux (PXELinux)
    Kickstart default user data (user_data)
    kickstart_ifcfg_bonded_interface ()
    kickstart_ifcfg_bond_interface ()
    kickstart_ifcfg_generic_interface ()
    kickstart_ifcfg_get_identifier_names ()
    kickstart_networking_setup ()
    Kickstart oVirt-RHVH (provision)
    Kickstart oVirt-RHVH PXELinux (PXELinux)
    NX-OS default POAP setup (POAP)
    Preseed default (provision)
    Preseed default finish (finish)
    Preseed default iPXE (iPXE)
    Preseed default PXEGrub2 (PXEGrub2)
    Preseed default PXELinux (PXELinux)
    Preseed default user data (user_data)
    preseed_networking_setup ()
    puppet.conf ()
    puppetlabs_repo ()
    puppet_setup ()
    pxegrub2_chainload ()
    PXEGrub2 default local boot (PXEGrub2)
    pxegrub2_discovery ()
    PXEGrub2 global default (PXEGrub2)
    pxegrub_chainload ()
    PXEGrub default local boot (PXEGrub)
    pxegrub_discovery ()
    PXEGrub global default (PXEGrub)
    PXELinux chain iPXE (PXELinux)
    PXELinux chain iPXE UNDI (PXELinux)
    pxelinux_chainload ()
    PXELinux default local boot (PXELinux)
    PXELinux default memdisk (PXELinux)
    pxelinux_discovery ()
    PXELinux global default (PXELinux)
    rancheros_cloudconfig ()
    RancherOS provision (provision)
    RancherOS PXELinux (PXELinux)
    redhat_register ()
    remote_execution_ssh_keys ()
    saltstack_minion ()
    saltstack_setup ()
    Satellite Atomic Kickstart Default (provision)
    Satellite Kickstart Default (provision)
    Satellite Kickstart Default Finish (finish)
    Satellite Kickstart Default User Data (user_data)
    UserData default (user_data)
    WAIK default PXELinux (PXELinux)
    XenServer default answerfile (provision)
    XenServer default finish (finish)
    XenServer default PXELinux (PXELinux)
Domains:                
    xl2ppkfyft
Environments:           
    6K752d7gzGN
Hostgroups:             

Parameters:             

Created at:             2018/06/26 07:36:05
Updated at:             2018/06/26 07:36:05
Label:                  bRbHbc
Description:            
Red Hat Repository URL: https://cdn.redhat.com
Service Levels:

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme partition-table info --id 141
Id:                141
Name:              ktDcyNBnmVbzjKYuuZD
OS Family:         
Locked:            no
Operating systems: 
    wanWtbXH 1263
Created at:        2018/06/26 07:36:10
Updated at:        2018/06/26 07:36:10
Locations:         
    Default Location
    tQvGVGLW
Organizations:     
    bRbHbc
    Default Organization

[root@intel-bakersville-01 ~]# hammer -u admin -p changeme proxy info --id 1
Id:            1
Name:          <fqdn>
URL:           https://<fqdn>:9090
Features:      
    Pulp
    TFTP
    Puppet
    Puppet CA
    Logs
    Dynflow
    SSH
    Discovery
    Ansible
    Openscap
Locations:     
    Default Location
    tQvGVGLW
Organizations: 
    bRbHbc
    Default Organization
Created at:    2018/06/25 12:03:46
Updated at:    2018/06/25 12:03:46

Comment 5 Ondřej Pražák 2018-07-02 11:31:23 UTC
I was able to get the error by stopping libvirt. When the compute resource is available/reachable, the host is created. Nevertheless, this is a bug as we should show a better error message.

Comment 6 Ondřej Pražák 2018-07-02 11:44:31 UTC
Created redmine issue http://projects.theforeman.org/issues/24125 from this bug

Comment 7 pm-sat@redhat.com 2018-07-02 12:20:15 UTC
Upstream bug assigned to oprazak@redhat.com

Comment 8 pm-sat@redhat.com 2018-07-10 14:20:02 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/24125 has been resolved.

Comment 9 Stephen Benjamin 2018-07-17 17:55:25 UTC
Verified:
  satellite-6.4.0-10.beta.el7sat.noarch
  foreman-1.18.0.1-1.el7sat.noarch

I verified this bug by adding a libvirt compute resource to my Satellite instance and then trying to provision a host with libvirtd shutoff.  Instead of the error mentioned in comment #0, Satellite correctly informs me of the true error:

[root@hp-moonshot-01-c09 ~]# hammer -u admin -p changeme host create --architecture-id="1" --compute-resource-id="1" --domain-id="2" --ip="192.168.121.19" --location-id="2" --mac="94:e3:d9:06:72:48" --medium-id="1" --name="stbenjam$RANDOM" --operatingsystem-id="2" --organization-id="1" --partition-table-id="94" --puppet-proxy-id="1" --root-password="\xea\xae\x8f\xf0\x98\x87\x8a\xe9\xb5\xa8\xd0\x9e\xec\x8b\xa4\xe6\xa9\x88\xe0\xae\x88\xe1\x8b\xb8\xe5\x83\x95\xf0\x97\xbf\xa3\xe7\x87\x93\xf0\x96\xa6\x9e\xeb\xa9\x83\xe7\x88\x8a\xe6\x88\x8f\xe7\x9d\x8d\xea\x85\xa0\xef\xac\x85" --environment-id 1


Could not create the host:
  ERF42-5864 [Foreman::Exception]: Unable to connect to libvirt due to: Error making a connection to libvirt URI qemu+ssh://stephen.usersys.redhat.com/system:
  Call to virConnectOpen failed: Cannot recv data: Host key verification failed.: Connection reset by peer. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions.

Comment 11 Bryan Kearney 2018-10-16 18:58:19 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:2927


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