Fix missing to convert the format of ScheduledOperation

Change-Id: I5d11f1bb37c330b73ea7e209701afefc87ee0042
This commit is contained in:
zengchen 2016-09-14 11:00:22 +08:00
parent 6b5f89a7c3
commit a2e6d273b9
2 changed files with 7 additions and 3 deletions

View File

@ -104,6 +104,7 @@ class ScheduledOperation(base.KarborPersistentObject, base.KarborObject,
def save(self): def save(self):
updates = self.karbor_obj_get_changes() updates = self.karbor_obj_get_changes()
if updates and self.id: if updates and self.id:
self._convert_operation_definition_to_db_format(updates)
db.scheduled_operation_update(self._context, db.scheduled_operation_update(self._context,
self.id, self.id,
updates) updates)

View File

@ -93,12 +93,15 @@ class TestScheduledOperation(test_objects.BaseObjectsTestCase):
op = self.Operation_Class._from_db_object(self.context, op = self.Operation_Class._from_db_object(self.context,
self.Operation_Class(), self.Operation_Class(),
db_op) db_op)
fake_op_def = {'a': '1'}
op.name = 'protect volume' op.name = 'protect volume'
op.operation_definition = fake_op_def
op.save() op.save()
operation_update.assert_called_once_with(self.context, operation_update.assert_called_once_with(
op.id, self.context, op.id,
{'name': 'protect volume'}) {'name': 'protect volume',
'operation_definition': jsonutils.dumps(fake_op_def)})
@mock.patch('karbor.db.scheduled_operation_delete') @mock.patch('karbor.db.scheduled_operation_delete')
def test_destroy(self, operation_delete): def test_destroy(self, operation_delete):