1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

split dhcp options

This commit is contained in:
Kelly Brazil
2022-02-24 18:22:19 -08:00
parent 19dcef5135
commit 937fa5aad2

View File

@ -144,6 +144,17 @@ def _split_routes(value: str) -> Dict:
return output_dict
def _split_options(value: str) -> Dict:
# ip_address = 192.168.71.180
# requested_broadcast_address = 1
output_dict = {}
k, v = value.split('=')
output_dict['name'] = k.strip()
output_dict['value'] = v.strip()
return output_dict
def _device_show_parse(data: str) -> List[Dict]:
raw_output: List = []
item: Dict = {}
@ -166,6 +177,12 @@ def _device_show_parse(data: str) -> List[Dict]:
item[key_n] = _remove_text_from_value(value_n)
item.update(text_kv)
if '_option_' in key_n and key_n[-1].isdigit():
item[key_n] = _split_options(item[key_n])
if '_route_' in key_n and key_n[-1].isdigit():
item[key_n] = _split_routes(item[key_n])
# get final item
if item:
raw_output.append(item)
@ -189,6 +206,9 @@ def _connection_show_x_parse(data: str) -> List[Dict]:
item[key_n] = _remove_text_from_value(value_n)
item.update(text_kv)
if '_option_' in key_n and key_n[-1].isdigit():
item[key_n] = _split_options(item[key_n])
if '_route_' in key_n and key_n[-1].isdigit():
item[key_n] = _split_routes(item[key_n])