Skip to content

Openstack:VMs from cURL

lbonanomi edited this page Mar 22, 2019 · 2 revisions

First principles, simplest tools.

From https://openstack.whatever_domain.com/horizon/project/access_and_security/ get the "Compute" endpoint

  1. Fetch a token
curl -i -H 'Content-Type: application/json' -d '{ 
    "auth": { 
        "identity": { 
            "methods": [ "password" ], 
            "password": { 
                "user": { 
                    "name": "lbonanomi", 
                    "domain": { "name": "Default" }, 
                    "password": "LULZ_NO_PASSWORDS" } 
                } 
            }, 
            "scope": { 
                "project": { 
                    "name":"$TENANCY_NAME", 
                    "domain": { 
                    "id": "default"
                }
            }
        }
    }
}'  https://openstack.$DOMAIN.com:5000/v3/auth/tokens | awk '/X-Subject-Token/ { print $NF }'
  1. Get 'Flavor' list
curl -s -H 'X-Auth-Token: $FETCHED_TOKEN' https://$COMPUTE_ENDPOINT/flavors | python -m json.tool
  1. Get ISO
curl   -H 'Content-Type: application/json'  -H 'X-Auth-Token: $FETCHED_TOKEN' https://$COMPUTE_ENDPOINT/images | python -m json.tool
  1. Boot
curl -s -X POST -H 'Content-Type: application/json'  -H 'X-Auth-Token: $FETCHED_TOKEN' -d '{ "server" : { "flavorRef" : "$FLAVOR", "name" : "NAME OF THE SERVER", "key_name": "$KEYNAME" , "accessIPv4": "1.2.3.4", "accessIPv6": "80fe::", "imageRef": "$IMAGE", "OS-DCF:diskConfig": "AUTO" }}'  https://$COMPUTE_ENDPOINT/servers
  1. Get available IPs:
curl -i -H 'Content-Type: application/json' -d '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"lbonanomi","domain":{"id":"default"},"password":"LULZ_NO_PASSWORDS"}}},"scope":{"project":{"name":"$TENANCY_NAME","domain":{"id":"default"}}}}}'  "https://openstack.$DOMAIN.com:5000/v3/auth/tokens?nocatalog"
  1. Hang an IP on it
curl -s -X POST -H 'Content-Type: application/json'  -H 'X-Auth-Token: $FETCHED_TOKEN'   -d '{ 
    "addFloatingIp" : { 
            "address": "100.70.19.216"  
        } 
    }'  https://$COMPUTE_ENDPOINT
Clone this wiki locally