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:
@ -144,6 +144,17 @@ def _split_routes(value: str) -> Dict:
|
|||||||
return output_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]:
|
def _device_show_parse(data: str) -> List[Dict]:
|
||||||
raw_output: List = []
|
raw_output: List = []
|
||||||
item: Dict = {}
|
item: Dict = {}
|
||||||
@ -166,6 +177,12 @@ def _device_show_parse(data: str) -> List[Dict]:
|
|||||||
item[key_n] = _remove_text_from_value(value_n)
|
item[key_n] = _remove_text_from_value(value_n)
|
||||||
item.update(text_kv)
|
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
|
# get final item
|
||||||
if item:
|
if item:
|
||||||
raw_output.append(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[key_n] = _remove_text_from_value(value_n)
|
||||||
item.update(text_kv)
|
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():
|
if '_route_' in key_n and key_n[-1].isdigit():
|
||||||
item[key_n] = _split_routes(item[key_n])
|
item[key_n] = _split_routes(item[key_n])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user