def add_host_mapping(host_id, nexus_ip, interface, ch_grp, is_static):
LOG.debug("<STR_LIT>")<EOL>session = bc.get_writer_session()<EOL>mapping = nexus_models_v2.NexusHostMapping(host_id=host_id,<EOL>if_id=interface,<EOL>switch_ip=nexus_ip,<EOL>ch_grp=ch_grp,<EOL>is_static=is_static)<EOL>try:<EOL><INDENT>session.add(mapping)<EOL>session.flush()<EOL><DEDENT>except db_exc.DBDuplicateEntry:<EOL><INDENT>with excutils.save_and_reraise_exception() as ctxt:<EOL><INDENT>if is_static:<EOL><INDENT>ctxt.reraise = False<EOL>LOG.debug("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>{'<STR_LIT:host>': host_id, '<STR_LIT>': interface,<EOL>'<STR_LIT>': nexus_ip})<EOL><DEDENT><DEDENT><DEDENT>return mapping<EOL>
Add Host to interface mapping entry into mapping data base.

    :param host_id: is the name of the host to add
    :param interface: is the interface for this host
    :param nexus_ip: is the ip addr of the nexus switch for this interface
    :param ch_grp: is the port channel this interface belos
    :param is_static: whether this is from conf file or learned from baremetal.