darkpirate
darkpirate

Reputation: 722

Libcloud ECS access

trying to test out the ECS driver of libcloud for a project.

i wrote a simple test:

with open("conf.json") as f:
    data = json.loads(f.read())

driver = get_driver(getattr(Provider,'ECS'))

with open('.cloud_credentials/'+data['provider']+'/access_id', 'r') as myfile:
    ACCESS_KEY_ID = myfile.read().replace('\n', '')
    print ACCESS_KEY_ID

with open('.cloud_credentials/'+data['provider']+'/secret_key', 'r') as myfile:
    SECRET_KEY = myfile.read().replace('\n', '')
    print SECRET_KEY


timer.start()
conn = driver(access_id = ACCESS_KEY_ID,
              secret = SECRET_KEY,
              region = 'us-east-1')
timer.stop()


cluster = conn.create_cluster('pippo','us-east-1')

However running it produce this error:

Traceback (most recent call last):
  File "launch.py", line 32, in <module>
    cluster = conn.create_cluster('pippo',data['region'])
  File "/home/sergio/anaconda2/lib/python2.7/site-packages/libcloud/container/drivers/ecs.py", line 151, in create_cluster
    headers=self._get_headers('CreateCluster')
  File "/home/sergio/anaconda2/lib/python2.7/site-packages/libcloud/common/base.py", line 604, in request
    headers=headers, stream=stream)
  File "/home/sergio/anaconda2/lib/python2.7/site-packages/libcloud/http.py", line 212, in request
    verify=self.verification
  File "/home/sergio/anaconda2/lib/python2.7/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/sergio/anaconda2/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/home/sergio/anaconda2/lib/python2.7/site-packages/requests/adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ecs.%s.amazonaws.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5f16dca950>: Failed to establish a new connection: [Errno -2] Name or service not known',))

I Think that the problem lies with the host string, containing that %s. Digging in the library looks like that string is a dummy one initialized in the file:

/libcloud/container/drivers/ecs.py

I suppose that there should be somewhere in those files a function supposed to overwrite the base-string, that probably doesn't get called for some reasons but, being a novice with the libcloud library, makes it kind of difficult to find the culprit.

Curiously, inspecting the headers that are being sent, looks like they contain the correct(?) address there:

headers: {'Host': u'ecs.us-east-1.amazonaws.com', 'User-Agent': 'libcloud/2.2.1 (Amazon Elastic Container Service) ', 'Content-Type': 'application/x-amz-json-1.1', 'Accept-Encoding': 'gzip,deflate', 'x-amz-target': 'AmazonEC2ContainerServiceV20141113.CreateCluster'}

Anyone with more experience could point me in the right direction? It would be much appreciated.

Upvotes: 0

Views: 42

Answers (1)

anthony shaw
anthony shaw

Reputation: 213

This looks like a bug, it's not something you've done.

Upvotes: 0

Related Questions