Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Cloud:OpenStack:Newton:Staging
openstack-neutron
0001-Bulk-up-port-status-updating-in-ML2-RPC.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Bulk-up-port-status-updating-in-ML2-RPC.patch of Package openstack-neutron
diff -crB --new-file neutron-9.4.2.dev21-backup/neutron/plugins/ml2/plugin.py neutron-9.4.2.dev21/neutron/plugins/ml2/plugin.py *** neutron-9.4.2.dev21-backup/neutron/plugins/ml2/plugin.py 2019-03-25 15:02:16.544948204 -0700 --- neutron-9.4.2.dev21/neutron/plugins/ml2/plugin.py 2019-03-25 22:34:44.967695053 -0700 *************** *** 1662,1685 **** return {d: self._bind_port_if_needed(pctx) if pctx else None for d, pctx in result.items()} - @utils.transaction_guard - @db_api.retry_if_session_inactive() def update_port_status(self, context, port_id, status, host=None, network=None): """ Returns port_id (non-truncated uuid) if the port exists. Otherwise returns None. ! network can be passed in to avoid another get_network call if ! one was already performed by the caller. """ - updated = False session = context.session ! with session.begin(subtransactions=True): ! port = db.get_port(session, port_id) ! if not port: LOG.debug("Port %(port)s update to %(val)s by agent not found", {'port': port_id, 'val': status}) ! return None if (port.status != status and port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE): original_port = self._make_port_dict(port) --- 1662,1717 ---- return {d: self._bind_port_if_needed(pctx) if pctx else None for d, pctx in result.items()} def update_port_status(self, context, port_id, status, host=None, network=None): """ Returns port_id (non-truncated uuid) if the port exists. Otherwise returns None. ! 'network' is deprectated and has no effect """ session = context.session ! full = db.partial_port_ids_to_full_ids(session, [port_id]) ! if port_id not in full: ! return None ! port_id = full[port_id] ! return self.update_port_statuses( ! context, {port_id: status}, host)[port_id] ! ! @utils.transaction_guard ! @db_api.retry_if_session_inactive() ! def update_port_statuses(self, context, port_id_to_status, host=None): ! result = {} ! port_ids = port_id_to_status.keys() ! session = context.session ! port_dbs_by_id = db.get_port_db_objects(session, port_ids) ! for port_id, status in port_id_to_status.items(): ! if not port_dbs_by_id.get(port_id): LOG.debug("Port %(port)s update to %(val)s by agent not found", {'port': port_id, 'val': status}) ! result[port_id] = None ! continue ! result[port_id] = self._safe_update_individual_port_db_status( ! context, port_dbs_by_id[port_id], status, host) ! return result ! ! def _safe_update_individual_port_db_status(self, context, port, ! status, host): ! port_id = port.id ! session = context.session ! try: ! return self._update_individual_port_db_status( ! context, port, status, host) ! except Exception: ! with excutils.save_and_reraise_exception() as ectx: ! # don't reraise if port doesn't exist anymore ! ectx.reraise = bool(db.get_port(session, port_id)) ! ! def _update_individual_port_db_status(self, context, port, status, host): ! updated = False ! network = None ! port_id = port.id ! session = context.session ! with session.begin(subtransactions=True): if (port.status != status and port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE): original_port = self._make_port_dict(port) diff -crB --new-file neutron-9.4.2.dev21-backup/neutron/plugins/ml2/rpc.py neutron-9.4.2.dev21/neutron/plugins/ml2/rpc.py *** neutron-9.4.2.dev21-backup/neutron/plugins/ml2/rpc.py 2019-03-25 22:36:03.579529483 -0700 --- neutron-9.4.2.dev21/neutron/plugins/ml2/rpc.py 2019-03-25 22:39:18.249651772 -0700 *************** *** 193,201 **** # filter out any without status changes new_status_map = {p: s for p, s in new_status_map.items() if s} try: ! for port_id, new_status in new_status_map.items(): ! plugin.update_port_status(rpc_context, port_id, ! new_status, host) except Exception: LOG.exception("Failure updating statuses, retrying all") failed_devices = devices_to_fetch --- 193,199 ---- # filter out any without status changes new_status_map = {p: s for p, s in new_status_map.items() if s} try: ! plugin.update_port_statuses(rpc_context, new_status_map, host) except Exception: LOG.exception("Failure updating statuses, retrying all") failed_devices = devices_to_fetch diff -crB --new-file neutron-9.4.2.dev21-backup/neutron/tests/unit/plugins/ml2/test_plugin.py neutron-9.4.2.dev21/neutron/tests/unit/plugins/ml2/test_plugin.py *** neutron-9.4.2.dev21-backup/neutron/tests/unit/plugins/ml2/test_plugin.py 2019-03-25 14:30:15.168278331 -0700 --- neutron-9.4.2.dev21/neutron/tests/unit/plugins/ml2/test_plugin.py 2019-03-25 15:48:34.278276616 -0700 *************** *** 827,836 **** plugin = manager.NeutronManager.get_plugin() with self.port() as port: net = plugin.get_network(ctx, port['port']['network_id']) ! with mock.patch.object(plugin, 'get_network') as get_net: plugin.update_port_status(ctx, port['port']['id'], 'UP', network=net) ! self.assertFalse(get_net.called) def test_update_port_mac(self): self.check_update_port_mac( --- 827,836 ---- plugin = manager.NeutronManager.get_plugin() with self.port() as port: net = plugin.get_network(ctx, port['port']['network_id']) ! with mock.patch.object(plugin, 'get_networks') as get_nets: plugin.update_port_status(ctx, port['port']['id'], 'UP', network=net) ! self.assertFalse(get_nets.called) def test_update_port_mac(self): self.check_update_port_mac(
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor