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

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

Issue 1433543003: ts_mon: removed support for https:// endpoints (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fixed overzealous cleanup Created 5 years, 1 month 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 | « infra_libs/ts_mon/api_monitor.py ('k') | infra_libs/ts_mon/test/api_monitor_test.py » ('j') | 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
11 import re 11 import re
12 12
13 import requests 13 import requests
14 14
15 from infra_libs.ts_mon import api_monitor
16 from infra_libs.ts_mon.common import interface 15 from infra_libs.ts_mon.common import interface
17 from infra_libs.ts_mon.common import metric_store 16 from infra_libs.ts_mon.common import metric_store
18 from infra_libs.ts_mon.common import monitors 17 from infra_libs.ts_mon.common import monitors
19 from infra_libs.ts_mon.common import standard_metrics 18 from infra_libs.ts_mon.common import standard_metrics
20 from infra_libs.ts_mon.common import targets 19 from infra_libs.ts_mon.common import targets
21 20
22 21
23 def load_machine_config(filename): 22 def load_machine_config(filename):
24 if not os.path.exists(filename): 23 if not os.path.exists(filename):
25 logging.info('Configuration file does not exist, ignoring: %s', filename) 24 logging.info('Configuration file does not exist, ignoring: %s', filename)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 config = load_machine_config(args.ts_mon_config_file) 173 config = load_machine_config(args.ts_mon_config_file)
175 endpoint = config.get('endpoint', '') 174 endpoint = config.get('endpoint', '')
176 credentials = config.get('credentials', '') 175 credentials = config.get('credentials', '')
177 176
178 # Command-line args override the values in the config file. 177 # Command-line args override the values in the config file.
179 if args.ts_mon_endpoint is not None: 178 if args.ts_mon_endpoint is not None:
180 endpoint = args.ts_mon_endpoint 179 endpoint = args.ts_mon_endpoint
181 if args.ts_mon_credentials is not None: 180 if args.ts_mon_credentials is not None:
182 credentials = args.ts_mon_credentials 181 credentials = args.ts_mon_credentials
183 182
183 interface.state.global_monitor = monitors.NullMonitor()
184
184 if endpoint.startswith('file://'): 185 if endpoint.startswith('file://'):
185 interface.state.global_monitor = monitors.DebugMonitor( 186 interface.state.global_monitor = monitors.DebugMonitor(
186 endpoint[len('file://'):]) 187 endpoint[len('file://'):])
187 elif credentials: 188 elif credentials:
188 if endpoint.startswith('pubsub://'): 189 if endpoint.startswith('pubsub://'):
189 url = urlparse.urlparse(endpoint) 190 url = urlparse.urlparse(endpoint)
190 project = url.netloc 191 project = url.netloc
191 topic = url.path.strip('/') 192 topic = url.path.strip('/')
192 interface.state.global_monitor = monitors.PubSubMonitor( 193 interface.state.global_monitor = monitors.PubSubMonitor(
193 credentials, project, topic, use_instrumented_http=True) 194 credentials, project, topic, use_instrumented_http=True)
194 else: 195 else:
195 interface.state.global_monitor = api_monitor.ApiMonitor( 196 logging.error('Monitoring is disabled because the endpoint provided is '
196 credentials, endpoint, use_instrumented_http=True) 197 'invalid or not supported: %s', endpoint)
197 else: 198 else:
198 logging.error('Monitoring is disabled because --ts-mon-credentials was not ' 199 logging.error('Monitoring is disabled because credentials are not '
199 'set') 200 'available')
200 interface.state.global_monitor = monitors.NullMonitor()
201 201
202 if args.ts_mon_target_type == 'device': 202 if args.ts_mon_target_type == 'device':
203 interface.state.target = targets.DeviceTarget( 203 interface.state.target = targets.DeviceTarget(
204 args.ts_mon_device_region, 204 args.ts_mon_device_region,
205 args.ts_mon_device_role, 205 args.ts_mon_device_role,
206 args.ts_mon_device_network, 206 args.ts_mon_device_network,
207 args.ts_mon_device_hostname) 207 args.ts_mon_device_hostname)
208 if args.ts_mon_target_type == 'task': # pragma: no cover 208 if args.ts_mon_target_type == 'task': # pragma: no cover
209 # Reimplement ArgumentParser.error, since we don't have access to the parser 209 # Reimplement ArgumentParser.error, since we don't have access to the parser
210 if not args.ts_mon_task_service_name: 210 if not args.ts_mon_task_service_name:
(...skipping 12 matching lines...) Expand all
223 args.ts_mon_task_number) 223 args.ts_mon_task_number)
224 224
225 interface.state.flush_mode = args.ts_mon_flush 225 interface.state.flush_mode = args.ts_mon_flush
226 226
227 if args.ts_mon_flush == 'auto': 227 if args.ts_mon_flush == 'auto':
228 interface.state.flush_thread = interface._FlushThread( 228 interface.state.flush_thread = interface._FlushThread(
229 args.ts_mon_flush_interval_secs) 229 args.ts_mon_flush_interval_secs)
230 interface.state.flush_thread.start() 230 interface.state.flush_thread.start()
231 231
232 standard_metrics.init() 232 standard_metrics.init()
233
OLDNEW
« no previous file with comments | « infra_libs/ts_mon/api_monitor.py ('k') | infra_libs/ts_mon/test/api_monitor_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698