Index: controlies/trunk/applications/controlies/modules/Hosts.py
===================================================================
--- controlies/trunk/applications/controlies/modules/Hosts.py	(revision 224)
+++ controlies/trunk/applications/controlies/modules/Hosts.py	(revision 225)
@@ -122,7 +122,7 @@
         page = int(args['page'])
         start = limit * page - limit
         finish = start + limit;             
-
+        print args
         # sort by field
         sortBy = args['sidx']
         #if sortBy == "uid":
@@ -135,43 +135,60 @@
                                 
         hostnames = self.getListTriplets()
         hostnames_data = {}
-		
-        search = self.ldap.search("cn=INTERNAL,cn=DHCP Config","cn=*",["cn","dhcpHWAddress"])     
+
+        search = self.ldap.search("cn=INTERNAL,cn=DHCP Config","cn=*",["cn","dhcpHWAddress"])
         for s in search:
             if s[0][1]['cn'][0] in hostnames:
 				hostnames_data[s[0][1]['cn'][0]] = {"mac" : s[0][1]['dhcpHWAddress'][0].replace("ethernet ",""), "host":s[0][1]['cn'][0]}						
-
+        
         search = self.ldap.search("dc="+self.domainname+",ou=hosts","dc=*",["dc","aRecord"])
         for s in search:
             if s[0][1]['dc'][0] in hostnames:
 				hostnames_data[s[0][1]['dc'][0]]["ip"] = s[0][1]['aRecord'][0]
-			
+
         rows = []
+
+        try:
+            host_search = args["cn"]
+        except:
+            host_search = ""
+            
+        try:
+            ip_search = args["ipHostNumber"]
+        except:
+            ip_search = ""
+
+        try:
+            mac_search = args["macAddress"]
+        except:
+            mac_search = ""
+            
         for k, v in hostnames_data.iteritems():
             try:
 				host = v["host"]
             except:
-				pass
+				host = ""
 
             try:
 				ip = v["ip"]
             except:
-				pass
+				ip = ""
 
             try:
 				mac = v["mac"]
             except:
-				pass
-				
-            row = {
-				"id":host, 
-				"cell":[host, ip, mac],
-				"cn":host,
-				"ipHostNumber":ip,
-				"macAddress":mac
-			}
-            rows.append(row)
+				mac = ""
 
+            if ((ip_search != "" and ip.find(ip_search)>=0) or (ip_search=="")) and ((mac_search != "" and mac.find(mac_search)>=0) or (mac_search=="")) and ((host_search != "" and host.find(host_search)>=0) or (host_search=="")):
+				row = {
+					"id":host, 
+					"cell":[host, ip, mac],
+					"cn":host,
+					"ipHostNumber":ip,
+					"macAddress":mac
+				}
+				rows.append(row)
+
         if len(rows) > 0:
             totalPages = ceil( len(rows) / int(limit) )
         else:
@@ -181,6 +198,7 @@
 
         result = sorted(rows, key=itemgetter(sortBy), reverse=reverseSort)
         return { "page":page, "total":totalPages, "records":len(rows), "rows":result[start:finish]  }       
+        
 
     def add(self):
         # Hosts
@@ -238,6 +256,22 @@
         ]
         self.ldap.modify("cn="+self.name+",ou=Hosts", attr)"""
 
+        # Hosts->arpa->in-addr->172
+        if not self.equalIP():
+            myIP = self.getIP()
+            if myIP != "":
+				ip = myIP.split(".")
+				self.ldap.delete("dc="+ip[3]+",dc="+ip[2]+",dc="+ip[1]+",dc="+ip[0]+",dc=in-addr,dc=arpa,ou=Hosts")
+				
+				ip = self.ip.split(".")
+				attr = [
+				('objectclass', ['top','dNSDomain2','domainRelatedObject']),
+				('associatedDomain', [ip[3]+"."+ip[2]+"."+ip[1]+"."+ip[0]+".in-addr.arpa"]),
+				('dc', [ip[3]]), 
+				('pTRRecord', [self.name+"."+self.domainname])
+				]
+				self.ldap.add("dc="+ip[3]+",dc="+ip[2]+",dc="+ip[1]+",dc="+ip[0]+",dc=in-addr,dc=arpa,ou=Hosts", attr)
+				
         # Hosts->domain
         attr = [(ldap.MOD_REPLACE, 'aRecord', [self.ip] )]
         self.ldap.modify("dc="+self.name+",dc="+self.domainname+",ou=Hosts", attr)
@@ -250,13 +284,15 @@
 
     def delete(self):
         self.ldap.delete("cn="+self.name+",ou=Hosts")
-        self.ldap.delete("dc="+self.name+",dc="+self.domainname+",ou=Hosts")
         self.ldap.delete("cn="+self.name+",cn=group1,cn=INTERNAL,cn=DHCP Config")
 
+        #Hosts->arpa
         myIP = self.getIP()
         if myIP != "":
             ip = myIP.split(".")
             self.ldap.delete("dc="+ip[3]+",dc="+ip[2]+",dc="+ip[1]+",dc="+ip[0]+",dc=in-addr,dc=arpa,ou=Hosts")
+
+        self.ldap.delete("dc="+self.name+",dc="+self.domainname+",ou=Hosts")
             
         # Netgroup            
         triplets = self.getTriplets()
