'Get the appropriate UID and GID for a new cluster user. If the user\'s
home folder exists but the user doesn\'t exist the UID/GID owning the
home folder is returned. Otherwise it chooses the next available UID
and GID for a new user.'

def _get_new_user_id(self, user):

    user = (user or self._user)
    home_folder = ('/home/%s' % user)
    mconn = self._master.ssh
    if mconn.path_exists(home_folder):
        s = mconn.stat(home_folder)
        uid = s.st_uid
        gid = s.st_gid
    else:
        (uid, gid) = self._get_max_unused_user_id()
    return (uid, gid)
