forked from openstack/nova
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address issues with objects of same name
There are at least a couple of cases where we may (in the future) introduce multiple objects that have the same name: 1) When we subclass an object to override internal behavior, presenting the same version of the object. 2) When we want to introduce multiple versions of objects either via subclassing or completely separate classes if differences are large enough to warrant that. There was a rough plan to support this, however we're currently very broken. The code before this patch would happily track every one of the objects with the same name. However, in the case where we see the same version during 'object registration', we should actually always take the newest one that we see, replacing the old one. Also, throughout nova, we have code such as: from nova.objects import instance as instance_obj inst = instance_obj.Instance.<....> This means we're always using the base object, which may or may not be the correct ('newest') one. This patch fixes the object registration and adds an attribute to the 'nova.objects' module for every object that is registered, setting the attribute to the newest version we see. This will allow us to drop a number of object module imports in favor of simply importing nova.objects. The example above would become: from nova import objects inst = objects.Instance.<....> Because the object registration ensures objects.Instance is the newest version, we'll be golden. Partial-Blueprint: object-subclassing Change-Id: I04694ecd40e0d4ec40a87d319f2e689060b11651
- Loading branch information
Showing
2 changed files
with
99 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters