def get_device_version(id): device = Device.query.get_or_404(id) hostname = device.hostname ip = device.mgmt_ip prompt = hostname + "#" result = show_version(hostname, prompt, ip, 'cisco', 'cisco') return jsonify({"version": str(result)})
def get_role_version(device_role): device_id_list = [device.id for device in Device.query.all() if device.role == device_role] result = {} for id in device_id_list: device = Device.query.get_or_404(id) hostname = device.hostname ip = device.mgmt_ip prompt = hostname + "#" device_result = show_version(hostname, prompt, ip, 'cisco', 'cisco') result[hostname] = str(device_result) return jsonify(result)