amazon ec2 shell用于轻松管理多个帐户和区域

iboto的Python项目详细描述


简介

iboto提供了一个带有来自amazon的基本ec2命令集的交互式shell 命令行工具,类固醇!

它补充道:

  • 多帐户支持

  • 多区域支持

  • 强大的过滤功能

  • 参数的制表符完成:

    • 阿米斯
    • 实例ID
    • 标签
    • 区域
    • 实例类型等

    省去了很多繁琐的身份证复印粘贴工作。

  • 非常快

    在运行命令之前不必先加载所有Java 与amazon工具相比,许多snappier控制实例(尽管它们非常棒!).

  • 额外功能:

    • ec2ssh-等待实例运行和ssh 连接前可用;无需查找和复制 公共dns名称,猜猜它什么时候完全启动,甚至打开 ssh的新终端。
    • ec2watch-在您等待的时候密切监视您的实例发生了什么。
  • ipython的所有优点

    历史回忆、python集成、会话记录、可配置性等。

最好用演示会话来说明:

~ % iboto
iboto ready

Commands available:
%ec2din  (aka ls)
%limit   (aka .)
%pop     (aka ..)
%ec2ssh
%ec2run
%ec2start
%ec2stop
%ec2kill
%ec2watch
%account
%region

'%command?' for more information.

demo1:us-east-1,demo2:eu-west-1
[1]: limit Role:demo

demo1:us-east-1,demo2:eu-west-1 Role:demo
[2]: ec2run -T Role:demo
account (demo1,demo2): demo1
region: us-east-1
instance type (m1.small,m1.large,m1.xlarge,c1.medium,c1.xlarge,m2.xlarge,m2.2xlarge,m2.4xlarge,cc1.4xlarge,t1.micro): t1.micro
number [1]:
key: default
security group (default) [default]:
zone (us-east-1a,us-east-1b,us-east-1c,us-east-1d,us-east-1e) [default]:
arch (i386,x86_64) [x86_64]:
ebs: yes
ami (lucid,maverick,natty,oneiric,precise,ami-xxxxxx): lucid
tags: Role:demo
Out[2]: <Result: success, Instances: i-63f38e07>

demo1:us-east-1,demo2:eu-west-1 Role:demo i-63f38e07
[3]: ec2ssh
Instance i-63f38e07
Waiting for i-63f38e07 pending->running... (Ctrl+C to abort)
Waiting for i-63f38e07 SSH port... (Ctrl+C to abort)
Connecting to ec2-107-21-194-97.compute-1.amazonaws.com... (Ctrl+C to abort)
The authenticity of host 'ec2-107-21-194-97.compute-1.amazonaws.com (107.21.194.97)' can't be established.
RSA key fingerprint is e7:fe:c9:a9:bb:cc:ca:88:f1:26:0d:86:b0:b7:9d:87.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-107-21-194-97.compute-1.amazonaws.com,107.21.194.97' (RSA) to the list of known hosts.
Linux domU-12-31-38-01-A9-1C 2.6.32-342-ec2 #43-Ubuntu SMP Wed Jan 4 18:22:42 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS

Welcome to Ubuntu!
...
ubuntu@domU-12-31-38-01-A9-1C:~$ logout
Connection to ec2-107-21-194-97.compute-1.amazonaws.com closed.
Out[3]: 'i-63f38e07'

demo1:us-east-1,demo2:eu-west-1 Role:demo i-63f38e07
[4]: ..

demo1:us-east-1,demo2:eu-west-1 Role:demo
[5]: ec2run -T Role:demo
account (demo1,demo2): demo2
region: eu-west-1
instance type (m1.small,m1.large,m1.xlarge,c1.medium,c1.xlarge,m2.xlarge,m2.2xlarge,m2.4xlarge,cc1.4xlarge,t1.micro): t1.micro
number [1]:
key: default
security group (default) [default]:
zone (eu-west-1a,eu-west-1b,eu-west-1c) [default]:
arch (i386,x86_64) [x86_64]:
ebs: yes
ami (lucid,maverick,natty,oneiric,precise,ami-xxxxxx): lucid
tags: Role:demo
Out[5]: <Result: success, Instances: i-3affcd73>

demo1:us-east-1,demo2:eu-west-1 Role:demo i-3affcd73
[6]: ..

demo1:us-east-1,demo2:eu-west-1 Role:demo
[7]: ls
account instance    state    type      zone        ami           launch time       name
=======================================================================================
demo1 i-63f38e07  running  t1.micro  us-east-1d  ami-349b495d  2012-03-18 17:35
demo2 i-3affcd73  pending  t1.micro  eu-west-1b  ami-fb665f8f  2012-03-18 17:36

