]>
Commit | Line | Data |
---|---|---|
31f18b77 FG |
1 | import boto |
2 | import boto.s3.connection | |
39ae355f | 3 | import boto.iam.connection |
31f18b77 FG |
4 | |
5 | def get_gateway_connection(gateway, credentials): | |
6 | """ connect to the given gateway """ | |
7 | if gateway.connection is None: | |
8 | gateway.connection = boto.connect_s3( | |
9 | aws_access_key_id = credentials.access_key, | |
10 | aws_secret_access_key = credentials.secret, | |
11 | host = gateway.host, | |
12 | port = gateway.port, | |
13 | is_secure = False, | |
14 | calling_format = boto.s3.connection.OrdinaryCallingFormat()) | |
15 | return gateway.connection | |
16 | ||
9f95a23c TL |
17 | def get_gateway_secure_connection(gateway, credentials): |
18 | """ secure connect to the given gateway """ | |
19 | if gateway.ssl_port == 0: | |
20 | return None | |
21 | if gateway.secure_connection is None: | |
22 | gateway.secure_connection = boto.connect_s3( | |
23 | aws_access_key_id = credentials.access_key, | |
24 | aws_secret_access_key = credentials.secret, | |
25 | host = gateway.host, | |
26 | port = gateway.ssl_port, | |
27 | is_secure = True, | |
28 | validate_certs=False, | |
29 | calling_format = boto.s3.connection.OrdinaryCallingFormat()) | |
30 | return gateway.secure_connection | |
39ae355f TL |
31 | |
32 | def get_gateway_iam_connection(gateway, credentials): | |
33 | """ connect to iam api of the given gateway """ | |
34 | if gateway.iam_connection is None: | |
35 | gateway.iam_connection = boto.connect_iam( | |
36 | aws_access_key_id = credentials.access_key, | |
37 | aws_secret_access_key = credentials.secret, | |
38 | host = gateway.host, | |
39 | port = gateway.port, | |
40 | is_secure = False) | |
41 | return gateway.iam_connection |