def ztp_actions_all(action): actions = os.listdir(os.path.join(bp.static_folder, 'actions')) if action in actions: file = bp.send_static_file(f'actions/{action}') return response_with_content_type(file, 'text/x-python') return 'Action not found', 404
def ztp_config_mac(mac): device = inventory.device(mac) return response_with_content_type(render_template('config.j2', device=device), 'text/plain')
def test_response_with_content_type(self): expected = {'data': b'expected', 'content_type': 'text/plain'} got = response_with_content_type(expected['data'], expected['content_type']) self.assertEqual(got.data, expected['data']) self.assertEqual(got.content_type, expected['content_type'])
def ztp_bootstrap(): # TODO: Need to replace $SERVER dynamically file = bp.send_static_file('bootstrap') return response_with_content_type(file, 'text/x-python')
def ztp_serial_ztp_finished(serialnum): # TODO: send ZTP finish time. Need to make it persistent across requests #now = datetime.now().strftime('%F %T') return response_with_content_type('finished', 'text/plain')
def ztp_startup_config(serialnum): device = inventory.device(serialnum) return response_with_content_type(render_template('eos.j2', device=device), 'text/plain')
def ztp_cli_commands(): return response_with_content_type(cli_commands, 'text/plain')