Revisión 75
Añadido por Francisco Damián Méndez Palma hace alrededor de 14 años
controlies/Plugins/Hosts.py | ||
---|---|---|
return { "page":page, "total":totalPages, "records":len(search), "rows":result }
|
||
|
||
def add(self):
|
||
#record = [
|
||
#('objectclass', ['person','organizationalperson','inetorgperson']),
|
||
#('uid', ['francis']),
|
||
#('cn', [self.name] ),
|
||
#('sn', ['Bacon'] ),
|
||
#('userpassword', [self.password]),
|
||
#('ou', ['users'])
|
||
#]
|
||
#try:
|
||
# self.ldap.add("cn=hosts", record)
|
||
#except ldap.ALREADY_EXISTS:
|
||
# return "fail"
|
||
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] ),
|
||
#('jpegPhoto', ['jpegPhoto'] ),
|
||
('userpassword', [passwd])
|
||
]
|
||
|
||
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'] )
|
||
]
|
||
|
||
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] )
|
||
]
|
||
|
||
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)
|
||
|
||
return "OK"
|
||
|
||
|
||
def modify(self):
|
||
mod_attrs = [
|
||
(ldap.MOD_ADD, 'description', 'Author of New Organon'),
|
||
... | ... | |
|
||
|
||
def existsHostname(self):
|
||
|
||
|
||
if self.type == 'thinclient':
|
||
result = self.ldap.search("ou=hosts","cn="+self.name,["cn"])
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn"])
|
||
else:
|
||
result = self.ldap.search("ou=hosts","cn="+self.name,["cn"])
|
||
|
||
... | ... | |
return False
|
||
|
||
def existsMAC(self):
|
||
import pdb
|
||
# Compruebo con las macs de la rama hosts
|
||
pdb.set_trace()
|
||
if self.type == 'thinclient':
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=a*",["dhcpHWAddress"])
|
||
|
||
#print search [0][0][1]['dhcpHWAddress'][0]
|
||
#search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=a*",["dhcpHWAddress"])
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","dhcpHWAddress=*",["dhcpHWAddress"])
|
||
|
||
pdb.set_trace()
|
||
result = self.ldap.search("ou=hosts","macAddress="+self.mac,["macAddress"])
|
||
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
|
||
if len(result) > 0:
|
||
return True
|
||
|
||
return False
|
||
|
||
... | ... | |
|
||
return False
|
||
|
||
def getThinclientGroups (self):
|
||
import pdb
|
||
|
||
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 wakeup(self):
|
||
# from twisted.internet.task import LoopingCall
|
||
# from twisted.internet import defer
|
controlies/www/groups/form.html | ||
---|---|---|
});
|
||
return false;
|
||
}
|
||
|
||
|
||
</script>
|
||
|
||
<form id="form_data" onSubmit="return send();">
|
controlies/www/thinclients/index.html | ||
---|---|---|
autowidth: false,
|
||
viewrecords: true,
|
||
sortorder: "desc",
|
||
caption:"Maquinas"
|
||
caption:"Clientes Ligeros"
|
||
});
|
||
|
||
$("#list").jqGrid('navGrid','#pager',{add:false,edit:false,del:false,search:false,refresh:false});
|
controlies/MainLoop.py | ||
---|---|---|
|
||
# Gestion de Grupos
|
||
if command == "hosts":
|
||
|
||
from Plugins.Hosts import Hosts
|
||
|
||
|
||
if request.args['action'][0] == "list":
|
||
h = Hosts (l,"","","","")
|
||
response = h.list(request.args)
|
||
... | ... | |
#print "Encendiendo host "+h.getName()
|
||
#h.wakeup()
|
||
return json.dumps(response)
|
||
|
||
elif request.args['action'][0] == "getThinclientGroups":
|
||
h = Hosts (l,"","","","")
|
||
response = h.getThinclientGroups ()
|
||
return json.dumps({"response" : response})
|
||
else:
|
||
if request.args ['type'][0] == 'thinclient':
|
||
ip = ""
|
Exportar a: Unified diff
Preparando alta de thinclients