summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-03-07 09:54:41 -0500
committerScott Moser <smoser@ubuntu.com>2012-03-07 09:54:41 -0500
commit8e705c8542719cf4d90083c9432497ff525247ce (patch)
treec1ba5371b8c3f099a9374f2987bffff62efb472e
parent3703ed74cea613e96f3d882e90af1cadae30a092 (diff)
downloadvyos-cloud-init-8e705c8542719cf4d90083c9432497ff525247ce.tar.gz
vyos-cloud-init-8e705c8542719cf4d90083c9432497ff525247ce.zip
DataSourceMaaS: add test code for the oauth path
This adds to the 'main' in cloudinit/DataSourceMaaS.py a method for testing oauth_headers.
-rw-r--r--cloudinit/DataSourceMaaS.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/cloudinit/DataSourceMaaS.py b/cloudinit/DataSourceMaaS.py
index 08a48443..4c89c2eb 100644
--- a/cloudinit/DataSourceMaaS.py
+++ b/cloudinit/DataSourceMaaS.py
@@ -245,11 +245,27 @@ def get_datasource_list(depends):
if __name__ == "__main__":
def main():
+ """
+ Call with single argument of directory or http or https url.
+ If url is given additional arguments are allowed, which will be
+ interpreted as consumer_key, token_key, token_secret, consumer_secret
+ """
import sys
import pprint
seed = sys.argv[1]
if seed.startswith("http://") or seed.startswith("https://"):
- (userdata, metadata) = read_maas_seed_url(seed)
+ def my_headers(url):
+ headers = oauth_headers(url, c_key, t_key, t_sec, c_sec)
+ print "%s\n %s\n" % (url, headers)
+ return headers
+ cb = None
+ (c_key, t_key, t_sec, c_sec) = (sys.argv + ["", "", "", ""])[2:6]
+ if c_key:
+ print "oauth headers (%s)" % str((c_key, t_key, t_sec, c_sec,))
+ (userdata, metadata) = read_maas_seed_url(seed, my_headers)
+ else:
+ (userdata, metadata) = read_maas_seed_url(seed)
+
else:
(userdata, metadata) = read_maas_seed_dir(seed)