demo1:us-east-1,demo2:eu-west-1 Role:demo
[8]: ec2watch
Watching 2 instance(s) (press Ctrl+C to end)
 i-3affcd73  state: pending->running
^C
demo1:us-east-1,demo2:eu-west-1 Role:demo
[9]: I.public_dns_name
Out[9]:
[u'ec2-107-21-194-97.compute-1.amazonaws.com',
 u'ec2-176-34-173-80.eu-west-1.compute.amazonaws.com']

demo1:us-east-1,demo2:eu-west-1 Role:demo
[10]: I.placement
Out[10]: [u'us-east-1d', u'eu-west-1b']

demo1:us-east-1,demo2:eu-west-1 Role:demo
[11]: I.add_tag('MyTag', '123')
This will add_tag 2 instances, ok? (y/N) y
Out[11]: <Result: success, Instances: i-63f38e07, i-3affcd73>

demo1:us-east-1,demo2:eu-west-1 Role:demo
[12]: I.tags
Out[12]:
[{u'MyTag': u'123', u'Role': u'demo'},
 {u'MyTag': u'123', u'Role': u'demo'}]

demo1:us-east-1,demo2:eu-west-1 Role:demo
[13]: limit MyTag:123

demo1:us-east-1,demo2:eu-west-1 MyTag:123
[14]: I.add_volume(1, '/dev/sdf')
Creating and attaching volumes...
Created 2 volumes

demo1:us-east-1,demo2:eu-west-1 MyTag:123
[15]: ec2ssh latest
Instance i-3affcd73
Connecting to ec2-176-34-173-80.eu-west-1.compute.amazonaws.com... (Ctrl+C to abort)
The authenticity of host 'ec2-176-34-173-80.eu-west-1.compute.amazonaws.com (176.34.173.80)' can't be established.
RSA key fingerprint is c9:cc:8b:fe:bc:8b:59:6c:3b:0a:07:54:fc:c2:a8:8c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-176-34-173-80.eu-west-1.compute.amazonaws.com,176.34.173.80' (RSA) to the list of known hosts.
Linux ip-10-227-133-146 2.6.32-342-ec2 #43-Ubuntu SMP Wed Jan 4 18:22:42 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
...
ubuntu@ip-10-227-133-146:~$ ls -al /dev/sdf
brw-rw---- 1 root disk 8, 80 2012-03-18 17:38 /dev/sdf
ubuntu@ip-10-227-133-146:~$ logout
Connection to ec2-176-34-173-80.eu-west-1.compute.amazonaws.com closed.
Out[15]: 'i-3affcd73'

demo1:us-east-1,demo2:eu-west-1 MyTag:123
[16]: ec2kill
This will terminate 2 instances, ok? (y/N) y
Out[16]: <Result: success, Instances: i-63f38e07, i-3affcd73>

demo1:us-east-1,demo2:eu-west-1 MyTag:123
[17]: ls
account instance    state    type      zone        ami           launch time       name
=======================================================================================
demo1 i-63f38e07  shutting t1.micro  us-east-1d  ami-349b495d  2012-03-18 17:35
demo2 i-3affcd73  shutting t1.micro  eu-west-1b  ami-fb665f8f  2012-03-18 17:36

demo1:us-east-1,demo2:eu-west-1 MyTag:123

安装

使用您喜爱的软件包管理器安装:

$ pip install iboto

然后您可以从您的路径运行iboto:

$ iboto

默认设置是在每个帐户/区域都可见的情况下启动shell。 您可以从命令行限制到特定的帐户/区域:

$ iboto demo1 eu-west-1

配置

第一次运行iboto时,您将看到一个向导,该向导将配置 您帐户的凭据。

帮助

最好的文档是通过输入%command访问的命令文档?'在 外壳提示,例如:

'%ec2start?'

'%limit?'

未来计划

  • 添加整套EC2工具
  • 添加更多的aws api。
  • 为多个主机并行执行ec2ssh。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何向xsi:nil元素添加另一个属性?   Java抽象泛型方法,使用具体类型实现通配符   java使用pcap4j截断pcap文件   当我放置字母a、b和c时,java中的异常预期会下降   java设置活动对话框不可取消   接口类型变量上的Java克隆   使用Java或BouncyCastle对CSR(证书签名请求)进行安全解码/读取   java调用SavingsAccount对象上的函数并打印结果   java如何在Android应用程序上显示地图上的兴趣点(POI)并与之交互?   如果在JavaFX中的ResultSet中未找到任何内容,则显示java警报   java我将springboot和@component与@scheduled一起使用,它每12小时锁定一次   ApachePOI如何使用java删除包含字符串的word表的行   java如果对象(x,y)靠近其他对象(x,y)   从未对JMSException调用java JMS CachingConnectionFactory OneException方法   javascript使用java将HTML页面转换为MS word