Revisión 106
Añadido por Francisco Damián Méndez Palma hace alrededor de 14 años
controlies/trunk/Plugins/Hosts.py | ||
---|---|---|
"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)
|
||
|
||
... | ... | |
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"])
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn","dhcpHWAddress"])
|
||
filter="(|(dhcpOption=*subnet*)(dhcpOption=*log*))"
|
||
import pdb
|
||
|
||
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"]],
|
||
"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]
|
||
"dhcpHWAddress":i[0][1]["dhcpHWAddress"][0],
|
||
"groupName":i[0][1]["dhcpHWAddress"][0]
|
||
}
|
||
#row = { "cn":i[0][0], "cell":[i[0][1]["cn"][0], i[0][1]["dhcpHWAddress"][0]]}
|
||
rows.append(row)
|
||
|
||
if len(rows) > 0:
|
||
totalPages = ceil( len(rows) / int(limit) )
|
||
else:
|
||
... | ... | |
('dhcpHWAddress', ['ethernet ' + self.mac] )
|
||
]
|
||
|
||
self.ldap.add("cn="+self.name +",cn=group2,cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
self.ldap.add("cn="+self.name +",cn="+self.group+",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
|
||
... | ... | |
]
|
||
self.ldap.modify_s('uid='+ uid +',cn=hosts', mod_attrs)
|
||
|
||
def delete(self,uid):
|
||
self.ldap.delete('uid='+ uid +',cn=hosts')
|
||
def delete(self):
|
||
if self.type=="thinclient":
|
||
self.ldap.delete('cn='+ self.name +',cn=' +self.group +',cn=THINCLIENTS,cn=DHCP Config')
|
||
|
||
return "OK"
|
||
|
||
def wakeup(self):
|
||
from Plugins import NetworkUtils
|
||
NetworkUtils.startup(self.mac)
|
||
... | ... | |
def existsMAC(self):
|
||
# Compruebo con las macs de la rama hosts
|
||
if self.type == 'thinclient':
|
||
#search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=a*",["dhcpHWAddress"])
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","dhcpHWAddress=*",["dhcpHWAddress"])
|
||
|
||
for i in range (0, len(result) - 1):
|
controlies/trunk/www/thinclients/index.html | ||
---|---|---|
url:'hosts?action=list&type=thinclient',
|
||
mtype: 'POST',
|
||
datatype: "json",
|
||
colNames:['Nombre','mac'],
|
||
colNames:['Nombre','MAC','Grupo'],
|
||
colModel:[
|
||
{name:'cn',index:'cn', width:80, align:"center"},
|
||
{name:'macAddress',index:'dhcpHWAddress', width:60, align:"center"}
|
||
{name:'macAddress',index:'dhcpHWAddress', width:60, align:"center"},
|
||
{name:'groupName',index:'groupName', width:60, align:"center"}
|
||
],
|
||
rowNum:25,
|
||
height:335,
|
||
... | ... | |
caption: "Modificar",
|
||
buttonicon :'ui-icon-pencil',
|
||
onClickButton : function (){
|
||
handleRecord('modify','Modificar Usuario');
|
||
modifyRecord();
|
||
}
|
||
});
|
||
$("#list").jqGrid('navButtonAdd','#pager',{
|
||
... | ... | |
$("#list").jqGrid('filterToolbar');
|
||
}
|
||
|
||
|
||
function getCell (column) {
|
||
var rowid = $("#list").jqGrid('getGridParam', 'selrow');
|
||
|
||
if( rowid == null ){
|
||
$( "#dialog-alert" ).dialog({
|
||
resizable: false,
|
||
height:150,
|
||
width:290,
|
||
modal: true,
|
||
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
|
||
}).dialog('open');
|
||
return false;
|
||
}
|
||
|
||
var Cell = $("#list").jqGrid('getCell', rowid, column);
|
||
|
||
|
||
return Cell;
|
||
}
|
||
|
||
|
||
function rowSelected(){
|
||
var id = $("#list").jqGrid('getGridParam','selrow');
|
||
|
||
... | ... | |
}
|
||
});
|
||
}
|
||
function deleteRecord(){
|
||
|
||
function deleteRecord(){
|
||
|
||
var id = rowSelected();
|
||
if(id==false)
|
||
var cn = rowSelected();
|
||
var grupo = getCell("groupName");
|
||
|
||
if(cn==false)
|
||
return false;
|
||
|
||
$( "#dialog-confirm" ).dialog({
|
||
... | ... | |
modal: true,
|
||
buttons: {
|
||
"Borrar": function() {
|
||
$.post("users","idUser="+id+"&action=delete", function(data){
|
||
$( this ).dialog( "close" );
|
||
$.post("hosts","cn="+cn+"&action=delete&type=thinclient&group="+grupo, function(data){
|
||
$("#dialog-confirm").dialog( "close" );
|
||
$("#list").trigger("reloadGrid");
|
||
});
|
||
},
|
||
"Cancelar": function() {
|
||
$( this ).dialog( "close" );
|
||
$(this).dialog( "close" );
|
||
}
|
||
}
|
||
}).dialog('open');
|
||
}
|
||
}
|
||
|
||
function loadGroups () {
|
||
|
||
... | ... | |
}).dialog('option', 'position', [x, y]);
|
||
});
|
||
}
|
||
|
||
function modifyRecord(){
|
||
var uid;
|
||
|
||
$("#messageLoading").show();
|
||
|
||
var uid = rowSelected();
|
||
if(uid==false)
|
||
return false;
|
||
|
||
$("#dialog-form").html("").css("display","none");
|
||
$("#dialog-form").load("users/form.html", function() {
|
||
|
||
getAllGroups();
|
||
|
||
$("#form_data #action").val("modify");
|
||
$("#form_data #user").attr("readonly","true");
|
||
$("#form_data #user").css("background-color","#DDD");
|
||
$("#form_data #messageForm").html("Si deja la contraseña en blanco no se modificará<br>El resto de campos son obligatorios");
|
||
|
||
$.post('users', 'action=getUserData&user='+uid, function(data) {
|
||
var result = $.parseJSON(data);
|
||
|
||
if(result.response['type']=="teacher")
|
||
var textType = "Profesor";
|
||
else
|
||
var textType = "Alumno";
|
||
|
||
var dep = Array(result.response['groups']['departments']);
|
||
|
||
$("#form_data #type").replaceWith(textType+"<input type='hidden' id='type' name='type' value='"+result.response['type']+"'/>");
|
||
$("#form_data #name").val(result.response['name']);
|
||
$("#form_data #nif").val(result.response['nif']);
|
||
$("#form_data #user").val(result.response['user']);
|
||
$("#form_data #surname").val(result.response['surname']);
|
||
|
||
$("#form_data #photo").attr("src","data:image/png;base64,"+result.response['photo']);
|
||
|
||
$.each(result.response['groups']['departments'], function(i, l){
|
||
$('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
||
});
|
||
|
||
$.each(result.response['groups']['classrooms'], function(i, l){
|
||
$('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
||
});
|
||
|
||
x = ($(window).width()-300)/2;
|
||
y = ($(window).height()-500)/2;
|
||
|
||
$("#messageLoading").hide();
|
||
|
||
$("#dialog-form").dialog({
|
||
resizable: false,
|
||
modal: true,
|
||
width: 300,
|
||
title: "Modificar Usuario"
|
||
}).dialog('option', 'position', [x, y]);
|
||
});
|
||
});
|
||
}
|
||
|
||
</script>
|
||
|
||
<div id="tabla_clientes">
|
controlies/trunk/MainLoop.py | ||
---|---|---|
return json.dumps({ "students" : s.Hosts() })
|
||
|
||
|
||
else:
|
||
elif request.args['action'][0]=="delete":
|
||
h = Hosts(l,request.args['cn'][0],"","",request.args['group'][0],request.args['type'][0])
|
||
response = h.process(request.args['action'][0])
|
||
return json.dumps({"response" : response})
|
||
else: #add
|
||
if request.args ['type'][0] == 'thinclient':
|
||
ip = ""
|
||
else:
|
||
ip = request.args ['ip'][0]
|
||
|
||
h = Hosts(l,request.args['name'][0],ip,request.args['mac'][0],request.args['group'][0],request.args['type'][0])
|
||
|
||
response = h.process(request.args['action'][0])
|
||
return json.dumps({"response" : response})
|
||
|
controlies/trunk/Server.py | ||
---|---|---|
|
||
# Start up the web service.
|
||
Root = MainLoop.ControlIESProtocol() #Resource object
|
||
Root.PageDir='/home/manu/proyectos/controlies/trunk/www/'
|
||
#Root.PageDir='/home/chisco/Proyectos/controlies/www'
|
||
#Root.PageDir='/home/manu/proyectos/controlies/trunk/www/'
|
||
Root.PageDir='/home/chisco/Proyectos/controlies/trunk/www'
|
||
site = server.Site(Root)
|
||
|
||
fileNameServers = '/tmp/controlIES.ltpsSevers'
|
Exportar a: Unified diff
Altas y bajas de thinclients depuradas