Exemplo n.º 1
0
def record(plugin_context,
           object_type,
           object_uuid,
           operation,
           data,
           ml2_context=None):
    if (object_type == odl_const.ODL_PORT
            and operation in (odl_const.ODL_CREATE, odl_const.ODL_UPDATE)):
        data = _enrich_port(plugin_context, ml2_context, object_type,
                            operation, data)

    # Calculate depending_on on other journal entries
    depending_on = dependency_validations.calculate(plugin_context.session,
                                                    operation, object_type,
                                                    object_uuid, data)

    # NOTE(mpeterson): Between the moment that a dependency is calculated and
    # the new entry is recorded in the journal, an operation can ocurr that
    # would make the dependency irrelevant. In that case we request a retry.
    # For more details, read the commit message that introduced this comment.
    try:
        db.create_pending_row(plugin_context.session,
                              object_type,
                              object_uuid,
                              operation,
                              data,
                              depending_on=depending_on)
    except exception.DBReferenceError as e:
        raise exception.RetryRequest(e)
Exemplo n.º 2
0
def record(plugin_context, object_type, object_uuid, operation, data,
           ml2_context=None):
    if (object_type == odl_const.ODL_PORT and
            operation in (odl_const.ODL_CREATE, odl_const.ODL_UPDATE)):
        data = _enrich_port(
            plugin_context, ml2_context, object_type, operation, data)

    # Calculate depending_on on other journal entries
    depending_on = dependency_validations.calculate(
        plugin_context, operation, object_type, object_uuid, data)

    # NOTE(mpeterson): Between the moment that a dependency is calculated and
    # the new entry is recorded in the journal, an operation can ocurr that
    # would make the dependency irrelevant. In that case we request a retry.
    # For more details, read the commit message that introduced this comment.
    try:
        entry = db.create_pending_row(
            plugin_context, object_type, object_uuid, operation, data,
            depending_on=depending_on)
    except exception.DBReferenceError as e:
        raise exception.RetryRequest(e)

    _log_entry(LOG_RECORDED, entry)
    LOG.debug('Entry with ID %(entry_id)s depends on these entries: '
              '%(depending_on)s',
              {'entry_id': entry.seqnum,
               'depending_on': [d.seqnum for d in depending_on]})
Exemplo n.º 3
0
 def test_dependency(self):
     db.create_pending_row(self.db_context, self.first_type, self.first_id,
                           self.first_operation,
                           get_data(self.first_type, self.first_operation))
     for data in get_data(self.second_type, self.second_operation):
         deps = dependency_validations.calculate(self.db_context,
                                                 self.second_operation,
                                                 self.second_type,
                                                 self.second_id, data)
         self.assertEqual(self.expected, len(deps))
 def test_dependency(self):
     db.create_pending_row(
         self.db_context, self.first_type, self.first_id,
         self.first_operation,
         get_data(self.first_type, self.first_operation))
     for data in get_data(self.second_type, self.second_operation):
         deps = dependency_validations.calculate(
             self.db_context, self.second_operation, self.second_type,
             self.second_id, data)
         self.assertEqual(self.expected, len(deps))
Exemplo n.º 5
0
def record(plugin_context,
           object_type,
           object_uuid,
           operation,
           data,
           ml2_context=None):
    if (object_type == odl_const.ODL_PORT
            and operation in (odl_const.ODL_CREATE, odl_const.ODL_UPDATE)):
        data = _enrich_port(plugin_context, ml2_context, object_type,
                            operation, data)

    # Calculate depending_on on other journal entries
    depending_on = dependency_validations.calculate(plugin_context.session,
                                                    operation, object_type,
                                                    object_uuid, data)
    db.create_pending_row(plugin_context.session,
                          object_type,
                          object_uuid,
                          operation,
                          data,
                          depending_on=depending_on)
Exemplo n.º 6
0
def record(plugin_context,
           object_type,
           object_uuid,
           operation,
           data,
           ml2_context=None):
    if (object_type == odl_const.ODL_PORT
            and operation in (odl_const.ODL_CREATE, odl_const.ODL_UPDATE)):
        data = _enrich_port(plugin_context, ml2_context, object_type,
                            operation, data)

    # Calculate depending_on on other journal entries
    depending_on = dependency_validations.calculate(plugin_context, operation,
                                                    object_type, object_uuid,
                                                    data)

    # NOTE(mpeterson): Between the moment that a dependency is calculated and
    # the new entry is recorded in the journal, an operation can ocurr that
    # would make the dependency irrelevant. In that case we request a retry.
    # For more details, read the commit message that introduced this comment.
    try:
        entry = db.create_pending_row(plugin_context,
                                      object_type,
                                      object_uuid,
                                      operation,
                                      data,
                                      depending_on=depending_on)
    except exception.DBReferenceError as e:
        raise exception.RetryRequest(e)

    _log_entry(LOG_RECORDED, entry)
    LOG.debug(
        'Entry with ID %(entry_id)s depends on these entries: '
        '%(depending_on)s', {
            'entry_id': entry.seqnum,
            'depending_on': [d.seqnum for d in depending_on]
        })