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()
return int(str)
return default
except ValueError:
- raise LconfError("text value is not integer:", str)
+ raise Lustre.LconfError("text value is not integer: " + str)
def get_first_ref(self, tag):
""" Get the first uuidref of the type TAG. Only
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
node_db = self.lookup_name(node_name)
if not node_db:
return None
- return self.get_tgt_dev(target_uuid)
+ return node_db.get_tgt_dev(target_uuid)
# get all network uuids for this node
def get_networks(self):
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:
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:
return ret
def _update_active(self, tgt, new):
- raise LconfError("updates not implemented for XML")
+ raise Lustre.LconfError("updates not implemented for XML")
# ================================================================
# LDAP Support
parent = None,
url = "ldap://localhost",
user = "cn=Manager, fs=lustre",
- pw = "secret"
+ pw = ""
):
self._name = name
self._attrs = attrs
# 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,