在云中创建、使用和销毁临时奴隶
django-cloudslave的Python项目详细描述
我有许多不同的应用程序需要在 云做各种事情。这个模块通常是有用的 为此目的。
这是什么?
这是一种非常简单的方法,可以在云中启动实例 不费吹灰之力。它基于 预定义图像。
什么不是?
各种openstack客户端库的通用包装器。它做了一个 做得很好。
如何使用?
首先,配置云:
>>> from cloudslave.models import Cloud >>> cloud = Cloud(user_name='user_name', tenant_name='tenant_name', password='v3rysecret', endpoint='http://auth/url/v2.0', region='XX-YY', # <-- Optional flavor_name = 'm1.small', image_name = 'regex that matches the name of the image (first match will be used)') >>> cloud.slave()
然后创建预订:
>>> res = cloud.create_reservation(5) # Starts 5 instances >>> res.start() >>> res.update_state() 1 >>> res.get_state_display() 'Booting' >>> res.update_state() 2 >>> res.get_state_display() 'Ready' >>> [slave.run_cmd('hostname').strip() for slave in res.slave_set.all()] ['cloudslave-nthdnsrn', 'cloudslave-blhhmncq', 'cloudslave-vygfls4t']
很可爱。
完成后,请终止预订:
>>> res.terminate()
就这样。