Update the data module of operation_log
Change-Id: I53375c67681f84c406e9da2c7d078628e1b4dce1 blueprint: operation-log-api
This commit is contained in:
parent
f5fbceced8
commit
498a127c4e
@ -93,12 +93,17 @@ def define_tables(meta):
|
|||||||
Column('deleted', Boolean, nullable=False),
|
Column('deleted', Boolean, nullable=False),
|
||||||
Column('id', String(length=36), primary_key=True, nullable=False),
|
Column('id', String(length=36), primary_key=True, nullable=False),
|
||||||
Column('project_id', String(length=255), nullable=False),
|
Column('project_id', String(length=255), nullable=False),
|
||||||
|
Column('operation_type', String(length=255), nullable=False),
|
||||||
|
Column('checkpoint_id', String(length=36)),
|
||||||
|
Column('plan_id', String(length=36)),
|
||||||
|
Column('provider_id', String(length=36)),
|
||||||
|
Column('restore_id', String(length=36)),
|
||||||
Column('scheduled_operation_id', String(length=36)),
|
Column('scheduled_operation_id', String(length=36)),
|
||||||
|
Column('status', String(length=64)),
|
||||||
Column('started_at', DateTime),
|
Column('started_at', DateTime),
|
||||||
Column('ended_at', DateTime),
|
Column('ended_at', DateTime),
|
||||||
Column('state', String(length=64)),
|
Column('error_info', Text),
|
||||||
Column('error', String(length=255)),
|
Column('extra_info', Text),
|
||||||
Column('entries', Text),
|
|
||||||
mysql_engine='InnoDB'
|
mysql_engine='InnoDB'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -194,12 +194,17 @@ class OperationLog(BASE, KarborBase):
|
|||||||
__tablename__ = 'operation_logs'
|
__tablename__ = 'operation_logs'
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
project_id = Column(String(255))
|
project_id = Column(String(255))
|
||||||
|
operation_type = Column(String(255))
|
||||||
|
checkpoint_id = Column(String(36))
|
||||||
|
plan_id = Column(String(36))
|
||||||
|
provider_id = Column(String(36))
|
||||||
|
restore_id = Column(String(36))
|
||||||
scheduled_operation_id = Column(String(36))
|
scheduled_operation_id = Column(String(36))
|
||||||
|
status = Column(String(64))
|
||||||
started_at = Column(DateTime)
|
started_at = Column(DateTime)
|
||||||
ended_at = Column(DateTime)
|
ended_at = Column(DateTime)
|
||||||
state = Column(String(64))
|
error_info = Column(Text)
|
||||||
error = Column(String(64))
|
extra_info = Column(Text)
|
||||||
entries = Column(Text)
|
|
||||||
|
|
||||||
|
|
||||||
class CheckpointRecord(BASE, KarborBase):
|
class CheckpointRecord(BASE, KarborBase):
|
||||||
|
@ -29,12 +29,17 @@ class OperationLog(base.KarborPersistentObject, base.KarborObject,
|
|||||||
fields = {
|
fields = {
|
||||||
'id': fields.UUIDField(),
|
'id': fields.UUIDField(),
|
||||||
'project_id': fields.UUIDField(),
|
'project_id': fields.UUIDField(),
|
||||||
'scheduled_operation_id': fields.UUIDField(),
|
'operation_type': fields.UUIDField(),
|
||||||
'started_at': base.DateTimeField(nullable=True),
|
'checkpoint_id': fields.UUIDField(nullable=True),
|
||||||
'ended_at': base.DateTimeField(nullable=True),
|
'plan_id': fields.UUIDField(nullable=True),
|
||||||
'state': fields.StringField(nullable=True),
|
'provider_id': fields.UUIDField(nullable=True),
|
||||||
'error': fields.StringField(nullable=True),
|
'restore_id': fields.UUIDField(nullable=True),
|
||||||
'entries': fields.StringField(nullable=True),
|
'scheduled_operation_id': fields.UUIDField(nullable=True),
|
||||||
|
'status': fields.StringField(nullable=True),
|
||||||
|
'started_at': fields.DateTimeField(nullable=True),
|
||||||
|
'ended_at': fields.DateTimeField(nullable=True),
|
||||||
|
'error_info': fields.StringField(nullable=True),
|
||||||
|
'extra_info': fields.StringField(nullable=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -547,10 +547,14 @@ class OperationLogTestCase(ModelBaseTestCase):
|
|||||||
fake_operation_log = {
|
fake_operation_log = {
|
||||||
"id": "36ea41b2-c358-48a7-9117-70cb7617410a",
|
"id": "36ea41b2-c358-48a7-9117-70cb7617410a",
|
||||||
"project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
|
"project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
|
||||||
|
"operation_type": "protect",
|
||||||
|
"checkpoint_id": "dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
|
||||||
|
"plan_id": "cf56bd3e-97a7-4078-b6d5-f36246333fd9",
|
||||||
|
"provider_id": "23902b02-5666-4ee6-8dfe-962ac09c3994",
|
||||||
"scheduled_operation_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
|
"scheduled_operation_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
|
||||||
"state": "failed",
|
"status": "failed",
|
||||||
"error": "Could not access bank",
|
"error_info": "Could not access bank",
|
||||||
"entries": "[entries:{'timestamp': '2015-08-27T09:50:51-05:00',"
|
"extra_info": "[entries:{'timestamp': '2015-08-27T09:50:51-05:00',"
|
||||||
"'message': 'Doing things'}]"
|
"'message': 'Doing things'}]"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,7 +566,7 @@ class OperationLogTestCase(ModelBaseTestCase):
|
|||||||
operation_log = db.operation_log_create(self.ctxt,
|
operation_log = db.operation_log_create(self.ctxt,
|
||||||
self.fake_operation_log)
|
self.fake_operation_log)
|
||||||
self.assertTrue(uuidutils.is_uuid_like(operation_log['id']))
|
self.assertTrue(uuidutils.is_uuid_like(operation_log['id']))
|
||||||
self.assertEqual('failed', operation_log.state)
|
self.assertEqual('failed', operation_log.status)
|
||||||
|
|
||||||
def test_operation_log_get(self):
|
def test_operation_log_get(self):
|
||||||
operation_log = db.operation_log_create(self.ctxt,
|
operation_log = db.operation_log_create(self.ctxt,
|
||||||
@ -581,9 +585,9 @@ class OperationLogTestCase(ModelBaseTestCase):
|
|||||||
operation_log = db.operation_log_create(self.ctxt,
|
operation_log = db.operation_log_create(self.ctxt,
|
||||||
self.fake_operation_log)
|
self.fake_operation_log)
|
||||||
db.operation_log_update(self.ctxt, operation_log['id'],
|
db.operation_log_update(self.ctxt, operation_log['id'],
|
||||||
{'state': 'finished'})
|
{'status': 'finished'})
|
||||||
operation_log = db.operation_log_get(self.ctxt, operation_log['id'])
|
operation_log = db.operation_log_get(self.ctxt, operation_log['id'])
|
||||||
self.assertEqual('finished', operation_log['state'])
|
self.assertEqual('finished', operation_log['status'])
|
||||||
|
|
||||||
def test_operation_log_update_nonexistent(self):
|
def test_operation_log_update_nonexistent(self):
|
||||||
self.assertRaises(exception.OperationLogNotFound,
|
self.assertRaises(exception.OperationLogNotFound,
|
||||||
|
@ -19,10 +19,14 @@ def fake_db_operation_log(**updates):
|
|||||||
db_operation_log = {
|
db_operation_log = {
|
||||||
"id": "36ea41b2-c358-48a7-9117-70cb7617410a",
|
"id": "36ea41b2-c358-48a7-9117-70cb7617410a",
|
||||||
"project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
|
"project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
|
||||||
|
"operation_type": "protect",
|
||||||
|
"checkpoint_id": "dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
|
||||||
|
"plan_id": "cf56bd3e-97a7-4078-b6d5-f36246333fd9",
|
||||||
|
"provider_id": "23902b02-5666-4ee6-8dfe-962ac09c3994",
|
||||||
"scheduled_operation_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
|
"scheduled_operation_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
|
||||||
"state": "failed",
|
"status": "failed",
|
||||||
"error": "Could not access bank",
|
"error_info": "Could not access bank",
|
||||||
"entries": "[entries:{'timestamp': '2015-08-27T09:50:51-05:00',"
|
"extra_info": "[entries:{'timestamp': '2015-08-27T09:50:51-05:00',"
|
||||||
"'message': 'Doing things'}]"
|
"'message': 'Doing things'}]"
|
||||||
}
|
}
|
||||||
for name, field in objects.OperationLog.fields.items():
|
for name, field in objects.OperationLog.fields.items():
|
||||||
|
@ -46,10 +46,10 @@ class TestOperationLog(test_objects.BaseObjectsTestCase):
|
|||||||
db_operation_log = fake_operation_log.fake_db_operation_log()
|
db_operation_log = fake_operation_log.fake_db_operation_log()
|
||||||
operation_log = objects.OperationLog._from_db_object(
|
operation_log = objects.OperationLog._from_db_object(
|
||||||
self.context, objects.OperationLog(), db_operation_log)
|
self.context, objects.OperationLog(), db_operation_log)
|
||||||
operation_log.state = 'finished'
|
operation_log.status = 'finished'
|
||||||
operation_log.save()
|
operation_log.save()
|
||||||
operation_log_update.assert_called_once_with(
|
operation_log_update.assert_called_once_with(
|
||||||
self.context, operation_log.id, {'state': 'finished'})
|
self.context, operation_log.id, {'status': 'finished'})
|
||||||
|
|
||||||
@mock.patch('karbor.db.sqlalchemy.api.operation_log_destroy')
|
@mock.patch('karbor.db.sqlalchemy.api.operation_log_destroy')
|
||||||
def test_destroy(self, operation_log_destroy):
|
def test_destroy(self, operation_log_destroy):
|
||||||
@ -63,5 +63,5 @@ class TestOperationLog(test_objects.BaseObjectsTestCase):
|
|||||||
|
|
||||||
def test_obj_field_status(self):
|
def test_obj_field_status(self):
|
||||||
operation_log = objects.OperationLog(context=self.context,
|
operation_log = objects.OperationLog(context=self.context,
|
||||||
state='finished')
|
status='finished')
|
||||||
self.assertEqual('finished', operation_log.state)
|
self.assertEqual('finished', operation_log.status)
|
||||||
|
Loading…
Reference in New Issue
Block a user