[Txawsteam] [Merge] lp:~oubiwann/txaws/416109-arbitrary-endpoints into lp:txaws
Duncan McGreggor has proposed merging lp:~oubiwann/txaws/416109-arbitrary-endpoints into lp:txaws. Requested reviews: txAWS Team (txawsteam) This branch adds support for a service object that manages host endpoints as well as authorization keys (thus obviating the need for the AWSCredential object). -- https://code.launchpad.net/~oubiwann/txaws/416109-arbitrary-endpoints/+merge/10477 Your team txAWS Team is subscribed to branch lp:txaws. === modified file 'txaws/client/gui/gtk.py' --- txaws/client/gui/gtk.py 2009-08-18 22:53:53 + +++ txaws/client/gui/gtk.py 2009-08-20 19:14:32 + @@ -8,7 +8,7 @@ import gobject import gtk -from txaws.credentials import AWSCredentials +from txaws.ec2.service import EC2Service __all__ = ['main'] @@ -27,10 +27,10 @@ # Nested import because otherwise we get 'reactor already installed'. self.password_dialog = None try: -creds = AWSCredentials() +service = AWSService() except ValueError: -creds = self.from_gnomekeyring() -self.create_client(creds) +service = self.from_gnomekeyring() +self.create_client(service) menu = ''' ui menubar name=Menubar @@ -54,10 +54,10 @@ '/Menubar/Menu/Stop instances').props.parent self.connect('popup-menu', self.on_popup_menu) -def create_client(self, creds): +def create_client(self, service): from txaws.ec2.client import EC2Client -if creds is not None: -self.client = EC2Client(creds=creds) +if service is not None: +self.client = EC2Client(service=service) self.on_activate(None) else: # waiting on user entered credentials. @@ -65,7 +65,7 @@ def from_gnomekeyring(self): # Try for gtk gui specific credentials. -creds = None +service = None try: items = gnomekeyring.find_items_sync( gnomekeyring.ITEM_GENERIC_SECRET, @@ -78,7 +78,7 @@ return None else: key_id, secret_key = items[0].secret.split(':') -return AWSCredentials(access_key=key_id, secret_key=secret_key) +return EC2Service(access_key=key_id, secret_key=secret_key) def show_a_password_dialog(self): self.password_dialog = gtk.Dialog( @@ -133,8 +133,8 @@ content = self.password_dialog.get_content_area() key_id = content.get_children()[0].get_children()[1].get_text() secret_key = content.get_children()[1].get_children()[1].get_text() -creds = AWSCredentials(access_key=key_id, secret_key=secret_key) -self.create_client(creds) +service = EC2Service(access_key=key_id, secret_key=secret_key) +self.create_client(service) gnomekeyring.item_create_sync( None, gnomekeyring.ITEM_GENERIC_SECRET, === removed file 'txaws/credentials.py' --- txaws/credentials.py 2009-08-17 11:18:56 + +++ txaws/credentials.py 1970-01-01 00:00:00 + @@ -1,37 +0,0 @@ -# Copyright (C) 2009 Robert Collins robe...@robertcollins.net -# Licenced under the txaws licence available at /LICENSE in the txaws source. - -Credentials for accessing AWS services. - -import os - -from txaws.util import * - - -__all__ = ['AWSCredentials'] - - -class AWSCredentials(object): - -def __init__(self, access_key=None, secret_key=None): -Create an AWSCredentials object. - -:param access_key: The access key to use. If None the environment -variable AWS_ACCESS_KEY_ID is consulted. -:param secret_key: The secret key to use. If None the environment -variable AWS_SECRET_ACCESS_KEY is consulted. - -self.secret_key = secret_key -if self.secret_key is None: -self.secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY') -if self.secret_key is None: -raise ValueError('Could not find AWS_SECRET_ACCESS_KEY') -self.access_key = access_key -if self.access_key is None: -self.access_key = os.environ.get('AWS_ACCESS_KEY_ID') -if self.access_key is None: -raise ValueError('Could not find AWS_ACCESS_KEY_ID') - -def sign(self, bytes): -Sign some bytes. -return hmac_sha1(self.secret_key, bytes) === modified file 'txaws/ec2/client.py' --- txaws/ec2/client.py 2009-08-18 21:56:36 + +++ txaws/ec2/client.py 2009-08-20 16:47:54 + @@ -8,7 +8,7 @@ from twisted.web.client import getPage -from txaws import credentials +from txaws.ec2.service import EC2Service from txaws.util import iso8601time, XML @@ -46,16 +46,15 @@ name_space = '{http://ec2.amazonaws.com/doc/2008-12-01/}' -def __init__(self, creds=None, query_factory=None): +def __init__(self, service=None, query_factory=None): Create an EC2Client. -
Re: [Txawsteam] [Merge] lp:~oubiwann/txaws/416109-arbitrary-endpoints into lp:txaws
On Thu, 2009-08-20 at 19:25 +, Duncan McGreggor wrote: Duncan McGreggor has proposed merging lp:~oubiwann/txaws/416109-arbitrary-endpoints into lp:txaws. Requested reviews: txAWS Team (txawsteam) This branch adds support for a service object that manages host endpoints as well as authorization keys (thus obviating the need for the AWSCredential object). Lets be careful to keep space under storage, ec2 etc for server components. storage.service isn't really a storage service :) Lets call the description of an end point AWSServiceEndpoint, or something like that. local and credentials appear orthogonal to me - for instance, EC2 EU and EC2 US are different endpoints/services with common credentials. I think conflating them is unnecessary and undesirable. Further to that, the AWSCredentials are usable on related services in a single region - EC2, S3 and so on, so when we're passing around a description, we probably want to have a region that describes the endpoints for a collection of services. The goal being able to have a static object AWS_US1 = #... AWS_US2 = #... and for people to make their own; my_eucalyptus_region = #... At runtime then, one would ask a region for a client of a particular service, using some credentials. AWS_US1.make_ec2_client(my_creds) AWS_US1.make_sqs_client(my_creds) etc. We could do this without changing the existing clients at all, by just storing scheme,host tuples in a AWSRegion - but I think it is cleaner to do the sort of refactoring you have done. I think it would be best by having an AWSServiceEndpoint which has the scheme and url, and keeping the creds separate. For instance, class AWSServiceRegion: def make_ec2_client(self, creds=None): return EC2Client(creds=creds, service_endpoint=self.ec2_endpoint) Also a bit of detail review - 'default_schema = https' - in URL terms (see http://www.ietf.org/rfc/rfc3986.txt) that is a _scheme_, not a _schema_. review needsfixing -- https://code.launchpad.net/~oubiwann/txaws/416109-arbitrary-endpoints/+merge/10477 Your team txAWS Team is subscribed to branch lp:txaws. ___ Mailing list: https://launchpad.net/~txawsteam Post to : txawsteam@lists.launchpad.net Unsubscribe : https://launchpad.net/~txawsteam More help : https://help.launchpad.net/ListHelp
Re: [Txawsteam] [Merge] lp:~oubiwann/txaws/416109-arbitrary-endpoints into lp:txaws
On Thu, 2009-08-20 at 19:25 +, Duncan McGreggor wrote: Duncan McGreggor has proposed merging lp:~oubiwann/txaws/416109-arbitrary-endpoints into lp:txaws. Requested reviews: txAWS Team (txawsteam) This branch adds support for a service object that manages host endpoints as well as authorization keys (thus obviating the need for the AWSCredential object). Lets be careful to keep space under storage, ec2 etc for server components. storage.service isn't really a storage service :) Lets call the description of an end point AWSServiceEndpoint, or something like that. local and credentials appear orthogonal to me - for instance, EC2 EU and EC2 US are different endpoints/services with common credentials. I think conflating them is unnecessary and undesirable. Further to that, the AWSCredentials are usable on related services in a single region - EC2, S3 and so on, so when we're passing around a description, we probably want to have a region that describes the endpoints for a collection of services. The goal being able to have a static object AWS_US1 = #... AWS_US2 = #... and for people to make their own; my_eucalyptus_region = #... At runtime then, one would ask a region for a client of a particular service, using some credentials. AWS_US1.make_ec2_client(my_creds) AWS_US1.make_sqs_client(my_creds) etc. We could do this without changing the existing clients at all, by just storing scheme,host tuples in a AWSRegion - but I think it is cleaner to do the sort of refactoring you have done. I think it would be best by having an AWSServiceEndpoint which has the scheme and url, and keeping the creds separate. For instance, class AWSServiceRegion: def make_ec2_client(self, creds=None): return EC2Client(creds=creds, service_endpoint=self.ec2_endpoint) Also a bit of detail review - 'default_schema = https' - in URL terms (see http://www.ietf.org/rfc/rfc3986.txt) that is a _scheme_, not a _schema_. review needsfixing +1 on these suggestions. I'll give it another go with this in mind. -- https://code.edge.launchpad.net/~oubiwann/txaws/416109-arbitrary-endpoints/+merge/10477 Your team txAWS Team is subscribed to branch lp:txaws. ___ Mailing list: https://launchpad.net/~txawsteam Post to : txawsteam@lists.launchpad.net Unsubscribe : https://launchpad.net/~txawsteam More help : https://help.launchpad.net/ListHelp
Re: [Txawsteam] [Merge] lp:~oubiwann/txaws/415491-instance-object into lp:txaws
+1 -- https://code.launchpad.net/~oubiwann/txaws/415491-instance-object/+merge/10505 Your team txAWS Team is subscribed to branch lp:txaws. ___ Mailing list: https://launchpad.net/~txawsteam Post to : txawsteam@lists.launchpad.net Unsubscribe : https://launchpad.net/~txawsteam More help : https://help.launchpad.net/ListHelp