Пример #1
0
def _handle_existing_resource(context, row):
    if row.operation == odl_const.ODL_CREATE:
        journal.entry_complete(context, row)
    elif row.operation == odl_const.ODL_DELETE:
        db.update_db_row_state(context, row, odl_const.PENDING)
    else:
        _sync_resource_to_odl(context, row, odl_const.ODL_UPDATE, True)
Пример #2
0
def _handle_existing_resource(context, row):
    if row.operation == odl_const.ODL_CREATE:
        journal.entry_complete(context, row)
    elif row.operation == odl_const.ODL_DELETE:
        db.update_db_row_state(context.session, row, odl_const.PENDING)
    else:
        _sync_resource_to_odl(context, row, odl_const.ODL_UPDATE, True)
Пример #3
0
 def _test_entry_complete(self, retention, expected_length):
     self.cfg.config(completed_rows_retention=retention, group='ml2_odl')
     db.create_pending_row(self.db_session, *test_db.DbTestCase.UPDATE_ROW)
     entry = db.get_all_db_rows(self.db_session)[-1]
     journal.entry_complete(self.db_context, entry)
     rows = db.get_all_db_rows(self.db_session)
     self.assertEqual(expected_length, len(rows))
     self.assertTrue(all(row.state == odl_const.COMPLETED for row in rows))
Пример #4
0
 def _test_entry_complete(self, retention, expected_length):
     self.cfg.config(completed_rows_retention=retention, group='ml2_odl')
     db.create_pending_row(self.db_context, *test_db.DbTestCase.UPDATE_ROW)
     entry = db.get_all_db_rows(self.db_context)[-1]
     journal.entry_complete(self.db_context, entry)
     rows = db.get_all_db_rows(self.db_context)
     self.assertEqual(expected_length, len(rows))
     self.assertTrue(
         all(row.state == odl_const.COMPLETED for row in rows))
 def test_entry_complete_with_retention_deletes_dependencies(self):
     self.cfg.config(completed_rows_retention=1, group='ml2_odl')
     db.create_pending_row(self.db_context, *test_db.DbTestCase.UPDATE_ROW)
     entry = db.get_all_db_rows(self.db_context)[-1]
     db.create_pending_row(self.db_context, *test_db.DbTestCase.UPDATE_ROW,
                           depending_on=[entry])
     dependant = db.get_all_db_rows(self.db_context)[-1]
     journal.entry_complete(self.db_context, entry)
     rows = db.get_all_db_rows(self.db_context)
     self.assertIn(entry, rows)
     self.assertEqual([], entry.dependencies)
     self.assertEqual([], dependant.depending_on)
Пример #6
0
def _sync_resource_to_odl(context, row, operation_type, exists_on_odl):
    resource = None
    try:
        resource = _get_latest_resource(context, row)
    except nexc.NotFound:
        if exists_on_odl:
            journal.record(context, row.object_type,
                           row.object_uuid, odl_const.ODL_DELETE, [])
    else:
        journal.record(context, row.object_type, row.object_uuid,
                       operation_type, resource)

    journal.entry_complete(context, row)
Пример #7
0
def _sync_resource_to_odl(context, row, operation_type, exists_on_odl):
    resource = None
    try:
        resource = _get_latest_resource(context, row)
    except nexc.NotFound:
        if exists_on_odl:
            journal.record(context, row.object_type, row.object_uuid,
                           odl_const.ODL_DELETE, [])
    else:
        journal.record(context, row.object_type, row.object_uuid,
                       operation_type, resource)

    journal.entry_complete(context, row)
Пример #8
0
def _handle_non_existing_resource(context, row):
    if row.operation == odl_const.ODL_DELETE:
        journal.entry_complete(context, row)
    else:
        _sync_resource_to_odl(context, row, odl_const.ODL_CREATE, False)
Пример #9
0
def _handle_non_existing_resource(context, row):
    if row.operation == odl_const.ODL_DELETE:
        journal.entry_complete(context, row)
    else:
        _sync_resource_to_odl(context, row, odl_const.ODL_CREATE, False)