简体   繁体   English

Libcloud ECS访问

[英]Libcloud ECS access

trying to test out the ECS driver of libcloud for a project. 尝试为项目测试libcloud的ECS驱动程序。

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. 我认为问题出在包含该%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. 我想这些文件中应该有一个覆盖基字符串的函数,由于某些原因可能不会被调用,但是作为libcloud库的新手,很难找到罪魁祸首。

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. 将不胜感激。

这看起来像个错误,不是您要做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM