From eb0d5c75b7be1a78803a7f938ee0e1ac70556dea Mon Sep 17 00:00:00 2001 From: Ed Leafe Date: Thu, 7 Jul 2011 21:07:49 +0000 Subject: [PATCH] Added support for request timeouts. --- novaclient/__init__.py | 5 +++-- novaclient/client.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/novaclient/__init__.py b/novaclient/__init__.py index b59970c57..727d53eed 100644 --- a/novaclient/__init__.py +++ b/novaclient/__init__.py @@ -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) diff --git a/novaclient/client.py b/novaclient/client.py index cf3555fc5..2e1d26404 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -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