From 8eb149db63b79845efd9f07eac0b915a1878c4a3 Mon Sep 17 00:00:00 2001 From: becue Date: Wed, 8 Aug 2012 00:35:40 +0200 Subject: [PATCH] =?UTF-8?q?[Nolslib]=20Python=202.6=20n'impl=C3=A9mente=20?= =?UTF-8?q?pas=20l'=C3=A9criture=20[@attrib=3D'value']?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ignore-this: 60e19bc82fad22afde3dc989c0526f7c Avec python 2.7, Element.find("BLOB[@attrib='value']") marche bien, mais python 2.6 n'inclut pas ce qu'il faut, du coup, je fais un patch moche. darcs-hash:20120807223540-ab199-c08efe7455373e7d996d19bded05efaa4dfbb79d.gz --- gestion/iscsi/nolslib.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gestion/iscsi/nolslib.py b/gestion/iscsi/nolslib.py index 05150c01..1efc29b0 100755 --- a/gestion/iscsi/nolslib.py +++ b/gestion/iscsi/nolslib.py @@ -101,8 +101,26 @@ class Nols(object): tree = ElementTree(root) Objects = tree.findall("OBJECT[@name='volume-view']") for Object in Objects: - name = Object.findall("PROPERTY[@name='volume-name']")[0].text - lun = Object.findall("OBJECT/PROPERTY[@name='lun']")[0].text + # Quand on passera à wheezy, décommenter ces lignes, et virer + # la merde que j'ai fait juste après. + #name = Object.findall("PROPERTY[@name='volume-name']")[0].text + #lun = Object.findall("OBJECT/PROPERTY[@name='lun']")[0].text + properties = Object.findall("PROPERTY") + for property in properties: + if property.attrib['name'] == "volume-name": + name = property.text + else: + pass + + subObjects = Object.findall("OBJECT") + for subObject in subObjects: + properties = subObject.findall("PROPERTY") + for property in properties: + if property.attrib['name'] == "lun": + lun = property.text + else: + pass + if lun is None: pass else: