/usr/lib/python2.7/dist-packages/provisioningserver/auth.py is in python-maas-provisioningserver 1.5+bzr2252-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""API credentials for node-group workers."""
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
str = None
__metaclass__ = type
__all__ = [
'get_recorded_api_credentials',
'get_recorded_nodegroup_uuid',
'record_api_credentials',
'record_nodegroup_uuid',
]
from apiclient.creds import convert_string_to_tuple
from provisioningserver import cache
# Cache key for the API credentials as last sent by the server.
API_CREDENTIALS_CACHE_KEY = 'api_credentials'
# Cache key for the uuid of the nodegroup that this worker manages.
NODEGROUP_UUID_CACHE_KEY = 'nodegroup_uuid'
def record_api_credentials(api_credentials):
"""Update the recorded API credentials.
:param api_credentials: Newly received API credentials, in the form of
a single string: consumer key, resource token, and resource seret
separated by colons.
"""
cache.cache.set(API_CREDENTIALS_CACHE_KEY, api_credentials)
def get_recorded_api_credentials():
"""Return API credentials as last received from the server.
:return: If credentials have been received, a tuple of
(consumer_key, resource_token, resource_secret) as expected by
:class:`MAASOauth`. Otherwise, None.
"""
credentials_string = cache.cache.get(API_CREDENTIALS_CACHE_KEY)
if credentials_string is None:
return None
else:
return convert_string_to_tuple(credentials_string)
def record_nodegroup_uuid(nodegroup_uuid):
"""Record the uuid of the nodegroup we manage, as sent by the server."""
cache.cache.set(NODEGROUP_UUID_CACHE_KEY, nodegroup_uuid)
def get_recorded_nodegroup_uuid():
"""Return the uuid of this worker's nodegroup, as sent by the server.
If the server has not sent the name yet, returns None.
"""
return cache.cache.get(NODEGROUP_UUID_CACHE_KEY)
|