aboutsummaryrefslogtreecommitdiffstats
path: root/app/discover/fetchers/cli/cli_fetch_host_pnics.py
diff options
context:
space:
mode:
authorKoren Lev <korenlev@gmail.com>2017-10-10 18:08:39 +0300
committerKoren Lev <korenlev@gmail.com>2017-10-10 18:08:39 +0300
commit5c6eb170878cefa12f717a62c31f7228d440e61e (patch)
tree1ac74fe56257a68ccf5a35499ba9e458a9b436ed /app/discover/fetchers/cli/cli_fetch_host_pnics.py
parenta947ad2815cea81e126e7813d718531be414b02c (diff)
release 1.1 for euphrates
Change-Id: Iddc0e0148db7c72458b7fcdfcb7664e4aa609be0 Signed-off-by: Koren Lev <korenlev@gmail.com>
Diffstat (limited to 'app/discover/fetchers/cli/cli_fetch_host_pnics.py')
-rw-r--r--app/discover/fetchers/cli/cli_fetch_host_pnics.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/app/discover/fetchers/cli/cli_fetch_host_pnics.py b/app/discover/fetchers/cli/cli_fetch_host_pnics.py
index 4af3ebc..26cd603 100644
--- a/app/discover/fetchers/cli/cli_fetch_host_pnics.py
+++ b/app/discover/fetchers/cli/cli_fetch_host_pnics.py
@@ -19,18 +19,12 @@ class CliFetchHostPnics(CliAccess):
self.inv = InventoryMgr()
self.ethtool_attr = re.compile('^\s+([^:]+):\s(.*)$')
self.regexps = [
- {'name': 'mac_address', 're': '^.*\sHWaddr\s(\S+)(\s.*)?$',
- 'description': 'MAC address with HWaddr'},
- {'name': 'mac_address', 're': '^.*\sether\s(\S+)(\s.*)?$',
- 'description': 'MAC address with ether'},
- {'name': 'IP Address', 're': '^\s*inet addr:?(\S+)\s.*$',
- 'description': 'IP Address with "inet addr"'},
- {'name': 'IP Address', 're': '^\s*inet ([0-9.]+)\s.*$',
- 'description': 'IP Address with "inet"'},
- {'name': 'IPv6 Address', 're': '^\s*inet6 addr:\s*(\S+)(\s.*)?$',
- 'description': 'IPv6 Address with "inet6 addr"'},
- {'name': 'IPv6 Address', 're': '^\s*inet6 \s*(\S+)(\s.*)?$',
- 'description': 'IPv6 Address with "inet6"'}
+ {'name': 'mac_address', 're': '^.*\slink/ether\s(\S+)\s',
+ 'description': 'MAC address'},
+ {'name': 'IP Address', 're': '^\s*inet ([0-9.]+)/',
+ 'description': 'IP Address v4'},
+ {'name': 'IPv6 Address', 're': '^\s*inet6 (\S+) .* global ',
+ 'description': 'IPv6 Address'}
]
def get(self, id):
@@ -52,7 +46,7 @@ class CliFetchHostPnics(CliAccess):
for line in interface_lines:
interface_name = line[line.rindex('/')+1:]
interface_name = interface_name.strip()
- # run ifconfig with specific interface name,
+ # run 'ip address show' with specific interface name,
# since running it with no name yields a list without inactive pNICs
interface = self.find_interface_details(host_id, interface_name)
if interface:
@@ -60,15 +54,15 @@ class CliFetchHostPnics(CliAccess):
return interfaces
def find_interface_details(self, host_id, interface_name):
- lines = self.run_fetch_lines("ifconfig " + interface_name, host_id)
+ cmd = "ip address show {}".format(interface_name)
+ lines = self.run_fetch_lines(cmd, host_id)
interface = None
status_up = None
for line in [l for l in lines if l != '']:
tokens = None
if interface is None:
tokens = line.split()
- line_remainder = line.strip('-')[len(interface_name)+2:]
- line_remainder = line_remainder.strip(' :')
+ line_remainder = line.split(":")[2].strip()
interface = {
"host": host_id,
"name": interface_name,