简体   繁体   English

适合 Eucalyptus 云的 boto 版本

[英]Proper version of boto for Eucalyptus cloud

I'm writing some code to interact with an HP Helion Eucalyptus 4.2 cloud server.我正在编写一些代码来与 HP Helion Eucalyptus 4.2 云服务器进行交互。 At the moment I'm using boto 2.38.0, but I discovered that also exists the boto3 version.目前我正在使用 boto 2.38.0,但我发现也存在 boto3 版本。 Which version should I use in order to keep the code up with the times?我应该使用哪个版本才能使代码与时俱进? I mean, It seems that boto3's proposal is a ground-up rewrite more focused on the "official" Amazon Web Services (AWS).我的意思是,boto3 的提议似乎是对“官方”亚马逊网络服务 (AWS) 的彻底重写。

You can easilly use boto3.您可以轻松使用 boto3。 Here is the article clearly explaining that.是文章清楚地解释了这一点。 I tried it myself with Eucalyptus 4.2.1.我自己用 Eucalyptus 4.2.1 试过了。 So I defined the config and credentials file.所以我定义了配置和凭证文件。

$ cat .aws/config 
[profile admin]
output = json
region = region1

$ cat .aws/credentials
[admin]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Then I used the interactive Ipython shell, so I listed my running instances.然后我使用了交互式 Ipython shell,所以我列出了我正在运行的实例。

In [1]: from boto3.session import Session

In [2]: session = Session(region_name='region1', profile_name="admin")

In [3]: client = session.client('ec2', endpoint_url='http://compute.region1.cloud.mydomain.net:8000/')

In [4]: for reservation in client.describe_instances()['Reservations']: 
   ...:       for instance in reservation['Instances']:
   ...:             print instance['InstanceId']
   ...:         
i-c706792f
i-af613099
i-fc0c55ee
i-4f493764
i-943d0ce3

I don't use verify argument in session.client() , because my testing EC2 endpoint doesn't use HTTPS but plain HTTP.我不在session.client() 中使用verify参数,因为我的测试 EC2 端点不使用 HTTPS,而是使用纯 HTTP。

2.38 is the right version. 2.38 是正确的版本。 boto3 is something totally different and I don't have experience with it. boto3 是完全不同的东西,我没有经验。

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

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