Exemplo n.º 1
0
def host_groups_get(host_id,host_name):
    if not os.path.exists( str(EXTERNAL_NODES) ):
        host_id = int(host_id)
        h = Host.read('id = %s', params=[host_id])
        if not h:
            return jsonify(msg='no such host')
        group_ids = GroupHost.group_ids(h.id)
    else:
        (status, output) =  commands.getstatusoutput(EXTERNAL_NODES + " GetHostGroupByHost " + host_id )
        group_ids = []
        h = {}
        if status == 0:
            decodejson = json.loads( output )         
            gname = "1"
            for i in decodejson:
                gname = gname + ",'" + decodejson[i] + "'"
            groupMsg = HostGroup.select(cols="id,grp_name", where="grp_name in (%s)" % gname)
            for m in groupMsg:
                group_ids.append( m[0] )
            h["id"] = host_id
            h["hostname"] = host_name


    groups = [HostGroup.read('id = %s', [group_id]) for group_id in group_ids]
    return render_template('host/groups.html', groups=groups, host=h)
Exemplo n.º 2
0
def host_groups_get(host_id):
    host_id = int(host_id)
    h = Host.read('id = %s', params=[host_id])
    if not h:
        return jsonify(msg='no such host')

    group_ids = GroupHost.group_ids(h.id)
    groups = [HostGroup.read('id = %s', [group_id]) for group_id in group_ids]
    return render_template('host/groups.html', groups=groups, host=h)
Exemplo n.º 3
0
def host_groups_get(host_id):
    host_id = int(host_id)
    h = Host.read('id = %s', params=[host_id])
    if not h:
        return jsonify(msg='no such host')

    group_ids = GroupHost.group_ids(h.id)
    groups = [HostGroup.read('id = %s', [group_id]) for group_id in group_ids]
    return render_template('host/groups.html', groups=groups, host=h)
Exemplo n.º 4
0
def host_templates_get(host_id):
    host_id = int(host_id)

    h = Host.read('id = %s', params=[host_id])
    if not h:
        return jsonify(msg='no such host')

    group_ids = GroupHost.group_ids(h.id)

    templates = GrpTpl.tpl_set(group_ids)
    for v in templates:
        v.parent = Template.get(v.parent_id)
    return render_template('host/templates.html', **locals())
Exemplo n.º 5
0
def host_templates_get(host_id):
    host_id = int(host_id)

    h = Host.read('id = %s', params=[host_id])
    if not h:
        return jsonify(msg='no such host')

    group_ids = GroupHost.group_ids(h.id)

    templates = GrpTpl.tpl_set(group_ids)
    for v in templates:
        v.parent = Template.get(v.parent_id)
    return render_template('host/templates.html', config=config, **locals())
Exemplo n.º 6
0
def host_templates_get(host_id, host_name):

    if not os.path.exists( str(EXTERNAL_NODES) ):
        host_id = int(host_id)
        h = Host.read('id = %s', params=[host_id])
        if not h:
            return jsonify(msg='no such host')
        group_ids = GroupHost.group_ids(h.id)
    else:
        (status, output) =  commands.getstatusoutput(EXTERNAL_NODES + " GetHostGroupByHost " + host_id )
        group_ids = []
        if status == 0:
            decodejson = json.loads( output )         
            gname = "1"
            for i in decodejson:
                gname = gname + ",'" + decodejson[i] + "'"
            groupMsg = HostGroup.select(cols="id,grp_name", where="grp_name in (%s)" % gname)
            for m in groupMsg:
                group_ids.append( m[0] )

    templates = GrpTpl.tpl_set(group_ids)
    for v in templates:
        v.parent = Template.get(v.parent_id)
    return render_template('host/templates.html', **locals())