Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: client/third_party/infra_libs/ts_mon/config.py

Issue 2673613003: luci-py: Roll infra_libs. (Closed)
Patch Set: rolll Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/third_party/infra_libs/ts_mon/common/monitors.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import logging 6 import logging
7 import os 7 import os
8 import socket 8 import socket
9 import sys 9 import sys
10 import urlparse 10 import urlparse
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 disabled by command line arguments. 185 disabled by command line arguments.
186 186
187 Args: 187 Args:
188 args (argparse.Namespace): the result of parsing the command line arguments 188 args (argparse.Namespace): the result of parsing the command line arguments
189 """ 189 """
190 # Parse the config file if it exists. 190 # Parse the config file if it exists.
191 config = load_machine_config(args.ts_mon_config_file) 191 config = load_machine_config(args.ts_mon_config_file)
192 endpoint = config.get('endpoint', '') 192 endpoint = config.get('endpoint', '')
193 credentials = config.get('credentials', '') 193 credentials = config.get('credentials', '')
194 autogen_hostname = config.get('autogen_hostname', False) 194 autogen_hostname = config.get('autogen_hostname', False)
195 use_new_proto = config.get('use_new_proto', False)
195 196
196 # Command-line args override the values in the config file. 197 # Command-line args override the values in the config file.
197 if args.ts_mon_endpoint is not None: 198 if args.ts_mon_endpoint is not None:
198 endpoint = args.ts_mon_endpoint 199 endpoint = args.ts_mon_endpoint
199 if args.ts_mon_credentials is not None: 200 if args.ts_mon_credentials is not None:
200 credentials = args.ts_mon_credentials 201 credentials = args.ts_mon_credentials
202 if args.ts_mon_use_new_proto:
203 use_new_proto = args.ts_mon_use_new_proto
201 204
202 if args.ts_mon_target_type == 'device': 205 if args.ts_mon_target_type == 'device':
203 hostname = args.ts_mon_device_hostname 206 hostname = args.ts_mon_device_hostname
204 if args.ts_mon_autogen_hostname or autogen_hostname: 207 if args.ts_mon_autogen_hostname or autogen_hostname:
205 hostname = 'autogen:' + hostname 208 hostname = 'autogen:' + hostname
206 interface.state.target = targets.DeviceTarget( 209 interface.state.target = targets.DeviceTarget(
207 args.ts_mon_device_region, 210 args.ts_mon_device_region,
208 args.ts_mon_device_role, 211 args.ts_mon_device_role,
209 args.ts_mon_device_network, 212 args.ts_mon_device_network,
210 hostname) 213 hostname)
(...skipping 29 matching lines...) Expand all
240 project = url.netloc 243 project = url.netloc
241 topic = url.path.strip('/') 244 topic = url.path.strip('/')
242 interface.state.global_monitor = monitors.PubSubMonitor( 245 interface.state.global_monitor = monitors.PubSubMonitor(
243 credentials, project, topic, use_instrumented_http=True, 246 credentials, project, topic, use_instrumented_http=True,
244 ca_certs=args.ts_mon_ca_certs) 247 ca_certs=args.ts_mon_ca_certs)
245 else: 248 else:
246 logging.error('ts_mon monitoring is disabled because credentials are not ' 249 logging.error('ts_mon monitoring is disabled because credentials are not '
247 'available') 250 'available')
248 elif endpoint.startswith('https://'): 251 elif endpoint.startswith('https://'):
249 interface.state.global_monitor = monitors.HttpsMonitor( 252 interface.state.global_monitor = monitors.HttpsMonitor(
250 endpoint, credentials) 253 endpoint, credentials, ca_certs=args.ts_mon_ca_certs)
251 elif endpoint.lower() == 'none': 254 elif endpoint.lower() == 'none':
252 logging.info('ts_mon monitoring has been explicitly disabled') 255 logging.info('ts_mon monitoring has been explicitly disabled')
253 else: 256 else:
254 logging.error('ts_mon monitoring is disabled because the endpoint provided' 257 logging.error('ts_mon monitoring is disabled because the endpoint provided'
255 ' is invalid or not supported: %s', endpoint) 258 ' is invalid or not supported: %s', endpoint)
256 259
257 interface.state.flush_mode = args.ts_mon_flush 260 interface.state.flush_mode = args.ts_mon_flush
258 interface.state.use_new_proto = args.ts_mon_use_new_proto 261 interface.state.use_new_proto = use_new_proto
259 262
260 if args.ts_mon_flush == 'auto': 263 if args.ts_mon_flush == 'auto':
261 interface.state.flush_thread = interface._FlushThread( 264 interface.state.flush_thread = interface._FlushThread(
262 args.ts_mon_flush_interval_secs) 265 args.ts_mon_flush_interval_secs)
263 interface.state.flush_thread.start() 266 interface.state.flush_thread.start()
264 267
265 standard_metrics.init() 268 standard_metrics.init()
266 269
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/ts_mon/common/monitors.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698