Bug 1391656

Summary: Host created via hammer does not show the CV & Lifecycle Environment inherited from hostgroup
Product: Red Hat Satellite Reporter: Stuart Auchterlonie <sauchter>
Component: Content ManagementAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2.2CC: akofink, bbuckingham, dhlavacd, ehelms, inecas, jcallaha, ktordeur, mhulan, 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-02-21 16:51:07 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:

Description Stuart Auchterlonie 2016-11-03 16:51:37 UTC
Description of problem:

If you create a host via hammer and inherit the CV and lifecycle environment
from the hostgroup, then when you edit the host in the UI, the CV and lifecycle
environments are blank.

Creating a host with the same settings via the GUI correctly pulls the CV
and lifecycle environment 

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

Satellite 6.2.2

How reproducible:

100%

Steps to Reproduce:
1. Create hostgroup, set lifecycle environment & CV
2. Create host via hammer setting hostgroup to the hostgroup
   created in #1
3.

Actual results:

Edit the host in the GUI, and the CV & Lifecycle environments
will be blank

Expected results:

Edit the host in the GUI, and the CV & Lifecycle environments
will be populated with the values from the hostgroup it is a
part of.


Additional info:

A host created using the GUI will have the CV and Lifecycle Env
correctly populated.

Found a related resolved bz
- https://bugzilla.redhat.com/show_bug.cgi?id=1312157
- https://projects.theforeman.org/issues/13910

Comment 2 Andrew Kofink 2016-11-17 20:38:59 UTC
Created redmine issue http://projects.theforeman.org/issues/17389 from this bug

Comment 3 Bryan Kearney 2016-11-17 21:09:47 UTC
Upstream bug component is Content Management

Comment 4 Bryan Kearney 2016-11-30 21:09:20 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17389 has been resolved.

Comment 5 Kenny Tordeurs 2016-12-01 07:51:44 UTC
*** Bug 1399128 has been marked as a duplicate of this bug. ***

Comment 6 Kenny Tordeurs 2016-12-01 07:53:53 UTC
Did a test on Satellite 6.2.4 and sharing the information here:

1. The hostgroup contains the following:

# curl -X GET -s -k -u admin:RedHat1! https://provisioning.sysmgmt.lan/api/v2/hostgroups/3 | python -m json.tool 
~~~
{
    "all_puppetclasses": [
        {
            "id": 15,
            "module_name": "foreman_scap_client",
            "name": "foreman_scap_client"
        }
    ],
    "ancestry": null,
    "architecture_id": 1,
    "architecture_name": "x86_64",
    "compute_profile_id": 1,
    "compute_profile_name": "1-Small",
    "config_groups": [],
    "content_source_id": 1,
    "content_source_name": "provisioning.sysmgmt.lan",
    "content_view_id": 1,
    "content_view_name": "Default Organization View",
    "created_at": "2016-02-29 08:34:14 UTC",
    "domain_id": 1,
    "domain_name": "sysmgmt.lan",
    "environment_id": 1,
    "environment_name": "production",
    "id": 3,
    "lifecycle_environment_id": 1,
    "lifecycle_environment_name": "Library",
    "locations": [
        {
            "description": "",
            "id": 2,
            "name": "Default Location",
            "title": "Default Location"
        },
        {
            "description": "",
            "id": 7,
            "name": "test_location",
            "title": "test_location"
        }
    ],
    "medium_id": null,
    "medium_name": null,
    "name": "RHEL7",
    "operatingsystem_id": 1,
    "operatingsystem_name": "RedHat 7.2",
    "organizations": [
        {
            "description": "",
            "id": 1,
            "name": "Default Organization",
            "title": "Default Organization"
        },
        {
            "description": "",
            "id": 4,
            "name": "virt_who_test",
            "title": "virt_who_test"
        }
    ],
    "parameters": [
        {
            "id": 3,
            "name": "kt_activation_keys",
            "value": "RHEL7_Library"
        }
    ],
    "parent_id": null,
    "parent_name": null,
    "ptable_id": 63,
    "ptable_name": "Kickstart default",
    "puppet_ca_proxy_id": 1,
    "puppet_proxy_id": 1,
    "puppetclasses": [
        {
            "id": 15,
            "module_name": "foreman_scap_client",
            "name": "foreman_scap_client"
        }
    ],
    "realm_id": null,
    "realm_name": null,
    "subnet_id": 1,
    "subnet_name": "sysmgmt.lan",
    "template_combinations": [],
    "title": "RHEL7",
    "updated_at": "2016-11-04 15:18:28 UTC"
}
~~~


2. When creating a new host with an API call like:

# curl -H "Accept:application/json,version=2" \
       -H "Content-Type:application/json" -X POST -u admin:RedHat1! \
       -k -d "{\"host\":{\"name\":\"ktordeur-test-api-7\",\"hostgroup_id\":\"3\",\"compute_resource_id\":\"1\",\"location_id\":\"2\",\"organization_id\":\"1\"}}" \
       https://provisioning.sysmgmt.lan/api/hosts

output:
~~~
{"ip":"192.168.111.124","environment_id":1,"environment_name":"production","last_report":null,"mac":"52:54:00:2a:64:4e","realm_id":null,"realm_name":null,"sp_mac":null,"sp_ip":null,"sp_name":null,"domain_id":1,"domain_name":"sysmgmt.lan","architecture_id":1,"architecture_name":"x86_64","operatingsystem_id":1,"operatingsystem_name":"RedHat 7.2","subnet_id":1,"subnet_name":"sysmgmt.lan","sp_subnet_id":null,"ptable_id":63,"ptable_name":"Kickstart default","medium_id":null,"medium_name":null,"build":false,"comment":null,"disk":null,"installed_at":null,"model_id":null,"hostgroup_id":3,"owner_id":3,"owner_type":"User","enabled":true,"puppet_ca_proxy_id":1,"managed":true,"use_image":null,"image_file":"","uuid":"490c4bf7-ac41-4c67-be38-ff247f9d3e15","compute_resource_id":1,"compute_resource_name":"satotest","compute_profile_id":1,"compute_profile_name":"1-Small","capabilities":["build","image"],"provision_method":"build","puppet_proxy_id":1,"certname":"ktordeur-test-api-7.sysmgmt.lan","image_id":null,"image_name":null,"created_at":"2016-11-28 10:18:47 UTC","updated_at":"2016-11-28 10:18:47 UTC","last_compile":null,"global_status":0,"global_status_label":"Warning","organization_id":1,"organization_name":"Default Organization","location_id":2,"location_name":"Default Location","puppet_status":0,"model_name":null,"configuration_status":0,"configuration_status_label":"No reports","build_status":0,"build_status_label":"Installed","name":"ktordeur-test-api-7.sysmgmt.lan","id":199,"hostgroup_name":"RHEL7","hostgroup_title":"RHEL7","parameters":[],"interfaces":[{"id":165,"name":"ktordeur-test-api-7.sysmgmt.lan","ip":"192.168.111.124","mac":"52:54:00:2a:64:4e","identifier":null,"primary":true,"provision":true,"type":"interface"}],"puppetclasses":[],"config_groups":[],"all_parameters":[{"id":3,"name":"kt_activation_keys","value":"RHEL7_Library"}],"all_puppetclasses":[{"id":15,"name":"foreman_scap_client","module_name":"foreman_scap_client"}],"permissions":{"view_hosts":true,"create_hosts":true,"edit_hosts":true,"destroy_hosts":true,"build_hosts":true,"power_hosts":true,"console_hosts":true,"ipmi_boot":true,"puppetrun_hosts":true,"view_discovered_hosts":true,"submit_discovered_hosts":true,"auto_provision_discovered_hosts":true,"provision_discovered_hosts":true,"edit_discovered_hosts":true,"destroy_discovered_hosts":true}}
~~~

3. The host gets created but some parts are missing:

