Bug 1620179

Summary: no way to list cluster IDs inside compute resource
Product: Red Hat Satellite Reporter: John Berninger <jberning>
Component: HammerAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: Sanket Jagtap <sjagtap>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.2CC: akarsale, apatel, chrobert, dhlavacd, kgaikwad, mbacovsk, mhulan, mshira, pcreech, rabajaj, sghai
Target Milestone: 6.5.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: https://projects.theforeman.org/issues/24748?next_issue_id=24747
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-14 12:37:48 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 John Berninger 2018-08-22 15:31:05 UTC
Description of problem:
A VMware type compute resource can have multiple clusters defined within it (defined by VMware). Full use of the `hammer` command for provisioning requires we specify a cluster ID to deploy to. There is no way to currently list the clusters within a compute resource.

Version-Release number of selected component (if applicable):
tfm-rubygem-hammer_cli-0.11.0.1-1.el7sat.noarch


How reproducible:
Always

Steps to Reproduce:
1. Configure a VMware type compute resource within Satellite 6.3
2. Issue `hammer compute resource info --id 1`
3. See no information about clusters within the given compute resource

Actual results:
No information on clusters, no additional commands to list information on clusters in `hammer compute-resource --help`

Expected results:
Either a listing of all clusters or an additional command sequence to get that list.

Additional info:

Comment 2 Chris Roberts 2018-08-29 19:33:18 UTC
Confirmed this is a bug with hammer and not Foreman:

We see it missing from here:

https://github.com/theforeman/hammer-cli-foreman/blob/master/lib/hammer_cli_foreman/compute_resource.rb

Yet I can see the ID when I query the API:

chrobert@vault111:~/certs$ http -j --verify=no -a admin:changeme -v GET https://vmwaresat.satellite.lab.eng.rdu2.redhat.com/api/compute_resources/1/available_clusters
GET /api/compute_resources/1/available_clusters HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Authorization: Basic YWRtaW46Y2hhbmdlbWU=
Connection: keep-alive
Content-Type: application/json
Host: vmwaresat.satellite.lab.eng.rdu2.redhat.com
User-Agent: HTTPie/0.9.8



HTTP/1.1 200 OK
Apipie-Checksum: d060cb9648d89f2f6c219b50d34e38d1
Cache-Control: max-age=0, private, must-revalidate
Connection: Keep-Alive
Content-Encoding: gzip
Content-Length: 180
Content-Security-Policy: default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data: *.gravatar.com; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'
Content-Type: application/json; charset=utf-8
Date: Wed, 29 Aug 2018 19:29:35 GMT
ETag: W/"0d520ae6afa3c835428dcc2e59e4c0e4-gzip"
Foreman_api_version: 2
Foreman_version: 1.15.6.45
Keep-Alive: timeout=5, max=10000
Server: Apache/2.4.6 (Red Hat Enterprise Linux)
Set-Cookie: _session_id=beccb5bb0220b12ce0c307b8c44bc67d; path=/; secure; HttpOnly
Status: 200 OK
Strict-Transport-Security: max-age=631152000; includeSubdomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: sameorigin
X-Permitted-Cross-Domain-Policies: none
X-Powered-By: Phusion Passenger 4.0.18
X-Request-Id: dfb22ed2-de79-411d-868b-ba6fd4c72d89
X-Runtime: 0.409989
X-XSS-Protection: 1; mode=block

{
    "page": 1,
    "per_page": 20,
    "results": [
        {
            "full_path": "Satellite_Engineering",
            "id": "domain-c7",
            "name": "Satellite_Engineering"
        },
        {
            "full_path": "SysMgmt_vMotion",
            "id": "domain-c20",
            "name": "SysMgmt_vMotion"
        }
    ],
    "search": null,
    "sort": {
        "by": null,
        "order": null
    },
    "subtotal": 1,
    "total": 1
}

Comment 3 Chris Roberts 2018-08-29 19:53:39 UTC
Played around on a 6.3 box and got this working after adding it into hammer:

hammer> compute-resource clusters --id 1
----------------------|-----------
NAME                  | ID        
----------------------|-----------
Satellite_Engineering | domain-c7 
SysMgmt_vMotion       | domain-c20
----------------------|-----------

Will create a PR for this.

Comment 4 Satellite Program 2018-08-29 22:13:05 UTC
Upstream bug assigned to akofink

Comment 5 Satellite Program 2018-08-29 22:13:10 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24747 has been resolved.

Comment 7 Sanket Jagtap 2018-11-28 07:44:25 UTC
Build:Satellite 6.5.0 snap 5

hammer> compute-resource clusters --id 3 
-----------|----------------------
ID         | NAME                 
-----------|----------------------
domain-c7  | Satellite_Engineering
domain-c20 | SysMgmt_vMotion      
-----------|----------------------
Page 1 of 1 (use --page and --per-page for navigation).
hammer> compute-resource clusters --help
Usage:
     compute-resource clusters [OPTIONS]

Options:
 --id ID                                  
 --location LOCATION_NAME                Location name
 --location-id LOCATION_ID                
 --location-title LOCATION_TITLE         Location title
 --name NAME                             Compute resource name
 --organization ORGANIZATION_NAME        Organization name
 --organization-id ORGANIZATION_ID       Organization ID
 --organization-title ORGANIZATION_TITLE Organization title
 -h, --help                              Print help

But, it shows use the parameters to sort it page wise which doesn't work. the current Vmware has only 2 clusters, but looking at error it seems the options are not recognised. Wnat to confirm if it is a issue.
hammer> compute-resource clusters --id 3 --per-page 2
Error: Unrecognised option '--per-page'.

See: ' compute-resource clusters --help'.
hammer> compute-resource clusters --id 3 --page 2
Error: Unrecognised option '--page'.

See: ' compute-resource clusters --help'.

Comment 8 Tomas Strachota 2018-11-28 08:13:54 UTC
The API for clusters always lists all the records. Pagination isn't supported there so it is correct that --page and --per-page is missing in the command. 

The bug is that hammer shouldn't be displaying the pagination message when an api doesn't offer page and per_page parameters. Since it's a generic problem in hammer's core I'd prefer fixing it in a separate bug.

Comment 9 Sanket Jagtap 2018-12-18 07:00:42 UTC
ACK, Let's create and track it as a separate bug


Moving the bug to verified,as it solves the original issue

Comment 11 errata-xmlrpc 2019-05-14 12:37:48 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-2019:1222