Added support for request timeouts.

This commit is contained in:
Ed Leafe 2011-07-07 21:07:49 +00:00
parent f81fc89cc8
commit eb0d5c75b7
2 changed files with 6 additions and 5 deletions

View File

@ -63,9 +63,10 @@ class OpenStack(object):
"""
def __init__(self, username, apikey, projectid,
auth_url='https://auth.api.rackspacecloud.com/v1.0'):
auth_url='https://auth.api.rackspacecloud.com/v1.0', timeout=None):
self.backup_schedules = BackupScheduleManager(self)
self.client = OpenStackClient(username, apikey, projectid, auth_url)
self.client = OpenStackClient(username, apikey, projectid, auth_url,
timeout=timeout)
self.flavors = FlavorManager(self)
self.images = ImageManager(self)
self.ipgroups = IPGroupManager(self)

View File

@ -28,8 +28,8 @@ class OpenStackClient(httplib2.Http):
USER_AGENT = 'python-novaclient/%s' % novaclient.__version__
def __init__(self, user, apikey, projectid, auth_url):
super(OpenStackClient, self).__init__()
def __init__(self, user, apikey, projectid, auth_url, timeout=None):
super(OpenStackClient, self).__init__(timeout=timeout)
self.user = user
self.apikey = apikey
self.projectid = projectid
@ -77,7 +77,7 @@ class OpenStackClient(httplib2.Http):
else:
body = None
if resp.status in (400, 401, 403, 404, 413, 500, 501):
if resp.status in (400, 401, 403, 404, 408, 413, 500, 501):
raise exceptions.from_response(resp, body)
return resp, body