Fix arista_trunk plugin to handle new payload format

A recent to the way neutron sends trunk/subport payloads
(0f3e04b00f)
breaks the arista_trunk service plugin.

This change adopts the new format.

Change-Id: Id0c46a2fc63eea0a6e80d6052649dedcebf4b041
changes/25/793525/1
Mitchell Jameson 2021-05-27 18:14:10 -07:00
parent 1327851e5a
commit 3230e30dee
1 changed files with 14 additions and 12 deletions

View File

@ -124,44 +124,46 @@ class AristaTrunkDriver(base.DriverBase):
def trunk_create(self, resource, event, trunk_plugin, payload):
ctx = context.get_admin_context()
parent_id = payload.current_trunk.port_id
parent_id = payload.states[0].port_id
parent = self.core_plugin.get_port(ctx, parent_id)
if parent.get(portbindings.VNIC_TYPE) != portbindings.VNIC_BAREMETAL:
return
subport_ids = [subport.port_id
for subport in payload.current_trunk.sub_ports]
for subport in payload.states[0].sub_ports]
self._bind_subports(ctx, subport_ids, parent)
trunk_plugin.update_trunk(ctx, payload.trunk_id,
trunk_plugin.update_trunk(ctx, payload.resource_id,
{t_api.TRUNK:
{'status': parent['status']}})
def trunk_update(self, resource, event, trunk_plugin, payload):
if payload.current_trunk.status != t_const.TRUNK_ACTIVE_STATUS:
self._delete_trunk(payload.current_trunk)
if payload.states[1].status != t_const.TRUNK_ACTIVE_STATUS:
self._delete_trunk(payload.states[1])
def trunk_delete(self, resource, event, trunk_plugin, payload):
self._delete_trunk(payload.original_trunk)
self._delete_trunk(payload.states[0])
def subport_create(self, resource, event, trunk_plugin, payload):
ctx = context.get_admin_context()
parent_id = payload.current_trunk.port_id
parent_id = payload.states[1].port_id
parent = self.core_plugin.get_port(ctx, parent_id)
if parent.get(portbindings.VNIC_TYPE) != portbindings.VNIC_BAREMETAL:
return
subport_ids = [subport.port_id for subport in payload.subports]
subport_ids = [subport.port_id for subport in
payload.metadata['subports']]
self._bind_subports(ctx, subport_ids, parent)
trunk_plugin.update_trunk(ctx, payload.trunk_id,
trunk_plugin.update_trunk(ctx, payload.resource_id,
{t_api.TRUNK:
{'status': parent['status']}})
def subport_delete(self, resource, event, trunk_plugin, payload):
ctx = context.get_admin_context()
parent_id = payload.current_trunk.port_id
parent_id = payload.states[1].port_id
parent = self.core_plugin.get_port(ctx, parent_id)
if parent.get(portbindings.VNIC_TYPE) != portbindings.VNIC_BAREMETAL:
return
subport_ids = [subport.port_id for subport in payload.subports]
subport_ids = [subport.port_id for subport in
payload.metadata['subports']]
self._unbind_subports(ctx, subport_ids, parent)
trunk_plugin.update_trunk(ctx, payload.trunk_id,
trunk_plugin.update_trunk(ctx, payload.resource_id,
{t_api.TRUNK:
{'status': parent['status']}})