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

Side by Side Diff: appengine/chrome_infra_mon_proxy/common.py

Issue 928043005: Monitoring proxy for time series data (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: More fine-tuning Created 5 years, 8 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
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
ghost stip (do not use) 2015/04/14 00:36:42 rename to something more meaningful like 'credenti
Sergey Berezin (google) 2015/04/15 01:38:09 It is actually a common set of functions, not just
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import hashlib
6 import logging
7 import os
8
9 from google.appengine.ext import ndb
10
11
12 CREDENTIALS_KEY = 'credentials_key'
13
14
15 def is_development_server():
ghost stip (do not use) 2015/04/14 00:36:42 there is another implementation of this, meaning i
Sergey Berezin (google) 2015/04/15 01:38:09 I fixed that, it's now the only (common) implement
16 return os.environ.get('SERVER_SOFTWARE', '').startswith('Development')
17
18
19 class MonAcqData(ndb.Model):
ghost stip (do not use) 2015/04/14 00:36:42 MonAcqCredentials
Sergey Berezin (google) 2015/04/15 01:38:09 It's not only creds, it's also the URL for the end
20 """Store the sensitive endpoint data."""
21 credentials = ndb.JsonProperty()
22 url = ndb.StringProperty()
23 scopes = ndb.StringProperty(repeated=True)
24 headers = ndb.JsonProperty(default={})
25
26
27 def get_data():
ghost stip (do not use) 2015/04/14 00:36:42 def _get_datastore_credentials()
Sergey Berezin (google) 2015/04/15 01:38:09 I'm moving this to vm_module.py, it's the only pla
28 data_entity = MonAcqData.get_by_id(CREDENTIALS_KEY)
29 logging.info('get_data(): entity = %r', data_entity)
30 if not data_entity:
31 return None
32 return data_entity.to_dict()
33
34
35 def get_credentials(credentials_dict, scopes):
ghost stip (do not use) 2015/04/14 00:36:42 def get_credentials(credentials_dict=None, scopes=
Sergey Berezin (google) 2015/04/16 04:39:06 Moved to vm_module. I don't see the need for defau
36 """Obtain Aquisition API credentials as Credentials object."""
37 from oauth2client.client import SignedJwtAssertionCredentials
38
ghost stip (do not use) 2015/04/14 00:36:42 credentials_dict = credentials_dict or self._get_d
Sergey Berezin (google) 2015/04/16 04:39:06 Same as above.
39 # Ideally, we should have loaded credentials with GoogleCredentials.
40 # However, it insists to load only from a file. So, here's a hack.
41 return SignedJwtAssertionCredentials(
42 service_account_name=credentials_dict['client_email'],
43 private_key=credentials_dict['private_key'],
44 scope=scopes,
45 # Extra **kwargs, just in case.
46 service_account_id=credentials_dict['client_id'],
47 private_key_id=credentials_dict['private_key_id'],
48 )
49
50
51 def payload_stats(data):
52 md5 = hashlib.md5()
53 md5.update(data)
54 md5hex = md5.hexdigest()
55 return 'type=%s, %d bytes, md5=%s' % (type(data), len(data), md5hex)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698