# curl -X GET -s -k -u admin:RedHat1! https://provisioning.sysmgmt.lan/api/v2/hosts/199 | python -m json.tool 
~~~
{
    "all_parameters": [
        {
            "id": 3,
            "name": "kt_activation_keys",
            "value": "RHEL7_Library"
        }
    ],
    "all_puppetclasses": [
        {
            "id": 15,
            "module_name": "foreman_scap_client",
            "name": "foreman_scap_client"
        }
    ],
    "architecture_id": 1,
    "architecture_name": "x86_64",
    "build": false,
    "build_status": 0,
    "build_status_label": "Installed",
    "capabilities": [
        "build",
        "image"
    ],
    "certname": "ktordeur-test-api-7.sysmgmt.lan",
    "comment": null,
    "compute_profile_id": 1,
    "compute_profile_name": "1-Small",
    "compute_resource_id": 1,
    "compute_resource_name": "satotest",
    "config_groups": [],
    "configuration_status": 0,
    "configuration_status_label": "No reports",
    "created_at": "2016-11-28 10:18:47 UTC",
    "disk": null,
    "domain_id": 1,
    "domain_name": "sysmgmt.lan",
    "enabled": true,
    "environment_id": 1,
    "environment_name": "production",
    "global_status": 0,
    "global_status_label": "Warning",
    "hostgroup_id": 3,
    "hostgroup_name": "RHEL7",
    "hostgroup_title": "RHEL7",
    "id": 199,
    "image_file": "",
    "image_id": null,
    "image_name": null,
    "installed_at": null,
    "interfaces": [
        {
            "id": 165,
            "identifier": null,
            "ip": "192.168.111.124",
            "mac": "52:54:00:2a:64:4e",
            "name": "ktordeur-test-api-7.sysmgmt.lan",
            "primary": true,
            "provision": true,
            "type": "interface"
        }
    ],
    "ip": "192.168.111.124",
    "last_compile": null,
    "last_report": null,
    "location_id": 2,
    "location_name": "Default Location",
    "mac": "52:54:00:2a:64:4e",
    "managed": true,
    "medium_id": null,
    "medium_name": null,
    "model_id": null,
    "model_name": null,
    "name": "ktordeur-test-api-7.sysmgmt.lan",
    "operatingsystem_id": 1,
    "operatingsystem_name": "RedHat 7.2",
    "organization_id": 1,
    "organization_name": "Default Organization",
    "owner_id": 3,
    "owner_type": "User",
    "parameters": [],
    "permissions": {
        "auto_provision_discovered_hosts": true,
        "build_hosts": true,
        "console_hosts": true,
        "create_hosts": true,
        "destroy_discovered_hosts": true,
        "destroy_hosts": true,
        "edit_discovered_hosts": true,
        "edit_hosts": true,
        "ipmi_boot": true,
        "power_hosts": true,
        "provision_discovered_hosts": true,
        "puppetrun_hosts": true,
        "submit_discovered_hosts": true,
        "view_discovered_hosts": true,
        "view_hosts": true
    },
    "provision_method": "build",
    "ptable_id": 63,
    "ptable_name": "Kickstart default",
    "puppet_ca_proxy_id": 1,
    "puppet_proxy_id": 1,
    "puppet_status": 0,
    "puppetclasses": [],
    "realm_id": null,
    "realm_name": null,
    "sp_ip": null,
    "sp_mac": null,
    "sp_name": null,
    "sp_subnet_id": null,
    "subnet_id": 1,
    "subnet_name": "sysmgmt.lan",
    "updated_at": "2016-11-28 10:18:47 UTC",
    "use_image": null,
    "uuid": "490c4bf7-ac41-4c67-be38-ff247f9d3e15"
}
~~~

4. The following parts are not being filled in:
- Lifecycle env
- Content view
- Media

Comment 7 Peter Ondrejka 2017-01-23 11:53:44 UTC
Verified in Satellite 6.3 snap 8, host created via hammer cli now correctly inherits lc and cv parameters from the host group:

~]# hammer host create --hostgroup-id 1 --location-id 2 --organization-id 1 --name myhost --root-pass changeme --medium rhel7-kickstart --subnet subsub --compute-resource libvirt-local
Host created

~]# hammer host info --id 11
...
Content Information:      
    Content View:          stage1
    Lifecycle Environment: Library
    Applicable Errata:     
        Enhancement: 0
        Bug Fix:     0
        Security:    0
...


Also via api .../api/v2/hosts/11:
...
"medium_id": 9,
"medium_name": "rhel7-kickstart",
...
"hostgroup_name": "testhg",
"hostgroup_title": "testhg",
"content_facet_attributes": {

    "id": 10,
    "uuid": null,
    "content_view_id": 2,
    "content_view_name": "stage1",
    "lifecycle_environment_id": 1,
    "lifecycle_environment_name": "Library",
    "content_view": {
        "id": 2,
        "name": "stage1"
    },
    "lifecycle_environment": {
        "id": 1,
        "name": "Library"
    },
    "errata_counts": {
        "security": 0,
        "bugfix": 0,
        "enhancement": 0,
        "total": 0
    },
    "content_view_version": "1.0",
    "content_view_version_id": 2,
    "content_view_default?": false,
    "lifecycle_environment_library?": true,
    "katello_agent_installed": false

},
...

Comment 8 Satellite Program 2018-02-21 16:51:07 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