コード例 #1
0
 def test_bump_revision_row_not_found(self, mock_log):
     self.net['revision_number'] = 123
     ovn_rn_db.bump_revision(self.ctx, self.net, ovn_rn_db.TYPE_NETWORKS)
     # Assert the revision number wasn't bumped
     row = ovn_rn_db.get_revision_row(self.ctx, self.net['id'])
     self.assertEqual(123, row.revision_number)
     self.assertIn('No revision row found for', mock_log.call_args[0][0])
コード例 #2
0
 def test_bump_revision(self):
     self._create_initial_revision(self.net['id'], ovn_rn_db.TYPE_NETWORKS)
     self.net['revision_number'] = 123
     ovn_rn_db.bump_revision(self.ctx, self.net,
                             ovn_rn_db.TYPE_NETWORKS)
     row = ovn_rn_db.get_revision_row(self.ctx, self.net['id'])
     self.assertEqual(123, row.revision_number)
コード例 #3
0
    def _fix_create_update(self, context, row):
        res_map = self._resources_func_map[row.resource_type]
        try:
            # Get the latest version of the resource in Neutron DB
            n_obj = res_map['neutron_get'](context, row.resource_uuid)
        except n_exc.NotFound:
            LOG.warning(
                'Skip fixing resource %(res_uuid)s (type: '
                '%(res_type)s). Resource does not exist in Neutron '
                'database anymore', {
                    'res_uuid': row.resource_uuid,
                    'res_type': row.resource_type
                })
            return

        ovn_obj = res_map['ovn_get'](row.resource_uuid)

        if not ovn_obj:
            res_map['ovn_create'](context, n_obj)
        else:
            if row.resource_type == ovn_const.TYPE_SECURITY_GROUP_RULES:
                LOG.error(
                    "SG rule %s found with a revision number while "
                    "this resource doesn't support updates", row.resource_uuid)
            elif row.resource_type == ovn_const.TYPE_SECURITY_GROUPS:
                # In OVN, we don't care about updates to security groups,
                # so just bump the revision number to whatever it's
                # supposed to be.
                revision_numbers_db.bump_revision(context, n_obj,
                                                  row.resource_type)
            else:
                ext_ids = getattr(ovn_obj, 'external_ids', {})
                ovn_revision = int(
                    ext_ids.get(ovn_const.OVN_REV_NUM_EXT_ID_KEY, -1))
                # If the resource exist in the OVN DB but the revision
                # number is different from Neutron DB, updated it.
                if ovn_revision != n_obj['revision_number']:
                    res_map['ovn_update'](context, n_obj)
                else:
                    # If the resource exist and the revision number
                    # is equal on both databases just bump the revision on
                    # the cache table.
                    revision_numbers_db.bump_revision(context, n_obj,
                                                      row.resource_type)
コード例 #4
0
ファイル: driver.py プロジェクト: tankertyp/openstack-neutron
 def _do_db_rev_bump_revision(self, context, check_rev_tuples):
     if not all(check_rev_cmd.result == ovn_const.TXN_COMMITTED
                for check_rev_cmd, _fip_obj in check_rev_tuples):
         return
     for _check_rev_cmd, fip_obj in check_rev_tuples:
         db_rev.bump_revision(context, fip_obj, ovn_const.TYPE_FLOATINGIPS)