在Amazon EC2上“预订”的目的是什么 [英] What is the purpose of 'Reservations' in Amazon EC2

查看:165
本文介绍了在Amazon EC2上“预订”的目的是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始去探索Amazon EC2上。我想听到一些解释或可能是如何以及为什么你需要在Amazon EC2上保留意见的一些简短的例子。我使用python框架博托管理​​亚马逊的服务。到目前为止我实在看不出任何理由为什么我们还要为了这个额外的步骤,让您的实例,例如:

I'm just starting to explore amazon ec2. And I want to hear some explanations or may be some brief examples of how and why do you need 'reservations' in amazon ec2. I'm using python framework boto to manage Amazon Service. And so far I don't really see any reasons why do we have this extra step in order to get your instances, for example:

reservations = ec2.get_all_instances()
instances = [instance for res in reservations for instance in res.instances]

这就是我让我所有的情况下,有些时候我这样做是这样的:

That's how I get all my instances, some times I do it like this:

reservation = ec2.run_instances(image_id, min_count, max_count, key_name .....)
instance = reservation.instances[0]

和比我用这些实例附加卷,添加标签,添加安全组等等....但是,什么是目的 boto.ec2.instance.Reservation (我不要求只有博托框架,当然它的preferred,但在这Amazon EC2的一个整体的意思)

And than I use those instances to attach volumes, add tags, add security groups and so on.... But what is the purpose of boto.ec2.instance.Reservation (I'm not asking only about boto framework, of course its preferred, but in a whole meaning of this in Amazon EC2)

>>> reservation = reservations[0]
>>> reservation
Reservation:r-74d11509
>>> dir(reservation)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'connection', 'endElement', 'groups', 'id', 'instances', 'item', 'owner_id', 'region', 'startElement', 'stop_all']
>>> reservation.__class__
<class 'boto.ec2.instance.Reservation'>

我找不到任何有用的方法。请给我解释一下为什么我们需要这个?什么是它在那里的原因是什么?在什么情况下,你会用吗?

I couldn't find any useful methods. Please explain me why do we need this? What's the reason it to be there? In what cases you would use it?

推荐答案

从我的理解,保留是发动实例的的行为的。基本上,保留就是你的执行的,而一个实例,如果你的获得的。如果启动多个实例从一个图像通过 run_instances()你做一个保留,但得到的多个实例。

From my understanding, a reservation is an act of launching instances. Basically, a reservation is what you do, while an instance if what you get. If you launch multiple instances from one image via run_instances() you make one reservation, but get multiple instances.

run_instances Reservation.stop_all()允许你运行了一堆的实例,等待他们共同完成该任务,然后停止他们的一次。

run_instances together with Reservation.stop_all() allows you to run a bunch of instances, wait them to complete the task and then stop them all at once.

这篇关于在Amazon EC2上“预订”的目的是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