summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2013-10-16 17:05:09 -0700
committerAndy Grover <agrover@redhat.com>2013-10-16 17:06:45 -0700
commitf669af1d8dfb427d1b9a546a6787c05f461293cf (patch)
tree05da20f870a53dc79964771048098e38cff533cd
parent072b9ff28b0603a65ea3f9d4b1e91f9e126df654 (diff)
downloadtargetcli-f669af1d8dfb427d1b9a546a6787c05f461293cf.tar.gz
Make use of ethtool module optional
targetcli will now use the python-ethtool module if present to generate a list of possible portal listening addresses, but will still work if it is not present. Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r--targetcli/ui_target.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/targetcli/ui_target.py b/targetcli/ui_target.py
index 0c24146..7919c89 100644
--- a/targetcli/ui_target.py
+++ b/targetcli/ui_target.py
@@ -22,8 +22,11 @@ from rtslib import RTSLibError, RTSLibBrokenLink, utils
from rtslib import NodeACL, NetworkPortal, MappedLUN
from rtslib import Target, TPG, LUN
from configshell import ExecutionError
-import ethtool
import os
+try:
+ import ethtool
+except ImportError:
+ ethtool = None
auth_params = ('userid', 'password', 'mutual_userid', 'mutual_password')
discovery_params = auth_params + ("enable",)
@@ -1242,6 +1245,9 @@ class UIPortals(UINode):
'''
def list_eth_ips():
+ if not ethtool:
+ return []
+
devcfgs = ethtool.get_interfaces_info(ethtool.get_devices())
addrs = set()
for d in devcfgs: