Adding Container Provider Through REST API


#1

Hi ,

I want to add a OpenShift Cluster to CloudForms I have the SA token and all the necessary information and I was successful in adding the Cluster through CloudForms Web UI but I would to to do a curl command to CloudForms and add the OpenShift Cluster.

I can see the REST API docs but not able to find the endpoint to add a container provider.

Can anyone let me know is it not being documented or it does not exists at this moment.

Thanks
Mohammed


#2

@abonas do you know anyone who can help me with this?


#3

Hi, does example help ?

This API syntax works on current ManageIQ version:
( Note: you will have to adjust the urls and ports in the example )

curl --user admin:smartvm \
      -i -X POST -H "Accept: application/json" \
      -d '{
            "type"      : "ManageIQ::Providers::Openshift::ContainerManager",
            "name"      : "TestEndpoints",
            "connection_configurations": [
                {
                    "endpoint": {
                        "role":     "default",
                        "hostname": "east.example.com",
                        "port":     "8443"
                    },
                    "authentication": {
                        "authtype": "bearer",
                        "auth_key": "SecretAuthToken"
                    }
                },
                {
                    "endpoint": {
                        "role":     "hawkular",
                        "hostname": "west.example.com",
                        "port":     "443"
                    },
                    "authentication": {
                        "authtype": "hawkular",
                        "auth_key": "SecretAuthToken"
                    }
                }
            ]
      }' \
      http://127.0.0.1:3000/api/providers -k

#4

If you use Ansible, you can also use the ansible module for that:

http://docs.ansible.com/ansible/latest/manageiq_provider_module.html

for example:

- name: Create a new provider in ManageIQ ('Hawkular' metrics)
  manageiq_provider:
    name: 'EngLab'
    type: 'OpenShift'
    provider:
      auth_key: 'topSecret'
      hostname: 'example.com'
      port: 8443
    metrics:
      role: 'hawkular'
      hostname: 'example.com'
      port: 443
    manageiq_connection:
      url: 'http://127.0.0.1:3000'
      username: 'admin'
      password: 'smartvm'

#5

@Yaacov_Zamir Thanks for the reply I tried the curl command and its works for me.


#6

:slight_smile: