Whamcloud - gitweb
- landing b_fid.
[fs/lustre-release.git] / lustre / utils / Lustre / lustredb.py
index 82d487c..12656b5 100644 (file)
@@ -27,6 +27,13 @@ class LustreDB:
             return default
         return None
 
+    def get_hostaddr(self):
+       ret = []
+       list = self.dom_node.getElementsByTagName('hostaddr')
+       for node in list:
+           ret.append(node.firstChild.data)
+       return ret
+                
     def get_class(self):
         return self._get_class()
 
@@ -57,10 +64,17 @@ class LustreDB:
         uuids = self._get_all_refs()
         return uuids
 
-    def nid2server(self, nid, net_type):
+    def get_lov_tgts(self, tag):
+        """ Returns list of lovtgts. """
+        tgts = self._get_lov_tgts(tag)
+        return tgts
+
+    def nid2server(self, nid, net_type, cluster_id):
         netlist = self.lookup_class('network')
         for net_db in netlist:
-            if net_db.get_val('nid') == nid and net_db.get_val('nettype') == net_type: 
+            if (net_db.get_val('nid') == nid and
+                net_db.get_val('nettype') == net_type and
+                net_db.get_val('clusterid') == cluster_id):
                 return net_db
         return None
     
@@ -127,6 +141,10 @@ class LustreDB_XML(LustreDB):
         self.dom_node = dom
         self.root_node = root_node
 
+    def close(self):
+        # do nothing
+        return None
+
     def xmltext(self, dom_node, tag):
         list = dom_node.getElementsByTagName(tag)
         if len(list) > 0:
@@ -177,6 +195,18 @@ class LustreDB_XML(LustreDB):
             uuids.append(self.xml_get_ref(r))
         return uuids
 
+    def _get_lov_tgts(self, tag):
+        """ Get all the refs of type TAG.  Returns list of lov_tgts. """
+        tgts = []
+        tgtlist = self.dom_node.getElementsByTagName(tag)
+        for tgt in tgtlist:
+            uuidref = tgt.getAttribute('uuidref')
+            index = tgt.getAttribute('index')
+            generation = tgt.getAttribute('generation')
+            active = int(tgt.getAttribute('active'))
+            tgts.append((uuidref, index, generation, active))
+        return tgts
+
     def xmllookup_by_uuid(self, dom_node, uuid):
         for n in dom_node.childNodes:
             if n.nodeType == n.ELEMENT_NODE:
@@ -298,7 +328,7 @@ class LustreDB_LDAP(LustreDB):
             # user and pw only needed if modifying db
             self.l.bind_s(self._user, self._pw, ldap.AUTH_SIMPLE);
         except ldap.LDAPError, e:
-            raise Lustre.LconfError('Unable to connection to ldap server')
+            raise Lustre.LconfError('Unable to connect to ldap server:' + self._url)
 
         try:
             self._name, self._attrs = self.l.search_s(self._base,