Bug 1721848 - Implement CLI and API endpoints for GCE Compute Resource
Summary: Implement CLI and API endpoints for GCE Compute Resource
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Compute Resources - GCE
Version: 6.6.0
Hardware: Unspecified
OS: Unspecified
unspecified
urgent vote
Target Milestone: 6.7.0
Assignee: Kavita
QA Contact: Jitendra Yejare
URL:
Whiteboard:
Depends On:
Blocks: 1721890 1777312
TreeView+ depends on / blocked
 
Reported: 2019-06-19 07:11 UTC by Jitendra Yejare
Modified: 2020-04-14 13:25 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Support has been added to the Google Compute Engine (GCE) compute resource for Hammer CLI and API endpoints.
Clone Of:
Environment:
Last Closed: 2020-04-14 13:24:36 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 27155 Normal Closed Implement CLI and API endpoints for GCE Compute Resource 2020-02-24 07:53:01 UTC
Red Hat Product Errata RHSA-2020:1454 None None None 2020-04-14 13:24:59 UTC

Description Jitendra Yejare 2019-06-19 07:11:07 UTC
- Description of problem:

Looks like the GCE Compute Resource creation from API and CLI isn't possible for now as the options to create the GCE CR are not available from those endpoints.

CLI: No options for GCE CR:
--------------------------------

# hammer -u admin -p changeme compute-resource create --help


API: No options for GCE CR:
--------------------------------
https://<server_fqdn>/apidoc/v2/compute_resources/create.html


- Version-Release number of selected component (if applicable):
Satellite 6.6 snap 7

- How reproducible:
Always

- Steps to Reproduce:
1. Attempt to create a GCE Compute Resource from CLI / API.

- Actual results:
No options/fields to create GCE CR from API / CLI as said in the description of this bug.

- Expected results:
Options/fields to create GCE CR from API/CLI should be available.

Additional info:

Comment 3 Kavita 2019-06-26 07:22:04 UTC
Created redmine issue https://projects.theforeman.org/issues/27155 from this bug

Comment 4 Kavita 2019-06-26 12:49:39 UTC
Hello Jitendra,

Could you please confirm it was working previously? 
As far as I know it wasn't working before.If that is the case BZ should be marked as RFE not a bug.

Comment 5 Jitendra Yejare 2019-06-26 14:44:09 UTC
Not sure if those options were present for previous satellite versions like 6.4 and below but, in 6.5 those options to create GCE CR is not present in API and CLI.

Comment 6 Anurag Patel 2019-07-04 19:01:51 UTC
If API and CLI support is missing in 6.5, then I believe it is unimplemented. I've reached out to PM to clarify if this can be broken out into a story for Sat 6.7. If that's the case, we can mark this as RFE and defer it.

Comment 7 Jitendra Yejare 2020-01-17 07:51:17 UTC
Verified!

@Satellie 6.7 snap 8


Steps and Observation :
--------------------------------

CLI:

# hammer compute-resource create --help | grep GCE
 --email EMAIL                               Email for GCE only
 --key-path KEY_PATH                         Certificate path for GCE only
 --project PROJECT                           Project id for GCE only
 --provider PROVIDER                         Providers include Libvirt, Ovirt, EC2, Vmware, Openstack, GCE
 --zone ZONE                                 For GCE only




API/ APIDOC:

compute_resource[project]
optional , nil allowed 	

Project id for GCE only

Validations:

    Must be a String

compute_resource[email]
optional , nil allowed 	

Email for GCE only

Validations:

    Must be a String

compute_resource[key_path]
optional , nil allowed 	

Certificate path for GCE only

Validations:

    Must be a String

compute_resource[zone]
optional , nil allowed 	

for GCE only

Validations:

    Must be a String



COMPUTE RESOURCE CREATE using API / CLI:


Thanks for fixing / improving GCE.
The CR create has been verified by API / CLI endpoints and it works flawlessly.
The Compute Resource c

Comment 8 Kavita 2020-02-10 14:04:33 UTC
Hello,

I got the feedback during "CEE enablement for Satellite 6.7 - Demo sessions" that it would be good to add sample hammer commands for GCE.
Most of the GCE Hammer commands are similar with other compute-resources so adding below sample commands specific to GCE compute-resource.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sample Hammer commands for Documentation:


## Create GCE Compute Resource:

Please check below list of options available for GCE compute-resource:

# hammer compute-resource create --help | grep GCE

 --email EMAIL                               Email for GCE only
 --key-path KEY_PATH                         Certificate path for GCE only
 --project PROJECT                           Project id for GCE only
 --provider PROVIDER                         Providers include Libvirt, Ovirt, EC2, Vmware, Openstack, GCE
 --zone ZONE                                 For GCE only



# hammer compute-resource create --name 'test-hammer-gce' --provider 'gce' --project 'test-dev' --key-path 'gce_config.json' --zone 'us-west1-b' --email 'xyz@test.com'


## Create Image:

# hammer  compute-resource image create --name 'test-image' --operatingsystem-id 1 --architecture-id 1 --uuid '378010XXXXXXXXX' --compute-resource-id 6 --username 'test-admin'

Note that Google do not provide the ability to ssh in directly as root so while creating an image, enter username except root.


## Create Compute Profile:

# hammer compute-profile create --name gce_cp

## Set Compute Attributes for Compute Profile:

# hammer compute-profile values create --help

GCE:
    --volume:
      size_gb             Volume size in GB, integer value

    --compute-attributes:
      machine_type
      network
      associate_external_ip


# hammer compute-profile values create --compute-attributes "machine_type=f1-micro,associate_external_ip=true,network=default" --compute-profile-id 8 --compute-resource-id 6 --volume "size_gb=20"  --location-id 1 --organization-id  2


## Host creation:

# hammer host create --name gceHammer --organization-id 1 --location-id 2 --compute-resource-id 6  --puppet-environment-id 1 --compute-attributes 'machine_type=g1-small,network=default,associate_external_ip=true' --volume 'size_gb=13' --provision-method 'image' --root-password changeme --interface "type=interface,domain_id=1,managed=true,primary=true,provision=true" --image-id 1 --puppet-ca-proxy-id 1 --puppet-proxy-id 1 --architecture-id 1 --operatingsystem-id 1

Note that using hammer, User needs to send Foreman image ID inside --image-id option 
whereas using API, User needs to send image UUID inside compute-attributes param against "image_id" key.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As it is part of hammer-cli-foreman not having separate plugin, would it be possible to include these example commands in Hammer documentation?

Comment 9 Melanie Corr 2020-02-10 14:29:25 UTC
Hi Kavita, 

thank you very much for bringing this to my attention. 

I have created a docs bug to capture this. I might be back to you with some questions as I work: 

https://bugzilla.redhat.com/show_bug.cgi?id=1801257

Thanks, 

Melanie

Comment 12 errata-xmlrpc 2020-04-14 13:24:36 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-2020:1454


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