Remove usage of remotable context parameter in agent, aggregate

This removes the use of the context parameter in remotable methods
in these objects. This is a precursor to actually removing the
context from the call, but we need to remove dependence on the
argument first. Remotable methods should be using the bundled object
context.

Related to blueprint kilo-objects

Change-Id: Iad5093622337077418a8ef94c9867dfd7a7fdf64
This commit is contained in:
Dan Smith
2015-03-13 09:37:06 -07:00
parent 3b73eaf576
commit 88fc30cd82

View File

@@ -70,14 +70,15 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject,
if 'metadata' in updates:
# NOTE(danms): For some reason the notification format is weird
payload['meta_data'] = payload.pop('metadata')
compute_utils.notify_about_aggregate_update(context,
compute_utils.notify_about_aggregate_update(self._context,
"create.start",
payload)
metadata = updates.pop('metadata', None)
db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
self._from_db_object(context, self, db_aggregate)
db_aggregate = db.aggregate_create(self._context, updates,
metadata=metadata)
self._from_db_object(self._context, self, db_aggregate)
payload['aggregate_id'] = self.id
compute_utils.notify_about_aggregate_update(context,
compute_utils.notify_about_aggregate_update(self._context,
"create.end",
payload)
@@ -89,28 +90,28 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject,
payload = {'aggregate_id': self.id}
if 'metadata' in updates:
payload['meta_data'] = updates['metadata']
compute_utils.notify_about_aggregate_update(context,
compute_utils.notify_about_aggregate_update(self._context,
"updateprop.start",
payload)
updates.pop('id', None)
db_aggregate = db.aggregate_update(context, self.id, updates)
compute_utils.notify_about_aggregate_update(context,
db_aggregate = db.aggregate_update(self._context, self.id, updates)
compute_utils.notify_about_aggregate_update(self._context,
"updateprop.end",
payload)
self._from_db_object(context, self, db_aggregate)
self._from_db_object(self._context, self, db_aggregate)
@base.remotable
def update_metadata(self, context, updates):
payload = {'aggregate_id': self.id,
'meta_data': updates}
compute_utils.notify_about_aggregate_update(context,
compute_utils.notify_about_aggregate_update(self._context,
"updatemetadata.start",
payload)
to_add = {}
for key, value in updates.items():
if value is None:
try:
db.aggregate_metadata_delete(context, self.id, key)
db.aggregate_metadata_delete(self._context, self.id, key)
except exception.AggregateMetadataNotFound:
pass
try:
@@ -120,19 +121,19 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject,
else:
to_add[key] = value
self.metadata[key] = value
db.aggregate_metadata_add(context, self.id, to_add)
compute_utils.notify_about_aggregate_update(context,
db.aggregate_metadata_add(self._context, self.id, to_add)
compute_utils.notify_about_aggregate_update(self._context,
"updatemetadata.end",
payload)
self.obj_reset_changes(fields=['metadata'])
@base.remotable
def destroy(self, context):
db.aggregate_delete(context, self.id)
db.aggregate_delete(self._context, self.id)
@base.remotable
def add_host(self, context, host):
db.aggregate_host_add(context, self.id, host)
db.aggregate_host_add(self._context, self.id, host)
if self.hosts is None:
self.hosts = []
self.hosts.append(host)
@@ -140,7 +141,7 @@ class Aggregate(base.NovaPersistentObject, base.NovaObject,
@base.remotable
def delete_host(self, context, host):
db.aggregate_host_delete(context, self.id, host)
db.aggregate_host_delete(self._context, self.id, host)
self.hosts.remove(host)
self.obj_reset_changes(fields=['hosts'])