Fix object code direct use of other object modules

The object code itself should not explicitly reference its own objects,
as objects could be subclassed.

Also: There were a few objects that had their own __init__()s that
didn't support accepting 'context' or kwargs. At some point here, we
should also require that context is passed when instantiating the
objects. So, I added the (currently optional) context argument on some
object instantiations near the places I was touching.

Partial-Blueprint: object-subclassing

Change-Id: Icf631c770e347b4bb32999c4ba2431d1db49e11c
This commit is contained in:
Chris Behrens
2014-05-17 16:06:33 -07:00
parent 13be274fb8
commit dcb2808f52

View File

@@ -15,6 +15,7 @@
from nova.compute import utils as compute_utils
from nova import db
from nova import exception
from nova import objects
from nova.objects import base
from nova.objects import fields
@@ -165,11 +166,11 @@ class AggregateList(base.ObjectListBase, base.NovaObject):
@base.remotable_classmethod
def get_all(cls, context):
db_aggregates = db.aggregate_get_all(context)
return base.obj_make_list(context, AggregateList(), Aggregate,
return base.obj_make_list(context, cls(context), objects.Aggregate,
db_aggregates)
@base.remotable_classmethod
def get_by_host(cls, context, host, key=None):
db_aggregates = db.aggregate_get_by_host(context, host, key=key)
return base.obj_make_list(context, AggregateList(), Aggregate,
return base.obj_make_list(context, cls(context), objects.Aggregate,
db_aggregates)