Skip to content

Commit

Permalink
Merge pull request boto#1462 from thobrla/portoverride
Browse files Browse the repository at this point in the history
Allow port override in boto config
  • Loading branch information
mfschwartz committed Apr 26, 2013
2 parents 6df1ae6 + 08e893d commit f48a8c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion boto/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,11 @@ def __init__(self, host, aws_access_key_id=None,
aws_secret_access_key,
security_token)

# allow config file to override default host
# Allow config file to override default host and port.
if self.provider.host:
self.host = self.provider.host
if self.provider.port:
self.port = self.provider.port

self._pool = ConnectionPool()
self._connection = (self.server_name(), self.is_secure)
Expand Down
9 changes: 7 additions & 2 deletions boto/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class Provider(object):
'metadata-directive',
RESUMABLE_UPLOAD_HEADER_KEY: None,
SECURITY_TOKEN_HEADER_KEY: AWS_HEADER_PREFIX + 'security-token',
SERVER_SIDE_ENCRYPTION_KEY: AWS_HEADER_PREFIX + 'server-side-encryption',
SERVER_SIDE_ENCRYPTION_KEY: AWS_HEADER_PREFIX +
'server-side-encryption',
VERSION_ID_HEADER_KEY: AWS_HEADER_PREFIX + 'version-id',
STORAGE_CLASS_HEADER_KEY: AWS_HEADER_PREFIX + 'storage-class',
MFA_HEADER_KEY: AWS_HEADER_PREFIX + 'mfa',
Expand Down Expand Up @@ -166,6 +167,7 @@ class Provider(object):
def __init__(self, name, access_key=None, secret_key=None,
security_token=None):
self.host = None
self.port = None
self.access_key = access_key
self.secret_key = secret_key
self.security_token = security_token
Expand All @@ -176,10 +178,13 @@ def __init__(self, name, access_key=None, secret_key=None,
self.get_credentials(access_key, secret_key)
self.configure_headers()
self.configure_errors()
# allow config file to override default host
# Allow config file to override default host and port.
host_opt_name = '%s_host' % self.HostKeyMap[self.name]
if config.has_option('Credentials', host_opt_name):
self.host = config.get('Credentials', host_opt_name)
port_opt_name = '%s_port' % self.HostKeyMap[self.name]
if config.has_option('Credentials', port_opt_name):
self.port = config.getint('Credentials', port_opt_name)

def get_access_key(self):
if self._credentials_need_refresh():
Expand Down

0 comments on commit f48a8c3

Please sign in to comment.