Merge "[OVN] Pass context while removing objects in OVN client"
This commit is contained in:
commit
1c792633ec
|
@ -267,7 +267,8 @@ class OVNMechanismDriver(api.MechanismDriver):
|
||||||
|
|
||||||
def _delete_security_group(self, resource, event, trigger,
|
def _delete_security_group(self, resource, event, trigger,
|
||||||
security_group_id, **kwargs):
|
security_group_id, **kwargs):
|
||||||
self._ovn_client.delete_security_group(security_group_id)
|
self._ovn_client.delete_security_group(kwargs['context'],
|
||||||
|
security_group_id)
|
||||||
|
|
||||||
def _update_security_group(self, resource, event, trigger,
|
def _update_security_group(self, resource, event, trigger,
|
||||||
security_group, **kwargs):
|
security_group, **kwargs):
|
||||||
|
@ -289,10 +290,11 @@ class OVNMechanismDriver(api.MechanismDriver):
|
||||||
self._ovn_client.create_security_group_rule(
|
self._ovn_client.create_security_group_rule(
|
||||||
kwargs.get('security_group_rule'))
|
kwargs.get('security_group_rule'))
|
||||||
elif event == events.BEFORE_DELETE:
|
elif event == events.BEFORE_DELETE:
|
||||||
admin_context = n_context.get_admin_context()
|
|
||||||
sg_rule = self._plugin.get_security_group_rule(
|
sg_rule = self._plugin.get_security_group_rule(
|
||||||
admin_context, kwargs.get('security_group_rule_id'))
|
kwargs['context'], kwargs.get('security_group_rule_id'))
|
||||||
self._ovn_client.delete_security_group_rule(sg_rule)
|
self._ovn_client.delete_security_group_rule(
|
||||||
|
kwargs['context'],
|
||||||
|
sg_rule)
|
||||||
|
|
||||||
def _is_network_type_supported(self, network_type):
|
def _is_network_type_supported(self, network_type):
|
||||||
return (network_type in [const.TYPE_LOCAL,
|
return (network_type in [const.TYPE_LOCAL,
|
||||||
|
@ -398,7 +400,9 @@ class OVNMechanismDriver(api.MechanismDriver):
|
||||||
expected, and will not prevent the resource from being
|
expected, and will not prevent the resource from being
|
||||||
deleted.
|
deleted.
|
||||||
"""
|
"""
|
||||||
self._ovn_client.delete_network(context.current['id'])
|
self._ovn_client.delete_network(
|
||||||
|
context._plugin_context,
|
||||||
|
context.current['id'])
|
||||||
|
|
||||||
def create_subnet_precommit(self, context):
|
def create_subnet_precommit(self, context):
|
||||||
ovn_revision_numbers_db.create_initial_revision(
|
ovn_revision_numbers_db.create_initial_revision(
|
||||||
|
|
|
@ -189,7 +189,7 @@ class DBInconsistenciesPeriodics(object):
|
||||||
revision_numbers_db.delete_revision(
|
revision_numbers_db.delete_revision(
|
||||||
context, row.resource_uuid, row.resource_type)
|
context, row.resource_uuid, row.resource_type)
|
||||||
else:
|
else:
|
||||||
res_map['ovn_delete'](row.resource_uuid)
|
res_map['ovn_delete'](context, row.resource_uuid)
|
||||||
|
|
||||||
def _fix_create_update_subnet(self, context, row):
|
def _fix_create_update_subnet(self, context, row):
|
||||||
# Get the lasted version of the port in Neutron DB
|
# Get the lasted version of the port in Neutron DB
|
||||||
|
|
|
@ -1609,8 +1609,7 @@ class OVNClient(object):
|
||||||
self.create_metadata_port(admin_context, network)
|
self.create_metadata_port(admin_context, network)
|
||||||
return network
|
return network
|
||||||
|
|
||||||
def delete_network(self, network_id):
|
def delete_network(self, context, network_id):
|
||||||
admin_context = n_context.get_admin_context()
|
|
||||||
with self._nb_idl.transaction(check_error=True) as txn:
|
with self._nb_idl.transaction(check_error=True) as txn:
|
||||||
ls, ls_dns_record = self._nb_idl.get_ls_and_dns_record(
|
ls, ls_dns_record = self._nb_idl.get_ls_and_dns_record(
|
||||||
utils.ovn_name(network_id))
|
utils.ovn_name(network_id))
|
||||||
|
@ -1620,7 +1619,7 @@ class OVNClient(object):
|
||||||
if ls_dns_record:
|
if ls_dns_record:
|
||||||
txn.add(self._nb_idl.dns_del(ls_dns_record.uuid))
|
txn.add(self._nb_idl.dns_del(ls_dns_record.uuid))
|
||||||
db_rev.delete_revision(
|
db_rev.delete_revision(
|
||||||
admin_context, network_id, ovn_const.TYPE_NETWORKS)
|
context, network_id, ovn_const.TYPE_NETWORKS)
|
||||||
|
|
||||||
def _is_qos_update_required(self, network):
|
def _is_qos_update_required(self, network):
|
||||||
# Is qos service enabled
|
# Is qos service enabled
|
||||||
|
@ -2045,8 +2044,7 @@ class OVNClient(object):
|
||||||
if self._nb_idl.get_port_group(pg_name):
|
if self._nb_idl.get_port_group(pg_name):
|
||||||
txn.add(self._nb_idl.pg_del_ports(pg_name, port))
|
txn.add(self._nb_idl.pg_del_ports(pg_name, port))
|
||||||
|
|
||||||
def delete_security_group(self, security_group_id):
|
def delete_security_group(self, context, security_group_id):
|
||||||
admin_context = n_context.get_admin_context()
|
|
||||||
with self._nb_idl.transaction(check_error=True) as txn:
|
with self._nb_idl.transaction(check_error=True) as txn:
|
||||||
if self._nb_idl.is_port_groups_supported():
|
if self._nb_idl.is_port_groups_supported():
|
||||||
name = utils.ovn_port_group_name(security_group_id)
|
name = utils.ovn_port_group_name(security_group_id)
|
||||||
|
@ -2056,7 +2054,7 @@ class OVNClient(object):
|
||||||
name = utils.ovn_addrset_name(security_group_id,
|
name = utils.ovn_addrset_name(security_group_id,
|
||||||
ip_version)
|
ip_version)
|
||||||
txn.add(self._nb_idl.delete_address_set(name=name))
|
txn.add(self._nb_idl.delete_address_set(name=name))
|
||||||
db_rev.delete_revision(admin_context, security_group_id,
|
db_rev.delete_revision(context, security_group_id,
|
||||||
ovn_const.TYPE_SECURITY_GROUPS)
|
ovn_const.TYPE_SECURITY_GROUPS)
|
||||||
|
|
||||||
def _process_security_group_rule(self, rule, is_add_acl=True):
|
def _process_security_group_rule(self, rule, is_add_acl=True):
|
||||||
|
@ -2071,11 +2069,10 @@ class OVNClient(object):
|
||||||
db_rev.bump_revision(
|
db_rev.bump_revision(
|
||||||
admin_context, rule, ovn_const.TYPE_SECURITY_GROUP_RULES)
|
admin_context, rule, ovn_const.TYPE_SECURITY_GROUP_RULES)
|
||||||
|
|
||||||
def delete_security_group_rule(self, rule):
|
def delete_security_group_rule(self, context, rule):
|
||||||
admin_context = n_context.get_admin_context()
|
|
||||||
self._process_security_group_rule(rule, is_add_acl=False)
|
self._process_security_group_rule(rule, is_add_acl=False)
|
||||||
db_rev.delete_revision(
|
db_rev.delete_revision(
|
||||||
admin_context, rule['id'], ovn_const.TYPE_SECURITY_GROUP_RULES)
|
context, rule['id'], ovn_const.TYPE_SECURITY_GROUP_RULES)
|
||||||
|
|
||||||
def _find_metadata_port(self, context, network_id):
|
def _find_metadata_port(self, context, network_id):
|
||||||
if not ovn_conf.is_ovn_metadata_enabled():
|
if not ovn_conf.is_ovn_metadata_enabled():
|
||||||
|
|
|
@ -127,7 +127,7 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
|
||||||
def test__delete_security_group(self):
|
def test__delete_security_group(self):
|
||||||
self.mech_driver._delete_security_group(
|
self.mech_driver._delete_security_group(
|
||||||
resources.SECURITY_GROUP, events.AFTER_CREATE, {},
|
resources.SECURITY_GROUP, events.AFTER_CREATE, {},
|
||||||
security_group_id=self.fake_sg['id'])
|
security_group_id=self.fake_sg['id'], context=self.context)
|
||||||
ip4_name = ovn_utils.ovn_addrset_name(self.fake_sg['id'], 'ip4')
|
ip4_name = ovn_utils.ovn_addrset_name(self.fake_sg['id'], 'ip4')
|
||||||
ip6_name = ovn_utils.ovn_addrset_name(self.fake_sg['id'], 'ip6')
|
ip6_name = ovn_utils.ovn_addrset_name(self.fake_sg['id'], 'ip6')
|
||||||
delete_address_set_calls = [mock.call(name=name)
|
delete_address_set_calls = [mock.call(name=name)
|
||||||
|
@ -160,7 +160,7 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
|
||||||
return_value=rule):
|
return_value=rule):
|
||||||
self.mech_driver._process_sg_rule_notification(
|
self.mech_driver._process_sg_rule_notification(
|
||||||
resources.SECURITY_GROUP_RULE, events.BEFORE_DELETE, {},
|
resources.SECURITY_GROUP_RULE, events.BEFORE_DELETE, {},
|
||||||
security_group_rule=rule)
|
security_group_rule=rule, context=self.context)
|
||||||
ovn_acl_up.assert_called_once_with(
|
ovn_acl_up.assert_called_once_with(
|
||||||
mock.ANY, mock.ANY, mock.ANY,
|
mock.ANY, mock.ANY, mock.ANY,
|
||||||
'sg_id', rule, is_add_acl=False)
|
'sg_id', rule, is_add_acl=False)
|
||||||
|
|
Loading…
Reference in New Issue