Bug 1257220 - Unable to add RHEV hypervisors to deployment via API
Unable to add RHEV hypervisors to deployment via API
Status: CLOSED NOTABUG
Product: Red Hat Quickstart Cloud Installer
Classification: Red Hat
Component: Installation - RHCI (Show other bugs)
1.0
Unspecified Unspecified
unspecified Severity high
: TP2
: 1.0
Assigned To: jmagen@redhat.com
Tasos Papaioannou
Dan Macpherson
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-26 10:18 EDT by jcallaha
Modified: 2016-08-12 17:00 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-04-04 10:40:15 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description jcallaha 2015-08-26 10:18:52 EDT
Description of problem:
If a user wants to create a deployment, through the API, they are currently unable to add RHEV hypervisors.

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

How reproducible:
Always

Steps to Reproduce:
1. create a deployment either via API or UI, but do not add RHEV information.
2. send an API PUT request to /fusor/api/v21/deployments/:id with the rhev host information. (see additional details)
3. verify either via API or UI that the rhev hypervisors weren't selected.

Actual results:
See additional info

Expected results:
The hypervisors are added to the deployment.

Additional info:
http://pastebin.test.redhat.com/308023
Comment 1 John Matthews 2015-08-28 10:58:25 EDT
Joseph,

Please provide a sample JSON representation of a deployment object which can be passed into the REST API to help jcalla with his request.
Comment 2 jcallaha 2015-08-31 17:05:56 EDT
John,
I've got a pretty solid grasp on the deployment object json and have no issues updating any other value i've attempted. Not sure why the pastebin link has been cleared, but this is the result of passing along the rhev_engine_id, discovered_host_id, and discovered_hosts_ids. Notice that the host_ids list is still empty.

{
  "deployment": {
    "id": 2,
    "name": "new",
    "description": null,
    "deploy_rhev": true,
    "deploy_cfme": true,
    "deploy_openstack": false,
    "rhev_engine_admin_password": "changeme",
    "rhev_database_name": "Default",
    "rhev_cluster_name": "Default",
    "rhev_storage_name": "my_storage",
    "rhev_storage_type": "NFS",
    "rhev_storage_address": "192.168.77.1",
    "rhev_cpu_type": null,
    "rhev_share_path": "/home/nfs/rhev-data",
    "rhev_export_domain_name": "export",
    "rhev_export_domain_address": "192.168.77.1",
    "rhev_export_domain_path": "/home/nfs/rhev-exports",
    "rhev_local_storage_path": null,
    "rhev_gluster_node_name": null,
    "rhev_gluster_node_address": null,
    "rhev_gluster_ssh_port": null,
    "rhev_gluster_root_password": null,
    "rhev_is_self_hosted": false,
    "cfme_install_loc": null,
    "foreman_task_uuid": null,
    "upstream_consumer_uuid": "668899eb-dec7-4d88-99c1-8baf966f5ffd",
    "upstream_consumer_name": "jake-multi",
    "rhev_root_password": "changeme",
    "cfme_root_password": null,
    "host_naming_scheme": "Freeform",
    "custom_preprend_name": null,
    "enable_access_insights": true,
    "cfme_address": null,
    "rhev_engine_host_id": 2,
    "created_at": "2015-08-25T18:14:17Z",
    "updated_at": "2015-08-26T13:16:22Z",
    "organization_id": 1,
    "lifecycle_environment_id": null,
    "discovered_host_id": 2,
    "discovered_host_ids": [],
    "subscription_ids": []
  },
Comment 3 jcallaha 2015-09-01 16:39:03 EDT
API call
PUT https://smicro-5037-05.cfme.lab.eng.rdu2.redhat.com/fusor/api/v21/deployments/13
{
        "rhev_engine_host_id": 4,
        "discovered_host_id": 4,
        "discovered_host_ids": [5]
}


Returned data
{
  "deployment": {
    "id": 13,
    "name": "bz reproduction",
    "description": null,
    "deploy_rhev": true,
    "deploy_cfme": true,
    "deploy_openstack": false,
    "rhev_engine_admin_password": null,
    "rhev_database_name": "Default",
    "rhev_cluster_name": "Default",
    "rhev_storage_name": "my_storage",
    "rhev_storage_type": null,
    "rhev_storage_address": null,
    "rhev_cpu_type": null,
    "rhev_share_path": null,
    "rhev_export_domain_name": "my_export",
    "rhev_export_domain_address": null,
    "rhev_export_domain_path": null,
    "rhev_local_storage_path": null,
    "rhev_gluster_node_name": null,
    "rhev_gluster_node_address": null,
    "rhev_gluster_ssh_port": null,
    "rhev_gluster_root_password": null,
    "rhev_is_self_hosted": false,
    "cfme_install_loc": null,
    "foreman_task_uuid": null,
    "upstream_consumer_uuid": "668899eb-dec7-4d88-99c1-8baf966f5ffd",
    "upstream_consumer_name": "jake-multi",
    "rhev_root_password": null,
    "cfme_root_password": null,
    "cfme_admin_password": null,
    "host_naming_scheme": null,
    "custom_preprend_name": null,
    "enable_access_insights": true,
    "cfme_address": null,
    "rhev_engine_host_id": 4,
    "created_at": "2015-09-01T20:34:44Z",
    "updated_at": "2015-09-01T20:37:11Z",
    "organization_id": 1,
    "lifecycle_environment_id": null,
    "discovered_host_id": 4,
    "discovered_host_ids": [],
    "subscription_ids": []
  },
Comment 4 jmagen@redhat.com 2015-09-02 07:35:22 EDT
Jake, 

Below is the ember code for adding/removing hypervisors.
So, you see it users PUT with a payload of "deployment" as the root element and 
"discovered_host_ids" as taking an [array of host id's].
It looks like you are doing it right. I just verified locally and it worked.

{
   "deployment": {
    "discovered_host_ids": [2, 3]
   }
}

        Ember.$.ajax({
            url: '/fusor/api/v21/deployments/' + deployment.get('id'),
            type: "PUT",
            data: JSON.stringify({'deployment': { 'discovered_host_ids': hypervisorModelIds } }),
            headers: {
                "Accept": "application/json",
                "Content-Type": "application/json",
                "X-CSRF-Token": token,
                "Authorization": "Basic " + self.get('session.basicAuthToken')
            },
            success: function(response) {
              resolve(response);
              if (redirectPath) {
                self.transitionTo('rhev-options');
              }
            },

            error: function(response){
              reject(response);
            }
        });
Comment 5 jcallaha 2015-09-02 09:20:08 EDT
Using a PUT payload like you've suggested worked.
{
    "deployment": {
        "discovered_host_ids": [4,5]
    }
}

Received
...
"discovered_host_id": 4,
    "discovered_host_ids": [
      5,
      4
    ],
...

I guess the remaining question is why this particular parameter needs to be wrapped in a "deployment" element when most (if not all) others do not.
Comment 7 jmagen@redhat.com 2015-10-29 17:17:43 EDT
The root node vs non-root node is a long-standing issue with inconsistancy between the Foreman and Katello API's. Foreman used wrapped node and Katello did not, and then Foreman added functionality where non-root node would work, but all the documentation in Foreman is with the root node.  In short, the default of rails is with a root node. I didn't add the option to Fusor to not have it.
Comment 8 Tasos Papaioannou 2016-03-23 13:13:36 EDT
I've verified that using the "deployment" root element and passing a list of id's to discovered_host_ids adds those hosts to the list of selected hypervisors.

E.g.,

# curl -k -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' https://fusor.example.com/fusor/api/v21/deployments/1 -d '{"deployment": {"discovered_host_ids": [2]}}' -u admin:XXXX

Was any code actually modified here? The BZ was set to MODIFIED then ON_QA, but it's not clear what was changed, if anything.
Comment 9 John Matthews 2016-03-23 13:31:32 EDT
Hi Tasos,

In regard to code being modified, no I'm not aware of any code being modified for this BZ.  This BZ has not reported a problem for us to modify any code, way I understand this BZ it's been a conversation to learn how to use our API.

Is there anything you would like to see before we close this out?
Comment 10 Tasos Papaioannou 2016-04-04 10:24:52 EDT
If there's nothing being changed, then I'm not sure what we need the BZ to be ON_QA for. Shouldn't it be closed NOTABUG?

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