Re-define 'extra' as dict_or_none.
Changed type of 'extra' fields from str_or_none to dict_or_none for Port and Chassis. DB model defines 'extra' as a JSONEncodedDict which is a type decorator that stores a value as a json string to the database and parses it to a dict when loading the object. That's why we need to change the type of the 'extra' field from str_or_none to dict_or_none. Test utils have been modified to simulate behavior of DB layer better. Fixes: bug #1194072 Change-Id: I2c73069f795754078ce8cba50ee669cce2f4b27d
This commit is contained in:
parent
f54cd17c7e
commit
1541b40456
@ -25,7 +25,7 @@ class Chassis(base.IronicObject):
|
||||
fields = {
|
||||
'id': int,
|
||||
'uuid': utils.str_or_none,
|
||||
'extra': utils.str_or_none,
|
||||
'extra': utils.dict_or_none,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@ -27,7 +27,7 @@ class Port(base.IronicObject):
|
||||
'uuid': utils.str_or_none,
|
||||
'node_id': utils.int_or_none,
|
||||
'address': utils.str_or_none,
|
||||
'extra': utils.str_or_none,
|
||||
'extra': utils.dict_or_none,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@ -79,7 +79,7 @@ def get_test_node(**kw):
|
||||
'driver_info': kw.get('driver_info', fake_info),
|
||||
'properties': kw.get('properties', properties),
|
||||
'reservation': None,
|
||||
'extra': kw.get('extra', '{}'),
|
||||
'extra': kw.get('extra', {}),
|
||||
'updated_at': None,
|
||||
'created_at': None,
|
||||
}
|
||||
@ -92,7 +92,7 @@ def get_test_port(**kw):
|
||||
'uuid': kw.get('uuid', '1be26c0b-03f2-4d2e-ae87-c02d7f33c781'),
|
||||
'node_id': kw.get('node_id', 123),
|
||||
'address': kw.get('address', '52:54:00:cf:2d:31'),
|
||||
'extra': kw.get('extra', '{}'),
|
||||
'extra': kw.get('extra', {}),
|
||||
'created_at': kw.get('created_at'),
|
||||
'updated_at': kw.get('updated_at'),
|
||||
}
|
||||
@ -104,7 +104,7 @@ def get_test_chassis(**kw):
|
||||
chassis = {
|
||||
'id': kw.get('id', 42),
|
||||
'uuid': kw.get('uuid', 'e74c40e0-d825-11e2-a28f-0800200c9a66'),
|
||||
'extra': kw.get('extra', '{}'),
|
||||
'extra': kw.get('extra', {}),
|
||||
'created_at': kw.get('created_at'),
|
||||
'updated_at': kw.get('updated_at'),
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ class TestChassisObject(base.DbTestCase):
|
||||
self.mox.StubOutWithMock(self.dbapi, 'update_chassis')
|
||||
self.dbapi.get_chassis(uuid).AndReturn(self.fake_chassis)
|
||||
|
||||
self.dbapi.update_chassis(uuid, {'extra': '{"test": 123}'})
|
||||
self.dbapi.update_chassis(uuid, {'extra': {"test": 123}})
|
||||
self.mox.ReplayAll()
|
||||
|
||||
c = objects.Chassis.get_by_uuid(self.ctxt, uuid)
|
||||
c.extra = '{"test": 123}'
|
||||
c.extra = {"test": 123}
|
||||
c.save()
|
||||
self.mox.VerifyAll()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user