That worked the way it is suppose to, here is my fine code. def menu_config_port(): #Sub-Menu to configure port
clearconsole()
API_KEY = get_meraki_api_key()
dashboard = meraki.DashboardAPI(API_KEY, suppress_logging=True)
organization_id = ''
response = dashboard.organizations.getOrganizationInventoryDevices(
organization_id, total_pages='all'
)
SortedListOfDevices = sorted(response, key=lambda d: d['mac'] if d['name'] is None else d['name'])
device_type = "MS"
devices = []
for item in SortedListOfDevices:
name = item['name'] if item['name'] is None else item['name']
if device_type in item['model']:
devices.append((name, item['serial'] + "$" + name))
questions = [
inquirer.List('inventory',
message = "Pick your switch: ",
choices = devices,
),
]
answers = inquirer.prompt(questions, theme=GreenPassion())
ans = answers["inventory"].split("$")
print (Fore.WHITE,Style.BRIGHT + '\n' + 'Following Switch has been selected: '
+ ' ' + Fore.GREEN,Style.BRIGHT + ans[1]
+ Fore.WHITE,Style.BRIGHT + ":"
+ Fore.YELLOW,Style.BRIGHT + ans[0] + Style.RESET_ALL)
# Select Device
sw_sn = ans[0]
port = input ('\n' + 'What port would you like to update? (1,2...48): ')
print (Fore.BLUE,Style.BRIGHT +'\n' + 'Below is the current information for that port: ' + '\n')
API_KEY = get_meraki_api_key()
dashboard = meraki.DashboardAPI(API_KEY, suppress_logging=True)
serial = (sw_sn)
port_id = (port)
response = dashboard.switch.getDeviceSwitchPort(serial, port_id)
fields = ['portId', 'name', 'enabled', 'poeEnabled', 'type', 'vlan', 'voiceVlan', 'allowedVlans', 'isolationEnabled', 'rstpEnabled', 'stpGuard', 'linkNegotiation']
for field in fields:
print (f"{field}: {response[field]}")
... View more