Use uuids in services and os-hypervisors APIs

Registered by Matt Riedemann

We currently leak database id fields (primary keys) out of the compute REST API for services and compute_nodes which are all in a cell database (the 'nova' database in a cells v2 deployment). These are in the os-services and os-hypervisors APIs, respectively.

For example, to delete a service record, you must issue a DELETE request to /os-services/{service_id} to delete the service record with that id.

The os-hypervisors API exposes the id in GET (index) requests and uses it in the "show" and "uptime" methods to look up the ComputeNode object by that id.

This is gross but functional in a single-cell deployment. However, in a multi-cell deployment, we have no context on which cell we should query to get service/node details from, since you could have multiple cells each with a nova-compute service and compute node with id 1, so which cell do you pick to delete the service or show details about the hypervisor?

This blueprint proposes to add a microversion to the compute REST API which replaces the usage of the id field with a uuid field. The uuid would be returned instead of the id in GET responses and also taken as input for the id in CRUD APIs.

Then when a request to delete a service is made, if the uuid is provided we can simply iterate cells until we find the service, or error with a 404.

Before the microversion, if an id is passed and there is only one cell, or no duplicates in multiple cells, we'll continue to honor the request. But if an id is passed on the request (before the microversion) and we cannot uniquely identify the record out of multiple cells, we error with a 400. This is similar behavior to how creating a server works when a network or port is not provided and there are multiple networks available to the project, we fail with a 400 "NetworkAmbiguous" error.

The compute_nodes table already has a uuid field. The services table, however, does not, so as part of this blueprint we'll need to add a uuid column to that table and corresponding versioned object.

Blueprint information

Sean Dague
Matt Riedemann
Matt Riedemann
Series goal:
Accepted for pike
Milestone target:
milestone icon pike-3
Started by
Matt Riedemann
Completed by
Matt Riedemann


LGTM (dansmith 8-Mar-2017)

I'm going to remove os-pci from this blueprint since that API isn't even exposed:

-- mriedem 20170317

Gerrit topic:,topic:bp/service-hyper-uuid-in-api,n,z

Addressed by:
    Use uuids in services and os-hypervisors APIs (spec)

Addressed by:
    Add uuid to Service model

Addressed by:
    Add online data migration for populating services.uuid

Addressed by:
    db api: add get_service_by_uuid

Addressed by:
    objects: add Service.get_by_uuid method

Addressed by:
    db api: add compute_node_get_by_uuid method

Addressed by:
    objects: add ComputeNode.get_by_uuid method

Addressed by:
    Add uuid to service.update notification payload

Addressed by:
    Handle uuid in HostAPI._find_service

Addressed by:
    Handle uuid in HostAPI.compute_node_get

Gerrit topic:,topic:bp/service-hyper-uuid-in-ap,n,z

Addressed by:
    Use uuid for id in Services API

Addressed by:
    WIP: Handle uuids in os-hypervisors API

Addressed by:
    Centralize compute_node_search_by_hypervisor in os-hypervisors

Addressed by:
    Stop caching compute nodes in the request

Addressed by:
    Consolidate index and detail methods in HypervisorsController

Addressed by:
    Support paging over compute nodes with a uuid marker

Addressed by:
    api-ref: fix description of service_disable_reason

REST API changes are done for this blueprint with microversion 2.53. Now just need to complete the python-novaclient changes. -- mriedem 20170719

The python-novaclient support for microversion 2.53 is merged now so I'm going to mark this complete. -- mriedem 20170726


Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.


No subscribers.