Loginto Eucalyptus 3.2 via Python Script
I got this code from the Eucalyptus User Console .
It is written in Python ,with Python Tornado Server.
Authentication into Eucalyptus 3.2 is done via WebService.
Here is a sample code, where We shall authenticate a User and get
their Access Key, Secret Key, Session Token
import base64
import urllib2
import xml.sax
import boto
from boto.sts.credentials import Credentials
#Cloud Controller IP Address
host="10.184.39.224"
duration=43260
auth_url = "https://%s:8773/services/Tokens?Action=GetSessionToken&DurationSeconds=%d&Version=2011-06-15" % (host, duration)
req = urllib2.Request(auth_url)
user=raw_input("Enter User Name: ")
account=raw_input("Enter Account Name:")
passwd=raw_input("Enter Password:")
auth_string = "%s@%s:%s" % \
(base64.b64encode(user), \
base64.b64encode(account), \
passwd)
encoded_auth = base64.b64encode(auth_string)
req.add_header('Authorization', "Basic %s" % encoded_auth)
response = urllib2.urlopen(req, timeout=15)
body = response.read()
print body
# parse AccessKeyId, SecretAccessKey and SessionToken
creds = Credentials(None)
h = boto.handler.XmlHandler(creds, None)
xml.sax.parseString(body, h)
print ("authenticated user: "+account+"/"+user)
print "cred"
print " Session Token ->" +creds.session_token
print "Access_id =>"+ creds.access_key
print "secret_key =>" + creds.secret_key
You shall download the code from this URL.
http://onlineexaminationsysteminjava.googlecode.com/files/Connect-Eucalyptus3.2-Python.py
I got this code from the Eucalyptus User Console .
It is written in Python ,with Python Tornado Server.
Authentication into Eucalyptus 3.2 is done via WebService.
Here is a sample code, where We shall authenticate a User and get
their Access Key, Secret Key, Session Token
import base64
import urllib2
import xml.sax
import boto
from boto.sts.credentials import Credentials
#Cloud Controller IP Address
host="10.184.39.224"
duration=43260
auth_url = "https://%s:8773/services/Tokens?Action=GetSessionToken&DurationSeconds=%d&Version=2011-06-15" % (host, duration)
req = urllib2.Request(auth_url)
user=raw_input("Enter User Name: ")
account=raw_input("Enter Account Name:")
passwd=raw_input("Enter Password:")
auth_string = "%s@%s:%s" % \
(base64.b64encode(user), \
base64.b64encode(account), \
passwd)
encoded_auth = base64.b64encode(auth_string)
req.add_header('Authorization', "Basic %s" % encoded_auth)
response = urllib2.urlopen(req, timeout=15)
body = response.read()
print body
# parse AccessKeyId, SecretAccessKey and SessionToken
creds = Credentials(None)
h = boto.handler.XmlHandler(creds, None)
xml.sax.parseString(body, h)
print ("authenticated user: "+account+"/"+user)
print "cred"
print " Session Token ->" +creds.session_token
print "Access_id =>"+ creds.access_key
print "secret_key =>" + creds.secret_key
You shall download the code from this URL.
http://onlineexaminationsysteminjava.googlecode.com/files/Connect-Eucalyptus3.2-Python.py
No comments:
Post a Comment