-def _tracing_session_descriptors_from_arg(string):
- # Format is:
- # NAME,ID,HOSTNAME,FREQ,CLIENTS,TRACEPATH[,TRACEPATH]...
- parts = string.split(',')
- name = parts[0]
- tracing_session_id = int(parts[1])
- hostname = parts[2]
- live_timer_freq = int(parts[3])
- client_count = int(parts[4])
- traces = [LttngTrace(path) for path in parts[5:]]
- return LttngTracingSessionDescriptor(
- name, tracing_session_id, hostname, live_timer_freq, client_count, traces
- )
+def _session_descriptors_from_path(sessions_filename, trace_path_prefix):
+ # File format is:
+ #
+ # [
+ # {
+ # "name": "my-session",
+ # "id": 17,
+ # "hostname": "myhost",
+ # "live-timer-freq": 1000000,
+ # "client-count": 23,
+ # "traces": [
+ # {
+ # "path": "lol"
+ # },
+ # {
+ # "path": "meow/mix"
+ # }
+ # ]
+ # }
+ # ]
+ with open(sessions_filename, 'r') as sessions_file:
+ params = json.load(sessions_file)
+
+ sessions = []
+
+ for session in params:
+ name = session['name']
+ tracing_session_id = session['id']
+ hostname = session['hostname']
+ live_timer_freq = session['live-timer-freq']
+ client_count = session['client-count']
+ traces = []
+
+ for trace in session['traces']:
+ path = trace['path']
+
+ if not os.path.isabs(path):
+ path = os.path.join(trace_path_prefix, path)
+
+ traces.append(LttngTrace(path))
+
+ sessions.append(
+ LttngTracingSessionDescriptor(
+ name,
+ tracing_session_id,
+ hostname,
+ live_timer_freq,
+ client_count,
+ traces,
+ )
+ )
+
+ return sessions