'Wire trunk bridge with integration bridge.
The method calls into trunk manager to create patch ports for trunk and
patch ports for all subports associated with this trunk. If rewire is
True, a diff is performed between desired state (the one got from the
server) and actual state (the patch ports present on the trunk bridge)
and subports are wired/unwired accordingly.
:param trunk_br: OVSBridge object representing the trunk bridge.
:param port: Parent port dict.
:param rewire: True if local trunk state must be reconciled with
server\'s state.'

def _wire_trunk(self, trunk_br, port, rewire=False):

    ctx = self.context
    try:
        parent_port_id = self.trunk_manager.get_port_uuid_from_external_ids(port)
        trunk = self.trunk_rpc.get_trunk_details(ctx, parent_port_id)
    except tman.TrunkManagerError as te:
        LOG.error(_LE("Can't    obtain    parent    port    ID    from    port    %s"), port['name'])
        return
    except resources_rpc.ResourceNotFound:
        LOG.error(_LE('Port    %s    has    no    trunk    associated.'), parent_port_id)
        return
    try:
        registry.notify(constants.TRUNK, events.BEFORE_CREATE, self, context=ctx, trunk=trunk)
        self.trunk_manager.create_trunk(trunk.id, trunk.port_id, port['external_ids'].get('attached-mac'))
    except tman.TrunkManagerError as te:
        LOG.error(_LE('Failed    to    create    trunk    %(trunk_id)s:    %(err)s'), {'trunk_id': trunk.id, 'err': te})
        self.report_trunk_status(ctx, trunk.id, constants.ERROR_STATUS)
        return
    unwire_status = constants.ACTIVE_STATUS
    if rewire:
        old_subport_ids = self.get_connected_subports_for_trunk(trunk.id)
        subports = {p['port_id'] for p in trunk.sub_ports}
        subports_to_delete = (set(old_subport_ids) - subports)
        if subports_to_delete:
            unwire_status = self.unwire_subports_for_trunk(trunk.id, subports_to_delete)
    wire_status = self.wire_subports_for_trunk(ctx, trunk.id, trunk.sub_ports, trunk_bridge=trunk_br, parent_port=port)
    if ((unwire_status == wire_status) and (wire_status == constants.ACTIVE_STATUS)):
        status = constants.ACTIVE_STATUS
    else:
        status = constants.DEGRADED_STATUS
    self.report_trunk_status(ctx, trunk.id, status)
