def all_host_dict(cls): rows = db.query_all('SELECT id, hostname FROM host') ret = {} if rows: for row in rows: ret[row[0]] = row[1] return ret
def all_set(cls): sql = 'select id, grp_name from %s' % cls._tbl rows = db.query_all(sql) name_set = dict() name_id = dict() for row in rows: name = row[1] name_set[name] = set(name.split('_')) name_id[name] = row[0] return name_set, name_id
def all_group_dict(cls): rows = db.query_all('select id, grp_name from grp where come_from = 0') return [{'id': row[0], 'name': row[1]} for row in rows]