Revisión 85
Añadido por Francisco Damián Méndez Palma hace alrededor de 14 años
controlies/Server.py | ||
---|---|---|
|
||
# Start up the web service.
|
||
Root = MainLoop.ControlIESProtocol() #Resource object
|
||
Root.PageDir='/home/manu/proyectos/controlies/www/'
|
||
#Root.PageDir='/home/chisco/Proyectos/controlies/www'
|
||
#Root.PageDir='/home/manu/proyectos/controlies/www/'
|
||
Root.PageDir='/home/chisco/Proyectos/controlies/www'
|
||
site = server.Site(Root)
|
||
|
||
#my_server = static.File('/home/chisco/workspace/adminies/www/')
|
controlies/Plugins/Hosts.py | ||
---|---|---|
def __init__(self):
|
||
pass
|
||
|
||
def __init__(self,ldap,name,ip,mac,type):
|
||
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
|
||
|
||
def getName (self):
|
||
... | ... | |
|
||
if self.mac == "":
|
||
return "mac"
|
||
|
||
if self.type =="thinclient":
|
||
if self.group == "":
|
||
return "group"
|
||
|
||
if self.type == "":
|
||
return "type"
|
||
... | ... | |
return { "page":page, "total":totalPages, "records":len(search), "rows":result }
|
||
|
||
def add(self):
|
||
maxID = str(self.getMaxID())
|
||
passwd = hashlib.sha1(self.password).hexdigest()
|
||
#maxID = str(self.getMaxID())
|
||
#passwd = hashlib.sha1(self.password).hexdigest()
|
||
|
||
attr = [
|
||
('objectclass', ['top','posixAccount','shadowAccount','person','inetOrgPerson']),
|
||
('uid', [self.user]),
|
||
('cn', [self.name] ),
|
||
('employeenumber', [self.nif] ),
|
||
('sn', [self.surname] ),
|
||
('uidnumber', [maxID] ),
|
||
('gidnumber', [maxID] ),
|
||
('loginshell', ['/bin/bash'] ),
|
||
('homeDirectory', [self.whatHome() + self.user] ),
|
||
#attr = [
|
||
#('objectclass', ['top','posixAccount','shadowAccount','person','inetOrgPerson']),
|
||
#('uid', [self.user]),
|
||
#('cn', [self.name] ),
|
||
#('employeenumber', [self.nif] ),
|
||
#('sn', [self.surname] ),
|
||
#('uidnumber', [maxID] ),
|
||
#('gidnumber', [maxID] ),
|
||
#('loginshell', ['/bin/bash'] ),
|
||
#('homeDirectory', [self.whatHome() + self.user] ),
|
||
#('jpegPhoto', ['jpegPhoto'] ),
|
||
('userpassword', [passwd])
|
||
]
|
||
#('userpassword', [passwd])
|
||
#]
|
||
|
||
self.ldap.add("uid="+self.user+",ou=People", attr)
|
||
#self.ldap.add("uid="+self.user+",ou=People", attr)
|
||
|
||
# Add private group
|
||
attr = [
|
||
('objectclass', ['top','posixGroup','lisGroup']),
|
||
('grouptype', ['private']),
|
||
('gidnumber', [maxID] ),
|
||
('cn', [self.user] ),
|
||
('description', [self.name+' personal group'] )
|
||
]
|
||
#attr = [
|
||
#('objectclass', ['top','posixGroup','lisGroup']),
|
||
#('grouptype', ['private']),
|
||
#('gidnumber', [maxID] ),
|
||
#('cn', [self.user] ),
|
||
#('description', [self.name+' personal group'] )
|
||
#]
|
||
|
||
self.ldap.add("cn="+self.user+",ou=Group", attr)
|
||
#self.ldap.add("cn="+self.user+",ou=Group", attr)
|
||
|
||
|
||
# Add selected groups
|
||
attr = [
|
||
(ldap.MOD_ADD, 'member', ['uid='+self.user+',ou=People,dc=instituto,dc=extremadura,dc=es'] ),
|
||
(ldap.MOD_ADD, 'memberUid', [self.user] )
|
||
]
|
||
#attr = [
|
||
#(ldap.MOD_ADD, 'member', ['uid='+self.user+',ou=People,dc=instituto,dc=extremadura,dc=es'] ),
|
||
#(ldap.MOD_ADD, 'memberUid', [self.user] )
|
||
#]
|
||
|
||
for n in self.departments:
|
||
self.ldap.modify('cn='+ n +',ou=Group', attr)
|
||
#for n in self.departments:
|
||
# self.ldap.modify('cn='+ n +',ou=Group', attr)
|
||
|
||
for n in self.classrooms:
|
||
self.ldap.modify('cn='+ n +',ou=Group', attr)
|
||
#for n in self.classrooms:
|
||
# self.ldap.modify('cn='+ n +',ou=Group', attr)
|
||
|
||
return "OK"
|
||
|
controlies/www/thinclients/index.html | ||
---|---|---|
}).dialog('open');
|
||
}
|
||
|
||
function loadGroups () {
|
||
|
||
}
|
||
|
||
|
||
function addRecord(){
|
||
|
||
$("#dialog-form").html("");
|
||
$("#dialog-form").load("thinclients/form.html", function() {
|
||
$("#form_data #action").val("add");
|
||
$("#form_data #messageForm").html("Todos los campos son obligatorios");
|
||
});
|
||
$("#form_data #messageForm").html("Todos los campos son obligatorios");
|
||
|
||
$.post('hosts','action=getThinclientGroups', function(data) {
|
||
var result = $.parseJSON(data);
|
||
|
||
x = ($(window).width()-250)/2;
|
||
y = ($(window).height()-400)/2;
|
||
var selectGrupos = document.getElementById("group");
|
||
|
||
$("#dialog-form").dialog({
|
||
resizable: false,
|
||
position: top,
|
||
modal: true,
|
||
title: "Añadir Cliente Ligero"
|
||
}).dialog('option', 'position', [x, y]);
|
||
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];
|
||
|
||
selectGrupos.options.add (optn);
|
||
}
|
||
});
|
||
|
||
x = ($(window).width()-250)/2;
|
||
y = ($(window).height()-400)/2;
|
||
|
||
$("#dialog-form").dialog({
|
||
resizable: false,
|
||
position: top,
|
||
modal: true,
|
||
title: "Añadir Cliente Ligero"
|
||
}).dialog('option', 'position', [x, y]);
|
||
});
|
||
}
|
||
</script>
|
||
|
controlies/MainLoop.py | ||
---|---|---|
# Gestion de Grupos
|
||
if command == "hosts":
|
||
from Plugins.Hosts import Hosts
|
||
|
||
import pdb
|
||
if request.args['action'][0] == "list":
|
||
h = Hosts (l,"","","","")
|
||
h = Hosts (l,"","","","","")
|
||
response = h.list(request.args)
|
||
|
||
#prueba para encender un equipo
|
||
... | ... | |
return json.dumps(response)
|
||
|
||
elif request.args['action'][0] == "getThinclientGroups":
|
||
h = Hosts (l,"","","","")
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getThinclientGroups ()
|
||
return json.dumps({"response" : response})
|
||
else:
|
||
... | ... | |
ip = ""
|
||
else:
|
||
ip = request.args ['ip'][0]
|
||
h = Hosts(l,request.args['name'][0],ip,request.args['mac'][0],request.args['type'][0])
|
||
pdb.set_trace()
|
||
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})
|
||
|
Exportar a: Unified diff
Añadido atributo group en clase hosts, identifica rama de grupo del thinclient