curl命令访问openstack api

nova--debug list

 

curl -i'http://192.168.0.2:5000/v2.0/tokens' -X POST -H "Accept:application/json" -H "Content-Type: application/json" -H"User-Agent: python-novaclient" -d '{"auth": {"tenantName":"demo", "passwordCredentials": {"username":"admin", "password": "root"}}}'

返回信息如下:

HTTP/1.1 200 OK

Date: Tue, 25 Nov 2014 06:42:53 GMT

Server: Apache/2.4.7 (Ubuntu)

Vary: X-Auth-Token

Content-Length: 3861

Content-Type: application/json

 

{"access": {"token":{"issued_at": "2014-11-25T06:42:53.218237","expires": "2014-11-25T07:42:53Z", "id": "4aef6bf6c54c425f9217942a53aece7f[标注1] ", "tenant":{"description": null, "enabled": true, "id":"d49aaa14428c4b3b87e69cc41f8efa1d", "name":"demo"}, "audit_ids":["YFX-bWZTSf-hB2kRJ5emwQ"]}, "serviceCatalog":[{"endpoints": [{"adminURL":"http://192.168.0.2:8774/v2/d49aaa14428c4b3b87e69cc41f8efa1d","region": "RegionOne", "internalURL":"http://192.168.0.2:8774/v2/d49aaa14428c4b3b87e69cc41f8efa1d","id": "23707adfaf29418091aee3d67530ee29","publicURL":"http://192.168.0.2:8774/v2/d49aaa14428c4b3b87e69cc41f8efa1d"}],"endpoints_links": [], "type": "compute","name": "nova"}, {"endpoints":[{"adminURL":"http://192.168.0.2:8774/v2.1/d49aaa14428c4b3b87e69cc41f8efa1d","region": "RegionOne", "internalURL":"http://192.168.0.2:8774/v2.1/d49aaa14428c4b3b87e69cc41f8efa1d","id": "2340bfd52eb54a909342cc9718f86962","publicURL": "http://192.168.0.2:8774/v2.1/d49aaa14428c4b3b87e69cc41f8efa1d"}],"endpoints_links": [], "type": "computev21","name": "novav21"}, {"endpoints":[{"adminURL":"http://192.168.0.2:8776/v2/d49aaa14428c4b3b87e69cc41f8efa1d","region": "RegionOne", "internalURL":"http://192.168.0.2:8776/v2/d49aaa14428c4b3b87e69cc41f8efa1d","id": "098fa4d2f5734eb09d6e87e0fa09f465","publicURL":"http://192.168.0.2:8776/v2/d49aaa14428c4b3b87e69cc41f8efa1d"}],"endpoints_links": [], "type": "volumev2","name": "cinderv2"}, {"endpoints":[{"adminURL": "http://192.168.0.2:3333","region": "RegionOne", "internalURL":"http://192.168.0.2:3333", "id":"1caf05b4e9264c73a2b784d96464ab33", "publicURL":"http://192.168.0.2:3333"}], "endpoints_links": [],"type": "s3", "name": "s3"},{"endpoints": [{"adminURL":"http://192.168.0.2:9292", "region": "RegionOne","internalURL": "http://192.168.0.2:9292", "id":"475c5e3a58774c0db84ff8cda0ed5734", "publicURL":"http://192.168.0.2:9292"}], "endpoints_links": [],"type": "image", "name": "glance"},{"endpoints": [{"adminURL":"http://192.168.0.2:8000/v1", "region":"RegionOne", "internalURL":"http://192.168.0.2:8000/v1", "id":"06877bf26dbc44e5ae497cc0f2c256ad", "publicURL":"http://192.168.0.2:8000/v1"}], "endpoints_links": [],"type": "cloudformation", "name":"heat-cfn"}, {"endpoints": [{"adminURL":"http://192.168.0.2:8776/v1/d49aaa14428c4b3b87e69cc41f8efa1d","region": "RegionOne", "internalURL":"http://192.168.0.2:8776/v1/d49aaa14428c4b3b87e69cc41f8efa1d","id": "3a02f4652b134093865cfdfd2c7f951c", "publicURL":"http://192.168.0.2:8776/v1/d49aaa14428c4b3b87e69cc41f8efa1d"}],"endpoints_links": [], "type": "volume","name": "cinder"}, {"endpoints":[{"adminURL": "http://192.168.0.2:8773/services/Admin","region": "RegionOne", "internalURL":"http://192.168.0.2:8773/services/Cloud", "id":"078d77ee8279461fb2b444e0662afb6d", "publicURL":"http://192.168.0.2:8773/services/Cloud"}],"endpoints_links": [], "type": "ec2","name": "ec2"}, {"endpoints":[{"adminURL": "http://192.168.0.2:8004/v1/d49aaa14428c4b3b87e69cc41f8efa1d","region": "RegionOne", "internalURL":"http://192.168.0.2:8004/v1/d49aaa14428c4b3b87e69cc41f8efa1d","id": "341c971a3a3643fa971343351264b02b","publicURL":"http://192.168.0.2:8004/v1/d49aaa14428c4b3b87e69cc41f8efa1d"}],"endpoints_links": [], "type": "orchestration","name": "heat"}, {"endpoints":[{"adminURL": "http://192.168.0.2:35357/v2.0","region": "RegionOne", "internalURL":"http://192.168.0.2:5000/v2.0", "id":"44511932b07944d5bf55cb7943c657e8", "publicURL":"http://192.168.0.2:5000/v2.0"}], "endpoints_links": [],"type": "identity", "name":"keystone"}], "user": {"username":"admin", "roles_links": [], "id":"ce88df822c804c459c58245b90780c57", "roles":[{"name": "admin"}, {"name":"heat_stack_owner"}], "name": "admin"},"metadata": {"is_admin": 0, "roles":["0a31e70dbce740b0b469bc07975226b7", "13f9462fbf454d19b90d021d9e3f250a"]}}}

 

 

