Revisión 113
Añadido por Francisco Damián Méndez Palma hace alrededor de 14 años
Hosts.py | ||
---|---|---|
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
|
||
elif action == "modify":
|
||
return "OK"
|
||
elif action == "modify":
|
||
if self.groupOverflow(300):
|
||
return "groupOverflow"
|
||
|
||
if self.existsMAC():
|
||
return "macAlreadyExists"
|
||
|
||
return "OK"
|
||
|
||
def process(self,action):
|
||
... | ... | |
return response
|
||
|
||
if action == "modify":
|
||
val = self.validation()
|
||
val = self.validation(action)
|
||
|
||
if val != "OK":
|
||
return val
|
||
... | ... | |
return "OK"
|
||
|
||
def modify(self):
|
||
mod_attrs = [
|
||
(ldap.MOD_ADD, 'description', 'Author of New Organon'),
|
||
(ldap.MOD_ADD, 'description', 'British empiricist')
|
||
attr = [
|
||
(ldap.MOD_REPLACE, 'cn', [self.name] ),
|
||
(ldap.MOD_REPLACE, 'dhcpHWAddress', ["ethernet "+ self.mac])
|
||
]
|
||
self.ldap.modify_s('uid='+ uid +',cn=hosts', mod_attrs)
|
||
|
||
self.ldap.modify("cn="+self.name+",cn="+self.group +",cn=THINCLIENTS,cn=DHCP Config", attr)
|
||
|
||
return "OK"
|
||
|
||
def delete(self):
|
||
if self.type=="thinclient":
|
||
self.ldap.delete('cn='+ self.name +',cn=' +self.group +',cn=THINCLIENTS,cn=DHCP Config')
|
||
... | ... | |
# Compruebo con las macs de la rama hosts
|
||
if self.type == 'thinclient':
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","dhcpHWAddress=*",["dhcpHWAddress"])
|
||
|
||
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"])
|
||
|
||
... | ... | |
return False
|
||
|
||
def getThinclientGroups (self):
|
||
import pdb
|
||
|
||
groups = []
|
||
search = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn=group*",["cn"])
|
||
... | ... | |
|
||
return { "groups":groups }
|
||
|
||
def getHostData(self):
|
||
#self.getUserGroups()
|
||
if self.type == "thinclient":
|
||
result = self.ldap.search("cn=THINCLIENTS,cn=DHCP Config","cn="+self.name,["cn","dhcpHWAddress"])
|
||
|
||
dataHost = {
|
||
"cn":result[0][0][1]["cn"][0],
|
||
"mac":result[0][0][1]["dhcpHWAddress"][0].replace("ethernet ",""),
|
||
"group":self.group
|
||
}
|
||
|
||
return dataHost
|
||
|
||
|
||
def getLTSPServers (self):
|
||
triplets = self.ldap.search("ou=Netgroup","cn=ltsp-server-hosts",["nisNetgroupTriple"])
|
||
triplets = triplets [0][0][1]["nisNetgroupTriple"]
|
Exportar a: Unified diff
Terminado mantenimiento clientes ligeros (add-delete-modify)