# ok, res = sdclient_v1.get_dashboards() if not ok: print(res) sys.exit(1) for dashboard in res['dashboards']: file_name = '{}.json'.format(dashboard['id']) print( ('Saving v1 dashboard {} to file {}...'.format(dashboard['name'], file_name))) sdclient_v1.save_dashboard_to_file(dashboard, file_name) print('Importing dashboard to v2...') ok, res = sdclient_v2.create_dashboard_from_file( 'import of {}'.format(dashboard['name']), file_name, None, shared=dashboard['isShared'], public=dashboard['isPublic']) if ok: print(('Dashboard {} imported!'.format(dashboard['name']))) sdclient_v2.delete_dashboard(res['dashboard']) else: print(('Dashboard {} import failed:'.format(dashboard['name']))) print(res) print('\n')
# # Serialize the first user dashboard to disk # ok, res = sdclient.get_dashboards() if not ok: print(res) sys.exit(1) if len(res['dashboards']) > 0: sdclient.save_dashboard_to_file(res['dashboards'][0], 'dashboard.json') else: print('the user has no dashboards. Exiting.') sys.exit(0) # # Now create the dashboard from the file. We use a filter for the Cassandra process # as an example. # dashboardFilter = 'proc.name = "cassandra"' ok, res = sdclient.create_dashboard_from_file('test dasboard from file', 'dashboard.json', dashboardFilter) if ok: print('Dashboard created successfully') else: print(res) sys.exit(1)