import sqlite3
import logging


def get_row_from_vms_table(conn, tenant_uuid):
    """
        Get rows from vms table for a given tenant.

        Return value:
        -- error_msg: return None on success or error string
        -- result: returns rows in vms table with given tenant_uuid on success,
           return None on failure
    """

    try:
        cur = conn.execute(
            "SELECT * FROM vms WHERE tenant_id=?",
            (tenant_uuid,)
            )
    except sqlite3.Error as e:
        logging.error("Error: %s when querying vms table for tenant %s", e, tenant_uuid)
        return str(e), None

    result = cur.fetchall()
    return None, result