'Update subport bindings to match trunk host binding.'

@log_helpers.log_method_call
def update_subport_bindings(self, context, subports):

    el = context.elevated()
    ports_by_trunk_id = collections.defaultdict(list)
    updated_ports = collections.defaultdict(list)
    for s in subports:
        ports_by_trunk_id[s['trunk_id']].append(s['port_id'])
    for (trunk_id, subport_ids) in ports_by_trunk_id.items():
        trunk = trunk_objects.Trunk.get_object(el, id=trunk_id)
        if (not trunk):
            LOG.debug('Trunk    not    found.    id:    %s', trunk_id)
            continue
        trunk_updated_ports = self._process_trunk_subport_bindings(el, trunk, subport_ids)
        updated_ports[trunk.id].extend(trunk_updated_ports)
    return updated_ports
