diff options
author | 2017-09-07 23:29:16 +0300 | |
---|---|---|
committer | 2017-09-07 23:29:16 +0300 | |
commit | 19f3ee98dc6321362cef4bef581e7e6f859a7aaf (patch) | |
tree | c4467c149acd5aac86d1812fd869100f13550ed0 /app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py | |
parent | f95cd97e11f6d11d5412ef19704dcb6e8b9d022c (diff) |
fix setting of MAC address for host pNIC in VPP
Change-Id: I671460410fc1a6a0fd5fd929a6ef3e9da23ecbdb
Signed-off-by: yayogev <yaronyogev@gmail.com>
Diffstat (limited to 'app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py')
-rw-r--r-- | app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py b/app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py index d783998..13914bb 100644 --- a/app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py +++ b/app/discover/fetchers/cli/cli_fetch_host_pnics_vpp.py @@ -9,12 +9,13 @@ ############################################################################### import re -from discover.fetcher import Fetcher +from discover.fetchers.cli.cli_access import CliAccess from utils.inventory_mgr import InventoryMgr NAME_RE = '^[a-zA-Z]*GigabitEthernet' +MAC_FIELD_RE = '^.*\sEthernet address\s(\S+)(\s.*)?$' -class CliFetchHostPnicsVpp(Fetcher): +class CliFetchHostPnicsVpp(CliAccess): def __init__(self): super().__init__() self.inv = InventoryMgr() @@ -39,6 +40,17 @@ class CliFetchHostPnicsVpp(Fetcher): pnic['id'] = host_id + "-pnic-" + pnic_name pnic['type'] = 'host_pnic' pnic['object_name'] = pnic_name + self.get_pnic_mac_address(pnic) pnic['Link detected'] = 'yes' if pnic['state'] == 'up' else 'no' ret.append(pnic) return ret + + def get_pnic_mac_address(self, pnic): + cmd = 'vppctl show hardware-interfaces {}'.format(pnic['object_name']) + output_lines = self.run_fetch_lines(cmd, ssh_to_host=pnic['host']) + if output_lines: + regexps = [{'name': 'mac_address', 're': MAC_FIELD_RE}] + for line in output_lines: + self.find_matching_regexps(pnic, line, regexps) + if 'mac_address' in pnic: + break |