美文网首页
'openstack stack list' 背

'openstack stack list' 背

作者: louyang | 来源:发表于2019-02-13 10:16 被阅读4次

    1 通过用户名密码换令牌

    $ curl -i -d '
        {
            "auth": {
                "identity": {
                    "methods": ["password"],
                    "password": {
                        "user": {
                            "domain": {"name": "Default"},
                            "name": "cranuser8",
                            "password": "systeM!23"
                        }
                    }
                }
            }
        }' -H "Content-type: application/json" "http://192.168.54.5:5000/v3/auth/tokens?nocatalog"
    

    收到,令牌在X-Subject-Token里。

    HTTP/1.1 201 Created
    Server: nginx
    Date: Wed, 13 Feb 2019 01:58:16 GMT
    Content-Type: application/json
    Content-Length: 660
    X-Subject-Token: gAAAAABcY3m4ois0ZuVOV9WQRiITUtng_YOWKXPV0vQ-QZy5Ml_R8FKqXgh5z_EGKgjsPdTEYVx59E2hdiDYLFMRl4L0aaQsu9wyMaVXpP9ylnEx0_eKlO9YAS7pcbTLWyq8lP1ifOL35OLqNQXfhtBzunEkGiOpTcHxV4tAali2WXMvujtVQ94
    Vary: X-Auth-Token
    x-openstack-request-id: req-972eccf6-780e-4df0-9c80-327ae98ad8e4
    X-Content-Type-Options: nosniff
    X-XSS-Protection: 1; mode=block
    Content-Security-Policy: default-src 'self' https: wss:;
    X-Frame-Options: DENY
    X-Frame-Options: SAMEORIGIN
    Strict-Transport-Security: max-age=15768000
    
    {"token": {"is_domain": false, "methods": ["password"], "roles": [{"id": "9fe2ff9ee4384b1894a90878d3e92bab", "name": "_member_"}, {"id": "d055e66cc6e848ab91ba86248b16023f", "name": "admin"}, {"id": "bf2a951ecbdc48c090eec4b0a00f3f80", "name": "network_user"}], "expires_at": "2019-02-13T13:58:16.000000Z", "project": {"domain": {"id": "default", "name": "Default"}, "id": "6bcb7e7677a5449196fd56565f68fc7f", "name": "cran8"}, "user": {"password_expires_at": null, "domain": {"id": "default", "name": "Default"}, "id": "49c75d7fa6844c8f81cbf19be783e7db", "name": "cranuser8"}, "audit_ids": ["jdBU9UriTRW1J3nv0kxViA"], "issued_at": "2019-02-13T01:58:16.000000Z"}}
    

    2 要stack的列表

    curl -g -i -X GET http://192.168.54.5:8004/v1/6bcb7e7677a5449196fd56565f68fc7f/stacks?tenant=6bcb7e7677a5449196fd56565f68fc7f -H "Accept: application/json" -H "X-Auth-Token: gAAAAABcY3m4ois0ZuVOV9WQRiITUtng_YOWKXPV0vQ-QZy5Ml_R8FKqXgh5z_EGKgjsPdTEYVx59E2hdiDYLFMRl4L0aaQsu9wyMaVXpP9ylnEx0_eKlO9YAS7pcbTLWyq8lP1ifOL35OLqNQXfhtBzunEkGiOpTcHxV4tAali2WXMvujtVQ94"
    

    收到

    HTTP/1.1 200 OK
    Content-Type: application/json
    Content-Length: 632
    x-openstack-request-id: req-a624aab8-308c-49ce-bf64-65b7be4f8d63
    X-Frame-Options: SAMEORIGIN
    Strict-Transport-Security: max-age=15768000
    
    {"stacks": [{"description": "", "parent": null, "stack_status_reason": "Stack CREATE completed successfully", "stack_name": "cranuser8_rcpautoinstall", "stack_user_project_id": "62e91a68421f409ba0657026c289d06c", "deletion_time": null, "creation_time": "2019-02-12T06:43:21Z", "links": [{"href": "http://192.168.54.5:8004/v1/6bcb7e7677a5449196fd56565f68fc7f/stacks/cranuser8_rcpautoinstall/338fa8ed-368c-4290-97ec-e5277d76f951", "rel": "self"}], "updated_time": null, "project": "6bcb7e7677a5449196fd56565f68fc7f", "stack_owner": null, "stack_status": "CREATE_COMPLETE", "id": "338fa8ed-368c-4290-97ec-e5277d76f951", "tags": null}]}
    
    image.png

    和命令行对照一下,内容吻合。

    $ openstack stack list | grep user8
    | 338fa8ed-368c-4290-97ec-e5277d76f951 | cranuser8_rcpautoinstall | 6bcb7e7677a5449196fd56565f68fc7f | CREATE_COMPLETE | 2019-02-12T06:43:21Z | None |
    

    其中,tenant id由下面命令获得:

    $ openstack project list --user cranuser8
    +----------------------------------+-------+
    | ID                               | Name  |
    +----------------------------------+-------+
    | 6bcb7e7677a5449196fd56565f68fc7f | cran8 |
    +----------------------------------+-------+
    

    API说明从这里看:
    https://developer.openstack.org/api-ref/orchestration/v1/index.html?expanded=list-stacks-detail#stacks

    相关文章

      网友评论

          本文标题:'openstack stack list' 背

          本文链接:https://www.haomeiwen.com/subject/oodreqtx.html