Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 219

Gestión de workstations

Ver diferencias:

controlies/trunk/applications/controlies/models/menu.py
('Usuarios', False, URL( 'usuarios', 'index' )),
('Grupos', False,URL( 'grupos', 'index' )),
('Servidores LTSP',False, URL( 'hosts', 'ltspservers' )),
('Workstations', False,URL( 'workstations', 'index' )),
('Workstations', False,URL( 'hosts', 'workstations' )),
('Clientes Ligeros', False,URL( 'thinclients', 'index' )),
#('Parámetros DHCP', False,URL( 'dhcpd', 'index' )),
controlies/trunk/applications/controlies/controllers/hosts.py
#equivalente a list
return dict(message="hello from hosts.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()
......
@auth.requires_login()
def list():
l=conecta()
h = Hosts (l,"","","","")
h = Hosts (l,"","","",request.vars['type_host'])
a=request.vars
response = h.list(a)
l.close()
......
@auth.requires_login()
def modify():
l=conecta()
ip=''
if request.vars['type_host']!='thinclient':ip=request.vars['ip']
h = Hosts(l,request.vars['name'],ip,request.vars['mac'],request.vars['type_host'])
h = Hosts(l,request.vars['name'],request.vars['ip'],request.vars['mac'],request.vars['type_host'])
response=h.process(request.vars['action'])
l.close()
return dict(response=response)
......
def workstations():
return dict()
def thinclients():
return dict()
def form_thinclient():
return dict()
def form_ltspserver():
return dict()
controlies/trunk/applications/controlies/modules/Hosts.py
type_host = args['type_host']
if type_host == "ltsp":
if type_host == "ltsp-server-hosts":
# Obtengo todos los elementos del nodo hosts
#search = l.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
#filter = self.buildFilter(args)
......
result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish] }
elif type_host == "workstation":
elif type_host == "workstation-hosts":
# Obtengo todos los elementos del nodo hosts
#search = l.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
search = self.ldap.search("ou=hosts","cn=*",["cn","ipHostNumber","macAddress"])
......
triplets.sort()
attr = [(ldap.MOD_REPLACE, 'nisNetgroupTriple', triplets )]
self.ldap.modify("cn=ltsp-server-hosts,ou=Netgroup", attr)
self.ldap.modify("cn="+self.type_host+",ou=Netgroup", attr)
return "OK"
......
triplets.sort()
attr = [(ldap.MOD_REPLACE, 'nisNetgroupTriple', triplets )]
self.ldap.modify("cn=ltsp-server-hosts,ou=Netgroup", attr)
self.ldap.modify("cn="+self.type_host+",ou=Netgroup", attr)
return "OK"
......
return { "groups":groups }
def getTriplets(self):
triplets = self.ldap.search("ou=Netgroup","cn=ltsp-server-hosts",["nisNetgroupTriple"])
triplets = self.ldap.search("ou=Netgroup","cn="+self.type_host+"",["nisNetgroupTriple"])
print triplets
triplets = triplets [0][0][1]["nisNetgroupTriple"]
return triplets
......
return dataHost
def getLTSPServers (self):
triplets = self.ldap.search("ou=Netgroup","cn=ltsp-server-hosts",["nisNetgroupTriple"])
triplets = self.ldap.search("ou=Netgroup","cn="+self.type_host+"",["nisNetgroupTriple"])
triplets = triplets [0][0][1]["nisNetgroupTriple"]
hostnames=list()
controlies/trunk/applications/controlies/views/hosts/workstations.html
{{extend 'layout_hosts.html'}}
{{block camposgrid}}
colNames:['Nombre','IP','mac'],
colModel:[
{name:'cn',index:'cn', width:80, align:"center"},
{name:'ipHostNumber',index:'ipHostNumber', width:60, align:"center"},
{name:'macAddress',index:'macAddress', width:60, align:"center"}
],
postData:{type:'workstation'},
postData:{type_host:'workstation-hosts'},
caption:"Workstations",
{{end}}
{{block edit2_form}}
jQuery.post('call/json/getHostData',{ cn:hid,type_host:'workstation-hosts' }, function(result) {
{{end}}
{{block edit3_form}}
title: "Modificar Workstation"
{{end}}
......
{{block add_host}}
title: "Añadir Workstation"
{{end}}
{{block delete_host}}
jQuery.post("call/json/delete",{cn:cn,action:'delete',group:grupo,type:'workstation'}, function(data){
jQuery.post("call/json/delete",{cn:cn,action:'delete',type:'workstation-hosts'}, function(data){
{{end}}
controlies/trunk/applications/controlies/views/layout_hosts.html
<script type="text/javascript">
{{block vars_definition}}
{{end}}
jQuery(function() {
jQuery("#dialog-confirm").dialog({ autoOpen: false });
jQuery("#dialog-alert").dialog({ autoOpen: false });
......
data: "{}",
datatype: 'json',
mtype: 'GET',
{{block camposgrid}}
colNames:['Nombre','IP','mac'],
colModel:[
{name:'cn',index:'cn', width:80, align:"center"},
{name:'ipHostNumber',index:'ipHostNumber', width:60, align:"center"},
{name:'macAddress',index:'macAddress', width:60, align:"center"}
],
postData:{type_host:'ltsp'},
{{block camposgrid}}
postData:{type_host:'ltsp-server-hosts'},
caption:"Servidores de Aula (LTSP)",
{{end}}
rowNum:25,
......
}
return id;
}
function getCell (column) {
var rowid = jQuery("#list").jqGrid('getGridParam', 'selrow');
if( rowid == null ){
jQuery( "#dialog-alert" ).dialog({
resizable: false,
height:150,
width:290,
modal: true,
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
}).dialog('open');
return false;
}
var Cell = jQuery("#list").jqGrid('getCell', rowid, column);
return Cell;
}
function getThinClientGroups(selected) {
jQuery.post('call/json/getThinclientGroups', function(result) {
function modifyRecord(){
var selectGrupos = document.getElementById("group");
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];
if (selected==optn.text)
optn.selected = true;
selectGrupos.options.add (optn);
}
});
}
jQuery("#messageLoading").show();
var hid = rowSelected();
if(hid==false)
return false;
function modifyRecord(){
var hid;
var group;
jQuery("#messageLoading").show();
var hid = rowSelected();
var group = getCell("groupName");
if(hid==false)
return false;
jQuery("#dialog-form").html("").css("display","none");
{{block edit_form}}
jQuery("#dialog-form").load("form_ltspserver.html", function() {
{{end}}
jQuery("#form_data #action").val("modify");
jQuery("#form_data #name").attr("readonly","true");
jQuery("#form_data #name").css("background-color","#DDD");
jQuery("#dialog-form").html("").css("display","none");
jQuery("#dialog-form").load("form_ltspserver.html", function() {
jQuery("#form_data #action").val("modify");
jQuery("#form_data #name").attr("readonly","true");
jQuery("#form_data #name").css("background-color","#DDD");
{{block edit2_form}}
jQuery.post('call/json/getHostData',{ cn:hid,type_host:'ltsp' }, function(result) {
jQuery("#form_data #name").val(result.response['cn']);
jQuery("#form_data #ip").val(result.response['ip']);
jQuery("#form_data #mac").val(result.response['mac']);
{{end}}
x = (jQuery(window).width()-300)/2;
y = (jQuery(window).height()-500)/2;
jQuery("#messageLoading").hide();
jQuery("#dialog-form").dialog({
resizable: false,
modal: true,
width: 300,
jQuery.post('call/json/getHostData',{ cn:hid,type_host:'ltsp-server-hosts' }, function(result) {
{{end}}
jQuery("#form_data #name").val(result.response['cn']);
jQuery("#form_data #ip").val(result.response['ip']);
jQuery("#form_data #mac").val(result.response['mac']);
x = (jQuery(window).width()-300)/2;
y = (jQuery(window).height()-500)/2;
jQuery("#messageLoading").hide();
jQuery("#dialog-form").dialog({
resizable: false,
modal: true,
width: 300,
{{block edit3_form}}
title: "Modificar Servidor de aula"
title: "Modificar Servidor de aula"
{{end}}
}).dialog('option', 'position', [x, y]);
});
});
}
}).dialog('option', 'position', [x, y]);
});
});
}
function addRecord(){
jQuery("#dialog-form").html("");
{{block edit_form}}
jQuery("#dialog-form").load("form_ltspserver.html", function() {
{{end}}
jQuery("#form_data #action").val("add");
jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");
});
......
function deleteRecord(){
var cn = rowSelected();
var grupo = getCell("groupName");
if(cn==false)
return false;
jQuery( "#dialog-confirm" ).dialog({
resizable: false,
height:160,
......
buttons: {
"Borrar": function() {
{{block delete_host}}
jQuery.post("call/json/delete",{cn:cn,action:'delete',group:grupo,type_host:'ltsp'}, function(data){
jQuery.post("call/json/delete",{cn:cn,action:'delete',type_host:'ltsp-server-hosts'}, function(data){
{{end}}
jQuery("#dialog-confirm").dialog( "close" );
jQuery("#list").trigger("reloadGrid");
controlies/trunk/applications/controlies/views/layout_form_hosts.html
{{block controlador}}
jQuery.post('call/json/modify', jQuery("#form_data").serialize(), function(result) {
{{end}}
//var result = $.parseJSON(data);
switch(result.response){
case "OK":{
jQuery('#message').html("Operación realizada correctamente").css("color","green").effect("highlight", {"color":"yellow"}, 1000);
......
<input type="hidden" id="action" name="action"/>
{{block form_table}}
<input type="hidden" id="type_host" name="type_host" value="ltsp"/>
<p><span id="nameTag">Nombre del equipo:</span><br><input type="text" id="name" name="name" maxlength="20" onChange="searchUsername();"/></p>
<p><span id="nameTag">Nombre del equipo:</span><br><input type="text" id="name" name="name" maxlength="20"/></p>
<p><span id="ipTag">Ip</span><br><input type="text" id="ip" name="ip" maxlength="15"/></p>
<p><span id="macTag">MAC</span><br><input type="text" id="mac" name="mac" maxlength="17"/></p>

Exportar a: Unified diff