I have data like this:
data = [{'1234': [{u'gateway_ip': u'172.20.21.1',
u'ipv6_block': None,
u'private_block': u'172.20.21.0/24',
u'segment_name': u'VLAN1',
u'switch_ports': [{u'name': u'fa0/32',
u'switch_name': u'switch1.local',
u'switch_port_interface_type_name': u'eth'},
{u'name': u'fa0/15',
u'switch_name': u'switch2.local',
u'switch_port_interface_type_name': u'eth'}],
u'vlan_name': u'INSIDE',
u'vlan_number': 2031},
{u'gateway_ip': u'172.20.31.1',
u'ipv6_block': None,
u'private_block': u'172.20.31.0/24',
u'segment_name': u'VLAN2',
u'switch_ports': [{u'name': u'fa0/32',
u'switch_name': u'switch1.local',
u'switch_port_interface_type_name': u'eth'},
{u'name': u'fa0/15',
u'switch_name': u'switch2.local',
u'switch_port_interface_type_name': u'eth'}],
u'vlan_name': u'DMZ',
u'vlan_number': 2037}]}]
I want to parse this data to get something like this:
[{1234:[{switch1.local:[{fa0/32:[2031,2037],{fa0/15:[2031,2037]}}]},{switch2.local:[{fa0/32:[2031,2037],{fa0/15:[2031,2037]}}]}]}]
basically I want to get list of vlans assigned to specific switchport and device
[{device:[{switch1:{port1:[vlans-list]}},{switch1:{port2:[vlans-list]}}]}]
when I do it with append on list what I know now is not correct I get result like that :
[{device:[{switch1:{port1:[vlan1]}},{device:[{switch1:{port2:[vlan2]}]}}]}]
I'm sure this will not make sense to you in first place so please ask questions I will try answer them best I can.