Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to test keystone rest api V3 version

Shulou Source: shulou.com Published: 2022-05-31 17:12:19 09月28日 Update

How to carry out keystone rest api V3 version testing, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a simpler and easier way.

User authentication, token of the default domain

Curl-I\-H "Content-Type: application/json"\-d'{"auth": {"identity": {"methods": ["password"], "password": {"user": {"domain": {"id": "default"} "name": "admin", "password": "openstack"}}'\ http://localhost:5000/v3/auth/tokens Echo

HTTP/1.1 CreatedX-Subject-Token: ecfc51857b5747d2b6438f17e5e2fe0cVary: X-Auth-TokenContent-Type: application/jsonContent-Length: 297X-Openstack-Request-Id: req-86ba31ca-0d90-4130-b6cc-01ebfeb74b31Date: Fri, 15 Jan 2016 02:20:34 GMT {"token": {"methods": ["password"], "expires_at": "2016-01-15T03:20:34.170384Z", "extras": {}, "user": {"domain": {"id": "default" "name": "Default", "id": "ddce55e5af8241ec96e39e511a4928a1", "name": "admin"}, "audit_ids": ["lJW70I0bTcOl5tQ27kKP0Q"], "issued_at": "2016-01-15T02:20:34.170469Z"}}

Save the returned Header

X-Subject-Token: ecfc51857b5747d2b6438f17e5e2fe0c

Take token and project to get another token

Curl-I\-H "Content-Type: application/json"\-d'{"auth": {"identity": {"methods": ["token"], "token": {"id": "ecfc51857b5747d2b6438f17e5e2fe0c"}}, "scope": {"project": {"name": "admin" "domain": {"name": "default"}'\ http://localhost:5000/v3/auth/tokens Echo

HTTP/1.1 CreatedX-Subject-Token: 76d45acefa7d4b928a5573db3a5ff39eVary: X-Auth-TokenContent-Type: application/jsonContent-Length: 4858X-Openstack-Request-Id: req-1b637a94-66bb-4a05-83b5-b1531c85a56dDate: Fri, 15 Jan 2016 02:32:02 GMT {"token": {"methods": ["token", "password"], "roles": [{"id": "a7db951cbc0040bfab9f1b9124b9e6a9", "name": "admin"}] "expires_at": "2016-01-15T03:20:34.170384Z", "project": {"domain": {"id": "default", "name": "Default"}, "id": "9c2b1ae7eb0d48e2b7ed3b4399ee4d3d", "name": "admin"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url": "http://172.16.10.33:8776/v1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," "region": "RegionOne", "interface": "internal", "id": "62c8ac942c8b4930936ebc15d02016ea"}, {"region_id": "RegionOne", "url": "http://172.16.10.33:8776/v1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" public "," id ":" 95fac1cf199345a6b30cf216ada6114a "}, {" region_id ":" RegionOne " "url": "http://172.16.10.33:8776/v1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" admin "," id ":" c8b4bd03de5b494b8dad82b811af883b "}]," type ":" volume "," id ":" 58f08b76576c4d13b79c691fbc7cae11 "," name ":" cinder "}, {" endpoints ": [{" region_id ":" RegionOne " Url: "http://172.16.10.33:35357/v2.0"," region ":" RegionOne "," interface ":" admin "," id ":" 04ae0815504e4b01bb69096de2655ed7 "}, {" region_id ":" RegionOne "," url ":" http://172.16.10.33:5000/v2.0", "region": "RegionOne", "interface": "public", "id": "a3e08f9bf91845cbb01ee17b4381fef8"} {"region_id": "RegionOne", "url": "http://172.16.10.33:5000/v2.0"," region ":" RegionOne "," interface ":" internal "," id ":" c4d004f6ff9449ecb4beb3a3ade79a5b "}]," type ":" identity "," id ":" 5a7e533e712b46dcbc1b520dadc1d17f "," name ":" keystone "}, {" endpoints ": [{" region_id ":" RegionOne " Url: "http://172.16.10.33:8774/v2/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" public "," id ":" 4e09a9f6eb8342feac18753b47f34014 "}, {" region_id ":" RegionOne "," url ":" http://172.16.10.33:8774/v2/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d", "region": "RegionOne", "interface": "admin", "id": "96685c58c74c408fa2eb30555cd9e4e5"} {"region_id": "RegionOne", "url": "http://172.16.10.33:8774/v2/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" internal "," id ":" e8802a42ed664c25af8f60998c503240 "}]," type ":" compute_legacy "," id ":" 7ec54c4e744c44d48e3f9fa435daabbe "," name ":" nova_legacy "}, {" endpoints ": [{" region_id ":" RegionOne " Url: "http://172.16.10.33:8776/v2/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" internal "," id ":" 1ef7bbe882bf4a04a33332de35c70e84 "}, {" region_id ":" RegionOne "," url ":" http://172.16.10.33:8776/v2/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d", "region": "RegionOne", "interface": "public", "id": "64b1b4be5a8548e5b1e7343feec38c3d"} {"region_id": "RegionOne", "url": "http://172.16.10.33:8776/v2/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" admin "," id ":" 7f1635373c9b4651867bdccda1a0f8d1 "}]," type ":" volumev2 "," id ":" 874e95350ad84f0998d4a809ad4925ea "," name ":" cinderv2 "}, {" endpoints ": [{" region_id ":" RegionOne " Url: "http://172.16.10.33:9696/"," region ":" RegionOne "," interface ":" internal "," id ":" 4bb75d5dea254955ab0e237f44572ddf "}, {" region_id ":" RegionOne "," url ":" http://172.16.10.33:9696/", "region": "RegionOne", "interface": "admin", "id": "6f8c2b0902a54ec39ecbeea8877ec9a7"} {"region_id": "RegionOne", "url": "http://172.16.10.33:9696/"," region ":" RegionOne "," interface ":" public "," id ":" cf888a8965944479a5df1b8007eb84db "}]," type ":" network "," id ":" 9d207ba3d5c248fd911cfcce51ef814a "," name ":" neutron "}, {" endpoints ": [{" region_id ":" RegionOne " Url: "http://172.16.10.33:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" internal "," id ":" 1b7f94fa75964ee7aa501d28573333a2 "}, {" region_id ":" RegionOne "," url ":" http://172.16.10.33:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d", "region": "RegionOne", "interface": "public", "id": "3217e1bb5f114c268c74e8d1550912d6"} {"region_id": "RegionOne", "url": "http://172.16.10.33:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d"," region ":" RegionOne "," interface ":" admin "," id ":" d0796d4c2ddb4a67a339908158945d49 "}]," type ":" compute "," id ":" df1c318a37ec432c82571c15ac6442c8 "," name ":" nova "}, {" endpoints ": [{" region_id ":" RegionOne " Url: "http://172.16.10.33:9292"," region ":" RegionOne "," interface ":" admin "," id ":" 15baf7fdf5e348e59294f1eda171dc67 "}, {" region_id ":" RegionOne "," url ":" http://172.16.10.33:9292", "region": "RegionOne", "interface": "public", "id": "1acb1f06c7d44885969e4facd2e478ae"}, {"region_id": "RegionOne" "url": "http://172.16.10.33:9292"," region ":" RegionOne "," interface ":" internal "," id ":" 8c775c8498684cb1847b79a640849427 "}]," type ":" image "," id ":" e5a05e1e70894013a4533e748c9c5e87 "," name ":" glance "}]," extras ": {}," user ": {" domain ": {" id ":" default "," name ":" Default "} "id": "ddce55e5af8241ec96e39e511a4928a1", "name": "admin"}, "audit_ids": ["qa8u-5naTXiolgh6vXM2Dg", "lJW70I0bTcOl5tQ27kKP0Q"], "issued_at": "2016-01-15T02:32:02.755979Z"}

Returns a token:X-Subject-Token: 76d45acefa7d4b928a5573db3a5ff39e within the range of project

Body contains many endpoint

At this point, you can use token to make requests to other services. For example: get flavors

Curl-I-H "X-Auth-Token: 76d45acefa7d4b928a5573db3a5ff39e" http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors; echo

HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 1692X-Openstack-Nova-Api-Version: 2.1Vary: X-OpenStack-Nova-API-VersionX-Compute-Request-Id: req-58676e13-4aea-4152-acca-00ea3f87e923Date: Fri, 15 Jan 2016 02:46:50 GMT {"flavors": [{"id": "1", "links": [{"href": "http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/1"," rel ":" self "} {"href": "http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/1"," rel ":" bookmark "}]," name ":" m1.tiny "}, {" id ":" 2 "," links ": [{" href ":" http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/2", "rel": "self"}, {"href": "http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/2"," "rel": "bookmark"}], "name": "m1.small"}, {"id": "3", "links": [{"href": "http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/3"," rel ":" self "}, {" href ":" http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/3", "rel": "bookmark"}], "name": "m1.medium"} {"id": "4", "links": [{"href": "http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/4"," rel ":" self "}, {" href ":" http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/4", "rel": "bookmark"}], "name": "m1.large"}, {"id": "42" "links": [{"href": "http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/42"," rel ":" self "}, {" href ":" http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/42", "rel": "bookmark"}], "name": "m1.nano"}, {"id": "5" "links": [{"href": "http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/5"," rel ":" self "}, {" href ":" http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/5", "rel": "bookmark"}], "name": "m1.xlarge"}, {"id": "84" "links": [{"href": "http://localhost:8774/v2.1/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/84"," rel ":" self "}, {" href ":" http://localhost:8774/9c2b1ae7eb0d48e2b7ed3b4399ee4d3d/flavors/84", "rel": "bookmark"}], "name": "m1.micro"}]} answers to questions about how to test keystone rest api V3 version are shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

Tags: Questions versions tests more help answers easy easy content guys partners methods users knowledge articles scope industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn NVidia Xiaomi Linux Redmi