Revision b9d07587
b/kamaki/cli/config.py | ||
---|---|---|
88 | 88 |
}, |
89 | 89 |
'astakos': { |
90 | 90 |
'cli': 'astakos_cli', |
91 |
'url': 'url = https://accounts.okeanos.grnet.gr'
|
|
91 |
'url': 'https://accounts.okeanos.grnet.gr' |
|
92 | 92 |
} |
93 | 93 |
} |
94 | 94 |
|
b/kamaki/clients/__init__.py | ||
---|---|---|
134 | 134 |
except Exception as err: |
135 | 135 |
self.http_client.reset_headers() |
136 | 136 |
self.http_client.reset_params() |
137 |
if isinstance(err, HTTPConnectionError): |
|
138 |
raise ClientError(message=err.message, status=err.status, details=err.details) |
|
139 |
raise |
|
137 |
errmsg = getattr(err, 'message', unicode(err)) |
|
138 |
errdetails = getattr(err, 'details', '')+' (%s)'%type(err) |
|
139 |
errstatus = getattr(err, 'status', 0) |
|
140 |
raise ClientError(message=errmsg,status=errstatus,details=errdetails) |
|
140 | 141 |
|
141 | 142 |
self.http_client.reset_headers() |
142 | 143 |
self.http_client.reset_params() |
b/kamaki/clients/connection/kamakicon.py | ||
---|---|---|
35 | 35 |
#from .pool.http import get_http_connection |
36 | 36 |
from synnefo.lib.pool.http import get_http_connection |
37 | 37 |
from kamaki.clients.connection import HTTPConnection, HTTPResponse, HTTPConnectionError |
38 |
from gevent.dns import DNSError |
|
38 | 39 |
|
39 | 40 |
from json import loads |
40 | 41 |
|
... | ... | |
126 | 127 |
url=str(self.url), |
127 | 128 |
headers=http_headers, |
128 | 129 |
body=data) |
129 |
except: |
|
130 |
except Exception as err:
|
|
130 | 131 |
conn.close() |
132 |
if isinstance(err, DNSError): |
|
133 |
raise HTTPConnectionError('Cannot connect to %s'%self.url, status=701, |
|
134 |
details='%s: %s'%(type(err),unicode(err))) |
|
131 | 135 |
raise |
132 | 136 |
return KamakiHTTPResponse(conn) |
b/kamaki/clients/tests.py | ||
---|---|---|
43 | 43 |
from kamaki.clients import ClientError |
44 | 44 |
from kamaki.clients.pithos import PithosClient as pithos |
45 | 45 |
from kamaki.clients.cyclades import CycladesClient as cyclades |
46 |
from kamaki.clients.image import ImageClient as image |
|
47 |
from kamaki.clients.astakos import AstakosClient as astakos |
|
46 | 48 |
|
47 | 49 |
TEST_ALL = False |
48 | 50 |
|
51 |
class testAstakos(unittest.TestCase): |
|
52 |
def setUp(self): |
|
53 |
url='https://accounts.okeanos.grnet.gr' |
|
54 |
token = 'Kn+G9dfmlPLR2WFnhfBOow==' |
|
55 |
self.client = astakos(url, token) |
|
56 |
def tearDown(self): |
|
57 |
pass |
|
58 |
def test_authenticate(self): |
|
59 |
r = self.client.authenticate() |
|
60 |
for term in ('username', |
|
61 |
'auth_token_expires', |
|
62 |
'auth_token', |
|
63 |
'auth_token_created', |
|
64 |
'groups', |
|
65 |
'uniq', |
|
66 |
'has_credits', |
|
67 |
'has_signed_terms'): |
|
68 |
self.assertTrue(r.has_key(term)) |
|
69 |
|
|
70 |
class testImage(unittest.TestCase): |
|
71 |
def setUp(self): |
|
72 |
url = 'https://plankton.okeanos.grnet.gr' |
|
73 |
token = 'Kn+G9dfmlPLR2WFnhfBOow==' |
|
74 |
self.client = image(url, token) |
|
75 |
|
|
76 |
def tearDown(self): |
|
77 |
pass |
|
78 |
|
|
79 |
def test_list_public(self): |
|
80 |
r = self.client.list_public() |
|
81 |
print(r) |
|
82 |
|
|
49 | 83 |
class testCyclades(unittest.TestCase): |
50 | 84 |
"""Set up a Cyclades thorough test""" |
51 | 85 |
def setUp(self): |
... | ... | |
1935 | 1969 |
suiteFew.addTest(testCyclades('test_000')) |
1936 | 1970 |
else: |
1937 | 1971 |
suiteFew.addTest(testCyclades('test_'+argv[1])) |
1972 |
if len(argv) == 0 or argv[0] == 'image': |
|
1973 |
if len(argv) == 1: |
|
1974 |
suiteFew.addTest(unittest.makeSuite(testImage)) |
|
1975 |
else: |
|
1976 |
suiteFew.addTest(testImage('test'+argv[1])) |
|
1977 |
if len(argv) == 0 or argv[0] == 'astakos': |
|
1978 |
if len(argv) == 1: |
|
1979 |
suiteFew.addTest(unittest.makeSuite(testAstakos)) |
|
1980 |
else: |
|
1981 |
suiteFew.addTest(testAstakos('test'+argv[1])) |
|
1938 | 1982 |
|
1939 | 1983 |
unittest.TextTestRunner(verbosity = 2).run(suiteFew) |
Also available in: Unified diff