curl -i'http://192.168.0.2:8774/v2/d49aaa14428c4b3b87e69cc41f8efa1d/servers/detail' -XGET -H "Accept: application/json" -H "User-Agent:python-novaclient" -H "X-Auth-Project-Id: demo" -H"X-Auth-Token: 4aef6bf6c54c425f9217942a53aece7f[标注2] "

返回信息如下:

HTTP/1.1 200 OK

Content-Type: application/json

Content-Length: 3323

X-Compute-Request-Id:req-0a1aae5e-9928-4ce0-8309-ea65cc1e8087

Date: Tue, 25 Nov 2014 06:49:57 GMT

 

{"servers":[{"status": "ACTIVE", "updated":"2014-11-25T01:33:54Z", "hostId":"d18fde7303f28c39f01d02ce07356447fae7f62b1c520e11a95a7e92","OS-EXT-SRV-ATTR:host": "ustack", "addresses":{"private": [{"OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:65:f6:04", "version": 4, "addr":"10.10.10.3", "OS-EXT-IPS:type": "fixed"}]},"links": [{"href":"http://192.168.0.2:8774/v2/d49aaa14428c4b3b87e69cc41f8efa1d/servers/201fbe70-8f8f-49c3-bd1e-19d72595422e","rel": "self"}, {"href":"http://192.168.0.2:8774/d49aaa14428c4b3b87e69cc41f8efa1d/servers/201fbe70-8f8f-49c3-bd1e-19d72595422e","rel": "bookmark"}], "key_name": null,"image": {"id":"73c9bad3-c315-416d-9d43-f687a27d32c8", "links":[{"href":"http://192.168.0.2:8774/d49aaa14428c4b3b87e69cc41f8efa1d/images/73c9bad3-c315-416d-9d43-f687a27d32c8","rel": "bookmark"}]}, "OS-EXT-STS:task_state":null, "OS-EXT-STS:vm_state": "active","OS-EXT-SRV-ATTR:instance_name": "instance-00000003","OS-SRV-USG:launched_at": "2014-11-25T01:33:54.000000","OS-EXT-SRV-ATTR:hypervisor_hostname": "ustack","flavor": {"id": "2", "links":[{"href":"http://192.168.0.2:8774/d49aaa14428c4b3b87e69cc41f8efa1d/flavors/2","rel": "bookmark"}]}, "id": "201fbe70-8f8f-49c3-bd1e-19d72595422e","security_groups": [{"name": "default"}],"OS-SRV-USG:terminated_at": null,"OS-EXT-AZ:availability_zone": "nova", "user_id":"ce88df822c804c459c58245b90780c57", "name":"fedora", "created": "2014-11-25T01:33:42Z","tenant_id": "d49aaa14428c4b3b87e69cc41f8efa1d","OS-DCF:diskConfig": "AUTO","os-extended-volumes:volumes_attached": [], "accessIPv4":"", "accessIPv6": "", "progress": 0,"OS-EXT-STS:power_state": 1, "config_drive": "","metadata": {}}, {"status": "ACTIVE","updated": "2014-11-25T01:30:35Z", "hostId":"d18fde7303f28c39f01d02ce07356447fae7f62b1c520e11a95a7e92","OS-EXT-SRV-ATTR:host": "ustack", "addresses":{"private": [{"OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:65:77:ed", "version": 4, "addr":"10.10.10.2", "OS-EXT-IPS:type": "fixed"}]},"links": [{"href":"http://192.168.0.2:8774/v2/d49aaa14428c4b3b87e69cc41f8efa1d/servers/d70eb657-6eac-4f4e-ae8d-65049185e6c7","rel": "self"}, {"href":"http://192.168.0.2:8774/d49aaa14428c4b3b87e69cc41f8efa1d/servers/d70eb657-6eac-4f4e-ae8d-65049185e6c7","rel": "bookmark"}], "key_name": null,"image": {"id": "f61bd91e-ea87-4fe7-a68c-ea8338859370","links": [{"href":"http://192.168.0.2:8774/d49aaa14428c4b3b87e69cc41f8efa1d/images/f61bd91e-ea87-4fe7-a68c-ea8338859370","rel": "bookmark"}]}, "OS-EXT-STS:task_state": null,"OS-EXT-STS:vm_state": "active","OS-EXT-SRV-ATTR:instance_name": "instance-00000002","OS-SRV-USG:launched_at": "2014-11-25T01:30:35.000000","OS-EXT-SRV-ATTR:hypervisor_hostname": "ustack","flavor": {"id": "1", "links":[{"href":"http://192.168.0.2:8774/d49aaa14428c4b3b87e69cc41f8efa1d/flavors/1","rel": "bookmark"}]}, "id":"d70eb657-6eac-4f4e-ae8d-65049185e6c7", "security_groups":[{"name": "default"}],"OS-SRV-USG:terminated_at": null,"OS-EXT-AZ:availability_zone": "nova", "user_id":"ce88df822c804c459c58245b90780c57", "name":"cirros", "created": "2014-11-25T01:30:32Z","tenant_id": "d49aaa14428c4b3b87e69cc41f8efa1d","OS-DCF:diskConfig": "AUTO","os-extended-volumes:volumes_attached": [], "accessIPv4":"", "accessIPv6": "", "progress": 0,"OS-EXT-STS:power_state": 1, "config_drive": "","metadata": {}}]}

 [标注1]Token

 [标注2]替换成上文的Token


你可能感兴趣的:(openstack,curl)