clean up nova's db api

Registered by aeva black

Database access layer has grown organically, and could use some house keeping. For both nova/db/api and nova/db/sqlalchemy/api, let's clean up the API itself.

* identify and remove unused methods
* consolidate duplicate methods when possible
* ensure SQLAlchemy objects are not leaking out of the API
* ensure related methods are grouped together and named consistently

Blueprint information

Status:
Complete
Approver:
Russell Bryant
Priority:
High
Drafter:
aeva black
Direction:
Approved
Assignee:
Joe Gordon
Definition:
Approved
Series goal:
Accepted for grizzly
Implementation:
Implemented
Milestone target:
milestone icon 2013.1
Started by
Joe Gordon
Completed by
Russell Bryant

Related branches

Sprints

Whiteboard

https://review.openstack.org/21395 was postponed to Havana. We have declared everything else that was done the completion of this blueprint for Grizzly. New work can be scoped out for a Havana blueprint.

List of db functions that return sqlalchemy model objects: https://etherpad.openstack.org/sqlalchemy-leaks (generated using https://review.openstack.org/#/c/15450/)

Should use jsonutils.to_primitive()

"once that's done we can probably remove most of the to_primitive() calls that are scattered everywhere else" ~russellb 11/27/2012

Going in the direction of only allowing primitives to be returned from nova.db.api (potentially with a few explicit exceptions) ~Joe Gordon 11/28/2012

Gerrit topic: https://review.openstack.org/#q,topic:bp/db-api-cleanup,n,z

Addressed by: https://review.openstack.org/17099
    Access DB values as dict not as Attributes

Addressed by: https://review.openstack.org/17178
    Access DB values as dict not as attributes. Part 2

Addressed by: https://review.openstack.org/17247
    Access DB values as dict not as attributes. Part 3

Addressed by: https://review.openstack.org/17610
    Clean up soft deletion in sqlaclhemy db api

Addressed by: https://review.openstack.org/17789
    Access DB values as dict not as attributes. Part 4

Addressed by: https://review.openstack.org/#/c/21236/
   Allow to_primitive to ignore datetimes

Addressed by: https://review.openstack.org/21280
    Access DB as dict not as attributes part 5

Addressed by: https://review.openstack.org/21281
    Use joined version of db.api calls

Addressed by: https://review.openstack.org/21282
    Update nova/compute/api to handle instance as dict

Addressed by: https://review.openstack.org/21393
    Update jsonutils from oslo-incubator

Addressed by: https://review.openstack.org/21394
    Use joinedload for system_metadata in db

Gerrit topic: https://review.openstack.org/#q,topic:db-api-cleanup,n,z

Addressed by: https://review.openstack.org/26951
    Remove orphaned db method instance_test_and_set

(?)

Work Items

Work items:
identify and remove unused methods: DONE
Don't use Attributes for objects returned from nova.db.api: DONE
make nova.db.api only return primitives (potentially with a few exceptions): POSTPONED
consolidate duplicate methods when possible: DONE
ensure related methods are grouped together and named consistently: TODO

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.