Martin Polednik has uploaded a new change for review.

Change subject: caps: use storage's getDefaultInitiatorName
......................................................................

caps: use storage's getDefaultInitiatorName

Caps reimplemented the functionality to acquire host's scsi initiator
name. This patch throws away the reimplementation and uses
getDefaultInitiatorName from storage/iscsi, using a small helper to
format the output and handly possible exception correctly.

Although this patch itself does not significantly affect line count of
caps.py, it is better to use the function as provided by storage rather
than reimplementing it with different semantics.

Change-Id: If49286165b7855b96dd88221de06579485d576f4
Signed-off-by: Martin Polednik <mpoled...@redhat.com>
---
M vdsm/caps.py
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/10/54510/1

diff --git a/vdsm/caps.py b/vdsm/caps.py
index f254a96..5568cbf 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -44,6 +44,7 @@
 from vdsm import host
 from vdsm import utils
 import storage.hba
+import storage.iscsi
 from virt import vmdevices
 
 # For debian systems we can use python-apt if available
@@ -174,11 +175,10 @@
     return d
 
 
-def _getIscsiIniName():
+def _iscsi_initiatorname():
     try:
-        with open('/etc/iscsi/initiatorname.iscsi') as f:
-            return _parseKeyVal(f)['InitiatorName']
-    except:
+        return {'InitiatorName': storage.iscsi.getDefaultInitiatorName()}
+    except IOError:
         logging.error('reporting empty InitiatorName', exc_info=True)
     return ''
 
@@ -295,7 +295,7 @@
     caps['packages2'] = _getKeyPackages()
     caps['emulatedMachines'] = machinetype.getEmulatedMachines(
         cpuarch.effective())
-    caps['ISCSIInitiatorName'] = _getIscsiIniName()
+    caps['ISCSIInitiatorName'] = _iscsi_initiatorname()
     caps['HBAInventory'] = storage.hba.HBAInventory()
     caps['vmTypes'] = ['kvm']
 


-- 
To view, visit https://gerrit.ovirt.org/54510
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If49286165b7855b96dd88221de06579485d576f4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoled...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to