Revisión 89
Añadido por Manu Mora Gordillo 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/Utils/avahiClient.py | ||
---|---|---|
import dbus, gobject, avahi
|
||
from dbus import DBusException
|
||
from dbus.mainloop.glib import DBusGMainLoop
|
||
|
||
class avahiClient(object):
|
||
|
||
names = []
|
||
|
||
def __init__ (self):
|
||
|
||
loop = DBusGMainLoop()
|
||
bus = dbus.SystemBus(mainloop=loop)
|
||
|
||
self.server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, '/'), 'org.freedesktop.Avahi.Server')
|
||
|
||
sbrowser = dbus.Interface(bus.get_object(avahi.DBUS_NAME, self.server.ServiceBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "_workstation._tcp", 'local', dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)
|
||
sbrowser.connect_to_signal("ItemNew", self.myhandler)
|
||
|
||
self.loop = gobject.MainLoop()
|
||
self.loop.run()
|
||
|
||
|
||
def service_resolved(self,*args):
|
||
#print args
|
||
print 'service resolved'
|
||
print 'name:', args[2]
|
||
print 'address:', args[7]
|
||
print 'port:', args[8]
|
||
#print args
|
||
self.names.append(args[2])
|
||
|
||
#self.loop.quit()
|
||
|
||
|
||
def print_error(self,*args):
|
||
print 'error_handler'
|
||
print args[0]
|
||
|
||
def myhandler(self,interface, protocol, name, stype, domain, flags):
|
||
#print "Found service '%s' type '%s' domain '%s' " % (name, stype, domain)
|
||
|
||
if flags & avahi.LOOKUP_RESULT_LOCAL:
|
||
#print "que es esto"
|
||
pass
|
||
|
||
self.server.ResolveService(interface, protocol, name, stype, domain, avahi.PROTO_UNSPEC, dbus.UInt32(0), reply_handler=self.service_resolved, error_handler=self.print_error)
|
||
|
||
def getList(self):
|
||
return self.names
|
||
|
||
def kill(self):
|
||
self.loop.quit()
|
controlies/Plugins/Hosts.py | ||
---|---|---|
|
||
import ldap
|
||
import logging
|
||
import time
|
||
from math import ceil
|
||
from operator import itemgetter
|
||
|
||
... | ... | |
search = self.ldap.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
|
||
|
||
# triplets que contiene los nombres de los ltsp-servers
|
||
#triplets = l.search("ou=Netgroup","cn=ltsp-server-hosts",["nisNetgroupTriple"])
|
||
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 = 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:
|
||
... | ... | |
groups.append (g[0][1]["cn"][0])
|
||
|
||
return { "groups":groups }
|
||
|
||
|
||
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
|
||
|
||
|
||
def getLTSPStatus (self):
|
||
from Utils.avahiClient import avahiClient
|
||
|
||
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
|
controlies/www/main.html | ||
---|---|---|
<li><a href="javascript:loadForm('show','Parametros DHCP')">Parámetros DHCP</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#" class="dir">Gestión</a>
|
||
<ul>
|
||
<li><a href="javascript:loadModule('classroomServers')">Servidores de Aula</a></li>
|
||
</ul>
|
||
</li>
|
||
<!-- <li><a href="#" class="dir">Sincronización</a>
|
||
<ul>
|
||
<li><a href="#">Importación Rayuela</a></li>
|
controlies/www/css/helper.css | ||
---|---|---|
* html ul.dropdown ul { background-image: url(images/dropdown_pane_8bit.png); }
|
||
|
||
.centerAuth{ position:absolute; left:50%; margin-left:-150px; }
|
||
.centerGrid{ position:absolute; left:50%; margin-left:-400px; }
|
||
.centerGrid{ position:absolute; left:50%; margin-left:-450px; }
|
||
|
||
form p{ margin-bottom:10px; font-weight:bold;}
|
||
form input{ border:1px solid #DDD; }
|
controlies/www/classroomServers/index.html | ||
---|---|---|
<style>
|
||
#selectable .ui-selecting { background: #FECA40; }
|
||
#selectable .ui-selected { background: #F39814; color: white; }
|
||
#selectable { list-style-type: none; margin: 0; padding: 0; }
|
||
#selectable li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 80px; height: 95px; font-size: 1px; text-align: center; cursor:pointer; }
|
||
</style>
|
||
<script>
|
||
$(function() {
|
||
$( "#selectable" ).selectable();
|
||
getLTSPServers();
|
||
});
|
||
|
||
function getLTSPServers(){
|
||
$.post('hosts','action=getLTSPServers', function(data) {
|
||
var result = $.parseJSON(data);
|
||
|
||
$.each(result.response, function(i, l){
|
||
$('#selectable').append('<li class="ui-state-default" id="selectable-'+l+'"><div id="pcName" style="font-size:11px;">'+l+'</div><img class="thumb-image" src="img/turnOff.png"/><div id="userName" style="font-size:11px;">ajimenezf01</div></li>');
|
||
});
|
||
|
||
getLTSPStatus();
|
||
});
|
||
}
|
||
|
||
function getLTSPStatus(){
|
||
$.post('hosts','action=getLTSPStatus', function(data) {
|
||
var result = $.parseJSON(data);
|
||
|
||
$.each(result.response, function(i, l){
|
||
$('#selectable').append('<li class="ui-state-default" id="selectable-'+l+'"><div id="pcName" style="font-size:11px;">'+l+'</div><img class="thumb-image" src="img/turnOff.png"/><div id="userName" style="font-size:11px;">ajimenezf01</div></li>');
|
||
});
|
||
|
||
setTimeout("getLTSPStatus()",2000);
|
||
});
|
||
}
|
||
|
||
</script>
|
||
|
||
<ol id="selectable" style="width:900px;"></ol>
|
controlies/www/groups/index.html | ||
---|---|---|
],
|
||
rowNum:25,
|
||
height:335,
|
||
width: 800,
|
||
width: 900,
|
||
rowList:[25,50,75],
|
||
pager: '#pager',
|
||
sortname: 'cn',
|
controlies/www/users/index.html | ||
---|---|---|
],
|
||
rowNum:25,
|
||
height:335,
|
||
width: 800,
|
||
width: 900,
|
||
rowList:[25,50,75],
|
||
pager: '#pager',
|
||
sortname: 'cn',
|
controlies/MainLoop.py | ||
---|---|---|
response = g.process(request.args['action'][0])
|
||
return json.dumps({"response" : response})
|
||
|
||
# Gestion de Grupos
|
||
|
||
if command == "hosts":
|
||
from Plugins.Hosts import Hosts
|
||
import pdb
|
||
... | ... | |
elif request.args['action'][0] == "getThinclientGroups":
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getThinclientGroups ()
|
||
return json.dumps({"response" : response})
|
||
return json.dumps({"response" : response})
|
||
|
||
elif request.args['action'][0] == "getLTSPServers":
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getLTSPServers ()
|
||
return json.dumps({"response" : response})
|
||
|
||
elif request.args['action'][0] == "getLTSPStatus":
|
||
h = Hosts (l,"","","","","")
|
||
response = h.getLTSPStatus ()
|
||
return json.dumps({"response" : response})
|
||
|
||
else:
|
||
if request.args ['type'][0] == 'thinclient':
|
||
ip = ""
|
Exportar a: Unified diff
Intentando implementar avahi