zoukankan      html  css  js  c++  java
  • OpenStack实例noVNC URL获取

    Compute API地址获取

    登录OpenStack Dashborad,选择项目下的访问API:

    Server Consoles

    Manage server consoles.
        POST                        /servers/{server_id}/remote-consoles

                                         Create Console

    Microversion 2.6 or greater is required for this API.

    The API provides a unified request for creating a remote console. The user can get a URL to connect the console from this API. The URL includes the token which is used to get permission to access the console. Servers may support different console protocols. To return a remote console using a specific protocol, such as RDP, set the protocol parameter to rdp.

    Normal response codes: 200

    Error response codes: badRequest(400), unauthorized(401), forbidden(403), itemNotFound(404), conflict(409), notImplemented(501)

    Request

    Name
    In
    Type
    Description
    server_id path string The UUID of the server.
    remote_console body object The remote console object.
    protocol body string

    The protocol of remote console. The valid values are vncspicerdpserial and mks.

    The protocol mks is added since Microversion 2.8.

    type body string The type of remote console. The valid values are novncrdp-html5spice-html5serial, and webmks. The type webmks is added since Microversion 2.8.

    X-Auth-Token

    header

    String

    token(生成token接口说明)

    X-OpenStack-Nova-API-Version

    header

    String

    microversion request header

    OpenStack-API-Version

    header

    String

    microversion request header

      X-OpenStack-Nova-API-VersionOpenStack-API-Version必须在Request Headers中进行设置,例如(2.79),否则接口请求会失败,返回404

      API Versions

      In order to bring new features to users over time, the Nova API supports versioning. There are two kinds of versions in Nova.

      •   ‘’major versions’’, which have dedicated urls
      •   ‘’microversions’’, which can be requested through the use of the X-OpenStack-Nova-API-Version header, or since microversion 2.27 the OpenStack-API-Version header may also be used.

    Example Get Remote VNC Console

    {
        "remote_console": {
            "protocol": "vnc",
            "type": "novnc"
        }
    }

      

    Response

    Name
    In
    Type
    Description
    remote_console body object The remote console object.
    protocol body string

    The protocol of remote console. The valid values are vncspicerdpserial and mks. The protocol mks is added since Microversion 2.8.

    type body string The type of remote console. The valid values are novncrdp-html5spice-html5serial, and webmks. The type webmks is added since Microversion 2.8.
    url body string The URL is used to connect the console.

    Example Get Remote VNC Console

    {
        "remote_console": {
            "protocol": "vnc",
            "type": "novnc",
            "url": "http://172.18.0.188:6080/vnc_auto.html?path=%3Ftoken%3D9a8b610f-071b-4021-9574-438c74a3d92e"
        }
    }
    

    2.生成token接口说明

    接口链接:https://docs.openstack.org/api-ref/identity/v3/index.html?expanded=password-authentication-with-scoped-authorization-detail#password-authentication-with-scoped-authorization

    Identity API地址获取

    登录OpenStack Dashborad,选择项目下的访问API:

    Authentication and token management

    1.Tokens have IDs, which the Identity API returns in the X-Subject-Token response header.(样例)

    2.After you obtain an authentication token, you can:

    • Make REST API requests to other OpenStack services. You supply the ID of your authentication token in the X-Auth-Token request header.(样例)

    • Validate your authentication token and list the domains, projects, roles, and endpoints that your token gives you access to.

    • Use your token to request another token scoped for a different domain and project.

    • Force the immediate revocation of a token.

    • List revoked public key infrastructure (PKI) tokens.

    Authentication errors

    Response code

    Description

    Bad Request (400)

    The Identity service failed to parse the request as expected. One of the following errors occurred:

    • A required attribute was missing.

    • An attribute that is not allowed was specified, such as an ID on a POST request in a basic CRUD operation.

    • An attribute of an unexpected data type was specified.

    Unauthorized (401)

    One of the following errors occurred:

    • Authentication was not performed.

    • The specified X-Auth-Token header is not valid.

    • The authentication credentials are not valid.

    • Not all MFA rules were satisfied.

    • The specified Openstack-Auth-Receipt header is not valid.

    Forbidden (403)

    The identity was successfully authenticated but it is not authorized to perform the requested action.

    Not Found (404)

    An operation failed because a referenced entity cannot be found by ID. For a POST request, the referenced entity might be specified in the request body rather than in the resource path.

    Conflict (409)

    A POST or PATCH operation failed. For example, a client tried to update a unique attribute for an entity, which conflicts with that of another entity in the same collection.

    Or, a client issued a create operation twice on a collection with a user-defined, unique attribute. For example, a client made a POST /users request two times for the unique, user-defined name attribute for a user entity.

       POST                              /v3/auth/tokens

                                               Password authentication with scoped authorization

    Authenticates an identity and generates a token. Uses the password authentication method and scopes authorization to a project, domain, or the system.

    The request body must include a payload that specifies the password authentication method which includes the credentials in addition to a projectdomain, or system authorization scope.

    Relationship: https://docs.openstack.org/api/openstack-identity/3/rel/auth_tokens

    Request

    Parameters

    Name

    In

    Type

    Description

    nocatalog (Optional)

    query

    string

    (Since v3.1) The authentication response excludes the service catalog. By default, the response includes the service catalog.

    name (Optional)

    body

    string

    The user name. Required if you do not specify the ID of the user. If you specify the user name, you must also specify the domain, by ID or name.

    auth

    body

    object

    An auth object.

    user

    body

    object

    user object.

    scope (Optional)

    body

    string

    The authorization scope, including the system (Since v3.10), a project, or a domain (Since v3.4). If multiple scopes are specified in the same request (e.g. project and domain or domain and system) an HTTP 400 Bad Request will be returned, as a token cannot be simultaneously scoped to multiple authorization targets. An ID is sufficient to uniquely identify a project but if a project is specified by name, then the domain of the project must also be specified in order to uniquely identify the project by name. A domain scope may be specified by either the domain’s ID or name with equivalent results.

    password

    body

    object

    The password object, contains the authentication information.

    id (Optional)

    body

    string

    The ID of the user. Required if you do not specify the user name.

    identity

    body

    object

    An identity object.

    methods

    body

    array

    The authentication method. For password authentication, specify password.

    Project-Scoped with Project Name Example

    {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
                        "name": "admin",
                        "domain": {
                            "name": "Default"
                        },
                        "password": "1qaz2wsx"
                    }
                }
            },
            "scope": {
                "project": {
                    "name": "admin",
                    "domain": { "id": "default" }
                }
            }
        }
    } 

    Response

    Parameters

    Name

    In

    Type

    Description

    X-Subject-Token

    header

    string

    The authentication token. An authentication response returns the token ID in this header rather than in the response body.

    region_id

    body

    string

    (Since v3.2) The ID of the region that contains the service endpoint.

    methods

    body

    array

    The authentication method. For password authentication, specify password.

    roles

    body

    array

    A list of role objects

    url

    body

    string

    The endpoint URL.

    region

    body

    string

    (Deprecated in v3.2) The geographic location of the service endpoint.

    token

    body

    object

    token object.

    expires_at

    body

    string

    The date and time when the token expires.

    The date and time stamp format is ISO 8601:

    CCYY-MM-DDThh:mm:ss.sssZ
    

    For example, 2015-08-27T09:49:58.000000Z.

    null value indicates that the token never expires.

    system (Optional)

    body

    object

    system object containing information about which parts of the system the token is scoped to. If the token is scoped to the entire deployment system, the system object will consist of {"all": true}. This is only included in tokens that are scoped to the system.

    domain (Optional)

    body

    object

    domain object including the id and name representing the domain the token is scoped to. This is only included in tokens that are scoped to a domain.

    project (Optional)

    body

    object

    project object including the idname and domain object representing the project the token is scoped to. This is only included in tokens that are scoped to a project.

    issued_at

    body

    string

    The date and time when the token was issued.

    The date and time stamp format is ISO 8601:

    CCYY-MM-DDThh:mm:ss.sssZ

    For example, 2015-08-27T09:49:58.000000Z.

    catalog

    body

    array

    catalog object.

    user

    body

    object

    user object.

    audit_ids

    body

    array

    A list of one or two audit IDs. An audit ID is a unique, randomly generated, URL-safe string that you can use to track a token. The first audit ID is the current audit ID for the token. The second audit ID is present for only re-scoped tokens and is the audit ID from the token before it was re-scoped. A re- scoped token is one that was exchanged for another token of the same or different scope. You can use these audit IDs to track the use of a token or chain of tokens across multiple requests and endpoints without exposing the token ID to non-privileged users.

    interface

    body

    string

    The interface type, which describes the visibility of the endpoint. Value is: - public. Visible by end users on a publicly available network interface. - internal. Visible by end users on an unmetered internal network interface. - admin. Visible by administrative users on a secure network interface.

    endpoints

    body

    array

    A list of endpoint objects.

    type

    body

    string

    The endpoint type.

    id (Optional)

    body

    string

    The ID of the user. Required if you do not specify the user name.

    name (Optional)

    body

    string

    The user name. Required if you do not specify the ID of the user. If you specify the user name, you must also specify the domain, by ID or name.

    Status Codes

    Success

    Code

    Reason

    201 - Created

    Resource was created and is ready to use.

    Error

    Code

    Reason

    400 - Bad Request

    Some content in the request was invalid.

    401 - Unauthorized

    User must authenticate before making a request.

    403 - Forbidden

    Policy does not allow current user to do this operation.

    404 - Not Found

    The requested resource could not be found.

    Project-Scoped Example

    {
        "token": {
            "is_domain": false,
            "methods": [
                "password"
            ],
            "roles": [
                {
                    "id": "cc616aada8f943b2a11312dfc51b04d1",
                    "name": "reader"
                },
                {
                    "id": "67d0d79186e9408c94acdf0c2ea3e64f",
                    "name": "admin"
                },
                {
                    "id": "eb8529a2f9504459b6f569f764821a1a",
                    "name": "member"
                }
            ],
            "expires_at": "2020-08-19T04:24:01.000000Z",
            "project": {
                "domain": {
                    "id": "default",
                    "name": "Default"
                },
                "id": "0f2dad84684e473d8e52678999888c8c",//项目ID
                "name": "admin"
            },
            "catalog": [
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8774/v2.1/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "a67bbc3131d341f5bb0b133c9641fdd5"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8774/v2.1/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "b5793e507b934e95ab725af1b6a2c875"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8774/v2.1/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "e65359e289d74a30bc1c3906dcfcda99"
                        }
                    ],
                    "type": "compute",
                    "id": "04499e16815d40c891f918d1ae852dd8",
                    "name": "nova"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8776/v2/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "5d727c292207466faf36b4c2cc996129"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8776/v2/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "7f56bee504a443bc9d453f2c76f34f7a"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8776/v2/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "c8141a41f0434ca88069043624c060f1"
                        }
                    ],
                    "type": "volumev2",
                    "id": "0f4b880ace0343c1b683cdc750a75d08",
                    "name": "cinderv2"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8080/v1/AUTH_0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "268246592b6146d3b527d816710d0c87"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8080/v1/AUTH_0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "28dfcf9c0328406aada0cd2c7f229a6b"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8080/v1/AUTH_0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "2d1075a4e0ec41ffa7fc458e114217ef"
                        }
                    ],
                    "type": "object-store",
                    "id": "1224e2cffc8b493b956aabe23083713f",
                    "name": "swift"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8042",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "a821fd4ddb9d4991a29feb5627c13948"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8042",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "b72770e0ccea4e24b9427d3e6930f9df"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8042",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "bd10f919bcfb45cf844c65c5dfac1901"
                        }
                    ],
                    "type": "alarming",
                    "id": "27a8c66f83d94eff9a4fec909ff5c37f",
                    "name": "aodh"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8777",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "208188fabe8f42f3bcf0a462515a9858"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8777",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "24b96ed31b334806a44816ddfd3357cc"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8777",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "25f42160465c4162bf2b6e4cd0df6b8c"
                        }
                    ],
                    "type": "metering",
                    "id": "2b75ba21deb64d32bcb1f315fce4bc38",
                    "name": "ceilometer"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8776/v3/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "39634629e79e42888831819f15106c9d"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8776/v3/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "7ee47ca9a42c46208e0321b64faa510d"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8776/v3/0f2dad84684e473d8e52678999888c8c",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "aeb7f41b9de94cd4bfe5f0d7cdd61065"
                        }
                    ],
                    "type": "volumev3",
                    "id": "420e975ca96640c88024ffb43ee20022",
                    "name": "cinderv3"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8778/placement",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "0f3f9b7d53b044f4952a6587f23cd3ed"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8778/placement",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "6b08bb919e244047aa6021fe1c1bdb91"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8778/placement",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "9ec79a51da434588973f3d5ac76586cc"
                        }
                    ],
                    "type": "placement",
                    "id": "58107947bfc14d41bdfdfc1da0e227be",
                    "name": "placement"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:9292",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "04439a9b033b49c9acccd5cf1b8f3ac3"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:9292",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "140b51d5f9584701bd15c0e391e7ca83"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:9292",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "e5e09ebba766457c9d4e992098da7153"
                        }
                    ],
                    "type": "image",
                    "id": "74d224bf828e4e23b46530ae6fecbdf4",
                    "name": "glance"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:5000/v3",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "379364edbfbb4ab68733e4b0e378a8a8"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:5000/v3",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "678bb5376ddb4a5cabaf01ebc9435cd7"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:5000/v3",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "974eae2b2e5c4861a33a18692cb523c2"
                        }
                    ],
                    "type": "identity",
                    "id": "8a1de3d940bc49ff9365bbbbeae0b4e4",
                    "name": "keystone"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:9696",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "2224caa099144ef19411f5d529aa51cb"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:9696",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "5b5b80e389104b6ea9b904b35bd0b700"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:9696",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "733e86741807444f84ba5fff22f55399"
                        }
                    ],
                    "type": "network",
                    "id": "e9a4a89740c9498bba52e6c868b4ca88",
                    "name": "neutron"
                },
                {
                    "endpoints": [
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8041",
                            "region": "RegionOne",
                            "interface": "public",
                            "id": "03e73ce855114e37b586bac8368c399a"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8041",
                            "region": "RegionOne",
                            "interface": "internal",
                            "id": "39b038f94fa3431e96c017c432eb19a5"
                        },
                        {
                            "region_id": "RegionOne",
                            "url": "http://172.18.0.188:8041",
                            "region": "RegionOne",
                            "interface": "admin",
                            "id": "4e4ee131f319499186e457ef816fe9e0"
                        }
                    ],
                    "type": "metric",
                    "id": "ff4e80f49e7848669ee65d6229370327",
                    "name": "gnocchi"
                }
            ],
            "user": {
                "password_expires_at": null,
                "domain": {
                    "id": "default",
                    "name": "Default"
                },
                "id": "12cdca90adc74bc6b5eb94592f92b3f9",
                "name": "admin"
            },
            "audit_ids": [
                "LUynSMLvT32bHK2AdkX3wQ"
            ],
            "issued_at": "2020-08-19T03:24:01.000000Z"
        }
    }
    

      

    请求样例

     

     
  • 相关阅读:
    eclipse+myeclipse 使用技巧备忘
    程序员的自我修养
    枚举工具类 EnumUtils
    日期/时间处理工具 DateTimeUtil
    轻松了解Spring中的控制反转和依赖注入(一)
    了解SpringMVC框架及基本工作流程
    HTTP请求行、请求头、请求体详解
    Tomcat项目部署问题记录
    入手IntelliJ IDEA 常用配置
    解决阿里云OSS跨域问题
  • 原文地址:https://www.cnblogs.com/Java-Script/p/13901240.html
Copyright © 2011-2022 走看看