diff options
author | Dan Smith <dansmith@redhat.com> | 2017-03-09 08:14:04 -0800 |
---|---|---|
committer | Dan Smith <dansmith@redhat.com> | 2017-03-10 09:58:34 -0800 |
commit | 35f803f6f4069902f1d343e5db7cdec081af91cd (patch) | |
tree | 2df9f04f646791153355e65b7be561d41156fded /nova/objects/cell_mapping.py | |
parent | 9b8ab58360f32aeea96e188d56ea4a6a2bbed50f (diff) | |
download | nova-35f803f6f4069902f1d343e5db7cdec081af91cd.tar.gz |
Add identity helper property to CellMapping
This adds CellMapping.identity, a property to help with quick logging of
a CellMapping. It's tempting to just log a a whole CellMapping object,
but that can be bad due to the credentials stored within. This adds a
convenient way to log the uuid or name-and-uuid of a CellMapping without
having to replicate the is-name-set-or-none logic everywhere.
Related to blueprint cells-aware-api
Change-Id: Ie8eaf08e9f5bda56431358c40ccf187251be4542
Diffstat (limited to 'nova/objects/cell_mapping.py')
-rw-r--r-- | nova/objects/cell_mapping.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nova/objects/cell_mapping.py b/nova/objects/cell_mapping.py index 62546f8948..11d22ef577 100644 --- a/nova/objects/cell_mapping.py +++ b/nova/objects/cell_mapping.py @@ -32,6 +32,13 @@ class CellMapping(base.NovaTimestampObject, base.NovaObject): 'database_connection': fields.StringField(), } + @property + def identity(self): + if 'name' in self and self.name: + return '%s(%s)' % (self.uuid, self.name) + else: + return self.uuid + @staticmethod def _from_db_object(context, cell_mapping, db_cell_mapping): for key in cell_mapping.fields: |