Merge "Deploy steps - versioned objects"

This commit is contained in:
Zuul 2018-07-14 04:26:27 +00:00 committed by Gerrit Code Review
commit f7a0a9b3bd
3 changed files with 29 additions and 3 deletions

View File

@ -118,7 +118,7 @@ RELEASE_MAPPING = {
'api': '1.43',
'rpc': '1.44',
'objects': {
'Node': ['1.24', '1.25'],
'Node': ['1.24', '1.25', '1.26'],
'Conductor': ['1.2'],
'Chassis': ['1.3'],
'Port': ['1.8'],

View File

@ -61,7 +61,8 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
# Version 1.23: Add traits field
# Version 1.24: Add bios_interface field
# Version 1.25: Add fault field
VERSION = '1.25'
# Version 1.26: Add deploy_step field
VERSION = '1.26'
dbapi = db_api.get_instance()
@ -82,6 +83,11 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
# or has not yet started.
'clean_step': object_fields.FlexibleDictField(nullable=True),
# A deploy step dictionary, indicating the current step
# being executed, or None, indicating deployment is not in progress
# or has not yet started.
'deploy_step': object_fields.FlexibleDictField(nullable=True),
'raid_config': object_fields.FlexibleDictField(nullable=True),
'target_raid_config': object_fields.FlexibleDictField(nullable=True),
@ -477,6 +483,22 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
elif self.fault is not None:
self.fault = None
def _convert_deploy_step_field(self, target_version,
remove_unavailable_fields=True):
# NOTE(rloo): Typically we set the value to None. However,
# deploy_step is a FlexibleDictField. Setting it to None
# causes it to be set to {} under-the-hood. So I am being
# explicit about that here.
step_is_set = self.obj_attr_is_set('deploy_step')
if target_version >= (1, 26):
if not step_is_set:
self.deploy_step = {}
elif step_is_set:
if remove_unavailable_fields:
delattr(self, 'deploy_step')
elif self.deploy_step:
self.deploy_step = {}
def _convert_to_version(self, target_version,
remove_unavailable_fields=True):
"""Convert to the target version.
@ -496,6 +518,8 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
removed).
Version 1.25: fault field was added. For versions prior to
this, it should be removed.
Version 1.26: deploy_step field was added. For versions prior to
this, it should be removed.
:param target_version: the desired version of the object
:param remove_unavailable_fields: True to remove fields that are
@ -547,6 +571,8 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
self.bios_interface = None
self._convert_fault_field(target_version, remove_unavailable_fields)
self._convert_deploy_step_field(target_version,
remove_unavailable_fields)
@base.IronicObjectRegistry.register

View File

@ -664,7 +664,7 @@ class TestObject(_LocalTest, _TestObject):
# version bump. It is an MD5 hash of the object fields and remotable methods.
# The fingerprint values should only be changed if there is a version bump.
expected_object_fingerprints = {
'Node': '1.25-3a468b3e88d0a8fe7709f822fc654e4b',
'Node': '1.26-31732244b5bc3f8c334f77c03449f4c6',
'MyObj': '1.5-9459d30d6954bffc7a9afd347a807ca6',
'Chassis': '1.3-d656e039fd8ae9f34efc232ab3980905',
'Port': '1.8-898a47921f4a1f53fcdddd4eeb179e0b',