[AIM] Make link update/delete transactional
Also, make sure it doesn't break other networks' path update when one fails Change-Id: I3634f2686434697c51adf685a9373f853ba7f5ec
This commit is contained in:
parent
4a143dcad6
commit
8b7206a1ad
@ -1994,6 +1994,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
', '.join([str(p) for p in
|
||||
(host, interface, mac, switch, module, port,
|
||||
pod_id, port_description)]))
|
||||
with db_api.context_manager.writer.using(context):
|
||||
if not switch:
|
||||
self.delete_link(context, host, interface, mac, switch, module,
|
||||
port)
|
||||
@ -2018,11 +2019,18 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
**attrs)
|
||||
hlink = self.aim.create(aim_ctx, hlink)
|
||||
# Update static paths of all EPGs with ports on the host
|
||||
nets_segs = self._get_non_opflex_segments_on_host(context, host)
|
||||
nets_segs = self._get_non_opflex_segments_on_host(context,
|
||||
host)
|
||||
for net, seg in nets_segs:
|
||||
self._update_static_path_for_network(session, net, seg,
|
||||
old_path=old_path,
|
||||
try:
|
||||
self._update_static_path_for_network(
|
||||
session, net, seg, old_path=old_path,
|
||||
new_path=hlink.path)
|
||||
except Exception as e:
|
||||
# If one fails don't affect all the others
|
||||
LOG.error("Static path update on update_link has "
|
||||
"failed for network %s: %s" % (net['id'],
|
||||
e.message))
|
||||
|
||||
# Topology RPC method handler
|
||||
def delete_link(self, context, host, interface, mac, switch, module, port):
|
||||
@ -2032,6 +2040,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
session = context.session
|
||||
aim_ctx = aim_context.AimContext(db_session=session)
|
||||
|
||||
with db_api.context_manager.writer.using(context):
|
||||
hlink = self.aim.get(aim_ctx,
|
||||
aim_infra.HostLink(host_name=host,
|
||||
interface_name=interface))
|
||||
@ -2044,10 +2053,17 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
# the static path to this host
|
||||
if not self.aim.find(aim_ctx, aim_infra.HostLink, host_name=host,
|
||||
path=hlink.path):
|
||||
nets_segs = self._get_non_opflex_segments_on_host(context, host)
|
||||
nets_segs = self._get_non_opflex_segments_on_host(context,
|
||||
host)
|
||||
for net, seg in nets_segs:
|
||||
self._update_static_path_for_network(session, net, seg,
|
||||
old_path=hlink.path)
|
||||
try:
|
||||
self._update_static_path_for_network(
|
||||
session, net, seg, old_path=hlink.path)
|
||||
except Exception as e:
|
||||
# If one fails don't affect all the others
|
||||
LOG.error("Static path update on update_link has "
|
||||
"failed for network %s: %s" % (net['id'],
|
||||
e.message))
|
||||
|
||||
def _agent_bind_port(self, context, agent_type, bind_strategy):
|
||||
current = context.current
|
||||
|
Loading…
Reference in New Issue
Block a user