Revisión 215
Añadido por Manu Mora Gordillo hace más de 13 años
controlies/trunk/applications/controlies/views/thinclients/index.html | ||
---|---|---|
});
|
||
}
|
||
|
||
function modifyRecord(){
|
||
var uid;
|
||
|
||
function modifyRecord(){
|
||
jQuery("#messageLoading").show();
|
||
|
||
var uid = rowSelected();
|
||
if(uid==false)
|
||
var name = rowSelected();
|
||
if(name==false)
|
||
return false;
|
||
|
||
jQuery("#dialog-form").html("").css("display","none");
|
||
jQuery("#dialog-form").load("form.html", function() {
|
||
|
||
jQuery("#form_data #action").val("modify");
|
||
jQuery("#form_data #user").attr("readonly","true");
|
||
jQuery("#form_data #user").css("background-color","#DDD");
|
||
jQuery("#form_data #name").attr("readonly","true");
|
||
jQuery("#form_data #name").css("background-color","#DDD");
|
||
jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");
|
||
|
||
jQuery.post('call/json/getHostData',{ username: uid }, function(result) {
|
||
//var result = jQuery.parseJSON(data);
|
||
jQuery.post('call/json/getHostData',{ name: name }, function(result) {
|
||
|
||
jQuery("#form_data #type").replaceWith(textType+"<input type='hidden' id='type' name='type' value='"+result.response['type']+"'/>");
|
||
jQuery("#form_data #name").val(result.response['name']);
|
||
jQuery("#form_data #nif").val(result.response['nif']);
|
||
jQuery("#form_data #user").val(result.response['user']);
|
||
jQuery("#form_data #surname").val(result.response['surname']);
|
||
if (result.response['photo']!='')
|
||
jQuery("#form_data #photo").attr("src","data:image/png;base64,"+result.response['photo']);
|
||
jQuery("#form_data #name").val(result.response['cn']);
|
||
jQuery("#form_data #mac").val(result.response['mac']);
|
||
|
||
$.each(result.response['groups']['departments'], function(i, l){
|
||
jQuery('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
||
});
|
||
|
||
$.each(result.response['groups']['classrooms'], function(i, l){
|
||
jQuery('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
||
});
|
||
|
||
x = (jQuery(window).width()-300)/2;
|
||
y = (jQuery(window).height()-500)/2;
|
||
|
controlies/trunk/applications/controlies/controllers/thinclients.py | ||
---|---|---|
#equivalente a list
|
||
return dict(message="hello from thinclients.py")
|
||
|
||
@service.json
|
||
def getThinclientGroups():
|
||
l=conecta()
|
||
h = Hosts (l,"","","","")
|
||
response = h.getThinclientGroups()
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
|
||
@service.json
|
||
def getHostData():
|
||
l=conecta()
|
||
h = Hosts(l,request.vars['cn'],"","",request.vars['type_host'])
|
||
h = Thinclients(l,request.vars['name'],"")
|
||
response = h.getHostData()
|
||
l.close()
|
||
return dict(response=response)
|
||
|
||
@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 = Thinclients (l,"","")
|
||
... | ... | |
def form():
|
||
return dict()
|
||
|
||
def ltspservers():
|
||
return dict()
|
||
|
||
def workstations():
|
||
return dict()
|
||
|
||
def thinclients():
|
||
return dict()
|
||
|
||
def form_thinclient():
|
||
return dict()
|
||
|
||
def form_ltspserver():
|
||
return dict()
|
||
|
||
def call():
|
||
"""
|
||
exposes services. for example:
|
controlies/trunk/applications/controlies/modules/Thinclients.py | ||
---|---|---|
return "macAlreadyExists"
|
||
|
||
elif action == "modify":
|
||
if self.groupOverflow(300):
|
||
return "groupOverflow"
|
||
|
||
if not self.equalMAC():
|
||
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
... | ... | |
('dhcpHWAddress', ['ethernet ' + self.mac] )
|
||
]
|
||
group = self.getFreeGroup()
|
||
|
||
print group["freeGroup"]
|
||
|
||
self.ldap.add("cn="+self.name +",cn="+group["freeGroup"]+",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
... | ... | |
def modify(self):
|
||
|
||
attr = [(ldap.MOD_REPLACE, 'dhcpHWAddress', ['ethernet ' + self.mac])]
|
||
self.ldap.modify("cn="+self.name+",cn="+self.group+",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
self.ldap.modify("cn="+self.name+",cn="+self.getGroup()+",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
|
||
... | ... | |
return False
|
||
|
||
def equalMAC(self):
|
||
result = self.ldap.search("ou=hosts","cn="+self.name,["macAddress"])
|
||
if result[0][0][1]['macAddress'][0] == self.mac:
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["dhcpHWAddress"])
|
||
if result[0][0][1]['dhcpHWAddress'][0].replace ("ethernet ", "") == self.mac:
|
||
return True
|
||
|
||
return False
|
||
... | ... | |
def getName (self):
|
||
return self.mac
|
||
|
||
def getHostData(self):
|
||
g = self.getGroup()
|
||
result = self.ldap.search("cn="+g+",cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn","dhcpHWAddress"])
|
||
|
||
dataHost = {
|
||
"cn":self.name,
|
||
"mac":result[0][0][1]["dhcpHWAddress"][0].replace("ethernet ","")
|
||
}
|
||
return dataHost
|
||
|
||
def getGroup (self):
|
||
groups = self.getThinclientGroups()
|
||
for g in groups['groups']:
|
||
... | ... | |
|
||
|
||
def groupOverflow(self,group,overflow):
|
||
search = self.ldap.search("cn="+group+",cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn"])
|
||
print len(search)
|
||
search = self.ldap.search("cn="+group+",cn=THINCLIENTS,cn=DHCP Config","cn=*",["cn"])
|
||
if len(search)-2 >= overflow:
|
||
return True
|
||
|
Exportar a: Unified diff
Ya inserta/modifica/borra thinclients