def api_host_variables(hostname): host = Host.read(where='hostname = %s', params=[hostname]) if not host: return jsonify(msg='no such host %s' % hostname) groups_host = GroupHost.select_vs(where='host_id = %s' % host.id) if not groups_host: return jsonify(msg='the host %s has no group attribute' % hostname) data = [] for gh in groups_host: variables = Variable.select_vs(where='grp_id = %s' % gh.grp_id) for v in variables: data.append({'key': v.name, 'value': v.content, 'note': v.note}) return jsonify(msg='ok', data=data)