'Creates and binds a new HA port for this agent.'

def create_ha_port_and_bind(self, plugin, context, router_id, tenant_id, agent, is_manual_scheduling=False):

    ctxt = context.elevated()
    router_db = plugin._get_router(ctxt, router_id)
    creator = functools.partial(self._add_port_from_net_and_ensure_vr_id, plugin, ctxt, router_db, tenant_id)
    dep_getter = functools.partial(plugin.get_ha_network, ctxt, tenant_id)
    dep_creator = functools.partial(plugin._create_ha_network, ctxt, tenant_id)
    dep_deleter = functools.partial(plugin._delete_ha_network, ctxt)
    dep_id_attr = 'network_id'
    binding = self.bind_router(plugin, context, router_id, agent['id'], is_manual_scheduling=is_manual_scheduling, is_ha=True)
    if (not binding):
        return
    try:
        port_binding = utils.create_object_with_dependency(creator, dep_getter, dep_creator, dep_id_attr, dep_deleter)[0]
        with db_api.autonested_transaction(context.session):
            port_binding.l3_agent_id = agent['id']
    except db_exc.DBDuplicateEntry:
        LOG.debug('Router    %(router)s    already    scheduled    for    agent    %(agent)s', {'router': router_id, 'agent': agent['id']})
    except l3.RouterNotFound:
        LOG.debug('Router    %s    has    already    been    removed    by    concurrent    operation', router_id)
        ha_net = plugin.get_ha_network(ctxt, tenant_id)
        if ha_net:
            plugin.safe_delete_ha_network(ctxt, ha_net, tenant_id)
