Added awslib, for interacting with Amazon AWS.
authorSapan Bhatia <gwsapan@gmail.com>
Tue, 22 Jul 2014 04:22:58 +0000 (00:22 -0400)
committerSapan Bhatia <gwsapan@gmail.com>
Tue, 22 Jul 2014 04:22:58 +0000 (00:22 -0400)
planetstack/ec2_observer/awslib.py [new file with mode: 0644]

diff --git a/planetstack/ec2_observer/awslib.py b/planetstack/ec2_observer/awslib.py
new file mode 100644 (file)
index 0000000..5df0768
--- /dev/null
@@ -0,0 +1,18 @@
+import os
+import json
+
+class AwsException(Exception):
+       pass
+
+def aws_run(cmd):
+       cmd = 'aws %s'%cmd
+       pipe = os.popen(cmd)
+       output_str = pipe.read()
+
+       if (not pipe.close()):
+               output = json.loads(output_str)
+               return output
+       else:
+               raise AwsException("Error: %s"%output_str)
+
+