Revisión 167
Añadido por jredrejo hace casi 14 años
controlies/branches/web2py/debian/changelog | ||
---|---|---|
controlies (0.2-1) unstable; urgency=low
|
||
|
||
* Completando funcionalidades
|
||
|
||
-- José L. Redrejo Rodríguez <jredrejo@debian.org> Fri, 13 May 2011 14:37:17 +0200
|
||
|
||
controlies (0.1-1) unstable; urgency=low
|
||
|
||
* First Debian package
|
controlies/branches/web2py/applications/controlies/models/menu.py | ||
---|---|---|
[
|
||
('Usuarios', False, URL( 'usuarios', 'index' )),
|
||
('Grupos', False,URL( 'grupos', 'index' )),
|
||
('Servidores LTSP',False, URL( 'hosts', 'getLTSPServers' )),
|
||
('Servidores LTSP',False, URL( 'hosts', 'ltspservers' )),
|
||
('Workstations', False,URL( 'hosts', 'workstations' )),
|
||
('Clientes Ligeros', False,URL( 'hosts', 'thinclient' )),
|
||
('Portátiles', False,URL( 'hosts', 'portatil' )),
|
||
('Clientes Ligeros', False,URL( 'hosts', 'thinclients' )),
|
||
('Parámetros DHCP', False,URL( 'dhcpd', 'index' )),
|
||
|
||
]
|
||
... | ... | |
('Alumnos', False, URL( 'gestion', 'rayuela_alumnos')),
|
||
|
||
]),
|
||
|
||
('Mantenimiento de LDAP', False, None,
|
||
[
|
||
('Limpieza de usuarios inexistentes en grupos', False, URL( 'gestion', 'limpieza_usuarios')),
|
||
('Detección de uid o gid duplicados', False, URL( 'gestion', 'duplicados')),
|
||
|
||
]),
|
||
|
||
]
|
||
)]
|
controlies/branches/web2py/applications/controlies/models/db.py | ||
---|---|---|
auth.settings.login_methods=[ldap_auth( server='localhost', base_dn='ou=People,dc=instituto,dc=extremadura,dc=es',secure=LdapConnection.ldap_secure,cert_path=LdapConnection.ldap_cert,mode='cn')]
|
||
|
||
#auth.settings.login_onaccept=lambda form: session_ldap(form)
|
||
def conecta():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
return l
|
controlies/branches/web2py/applications/controlies/controllers/grupos.py | ||
---|---|---|
# coding: utf8
|
||
from applications.controlies.modules.Groups import Groups
|
||
import applications.controlies.modules.Utils.LdapUtils as LdapUtils
|
||
import applications.controlies.modules.LdapConnection as LdapConnection
|
||
|
||
def index():
|
||
return dict()
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def list():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
g = Groups(l,"","","")
|
||
a=request.vars
|
||
response = g.list(a)
|
||
l.close()
|
||
return response
|
||
|
||
@service.json
|
||
@service.json
|
||
def getAllGroups():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
import applications.controlies.modules.Utils.LdapUtils as LdapUtils
|
||
l=conecta()
|
||
response = LdapUtils.getAllGroups(l)
|
||
l.close()
|
||
return response
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def modify():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
g = Groups(l,request.vars['type'], request.vars['name'], request.vars['users'])
|
||
response = g.process(request.vars['action'])
|
||
l.close()
|
||
... | ... | |
|
||
@service.json
|
||
def getGroupData():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
g = Groups(l,"",request.vars['name'],"")
|
||
response = g.getGroupData()
|
||
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
@service.json
|
||
@service.json
|
||
@auth.requires_login()
|
||
def delete():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
g = Groups(l,"",request.vars['name'],"")
|
||
response = g.delete()
|
||
|
||
l.close()
|
||
return dict(response=response)
|
||
|
controlies/branches/web2py/applications/controlies/controllers/hosts.py | ||
---|---|---|
# coding: utf8
|
||
|
||
from applications.controlies.modules.Hosts import Hosts
|
||
|
||
def index():
|
||
#equivalente a list
|
||
return dict(message="hello from hosts.py")
|
||
|
||
|
||
@service.json
|
||
def getThinclientGroups():
|
||
return dict()
|
||
l=conecta()
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getThinclientGroups()
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
|
||
def getInternalGroups():
|
||
return dict()
|
||
@service.json
|
||
def getHostData():
|
||
l=conecta()
|
||
h = Hosts(l,request.vars['cn'],"","",request.vars['group'],request.vars['type'])
|
||
response = h.getHostData()
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
def getLTSPServers():
|
||
return dict()
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def list_ltspservers():
|
||
l=conecta()
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getLTSPServers()
|
||
l.close()
|
||
return response
|
||
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def list():
|
||
l=conecta()
|
||
h = Hosts (l,"","","","","")
|
||
a=request.vars
|
||
response = h.list(a)
|
||
l.close()
|
||
return response
|
||
|
||
def getLTSPStatus():
|
||
return dict()
|
||
|
||
def getClassroomDetails():
|
||
return dict()
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def modify():
|
||
l=conecta()
|
||
ip=''
|
||
if request.vars['type']!='thinclient':ip=request.vars['ip']
|
||
h = Hosts(l,request.vars['name'],ip,request.vars['mac'],request.vars['group'],request.vars['type'])
|
||
response=h.process(request.vars['action'] )
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def delete():
|
||
l=conecta()
|
||
h = Hosts(l,request.vars['cn'],"","",request.vars['group'],request.vars['type'])
|
||
response=h.process(request.vars['action'] )
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
#necesaria estas funciones en el controlador para poder cargar las vistas correspondientes:
|
||
def ltspservers():
|
||
return dict()
|
||
|
||
def getHostData():
|
||
return dict()
|
||
def workstations():
|
||
return dict()
|
||
|
||
def thinclients():
|
||
return dict()
|
||
|
||
def thinclient():
|
||
def form_thinclient():
|
||
return dict()
|
||
|
||
def portatil():
|
||
def form_ltspserver():
|
||
return dict()
|
||
|
||
def call():
|
||
"""
|
||
exposes services. for example:
|
||
http://..../[app]/default/call/jsonrpc
|
||
decorate with @services.jsonrpc the functions to expose
|
||
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
|
||
"""
|
||
session.forget()
|
||
return service()
|
controlies/branches/web2py/applications/controlies/controllers/gestion.py | ||
---|---|---|
# coding: utf8
|
||
@service.json
|
||
@auth.requires_login()
|
||
def servidores_aula():
|
||
return dict()
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def getClassroomDetails():
|
||
import xmlrpclib
|
||
from applications.controlies.modules.Users import Users
|
||
l=conecta()
|
||
objUser = Users(l,"","","","",request.vars['teacher'],"","","","")
|
||
teacherData = objUser.getUserData()
|
||
|
||
s = xmlrpclib.Server("http://" + request.vars['classroom'] + ":8900");
|
||
|
||
users = s.Users()
|
||
|
||
response = []
|
||
for u in users:
|
||
user = u.split("@")
|
||
|
||
objUser = Users(l,"","","","",user[0],"","","","")
|
||
photo = objUser.getUserPhoto()
|
||
|
||
# response.append({ 'username': user[0], 'host': user[1], 'photo': photo })
|
||
|
||
#return json.dumps({ "teacher" : teacherData, "classroom" : request.args['classroom'][0], "students" : response })
|
||
|
||
|
||
|
||
return dict(message="hello from gestion.py")
|
||
|
||
|
||
... | ... | |
@auth.requires_login()
|
||
def rayuela_profesores():
|
||
return dict()
|
||
|
||
@service.json
|
||
def getLTSPServers():
|
||
return dict()
|
||
|
||
@service.json
|
||
def getLTSPStatus():
|
||
return dict()
|
||
|
||
def call():
|
||
"""
|
||
exposes services. for example:
|
||
http://..../[app]/default/call/jsonrpc
|
||
decorate with @services.jsonrpc the functions to expose
|
||
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
|
||
"""
|
||
session.forget()
|
||
return service()
|
controlies/branches/web2py/applications/controlies/controllers/usuarios.py | ||
---|---|---|
# coding: utf8
|
||
from applications.controlies.modules.Users import Users
|
||
import applications.controlies.modules.LdapConnection as LdapConnection
|
||
import applications.controlies.modules.Utils.LdapUtils as LdapUtils
|
||
|
||
def index():
|
||
return dict()
|
||
|
||
@service.json
|
||
@auth.requires_login()
|
||
def list():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
u = Users(l,"","","","","","","","","")
|
||
response = u.list(request.vars)
|
||
l.close()
|
||
return response
|
||
|
||
@service.json
|
||
@service.json
|
||
@auth.requires_login()
|
||
def searchUsername():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
u = Users(l,"",request.vars['name'],request.vars['surname'],"","","","","","")
|
||
response = u.searchNewUsername()
|
||
l.close()
|
||
... | ... | |
|
||
@service.json
|
||
def getUserData():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
u = Users(l,"","","","",request.vars['username'],"","","","")
|
||
response = u.getUserData()
|
||
l.close()
|
||
... | ... | |
|
||
@service.json
|
||
def getAllUsers():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
import applications.controlies.modules.Utils.LdapUtils as LdapUtils
|
||
l=conecta()
|
||
response = LdapUtils.getAllUsers(l)
|
||
l.close()
|
||
return response
|
||
|
||
@service.json
|
||
@service.json
|
||
@auth.requires_login()
|
||
def delete():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
u = Users(l,"","","","",request.vars['user'],"","","","")
|
||
response = u.delete()
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
@service.json
|
||
@service.json
|
||
@auth.requires_login()
|
||
def modify_user():
|
||
l=LdapConnection.LdapConnection(session)
|
||
l.process()
|
||
l=conecta()
|
||
departments=[]
|
||
classrooms=[]
|
||
if 'multiselect_departments' in request.vars: departments = request.vars['multiselect_departments']
|
controlies/branches/web2py/applications/controlies/static/js/utils.js | ||
---|---|---|
/* #########################################################################
|
||
# Project: ControlIES
|
||
# Module: utils.js
|
||
# Purpose: Util functions
|
||
# Language: javascript
|
||
# Copyright: 2009-2010 - Manuel Mora Gordillo <manuito @nospam@ gmail.com>
|
||
#
|
||
# This program is free software: you can redistribute it and/or modify
|
||
# it under the terms of the GNU General Public License as published by
|
||
# the Free Software Foundation, either version 3 of the License, or
|
||
# (at your option) any later version.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU General Public License for more details.
|
||
#
|
||
# You should have received a copy of the GNU General Public License
|
||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
#
|
||
############################################################################## */
|
||
|
||
function selectAll(){
|
||
$("#tabsClassroom").tabs("select","tabsClassroom-1");
|
||
$("#selectable li").addClass("ui-selected");
|
||
}
|
||
|
||
function selectNone(){
|
||
$("#tabsClassroom").tabs("select","tabsClassroom-1");
|
||
$("#selectable li").removeClass("ui-selected");
|
||
}
|
||
|
||
function computersSelected(){
|
||
var selected = Array();
|
||
var j=0;
|
||
|
||
$("#selectable li").each(function(i, item){
|
||
if($("#"+item.id).hasClass('ui-selected')==true){
|
||
selected[j] = $("#"+item.id + ":eq(0) > #pcName").html();
|
||
j++;
|
||
}
|
||
});
|
||
return selected;
|
||
}
|
||
|
||
function sendOrderSelected(url,args,action){
|
||
|
||
var selected = computersSelected(url);
|
||
|
||
if(selected.length==0){
|
||
modalAlert("Para realizar la acción debe seleccionar al menos un equipo");
|
||
return;
|
||
}
|
||
|
||
var classroom = {
|
||
"pclist" : selected,
|
||
"args" : args
|
||
}
|
||
|
||
var dataString = $.JSON.encode(classroom)
|
||
connection(url,dataString,action);
|
||
}
|
||
|
||
function sendOrder(url,args,action){
|
||
|
||
var classroom = {
|
||
"args" : args
|
||
}
|
||
|
||
var dataString = $.JSON.encode(classroom);
|
||
connection(url,dataString,action);
|
||
}
|
||
|
||
|
||
function modalAlert(message){
|
||
|
||
$("#dialogAlertMessage").html(message);
|
||
|
||
$("#dialogAlert")
|
||
.dialog({
|
||
modal: true,
|
||
width: 350,
|
||
resizable: false,
|
||
hide: "explode",
|
||
buttons: {
|
||
Ok: function() { $( this ).dialog( "close" ); }
|
||
}
|
||
})
|
||
.dialog('open');
|
||
|
||
return true;
|
||
}
|
||
|
||
function modalConfirm(message, funct){
|
||
|
||
$("#dialogAlertMessage").html(message);
|
||
|
||
$("#dialogAlert")
|
||
.dialog({
|
||
modal: true,
|
||
width: 350,
|
||
resizable: false,
|
||
buttons: {
|
||
"Si": function() { eval(funct); },
|
||
"No": function() { $( this ).dialog( "close" ); }
|
||
}
|
||
})
|
||
.dialog('open');
|
||
|
||
return true;
|
||
}
|
controlies/branches/web2py/applications/controlies/modules/Hosts.py | ||
---|---|---|
# Language: Python 2.5
|
||
# Date: 7-Feb-2011.
|
||
# Ver: 7-Feb-2011.
|
||
# Author: Manuel Mora Gordillo
|
||
# Francisco Mendez Palma
|
||
# Author: Manuel Mora Gordillo
|
||
# Francisco Mendez Palma
|
||
# Copyright: 2011 - Manuel Mora Gordillo <manuito @no-spam@ gmail.com>
|
||
# 2011 - Francisco Mendez Palma <fmendezpalma @no-spam@ gmail.com>
|
||
# 2011 - Francisco Mendez Palma <fmendezpalma @no-spam@ gmail.com>
|
||
#
|
||
# ControlIES is free software: you can redistribute it and/or modify
|
||
# it under the terms of the GNU General Public License as published by
|
||
... | ... | |
class Hosts(object):
|
||
|
||
def __init__(self):
|
||
pass
|
||
|
||
pass
|
||
|
||
def __init__(self,ldap,name,ip,mac,group,type):
|
||
self.ldap = ldap
|
||
self.name = name
|
||
self.ip = ip
|
||
self.mac = mac
|
||
self.group = group
|
||
self.type = type
|
||
|
||
self.ldap = ldap
|
||
self.name = name
|
||
self.ip = ip
|
||
self.mac = mac
|
||
self.group = group
|
||
self.type = type
|
||
|
||
def getName (self):
|
||
return self.mac
|
||
|
||
return self.mac
|
||
|
||
def validation(self,action):
|
||
|
||
if action == "add":
|
||
if self.type == "none":
|
||
return "type"
|
||
|
||
if self.name == "":
|
||
return "name"
|
||
|
||
if self.type <> 'thinclient':
|
||
if self.ip == "":
|
||
return "ip"
|
||
if action == "add":
|
||
if self.type == "none":
|
||
return "type"
|
||
|
||
if self.name == "":
|
||
return "name"
|
||
|
||
if self.type <> 'thinclient':
|
||
if self.ip == "":
|
||
return "ip"
|
||
|
||
if self.mac == "":
|
||
return "mac"
|
||
|
||
if self.type =="thinclient":
|
||
if self.group == "":
|
||
return "group"
|
||
if self.mac == "":
|
||
return "mac"
|
||
|
||
if self.type =="thinclient":
|
||
if self.group == "":
|
||
return "group"
|
||
|
||
if self.type == "":
|
||
return "type"
|
||
|
||
if action == "add":
|
||
if self.existsHostname():
|
||
return "hostAlreadyExists"
|
||
|
||
# thinclients no requieren ip, la cogen dinamicamente en el aula
|
||
if self.type <> "thinclient":
|
||
if self.existsIP():
|
||
return "ipAlreadyExists"
|
||
#controlar overflow en nodos
|
||
if self.groupOverflow(300):
|
||
return "groupOverflow"
|
||
if self.type == "":
|
||
return "type"
|
||
|
||
if action == "add":
|
||
if self.existsHostname():
|
||
return "hostAlreadyExists"
|
||
|
||
# thinclients no requieren ip, la cogen dinamicamente en el aula
|
||
if self.type <> "thinclient":
|
||
if self.existsIP():
|
||
return "ipAlreadyExists"
|
||
#controlar overflow en nodos
|
||
if self.groupOverflow(300):
|
||
return "groupOverflow"
|
||
|
||
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
|
||
elif action == "modify":
|
||
if self.groupOverflow(300):
|
||
return "groupOverflow"
|
||
elif action == "modify":
|
||
if self.groupOverflow(300):
|
||
return "groupOverflow"
|
||
|
||
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
|
||
return "OK"
|
||
|
||
return "OK"
|
||
|
||
def process(self,action):
|
||
if action == "add":
|
||
val = self.validation(action)
|
||
|
||
if val != "OK":
|
||
return val
|
||
else:
|
||
response = self.add()
|
||
return response
|
||
if action == "add":
|
||
val = self.validation(action)
|
||
|
||
if val != "OK":
|
||
return val
|
||
else:
|
||
response = self.add()
|
||
return response
|
||
|
||
if action == "modify":
|
||
val = self.validation(action)
|
||
|
||
if val != "OK":
|
||
return val
|
||
else:
|
||
response = self.modify()
|
||
return response
|
||
|
||
if action == "delete":
|
||
response = self.delete()
|
||
return response
|
||
|
||
if action == "list":
|
||
response = self.list();
|
||
return response
|
||
|
||
if action == "modify":
|
||
val = self.validation(action)
|
||
|
||
if val != "OK":
|
||
return val
|
||
else:
|
||
response = self.modify()
|
||
return response
|
||
|
||
if action == "delete":
|
||
response = self.delete()
|
||
return response
|
||
|
||
if action == "list":
|
||
response = self.list();
|
||
return response
|
||
|
||
def list(self,args):
|
||
|
||
#from Plugins.LdapConnection import LdapConnection
|
||
|
||
#from Plugins.LdapConnection import LdapConnection
|
||
|
||
#l = LdapConnection("172.23.36.5",'cn=admin,ou=People,dc=instituto,dc=extremadura,dc=es',"Sta1987teleco")
|
||
#l.connect()
|
||
|
||
# grid parameters
|
||
limit = int(args['rows'][0])
|
||
page = int(args['page'][0])
|
||
start = limit * page - limit
|
||
finish = start + limit;
|
||
#l = LdapConnection("172.23.36.5",'cn=admin,ou=People,dc=instituto,dc=extremadura,dc=es',"Sta1987teleco")
|
||
#l.connect()
|
||
|
||
# grid parameters
|
||
limit = int(args['rows'])
|
||
page = int(args['page'])
|
||
start = limit * page - limit
|
||
finish = start + limit;
|
||
|
||
# sort by field
|
||
sortBy = args['sidx'][0]
|
||
#if sortBy == "uid":
|
||
#sortBy = "id"
|
||
# sort by field
|
||
sortBy = args['sidx']
|
||
#if sortBy == "uid":
|
||
#sortBy = "id"
|
||
|
||
# reverse Sort
|
||
reverseSort = False
|
||
if args['sord'][0] == "asc":
|
||
reverseSort = True
|
||
|
||
#Distinguimos entre hosts ltsp, workstations y portatiles
|
||
type = args['type'][0]
|
||
|
||
|
||
if type == "ltsp":
|
||
# Obtengo todos los elementos del nodo hosts
|
||
#search = l.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
#filter = self.buildFilter(args)
|
||
search = self.ldap.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
|
||
# triplets que contiene los nombres de los ltsp-servers
|
||
hostnames = self.getLTSPServers()
|
||
|
||
# Ahora tengo que quedarme con los elementos de search que estan en hostnames: los que son ltsp
|
||
resultado=list()
|
||
for element in search:
|
||
if element[0][1]["cn"][0] in hostnames:
|
||
resultado.append(element)
|
||
|
||
search = resultado
|
||
# reverse Sort
|
||
reverseSort = False
|
||
if args['sord'] == "asc":
|
||
reverseSort = True
|
||
|
||
#Distinguimos entre hosts ltsp, workstations y portatiles
|
||
type = args['type']
|
||
|
||
|
||
if type == "ltsp":
|
||
# Obtengo todos los elementos del nodo hosts
|
||
#search = l.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
#filter = self.buildFilter(args)
|
||
search = self.ldap.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
|
||
# triplets que contiene los nombres de los ltsp-servers
|
||
hostnames = self.getLTSPServers()
|
||
|
||
# Ahora tengo que quedarme con los elementos de search que estan en hostnames: los que son ltsp
|
||
resultado=list()
|
||
for element in search:
|
||
if element[0][1]["cn"][0] in hostnames:
|
||
resultado.append(element)
|
||
|
||
search = resultado
|
||
|
||
rows = []
|
||
for i in search:
|
||
row = {
|
||
"id":i[0][1]["cn"][0],
|
||
"cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]],
|
||
"cn":i[0][1]["cn"][0],
|
||
"ipHostNumber":i[0][1]["ipHostNumber"][0],
|
||
"macAddress":i[0][1]["macAddress"][0]
|
||
}
|
||
#row = { "cn":i[0][0], "cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]]}
|
||
rows.append(row)
|
||
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
totalPages = 0
|
||
if page > totalPages:
|
||
page = totalPages
|
||
rows = []
|
||
for i in search:
|
||
row = {
|
||
"id":i[0][1]["cn"][0],
|
||
"cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]],
|
||
"cn":i[0][1]["cn"][0],
|
||
"ipHostNumber":i[0][1]["ipHostNumber"][0],
|
||
"macAddress":i[0][1]["macAddress"][0]
|
||
}
|
||
#row = { "cn":i[0][0], "cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]]}
|
||
rows.append(row)
|
||
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
totalPages = 0
|
||
if page > totalPages:
|
||
page = totalPages
|
||
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
|
||
|
||
elif type == "thinclient":
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn","dhcpHWAddress"])
|
||
filter="(|(dhcpOption=*subnet*)(dhcpOption=*log*))"
|
||
|
||
rows = []
|
||
|
||
# esto hay que cambiarlo: tenemos 4 groups en thinclientes
|
||
for i in search[6:len(search)]:
|
||
nodeinfo=i[0][0].replace ("cn=","").split(",")
|
||
row = {
|
||
"id":i[0][1]["cn"][0],
|
||
"cell":[i[0][1]["cn"][0], i[0][1]["dhcpHWAddress"][0].replace("ethernet ",""), nodeinfo[1]],
|
||
"cn":i[0][1]["cn"][0],
|
||
"dhcpHWAddress":i[0][1]["dhcpHWAddress"][0],
|
||
"groupName":i[0][1]["dhcpHWAddress"][0]
|
||
}
|
||
rows.append(row)
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
totalPages = 0
|
||
if page > totalPages:
|
||
page = totalPages
|
||
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
|
||
|
||
elif type == "workstation":
|
||
# Obtengo todos los elementos del nodo hosts
|
||
#search = l.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
search = self.ldap.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
# triplets que contiene los nombres de las workstations
|
||
#triplets = l.search("ou=Netgroup","cn=workstation-hosts",["nisNetgroupTriple"])
|
||
triplets = self.ldap.search("ou=Netgroup","cn=workstation-hosts",["nisNetgroupTriple"])
|
||
triplets = triplets [0][0][1]["nisNetgroupTriple"]
|
||
hostnames=list()
|
||
|
||
# obtengo lista de nombres de los hosts workstation
|
||
for node in triplets:
|
||
name = node.replace(",-,-)","").replace("(","")
|
||
hostnames.append(name)
|
||
|
||
# Ahora tengo que quedarme con los elementos de search que estan en hostnames
|
||
resultado=list()
|
||
for element in search:
|
||
if element[0][1]["cn"][0] in hostnames:
|
||
resultado.append(element)
|
||
|
||
search = resultado
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
|
||
|
||
elif type == "thinclient":
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn","dhcpHWAddress"])
|
||
filter="(|(dhcpOption=*subnet*)(dhcpOption=*log*))"
|
||
|
||
rows = []
|
||
|
||
# esto hay que cambiarlo: tenemos 4 groups en thinclientes
|
||
for i in search[6:len(search)]:
|
||
nodeinfo=i[0][0].replace ("cn=","").split(",")
|
||
row = {
|
||
"id":i[0][1]["cn"][0],
|
||
"cell":[i[0][1]["cn"][0], i[0][1]["dhcpHWAddress"][0].replace("ethernet ",""), nodeinfo[1]],
|
||
"cn":i[0][1]["cn"][0],
|
||
"dhcpHWAddress":i[0][1]["dhcpHWAddress"][0],
|
||
"groupName":i[0][1]["dhcpHWAddress"][0]
|
||
}
|
||
rows.append(row)
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
totalPages = 0
|
||
if page > totalPages:
|
||
page = totalPages
|
||
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
|
||
|
||
elif type == "workstation":
|
||
# Obtengo todos los elementos del nodo hosts
|
||
#search = l.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
search = self.ldap.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
# triplets que contiene los nombres de las workstations
|
||
#triplets = l.search("ou=Netgroup","cn=workstation-hosts",["nisNetgroupTriple"])
|
||
triplets = self.ldap.search("ou=Netgroup","cn=workstation-hosts",["nisNetgroupTriple"])
|
||
triplets = triplets [0][0][1]["nisNetgroupTriple"]
|
||
hostnames=list()
|
||
|
||
# obtengo lista de nombres de los hosts workstation
|
||
for node in triplets:
|
||
name = node.replace(",-,-)","").replace("(","")
|
||
hostnames.append(name)
|
||
|
||
# Ahora tengo que quedarme con los elementos de search que estan en hostnames
|
||
resultado=list()
|
||
for element in search:
|
||
if element[0][1]["cn"][0] in hostnames:
|
||
resultado.append(element)
|
||
|
||
search = resultado
|
||
|
||
rows = []
|
||
for i in search:
|
||
row = {
|
||
"id":i[0][1]["cn"][0],
|
||
"cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]],
|
||
"cn":i[0][1]["cn"][0],
|
||
"ipHostNumber":i[0][1]["ipHostNumber"][0],
|
||
"macAddress":i[0][1]["macAddress"][0]
|
||
}
|
||
#row = { "cn":i[0][0], "cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]]}
|
||
rows.append(row)
|
||
rows = []
|
||
for i in search:
|
||
row = {
|
||
"id":i[0][1]["cn"][0],
|
||
"cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]],
|
||
"cn":i[0][1]["cn"][0],
|
||
"ipHostNumber":i[0][1]["ipHostNumber"][0],
|
||
"macAddress":i[0][1]["macAddress"][0]
|
||
}
|
||
#row = { "cn":i[0][0], "cell":[i[0][1]["cn"][0], i[0][1]["ipHostNumber"][0],i[0][1]["macAddress"]]}
|
||
rows.append(row)
|
||
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
totalPages = 0
|
||
if page > totalPages:
|
||
page = totalPages
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
totalPages = 0
|
||
if page > totalPages:
|
||
page = totalPages
|
||
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
|
||
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
|
||
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
|
||
|
||
def add(self):
|
||
if self.type=="thinclient":
|
||
attr = [
|
||
('objectclass', ['top','dhcpHost']),
|
||
('cn', [self.name] ),
|
||
('dhcpStatements', ['filename "/var/lib/tftpboot/ltsp/i386/pxelinux.0"'] ),
|
||
('dhcpHWAddress', ['ethernet ' + self.mac] )
|
||
]
|
||
|
||
self.ldap.add("cn="+self.name +",cn="+self.group+",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
|
||
if self.type=="thinclient":
|
||
attr = [
|
||
('objectclass', ['top','dhcpHost']),
|
||
('cn', [self.name] ),
|
||
('dhcpStatements', ['filename "/var/lib/tftpboot/ltsp/i386/pxelinux.0"'] ),
|
||
('dhcpHWAddress', ['ethernet ' + self.mac] )
|
||
]
|
||
|
||
self.ldap.add("cn="+self.name +",cn="+self.group+",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
|
||
def modify(self):
|
||
attr = [
|
||
(ldap.MOD_REPLACE, 'cn', [self.name] ),
|
||
(ldap.MOD_REPLACE, 'dhcpHWAddress', ["ethernet "+ self.mac])
|
||
]
|
||
|
||
self.ldap.modify("cn="+self.name+",cn="+self.group +",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
attr = [
|
||
(ldap.MOD_REPLACE, 'cn', [self.name] ),
|
||
(ldap.MOD_REPLACE, 'dhcpHWAddress', ["ethernet "+ self.mac])
|
||
]
|
||
|
||
self.ldap.modify("cn="+self.name+",cn="+self.group +",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
return "OK"
|
||
|
||
def delete(self):
|
||
if self.type=="thinclient":
|
||
self.ldap.delete('cn='+ self.name +',cn=' +self.group +',cn=THINCLIENTS,cn=DHCP Config')
|
||
if self.type=="thinclient":
|
||
self.ldap.delete('cn='+ self.name +',cn=' +self.group +',cn=THINCLIENTS,cn=DHCP Config')
|
||
|
||
return "OK"
|
||
return "OK"
|
||
|
||
def wakeup(self):
|
||
from Plugins import NetworkUtils
|
||
NetworkUtils.startup(self.mac)
|
||
|
||
from Plugins import NetworkUtils
|
||
NetworkUtils.startup(self.mac)
|
||
|
||
def groupOverflow(self,overflow):
|
||
if self.type == 'thinclient':
|
||
search = self.ldap.search("cn=" + self.group +",cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn"])
|
||
if len(search)-2 >= overflow:
|
||
return True
|
||
|
||
return False
|
||
|
||
if self.type == 'thinclient':
|
||
search = self.ldap.search("cn=" + self.group +",cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn"])
|
||
if len(search)-2 >= overflow:
|
||
return True
|
||
|
||
return False
|
||
|
||
def existsHostname(self):
|
||
|
||
if self.type == 'thinclient':
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn"])
|
||
else:
|
||
result = self.ldap.search("ou=hosts","cn="+self.name,["cn"])
|
||
|
||
if len(result) > 0:
|
||
return True
|
||
|
||
return False
|
||
|
||
|
||
if self.type == 'thinclient':
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn"])
|
||
else:
|
||
result = self.ldap.search("ou=hosts","cn="+self.name,["cn"])
|
||
|
||
if len(result) > 0:
|
||
return True
|
||
|
||
return False
|
||
|
||
def existsMAC(self):
|
||
# Compruebo con las macs de la rama hosts
|
||
if self.type == 'thinclient':
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","dhcpHWAddress=*",["dhcpHWAddress"])
|
||
for i in range (0, len(result) - 1):
|
||
if result [i][0][1]['dhcpHWAddress'][0].replace ("ethernet ", "") == self.mac:
|
||
return True
|
||
else:
|
||
result = self.ldap.search("ou=hosts","macAddress="+self.mac,["macAddress"])
|
||
# Compruebo con las macs de la rama hosts
|
||
if self.type == 'thinclient':
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","dhcpHWAddress=*",["dhcpHWAddress"])
|
||
for i in range (0, len(result) - 1):
|
||
if result [i][0][1]['dhcpHWAddress'][0].replace ("ethernet ", "") == self.mac:
|
||
return True
|
||
else:
|
||
result = self.ldap.search("ou=hosts","macAddress="+self.mac,["macAddress"])
|
||
|
||
if len(result) > 0:
|
||
return True
|
||
|
||
return False
|
||
|
||
if len(result) > 0:
|
||
return True
|
||
|
||
return False
|
||
|
||
def existsIP (self):
|
||
# Cojo las ips de la rama hosts -> arpa -> in-addr
|
||
result = self.ldap.search ("dc=23,dc=172,dc=in-addr,dc=arpa,ou=hosts", "dc=*",["associatedDomain"])
|
||
|
||
myIP = self.ip.split (".")
|
||
# Cojo las ips de la rama hosts -> arpa -> in-addr
|
||
result = self.ldap.search ("dc=23,dc=172,dc=in-addr,dc=arpa,ou=hosts", "dc=*",["associatedDomain"])
|
||
|
||
myIP = self.ip.split (".")
|
||
|
||
for i in range (0, len (result) -1):
|
||
reverseIP = result [i][0][1]['associatedDomain'][0].replace (".in-addr.arpa","").split(".")
|
||
reverseIP.reverse()
|
||
if myIP == reverseIP:
|
||
return True
|
||
|
||
return False
|
||
|
||
for i in range (0, len (result) -1):
|
||
reverseIP = result [i][0][1]['associatedDomain'][0].replace (".in-addr.arpa","").split(".")
|
||
reverseIP.reverse()
|
||
if myIP == reverseIP:
|
||
return True
|
||
|
||
return False
|
||
|
||
def getThinclientGroups (self):
|
||
|
||
groups = []
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=group*",["cn"])
|
||
|
||
for g in search:
|
||
groups.append (g[0][1]["cn"][0])
|
||
|
||
return { "groups":groups }
|
||
|
||
groups = []
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=group*",["cn"])
|
||
|
||
for g in search:
|
||
groups.append (g[0][1]["cn"][0])
|
||
|
||
return { "groups":groups }
|
||
|
||
def getInternalGroups (self):
|
||
|
||
groups = []
|
||
search = self.ldap.search("cn=INTERNAL,cn=DHCP Config","cn=group*",["cn"])
|
||
|
||
for g in search:
|
||
groups.append (g[0][1]["cn"][0])
|
||
|
||
return { "groups":groups }
|
||
|
||
def getHostData(self):
|
||
#self.getUserGroups()
|
||
if self.type == "thinclient":
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn","dhcpHWAddress"])
|
||
|
||
dataHost = {
|
||
"cn":result[0][0][1]["cn"][0],
|
||
"mac":result[0][0][1]["dhcpHWAddress"][0].replace("ethernet ",""),
|
||
"group":self.group
|
||
}
|
||
|
||
return dataHost
|
||
|
||
|
||
|
||
groups = []
|
||
search = self.ldap.search("cn=INTERNAL,cn=DHCP Config","cn=group*",["cn"])
|
||
|
||
for g in search:
|
||
groups.append (g[0][1]["cn"][0])
|
||
|
||
return { "groups":groups }
|
||
|
||
def getHostData(self):
|
||
result1 = self.ldap.search("cn=DHCP Config","cn="+self.name,["cn","dhcpHWAddress"])
|
||
result2 = self.ldap.search(" ou=hosts","dc="+self.name,["aRecord"])
|
||
dataHost = {
|
||
"cn":self.name,
|
||
"group":self.group,
|
||
"mac":"",
|
||
"ip":""
|
||
}
|
||
if len(result1)==1:
|
||
dataHost["mac"]=result1[0][0][1]["dhcpHWAddress"][0].replace("ethernet ","")
|
||
if len(result2)==1:
|
||
dataHost["ip"]=result2[0][0][1]["aRecord"][0]
|
||
|
||
return dataHost
|
||
|
||
|
||
def getLTSPServers (self):
|
||
triplets = self.ldap.search("ou=Netgroup","cn=ltsp-server-hosts",["nisNetgroupTriple"])
|
||
triplets = triplets [0][0][1]["nisNetgroupTriple"]
|
||
hostnames=list()
|
||
|
||
for node in triplets:
|
||
name = node.replace(",-,-)","").replace("(","")
|
||
hostnames.append(name)
|
||
hostnames.sort()
|
||
return hostnames
|
||
triplets = self.ldap.search("ou=Netgroup","cn=ltsp-server-hosts",["nisNetgroupTriple"])
|
||
triplets = triplets [0][0][1]["nisNetgroupTriple"]
|
||
hostnames=list()
|
||
|
||
for node in triplets:
|
||
name = node.replace(",-,-)","").replace("(","")
|
||
hostnames.append(name)
|
||
hostnames.sort()
|
||
return hostnames
|
||
|
||
|
||
def getLTSPStatus (self):
|
||
from Utils.avahiClient import avahiClient
|
||
import threading
|
||
|
||
a = avahiClient()
|
||
a.start()
|
||
time.sleep(1000)
|
||
a.cancel()
|
||
names = a.getList()
|
||
print names
|
||
|
||
"""a = avahiClient()
|
||
time.sleep(1000)
|
||
names = a.getList()
|
||
print names
|
||
a.kill()"""
|
||
return names
|
||
from Utils.avahiClient import avahiClient
|
||
import threading
|
||
|
||
a = avahiClient()
|
||
a.start()
|
||
time.sleep(1000)
|
||
a.cancel()
|
||
names = a.getList()
|
||
print names
|
||
|
||
"""a = avahiClient()
|
||
time.sleep(1000)
|
||
names = a.getList()
|
||
print names
|
||
a.kill()"""
|
||
return names
|
||
|
||
# def wakeup(self):
|
||
# from twisted.internet.task import LoopingCall
|
||
# from twisted.internet import defer
|
||
# from Plugins import NetworkUtils
|
||
# NetworkUtils.startup(self.mac)
|
||
|
||
# def wakeup(self):
|
||
# from twisted.internet.task import LoopingCall
|
||
# from twisted.internet import defer
|
||
# from Plugins import NetworkUtils
|
||
# NetworkUtils.startup(self.mac)
|
||
|
||
|
||
# Encender el equipo
|
||
#def wakeup(self):
|
controlies/branches/web2py/applications/controlies/views/layout_form_hosts.html | ||
---|---|---|
<script language="javascript">
|
||
|
||
$(function() {
|
||
$("#name").focus();
|
||
$("#saveButton").button({ icons: { primary: "ui-icon-disk"}});
|
||
|
||
$("#cancelButton")
|
||
.button({ icons: { primary: "ui-icon-close"}})
|
||
.click( function(){ $('#dialog-form').dialog('close'); });
|
||
});
|
||
|
||
function restartStyle(){
|
||
$("#form_data p span").css("color","black");
|
||
$('#message').html("");
|
||
}
|
||
|
||
|
||
function send(){
|
||
|
||
restartStyle();
|
||
|
||
{{block controlador}}
|
||
jQuery.post('call/json/modify', jQuery("#form_data").serialize(), function(result) {
|
||
{{end}}
|
||
//var result = $.parseJSON(data);
|
||
switch(result.response){
|
||
case "OK":{
|
||
jQuery('#message').html("Operación realizada correctamente").css("color","green").effect("highlight", {"color":"yellow"}, 1000);
|
||
setTimeout("$('#dialog-form').dialog('close')",1000);
|
||
jQuery("#list").trigger("reloadGrid");
|
||
break;
|
||
}
|
||
case "fail":{
|
||
jQuery('#message').html("Se produjo un error").effect("highlight", {"color":"yellow"}, 1000);
|
||
break;
|
||
}
|
||
case "hostAlreadyExists":{
|
||
jQuery('#nameTag').css("color","red");
|
||
jQuery('#name').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Ya existe ese nombre de host").effect("slide");
|
||
break;
|
||
}
|
||
case "macAlreadyExists":{
|
||
jQuery('#macTag').css("color","red");
|
||
jQuery('#mac').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Ya existe un host con esa MAC").effect("slide");
|
||
break;
|
||
}
|
||
case "ipAlreadyExists":{
|
||
jQuery('#ipTag').css("color","red");
|
||
jQuery('#ip').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Ya existe un host con esa IP").effect("slide");
|
||
break;
|
||
}
|
||
case "groupOverflow":{
|
||
jQuery('#groupTag').css("color","red");
|
||
jQuery('#group').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("El grupo escogido esta completo").effect("slide");
|
||
break;
|
||
}
|
||
default:{
|
||
jQuery('#'+result.response+"Tag").css("color","red");
|
||
jQuery('#'+result.response).effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Hay campos vacíos o incorrectos").effect("slide");
|
||
break;
|
||
}
|
||
}
|
||
});
|
||
|
||
return false;
|
||
}
|
||
|
||
</script>
|
||
|
||
|
||
<form id="form_data" onSubmit="return send();">
|
||
<input type="hidden" id="action" name="action"/>
|
||
{{block form_table}}
|
||
<input type="hidden" id="type" name="type" value="ltsp"/>
|
||
<p><span id="nameTag">Nombre del equipo:</span><br><input type="text" id="name" name="name" onChange="searchUsername();"/></p>
|
||
<p><span id="ipTag">Ip</span><br><input type="text" id="ip" name="ip"/></p>
|
||
<p><span id="macTag">MAC</span><br><input type="text" id="mac" name="mac"/></p>
|
||
|
||
{{end}}
|
||
|
||
<div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
|
||
<div style="text-align:center;"><button id="saveButton" type="submit" style="width:100px;">Guardar</button> <button type="button" id="cancelButton" style="width:100px;">Cancelar</button></div>
|
||
<p style="padding-top:10px; text-align:center; font-size:10px;" id="messageForm"></p>
|
||
</form>
|
controlies/branches/web2py/applications/controlies/views/layout_hosts.html | ||
---|---|---|
{{extend 'layout.html'}}
|
||
<div id="tabla_clientes" class="centerGrid">
|
||
<table width="100%">
|
||
<tr>
|
||
<td style="width:2%"></td>
|
||
<td><table id="list" width="100%"></table></td>
|
||
<td style="width:2%"></td>
|
||
</tr>
|
||
</table>
|
||
<div id="pager" style=""></div>
|
||
<div id="filter" style="margin-left:30%;display:none">Search Invoices</div>
|
||
</div>
|
||
|
||
<div id="dialog-form"></div>
|
||
|
||
<div id="dialog-confirm" title="¿Borrar el registro seleccionado?" style="display:none;">
|
||
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Este elemento quedará permanentemente eliminado. ¿Está seguro?</p>
|
||
</div>
|
||
|
||
<div id="dialog-alert" title="Atención" style="display:none;">
|
||
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Para operar sobre un registro debe seleccionarlo previamente.</p>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function() {
|
||
jQuery("#dialog-confirm").dialog({ autoOpen: false });
|
||
jQuery("#dialog-alert").dialog({ autoOpen: false });
|
||
});
|
||
|
||
function print_grid(){
|
||
jQuery("#list").jqGrid({
|
||
url:"{{=URL(c='hosts',f='call',args=['json','list'])}}",
|
||
data: "{}",
|
||
datatype: 'json',
|
||
mtype: 'GET',
|
||
|
||
{{block camposgrid}}
|
||
colNames:['Nombre','IP','mac'],
|
||
colModel:[
|
||
{name:'cn',index:'cn', width:80, align:"center"},
|
||
{name:'ipHostNumber',index:'ipHostNumber', width:60, align:"center"},
|
||
{name:'macAddress',index:'macAddress', width:60, align:"center"}
|
||
],
|
||
|
||
postData:{type:'ltsp'},
|
||
caption:"Servidores de Aula (LTSP)",
|
||
{{end}}
|
||
rowNum:25,
|
||
height:335,
|
||
width: 800,
|
||
rowList:[25,50,75],
|
||
pager: '#pager',
|
||
sortname: 'cn',
|
||
autowidth: false,
|
||
viewrecords: true,
|
||
sortorder: "desc"
|
||
|
||
});
|
||
|
||
jQuery("#list").jqGrid('navGrid','#pager',{add:false,edit:false,del:false,search:false,refresh:false});
|
||
|
||
jQuery("#list").jqGrid('navButtonAdd','#pager',{
|
||
caption: "Insertar",
|
||
buttonicon :'ui-icon-plus',
|
||
onClickButton : function (){
|
||
addRecord();
|
||
}
|
||
});
|
||
jQuery("#list").jqGrid('navButtonAdd','#pager',{
|
||
caption: "Modificar",
|
||
buttonicon :'ui-icon-pencil',
|
||
onClickButton : function (){
|
||
modifyRecord();
|
||
}
|
||
});
|
||
jQuery("#list").jqGrid('navButtonAdd','#pager',{
|
||
caption: "Borrar",
|
||
buttonicon :'ui-icon-trash',
|
||
onClickButton : function (){
|
||
deleteRecord();
|
||
}
|
||
});
|
||
|
||
jQuery("#list").jqGrid('filterToolbar');
|
||
|
||
}
|
||
|
||
function rowSelected(){
|
||
var id = jQuery("#list").jqGrid('getGridParam','selrow');
|
||
|
||
if( id == null ){
|
||
jQuery( "#dialog-alert" ).dialog({
|
||
resizable: false,
|
||
height:150,
|
||
width:290,
|
||
modal: true,
|
||
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
|
||
}).dialog('open');
|
||
return false;
|
||
}
|
||
return id;
|
||
}
|
||
|
||
|
||
function getCell (column) {
|
||
var rowid = jQuery("#list").jqGrid('getGridParam', 'selrow');
|
||
|
||
if( rowid == null ){
|
||
jQuery( "#dialog-alert" ).dialog({
|
||
resizable: false,
|
||
height:150,
|
||
width:290,
|
||
modal: true,
|
||
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
|
||
}).dialog('open');
|
||
return false;
|
||
}
|
||
|
||
var Cell = jQuery("#list").jqGrid('getCell', rowid, column);
|
||
|
||
|
||
return Cell;
|
||
}
|
||
|
||
function getThinClientGroups(selected) {
|
||
jQuery.post('call/json/getThinclientGroups', function(result) {
|
||
|
||
var selectGrupos = document.getElementById("group");
|
||
|
||
for (i=0;i<result.response.groups.length;i++) {
|
||
var optn = document.createElement("option");
|
||
optn.text = result.response.groups[i];
|
||
optn.value = result.response.groups[i];
|
||
if (selected==optn.text)
|
||
optn.selected = true;
|
||
selectGrupos.options.add (optn);
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function modifyRecord(){
|
||
var hid;
|
||
var group;
|
||
jQuery("#messageLoading").show();
|
||
|
||
var hid = rowSelected();
|
||
var group = getCell("groupName");
|
||
if(hid==false)
|
||
return false;
|
||
|
||
jQuery("#dialog-form").html("").css("display","none");
|
||
{{block edit_form}}
|
||
jQuery("#dialog-form").load("form_ltspserver.html", function() {
|
||
|
||
|
||
{{end}}
|
||
jQuery("#form_data #action").val("modify");
|
||
jQuery("#form_data #name").attr("readonly","true");
|
||
jQuery("#form_data #name").css("background-color","#DDD");
|
||
jQuery("#form_data #group").attr("readonly","true");
|
||
jQuery("#form_data #group").css("background-color","#DDD");
|
||
{{block edit2_form}}
|
Exportar a: Unified diff
Completando funcionalidades de ControlIES