def get_master(db, service):
    """Get the master instance_id for a service.

    Args:
        db: mongodb db reference.
        service: str, service name of master whose instance id we need.
    Returns:
        str, master instance_id for service.
    """

    master_id = None
    res = list(db.servers.find(
            {'hostname': '%s-master' % service}))
    if len(res) > 1:
        logging.error('Multiple masters listed for %s service. Aborting' % service)
        return None
    if res:
        master_id = res[0]['instance_id']

    return master_id
dataset/ETHPy150Open urbanairship/aerostat/aerostat/aerostat.py/get_master/original