Handle uuids in os-hypervisors API
There are quite a few changes here as this is not only handling uuids for the hypervisor id but it's also a refactor in several APIs for consistency. The main changes are detailed in the REST API Version History doc in this change, but to summarize the changes: * Hypervisor and service IDs are handled as the UUIDs for those resources; this is necessary for accurately working with these resources across multiple cells. * The 'servers' and 'search' routes are deprecated and folded into the index and detail methods as query parameters, validated using json schema. * The show method will also be able to return the list of servers hosted on the given hypervisor using the with_servers query parameter. * The marker used when paging over lists of hypervisors is the compute node UUID. * Using the hypervisor_hostname_pattern query parameter will not work with paging parameters. * API reference docs are updated for the detailed changes. * Functional and unit tests are provided for all changes. Part of blueprint service-hyper-uuid-in-api Change-Id: I828350c179df8bcfa4739910abeafaba2f96982b
This commit is contained in:
parent
2f7bf29d47
commit
622bfb2e95
@ -25,7 +25,7 @@ the ``policy.json`` file.
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: unauthorized(401), forbidden(403)
|
||||
Error response codes: badRequest(400), unauthorized(401), forbidden(403)
|
||||
|
||||
Request
|
||||
-------
|
||||
@ -34,6 +34,9 @@ Request
|
||||
|
||||
- limit: hypervisor_limit
|
||||
- marker: hypervisor_marker
|
||||
- marker: hypervisor_marker_uuid
|
||||
- hypervisor_hostname_pattern: hypervisor_hostname_pattern_query
|
||||
- with_servers: hypervisor_with_servers_query
|
||||
|
||||
Response
|
||||
--------
|
||||
@ -43,15 +46,24 @@ Response
|
||||
- hypervisors: hypervisors
|
||||
- hypervisor_hostname: hypervisor_hostname
|
||||
- id: hypervisor_id_body
|
||||
- id: hypervisor_id_body_uuid
|
||||
- state: hypervisor_state
|
||||
- status: hypervisor_status
|
||||
- hypervisor_links: hypervisor_links
|
||||
- servers: hypervisor_servers
|
||||
- servers.uuid: hypervisor_servers_uuid
|
||||
- servers.name: hypervisor_servers_name
|
||||
|
||||
**Example List Hypervisors (v2.33): JSON response**
|
||||
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.33/hypervisors-list-resp.json
|
||||
:language: javascript
|
||||
|
||||
**Example List Hypervisors With Servers (v2.53): JSON response**
|
||||
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.53/hypervisors-with-servers-resp.json
|
||||
:language: javascript
|
||||
|
||||
List Hypervisors Details
|
||||
========================
|
||||
|
||||
@ -65,7 +77,7 @@ the ``policy.json`` file.
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: unauthorized(401), forbidden(403)
|
||||
Error response codes: badRequest(400), unauthorized(401), forbidden(403)
|
||||
|
||||
Request
|
||||
-------
|
||||
@ -74,6 +86,9 @@ Request
|
||||
|
||||
- limit: hypervisor_limit
|
||||
- marker: hypervisor_marker
|
||||
- marker: hypervisor_marker_uuid
|
||||
- hypervisor_hostname_pattern: hypervisor_hostname_pattern_query
|
||||
- with_servers: hypervisor_with_servers_query
|
||||
|
||||
Response
|
||||
--------
|
||||
@ -93,14 +108,19 @@ Response
|
||||
- hypervisor_type: hypervisor_type_body
|
||||
- hypervisor_version: hypervisor_version
|
||||
- id: hypervisor_id_body
|
||||
- id: hypervisor_id_body_uuid
|
||||
- local_gb: local_gb
|
||||
- local_gb_used: local_gb_used
|
||||
- memory_mb: memory_mb
|
||||
- memory_mb_used: memory_mb_used
|
||||
- running_vms: running_vms
|
||||
- servers: hypervisor_servers
|
||||
- servers.uuid: hypervisor_servers_uuid
|
||||
- servers.name: hypervisor_servers_name
|
||||
- service: hypervisor_service
|
||||
- service.host: host_name_body
|
||||
- service.id: service_id_body
|
||||
- service.id: service_id_body_2_52
|
||||
- service.id: service_id_body_2_53
|
||||
- service.disable_reason: service_disable_reason
|
||||
- vcpus: hypervisor_vcpus
|
||||
- vcpus_used: hypervisor_vcpus_used
|
||||
@ -111,6 +131,11 @@ Response
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.33/hypervisors-detail-resp.json
|
||||
:language: javascript
|
||||
|
||||
**Example List Hypervisors Details (v2.53): JSON response**
|
||||
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.53/hypervisors-detail-resp.json
|
||||
:language: javascript
|
||||
|
||||
Show Hypervisor Statistics
|
||||
==========================
|
||||
|
||||
@ -163,7 +188,7 @@ the ``policy.json`` file.
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
|
||||
Error response codes: badRequest(400), unauthorized(401), forbidden(403), itemNotFound(404)
|
||||
|
||||
Request
|
||||
-------
|
||||
@ -171,6 +196,8 @@ Request
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- hypervisor_id: hypervisor_id
|
||||
- hypervisor_id: hypervisor_id_uuid
|
||||
- with_servers: hypervisor_with_servers_query
|
||||
|
||||
Response
|
||||
--------
|
||||
@ -190,14 +217,19 @@ Response
|
||||
- hypervisor_type: hypervisor_type_body
|
||||
- hypervisor_version: hypervisor_version
|
||||
- id: hypervisor_id_body
|
||||
- id: hypervisor_id_body_uuid
|
||||
- local_gb: local_gb
|
||||
- local_gb_used: local_gb_used
|
||||
- memory_mb: memory_mb
|
||||
- memory_mb_used: memory_mb_used
|
||||
- running_vms: running_vms
|
||||
- servers: hypervisor_servers
|
||||
- servers.uuid: hypervisor_servers_uuid
|
||||
- servers.name: hypervisor_servers_name
|
||||
- service: hypervisor_service
|
||||
- service.host: host_name_body
|
||||
- service.id: service_id_body
|
||||
- service.id: service_id_body_2_52
|
||||
- service.id: service_id_body_2_53
|
||||
- service.disable_reason: service_disable_reason
|
||||
- vcpus: hypervisor_vcpus
|
||||
- vcpus_used: hypervisor_vcpus_used
|
||||
@ -207,6 +239,11 @@ Response
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.28/hypervisors-show-resp.json
|
||||
:language: javascript
|
||||
|
||||
**Example Show Hypervisor Details With Servers (v2.53): JSON response**
|
||||
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.53/hypervisors-show-with-servers-resp.json
|
||||
:language: javascript
|
||||
|
||||
Show Hypervisor Uptime
|
||||
======================
|
||||
|
||||
@ -220,7 +257,7 @@ the ``policy.json`` file.
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404), NotImplemented(501)
|
||||
Error response codes: badRequest(400), unauthorized(401), forbidden(403), itemNotFound(404), NotImplemented(501)
|
||||
|
||||
Request
|
||||
-------
|
||||
@ -228,6 +265,7 @@ Request
|
||||
.. rest_parameters:: parameters.yaml
|
||||
|
||||
- hypervisor_id: hypervisor_id
|
||||
- hypervisor_id: hypervisor_id_uuid
|
||||
|
||||
Response
|
||||
--------
|
||||
@ -237,6 +275,7 @@ Response
|
||||
- hypervisor: hypervisor
|
||||
- hypervisor_hostname: hypervisor_hostname
|
||||
- id: hypervisor_id_body
|
||||
- id: hypervisor_id_body_uuid
|
||||
- state: hypervisor_state
|
||||
- status: hypervisor_status
|
||||
- uptime: uptime
|
||||
@ -246,13 +285,23 @@ Response
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/hypervisors-uptime-resp.json
|
||||
:language: javascript
|
||||
|
||||
**Example Show Hypervisor Uptime (v2.53): JSON response**
|
||||
|
||||
.. literalinclude:: ../../doc/api_samples/os-hypervisors/v2.53/hypervisors-uptime-resp.json
|
||||
:language: javascript
|
||||
|
||||
Search Hypervisor
|
||||
=================
|
||||
|
||||
.. rest_method:: GET /os-hypervisors/{hypervisor_hostname_pattern}/search
|
||||
max_version: 2.52
|
||||
|
||||
Search hypervisor by a given hypervisor host name or portion of it.
|
||||
|
||||
.. warning:: This API is deprecated starting with microversion 2.53. Use
|
||||
`List Hypervisors`_ with the ``hypervisor_hostname_pattern`` query
|
||||
parameter with microversion 2.53 and later.
|
||||
|
||||
Policy defaults enable only users with the administrative role to perform
|
||||
this operation. Cloud providers can change these permissions through
|
||||
the ``policy.json`` file.
|
||||
@ -275,7 +324,7 @@ Response
|
||||
|
||||
- hypervisors: hypervisors
|
||||
- hypervisor_hostname: hypervisor_hostname
|
||||
- id: hypervisor_id_body
|
||||
- id: hypervisor_id_body_no_version
|
||||
- state: hypervisor_state
|
||||
- status: hypervisor_status
|
||||
|
||||
@ -288,10 +337,15 @@ List Hypervisor Servers
|
||||
=======================
|
||||
|
||||
.. rest_method:: GET /os-hypervisors/{hypervisor_hostname_pattern}/servers
|
||||
max_version: 2.52
|
||||
|
||||
List all servers belong to each hypervisor whose host name is matching
|
||||
a given hypervisor host name or portion of it.
|
||||
|
||||
.. warning:: This API is deprecated starting with microversion 2.53. Use
|
||||
`List Hypervisors`_ with the ``hypervisor_hostname_pattern`` and
|
||||
``with_servers`` query parameters with microversion 2.53 and later.
|
||||
|
||||
Policy defaults enable only users with the administrative role to perform
|
||||
this operation. Cloud providers can change these permissions through
|
||||
the ``policy.json`` file.
|
||||
@ -314,7 +368,7 @@ Response
|
||||
|
||||
- hypervisors: hypervisors
|
||||
- hypervisor_hostname: hypervisor_hostname
|
||||
- id: hypervisor_id_body
|
||||
- id: hypervisor_id_body_no_version
|
||||
- state: hypervisor_state
|
||||
- status: hypervisor_status
|
||||
- servers: servers
|
||||
|
@ -182,6 +182,14 @@ hypervisor_id:
|
||||
in: path
|
||||
required: true
|
||||
type: integer
|
||||
max_version: 2.52
|
||||
hypervisor_id_uuid:
|
||||
description: |
|
||||
The ID of the hypervisor as a UUID.
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
min_version: 2.53
|
||||
image_id:
|
||||
description: |
|
||||
The UUID of the image.
|
||||
@ -565,6 +573,19 @@ hostname_query_server:
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
hypervisor_hostname_pattern_query:
|
||||
description: |
|
||||
The hypervisor host name or a portion of it. The hypervisor hosts are
|
||||
selected with the host name matching this pattern.
|
||||
|
||||
.. note:: ``limit`` and ``marker`` query parameters for paging are
|
||||
not supported when listing hypervisors using a hostname pattern.
|
||||
Also, ``links`` will not be returned in the response when using this
|
||||
query parameter.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
min_version: 2.53
|
||||
hypervisor_limit:
|
||||
description: |
|
||||
Requests a page size of items. Returns a number of items up to a limit value.
|
||||
@ -584,12 +605,29 @@ hypervisor_marker:
|
||||
required: false
|
||||
type: integer
|
||||
min_version: 2.33
|
||||
max_version: 2.52
|
||||
hypervisor_marker_uuid:
|
||||
description: |
|
||||
The ID of the last-seen item as a UUID. Use the ``limit`` parameter to make
|
||||
an initial limited request and use the ID of the last-seen item from the
|
||||
response as the ``marker`` parameter value in a subsequent limited request.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
min_version: 2.53
|
||||
hypervisor_query:
|
||||
description: |
|
||||
Filters the response by a hypervisor type.
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
hypervisor_with_servers_query:
|
||||
description: |
|
||||
Include all servers which belong to each hypervisor in the response output.
|
||||
in: query
|
||||
required: false
|
||||
type: boolean
|
||||
min_version: 2.53
|
||||
image_name_query:
|
||||
description: |
|
||||
Filters the response by an image name, as a string.
|
||||
@ -2965,6 +3003,20 @@ hypervisor_id_body:
|
||||
in: body
|
||||
required: true
|
||||
type: integer
|
||||
max_version: 2.52
|
||||
hypervisor_id_body_no_version:
|
||||
description: |
|
||||
The id of the hypervisor.
|
||||
in: body
|
||||
required: true
|
||||
type: integer
|
||||
hypervisor_id_body_uuid:
|
||||
description: |
|
||||
The id of the hypervisor as a UUID.
|
||||
in: body
|
||||
required: true
|
||||
type: string
|
||||
min_version: 2.53
|
||||
hypervisor_links:
|
||||
description: |
|
||||
Links to the hypervisors resource. See `API Guide / Links and
|
||||
@ -2982,6 +3034,27 @@ hypervisor_os_diagnostics:
|
||||
type: string
|
||||
required: true
|
||||
min_version: 2.48
|
||||
hypervisor_servers:
|
||||
description: |
|
||||
A list of ``server`` objects.
|
||||
in: body
|
||||
required: false
|
||||
type: array
|
||||
min_version: 2.53
|
||||
hypervisor_servers_name:
|
||||
description: |
|
||||
The server name.
|
||||
in: body
|
||||
required: false
|
||||
type: string
|
||||
min_version: 2.53
|
||||
hypervisor_servers_uuid:
|
||||
description: |
|
||||
The server ID.
|
||||
in: body
|
||||
required: false
|
||||
type: string
|
||||
min_version: 2.53
|
||||
hypervisor_service:
|
||||
description: |
|
||||
The hypervisor service object.
|
||||
|
@ -0,0 +1,49 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"current_workload": 0,
|
||||
"status": "enabled",
|
||||
"state": "up",
|
||||
"disk_available_least": 0,
|
||||
"host_ip": "1.1.1.1",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "1bb62a04-c576-402c-8147-9e89757a09e3",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "host1",
|
||||
"id": "62f62f6e-a713-4cbe-87d3-3ecf8a1e0f8d",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
],
|
||||
"hypervisors_links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=1bb62a04-c576-402c-8147-9e89757a09e3",
|
||||
"rel": "next"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"current_workload": 0,
|
||||
"status": "enabled",
|
||||
"servers": [
|
||||
{
|
||||
"name": "test_server1",
|
||||
"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "test_server2",
|
||||
"uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
|
||||
}
|
||||
],
|
||||
"state": "up",
|
||||
"disk_available_least": 0,
|
||||
"host_ip": "1.1.1.1",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "host1",
|
||||
"id": "5d343e1d-938e-4284-b98b-6a2b5406ba76",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "1bb62a04-c576-402c-8147-9e89757a09e3",
|
||||
"state": "up",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"hypervisors_links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors?limit=1&marker=1bb62a04-c576-402c-8147-9e89757a09e3",
|
||||
"rel": "next"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"state": "up",
|
||||
"status": "enabled"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
{
|
||||
"hypervisor": {
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"current_workload": 0,
|
||||
"disk_available_least": 0,
|
||||
"host_ip": "1.1.1.1",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "043b3cacf6f34c90a7245151fc8ebcda",
|
||||
"id": "5d343e1d-938e-4284-b98b-6a2b5406ba76",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
{
|
||||
"hypervisor": {
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"servers": [
|
||||
{
|
||||
"name": "test_server1",
|
||||
"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "test_server2",
|
||||
"uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
|
||||
}
|
||||
],
|
||||
"current_workload": 0,
|
||||
"disk_available_least": 0,
|
||||
"host_ip": "1.1.1.1",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "043b3cacf6f34c90a7245151fc8ebcda",
|
||||
"id": "5d343e1d-938e-4284-b98b-6a2b5406ba76",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"hypervisor_statistics": {
|
||||
"count": 1,
|
||||
"current_workload": 0,
|
||||
"disk_available_least": 0,
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"hypervisor": {
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"uptime": " 08:32:11 up 93 days, 18:25, 12 users, load average: 0.20, 0.12, 0.14"
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"servers": [
|
||||
{
|
||||
"name": "test_server1",
|
||||
"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "test_server2",
|
||||
"uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "b1e43b5f-eec1-44e0-9f10-7b4945c0226d",
|
||||
"state": "up",
|
||||
"status": "enabled"
|
||||
}
|
||||
]
|
||||
}
|
@ -124,9 +124,10 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||
non-admins can see instance action event details except for the
|
||||
traceback field.
|
||||
* 2.52 - Adds support for applying tags when creating a server.
|
||||
* 2.53 - Service database ids are hidden. The os-services API now returns
|
||||
a uuid in the id field, and takes a uuid in
|
||||
DELETE /services/{service_uuid}.
|
||||
* 2.53 - Service and compute node (hypervisor) database ids are hidden.
|
||||
The os-services and os-hypervisors APIs now return a uuid in the
|
||||
id field, and takes a uuid in requests. PUT and GET requests
|
||||
and responses are also changed.
|
||||
"""
|
||||
|
||||
# The minimum and maximum versions of the API supported
|
||||
|
@ -17,21 +17,29 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import uuidutils
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack.compute.schemas import hypervisors as hyper_schema
|
||||
from nova.api.openstack.compute.views import hypervisors as hyper_view
|
||||
from nova.api.openstack import extensions
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.cells import utils as cells_utils
|
||||
from nova import compute
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.policies import hypervisors as hv_policies
|
||||
from nova import servicegroup
|
||||
from nova import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
UUID_FOR_ID_MIN_VERSION = '2.53'
|
||||
|
||||
|
||||
class HypervisorsController(wsgi.Controller):
|
||||
"""The Hypervisors API controller for the OpenStack API."""
|
||||
@ -46,15 +54,18 @@ class HypervisorsController(wsgi.Controller):
|
||||
def _view_hypervisor(self, hypervisor, service, detail, req, servers=None,
|
||||
**kwargs):
|
||||
alive = self.servicegroup_api.service_is_up(service)
|
||||
# The 2.53 microversion returns the compute node uuid rather than id.
|
||||
uuid_for_id = api_version_request.is_supported(
|
||||
req, min_version=UUID_FOR_ID_MIN_VERSION)
|
||||
hyp_dict = {
|
||||
'id': hypervisor.id,
|
||||
'id': hypervisor.uuid if uuid_for_id else hypervisor.id,
|
||||
'hypervisor_hostname': hypervisor.hypervisor_hostname,
|
||||
'state': 'up' if alive else 'down',
|
||||
'status': ('disabled' if service.disabled
|
||||
else 'enabled'),
|
||||
}
|
||||
|
||||
if detail and not servers:
|
||||
if detail:
|
||||
for field in ('vcpus', 'memory_mb', 'local_gb', 'vcpus_used',
|
||||
'memory_mb_used', 'local_gb_used',
|
||||
'hypervisor_type', 'hypervisor_version',
|
||||
@ -62,8 +73,9 @@ class HypervisorsController(wsgi.Controller):
|
||||
'running_vms', 'disk_available_least', 'host_ip'):
|
||||
hyp_dict[field] = getattr(hypervisor, field)
|
||||
|
||||
service_id = service.uuid if uuid_for_id else service.id
|
||||
hyp_dict['service'] = {
|
||||
'id': service.id,
|
||||
'id': service_id,
|
||||
'host': hypervisor.host,
|
||||
'disabled_reason': service.disabled_reason,
|
||||
}
|
||||
@ -108,21 +120,58 @@ class HypervisorsController(wsgi.Controller):
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
|
||||
try:
|
||||
compute_nodes = self.host_api.compute_node_get_all(
|
||||
context, limit=limit, marker=marker)
|
||||
except exception.MarkerNotFound:
|
||||
msg = _('marker [%s] not found') % marker
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
# The 2.53 microversion moves the search and servers routes into
|
||||
# GET /os-hypervisors and GET /os-hypervisors/detail with query
|
||||
# parameters.
|
||||
if api_version_request.is_supported(
|
||||
req, min_version=UUID_FOR_ID_MIN_VERSION):
|
||||
hypervisor_match = req.GET.get('hypervisor_hostname_pattern')
|
||||
with_servers = strutils.bool_from_string(
|
||||
req.GET.get('with_servers', False), strict=True)
|
||||
else:
|
||||
hypervisor_match = None
|
||||
with_servers = False
|
||||
|
||||
if hypervisor_match is not None:
|
||||
# We have to check for 'limit' in the request itself because
|
||||
# the limit passed in is CONF.api.max_limit by default.
|
||||
if 'limit' in req.GET or marker:
|
||||
# Paging with hostname pattern isn't supported.
|
||||
raise webob.exc.HTTPBadRequest(
|
||||
_('Paging over hypervisors with the '
|
||||
'hypervisor_hostname_pattern query parameter is not '
|
||||
'supported.'))
|
||||
|
||||
# Explicitly do not try to generate links when querying with the
|
||||
# hostname pattern since the request in the link would fail the
|
||||
# check above.
|
||||
links = False
|
||||
|
||||
# Get all compute nodes with a hypervisor_hostname that matches
|
||||
# the given pattern. If none are found then it's a 404 error.
|
||||
compute_nodes = self._get_compute_nodes_by_name_pattern(
|
||||
context, hypervisor_match)
|
||||
else:
|
||||
# Get all compute nodes.
|
||||
try:
|
||||
compute_nodes = self.host_api.compute_node_get_all(
|
||||
context, limit=limit, marker=marker)
|
||||
except exception.MarkerNotFound:
|
||||
msg = _('marker [%s] not found') % marker
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
hypervisors_list = []
|
||||
for hyp in compute_nodes:
|
||||
try:
|
||||
instances = None
|
||||
if with_servers:
|
||||
instances = self.host_api.instance_get_all_by_host(
|
||||
context, hyp.host)
|
||||
service = self.host_api.service_get_by_compute_host(
|
||||
context, hyp.host)
|
||||
hypervisors_list.append(
|
||||
self._view_hypervisor(
|
||||
hyp, service, detail, req))
|
||||
hyp, service, detail, req, servers=instances))
|
||||
except (exception.ComputeHostNotFound,
|
||||
exception.HostMappingNotFound):
|
||||
# The compute service could be deleted which doesn't delete
|
||||
@ -140,7 +189,21 @@ class HypervisorsController(wsgi.Controller):
|
||||
hypervisors_dict['hypervisors_links'] = hypervisors_links
|
||||
return hypervisors_dict
|
||||
|
||||
@wsgi.Controller.api_version("2.33") # noqa
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION)
|
||||
@validation.query_schema(hyper_schema.list_query_schema_v253,
|
||||
UUID_FOR_ID_MIN_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
def index(self, req):
|
||||
"""Starting with the 2.53 microversion, the id field in the response
|
||||
is the compute_nodes.uuid value. Also, the search and servers routes
|
||||
are superseded and replaced with query parameters for listing
|
||||
hypervisors by a hostname pattern and whether or not to include
|
||||
hosted servers in the response.
|
||||
"""
|
||||
limit, marker = common.get_limit_and_marker(req)
|
||||
return self._index(req, limit=limit, marker=marker, links=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.33", "2.52") # noqa
|
||||
@extensions.expected_errors((400))
|
||||
def index(self, req):
|
||||
limit, marker = common.get_limit_and_marker(req)
|
||||
@ -155,7 +218,21 @@ class HypervisorsController(wsgi.Controller):
|
||||
return self._get_hypervisors(req, detail=False, limit=limit,
|
||||
marker=marker, links=links)
|
||||
|
||||
@wsgi.Controller.api_version("2.33") # noqa
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION)
|
||||
@validation.query_schema(hyper_schema.list_query_schema_v253,
|
||||
UUID_FOR_ID_MIN_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
def detail(self, req):
|
||||
"""Starting with the 2.53 microversion, the id field in the response
|
||||
is the compute_nodes.uuid value. Also, the search and servers routes
|
||||
are superseded and replaced with query parameters for listing
|
||||
hypervisors by a hostname pattern and whether or not to include
|
||||
hosted servers in the response.
|
||||
"""
|
||||
limit, marker = common.get_limit_and_marker(req)
|
||||
return self._detail(req, limit=limit, marker=marker, links=True)
|
||||
|
||||
@wsgi.Controller.api_version("2.33", "2.52") # noqa
|
||||
@extensions.expected_errors((400))
|
||||
def detail(self, req):
|
||||
limit, marker = common.get_limit_and_marker(req)
|
||||
@ -170,12 +247,69 @@ class HypervisorsController(wsgi.Controller):
|
||||
return self._get_hypervisors(req, detail=True, limit=limit,
|
||||
marker=marker, links=links)
|
||||
|
||||
@staticmethod
|
||||
def _validate_id(req, hypervisor_id):
|
||||
"""Validates that the id is a uuid for microversions that require it.
|
||||
|
||||
:param req: The HTTP request object which contains the requested
|
||||
microversion information.
|
||||
:param hypervisor_id: The provided hypervisor id.
|
||||
:raises: webob.exc.HTTPBadRequest if the requested microversion is
|
||||
greater than or equal to 2.53 and the id is not a uuid.
|
||||
:raises: webob.exc.HTTPNotFound if the requested microversion is
|
||||
less than 2.53 and the id is not an integer.
|
||||
"""
|
||||
expect_uuid = api_version_request.is_supported(
|
||||
req, min_version=UUID_FOR_ID_MIN_VERSION)
|
||||
if expect_uuid:
|
||||
if not uuidutils.is_uuid_like(hypervisor_id):
|
||||
msg = _('Invalid uuid %s') % hypervisor_id
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
else:
|
||||
# This API is supported for cells v1 and as such the id can be
|
||||
# a cell v1 delimited string, so we have to parse it first.
|
||||
if cells_utils.CELL_ITEM_SEP in str(hypervisor_id):
|
||||
hypervisor_id = cells_utils.split_cell_and_item(
|
||||
hypervisor_id)[1]
|
||||
try:
|
||||
utils.validate_integer(hypervisor_id, 'id')
|
||||
except exception.InvalidInput:
|
||||
msg = (_("Hypervisor with ID '%s' could not be found.") %
|
||||
hypervisor_id)
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION)
|
||||
@validation.query_schema(hyper_schema.show_query_schema_v253,
|
||||
UUID_FOR_ID_MIN_VERSION)
|
||||
@extensions.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
"""The 2.53 microversion requires that the id is a uuid and as a result
|
||||
it can also return a 400 response if an invalid uuid is passed.
|
||||
|
||||
The 2.53 microversion also supports the with_servers query parameter
|
||||
to include a list of servers on the given hypervisor if requested.
|
||||
"""
|
||||
with_servers = strutils.bool_from_string(
|
||||
req.GET.get('with_servers', False), strict=True)
|
||||
return self._show(req, id, with_servers)
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.52") # noqa F811
|
||||
@extensions.expected_errors(404)
|
||||
def show(self, req, id):
|
||||
return self._show(req, id)
|
||||
|
||||
def _show(self, req, id, with_servers=False):
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
|
||||
self._validate_id(req, id)
|
||||
|
||||
try:
|
||||
hyp = self.host_api.compute_node_get(context, id)
|
||||
instances = None
|
||||
if with_servers:
|
||||
instances = self.host_api.instance_get_all_by_host(
|
||||
context, hyp.host)
|
||||
service = self.host_api.service_get_by_compute_host(
|
||||
context, hyp.host)
|
||||
except (ValueError, exception.ComputeHostNotFound,
|
||||
@ -183,12 +317,15 @@ class HypervisorsController(wsgi.Controller):
|
||||
msg = _("Hypervisor with ID '%s' could not be found.") % id
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
return dict(hypervisor=self._view_hypervisor(
|
||||
hyp, service, True, req))
|
||||
hyp, service, True, req, instances))
|
||||
|
||||
@extensions.expected_errors((400, 404, 501))
|
||||
def uptime(self, req, id):
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
|
||||
self._validate_id(req, id)
|
||||
|
||||
try:
|
||||
hyp = self.host_api.compute_node_get(context, id)
|
||||
except (ValueError, exception.ComputeHostNotFound):
|
||||
@ -214,8 +351,14 @@ class HypervisorsController(wsgi.Controller):
|
||||
return dict(hypervisor=self._view_hypervisor(hyp, service, False, req,
|
||||
uptime=uptime))
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.52')
|
||||
@extensions.expected_errors(404)
|
||||
def search(self, req, id):
|
||||
"""Prior to microversion 2.53 you could search for hypervisors by a
|
||||
hostname pattern on a dedicated route. Starting with 2.53, searching
|
||||
by a hostname pattern is a query parameter in the GET /os-hypervisors
|
||||
index and detail methods.
|
||||
"""
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
hypervisors = self._get_compute_nodes_by_name_pattern(context, id)
|
||||
@ -231,8 +374,15 @@ class HypervisorsController(wsgi.Controller):
|
||||
msg = _("No hypervisor matching '%s' could be found.") % id
|
||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||
|
||||
@wsgi.Controller.api_version('2.1', '2.52')
|
||||
@extensions.expected_errors(404)
|
||||
def servers(self, req, id):
|
||||
"""Prior to microversion 2.53 you could search for hypervisors by a
|
||||
hostname pattern and include servers on those hosts in the response on
|
||||
a dedicated route. Starting with 2.53, searching by a hostname pattern
|
||||
and including hosted servers is a query parameter in the
|
||||
GET /os-hypervisors index and detail methods.
|
||||
"""
|
||||
context = req.environ['nova.context']
|
||||
context.can(hv_policies.BASE_POLICY_NAME)
|
||||
compute_nodes = self._get_compute_nodes_by_name_pattern(context, id)
|
||||
|
@ -657,3 +657,30 @@ user documentation.
|
||||
|
||||
* ``PUT /os-services/{service_uuid}`` will now return a full service resource
|
||||
representation like in a ``GET`` response
|
||||
|
||||
**os-hypervisors**
|
||||
|
||||
Hypervisors are now identified by uuid instead of database id to ensure
|
||||
uniqueness across cells. This microversion brings the following changes:
|
||||
|
||||
* ``GET /os-hypervisors/{hypervisor_hostname_pattern}/search`` is deprecated
|
||||
and replaced with the ``hypervisor_hostname_pattern`` query parameter on
|
||||
the ``GET /os-hypervisors`` and ``GET /os-hypervisors/detail`` APIs.
|
||||
Paging with ``hypervisor_hostname_pattern`` is not supported.
|
||||
* ``GET /os-hypervisors/{hypervisor_hostname_pattern}/servers`` is deprecated
|
||||
and replaced with the ``with_servers`` query parameter on the
|
||||
``GET /os-hypervisors`` and ``GET /os-hypervisors/detail`` APIs.
|
||||
* ``GET /os-hypervisors/{hypervisor_id}`` supports the ``with_servers`` query
|
||||
parameter to include hosted server details in the response.
|
||||
* ``GET /os-hypervisors/{hypervisor_id}`` and
|
||||
``GET /os-hypervisors/{hypervisor_id}/uptime`` APIs now take a uuid value
|
||||
for the ``{hypervisor_id}`` path parameter.
|
||||
* The ``GET /os-hypervisors`` and ``GET /os-hypervisors/detail`` APIs will
|
||||
now use a uuid marker for paging across cells.
|
||||
* The following APIs will now return a uuid value for the hypervisor id and
|
||||
optionally service id fields in the response:
|
||||
|
||||
* ``GET /os-hypervisors``
|
||||
* ``GET /os-hypervisors/detail``
|
||||
* ``GET /os-hypervisors/{hypervisor_id}``
|
||||
* ``GET /os-hypervisors/{hypervisor_id}/uptime``
|
||||
|
43
nova/api/openstack/compute/schemas/hypervisors.py
Normal file
43
nova/api/openstack/compute/schemas/hypervisors.py
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright 2017 Huawei Technologies Co.,LTD.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.api.validation import parameter_types
|
||||
|
||||
|
||||
list_query_schema_v253 = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
# The 2.33 microversion added support for paging by limit and marker.
|
||||
'limit': parameter_types.single_param(
|
||||
parameter_types.non_negative_integer),
|
||||
'marker': parameter_types.single_param({'type': 'string'}),
|
||||
# The 2.53 microversion adds support for filtering by hostname pattern
|
||||
# and requesting hosted servers in the GET /os-hypervisors and
|
||||
# GET /os-hypervisors/detail response.
|
||||
'hypervisor_hostname_pattern': parameter_types.single_param(
|
||||
parameter_types.hostname),
|
||||
'with_servers': parameter_types.single_param(
|
||||
parameter_types.boolean)
|
||||
},
|
||||
'additionalProperties': False
|
||||
}
|
||||
|
||||
show_query_schema_v253 = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'with_servers': parameter_types.single_param(
|
||||
parameter_types.boolean)
|
||||
},
|
||||
'additionalProperties': False
|
||||
}
|
@ -34,7 +34,7 @@ PATH_CELL_SEP = '!'
|
||||
# meaningful PATH_CELL_SEP in an invalid way will need to suffice.
|
||||
BLOCK_SYNC_FLAG = '!!'
|
||||
# Separator used between cell name and item
|
||||
_CELL_ITEM_SEP = '@'
|
||||
CELL_ITEM_SEP = '@'
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
@ -192,12 +192,12 @@ def cell_with_item(cell_name, item):
|
||||
"""Turn cell_name and item into <cell_name>@<item>."""
|
||||
if cell_name is None:
|
||||
return item
|
||||
return cell_name + _CELL_ITEM_SEP + str(item)
|
||||
return cell_name + CELL_ITEM_SEP + str(item)
|
||||
|
||||
|
||||
def split_cell_and_item(cell_and_item):
|
||||
"""Split a combined cell@item and return them."""
|
||||
result = cell_and_item.rsplit(_CELL_ITEM_SEP, 1)
|
||||
result = cell_and_item.rsplit(CELL_ITEM_SEP, 1)
|
||||
if len(result) == 1:
|
||||
return (None, cell_and_item)
|
||||
else:
|
||||
|
@ -0,0 +1,49 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"current_workload": 0,
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"disk_available_least": 0,
|
||||
"host_ip": "%(ip)s",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "%(hypervisor_id)s",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "%(host_name)s",
|
||||
"id": "%(service_id)s",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
],
|
||||
"hypervisors_links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=%(hypervisor_id)s",
|
||||
"rel": "next"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"current_workload": 0,
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"servers": [
|
||||
{
|
||||
"name": "test_server1",
|
||||
"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "test_server2",
|
||||
"uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
|
||||
}
|
||||
],
|
||||
"disk_available_least": 0,
|
||||
"host_ip": "%(ip)s",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "%(hypervisor_id)s",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "%(host_name)s",
|
||||
"id": "%(service_id)s",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "%(hypervisor_id)s",
|
||||
"state": "up",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"hypervisors_links": [
|
||||
{
|
||||
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors?limit=1&marker=%(hypervisor_id)s",
|
||||
"rel": "next"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "%(hypervisor_id)s",
|
||||
"state": "up",
|
||||
"status": "enabled"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
{
|
||||
"hypervisor": {
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"current_workload": 0,
|
||||
"disk_available_least": 0,
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"host_ip": "%(ip)s",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "%(hypervisor_id)s",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "%(host_name)s",
|
||||
"id": "%(service_id)s",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
{
|
||||
"hypervisor": {
|
||||
"cpu_info": {
|
||||
"arch": "x86_64",
|
||||
"model": "Nehalem",
|
||||
"vendor": "Intel",
|
||||
"features": [
|
||||
"pge",
|
||||
"clflush"
|
||||
],
|
||||
"topology": {
|
||||
"cores": 1,
|
||||
"threads": 1,
|
||||
"sockets": 4
|
||||
}
|
||||
},
|
||||
"current_workload": 0,
|
||||
"disk_available_least": 0,
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"servers": [
|
||||
{
|
||||
"name": "test_server1",
|
||||
"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "test_server2",
|
||||
"uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
|
||||
}
|
||||
],
|
||||
"host_ip": "%(ip)s",
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"hypervisor_type": "fake",
|
||||
"hypervisor_version": 1000,
|
||||
"id": "%(hypervisor_id)s",
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"service": {
|
||||
"host": "%(host_name)s",
|
||||
"id": "%(service_id)s",
|
||||
"disabled_reason": null
|
||||
},
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"hypervisor_statistics": {
|
||||
"count": 1,
|
||||
"current_workload": 0,
|
||||
"disk_available_least": 0,
|
||||
"free_disk_gb": 1028,
|
||||
"free_ram_mb": 7680,
|
||||
"local_gb": 1028,
|
||||
"local_gb_used": 0,
|
||||
"memory_mb": 8192,
|
||||
"memory_mb_used": 512,
|
||||
"running_vms": 0,
|
||||
"vcpus": 1,
|
||||
"vcpus_used": 0
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"hypervisor": {
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "%(hypervisor_id)s",
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"uptime": " 08:32:11 up 93 days, 18:25, 12 users, load average: 0.20, 0.12, 0.14"
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "%(hypervisor_id)s",
|
||||
"state": "up",
|
||||
"status": "enabled",
|
||||
"servers": [
|
||||
{
|
||||
"name": "test_server1",
|
||||
"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "test_server2",
|
||||
"uuid": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"hypervisors": [
|
||||
{
|
||||
"hypervisor_hostname": "fake-mini",
|
||||
"id": "%(hypervisor_id)s",
|
||||
"state": "up",
|
||||
"status": "enabled"
|
||||
}
|
||||
]
|
||||
}
|
@ -169,3 +169,147 @@ class HypervisorsSampleJson233Tests(api_sample_base.ApiSampleTestBaseV21):
|
||||
}
|
||||
response = self._do_get('os-hypervisors/detail?limit=1&marker=1')
|
||||
self._verify_response('hypervisors-detail-resp', subs, response, 200)
|
||||
|
||||
|
||||
class HypervisorsSampleJson253Tests(HypervisorsSampleJson228Tests):
|
||||
microversion = '2.53'
|
||||
scenarios = [('v2_53', {'api_major_version': 'v2.1'})]
|
||||
|
||||
def setUp(self):
|
||||
super(HypervisorsSampleJson253Tests, self).setUp()
|
||||
self.compute_node_1 = self |