Beispiel #1
0
 def setUp(self):
     self.conn = connection.establish()
import time

import boto

from automaton.nectar import connection, config

conn = connection.establish()

my_instances = set()


def create_server(count):
    if count is None or count < 1:
        count = 1

    try:
        print('Creating instances....')

        placement = config.placement
        if placement == '':
            placement = None

        new_reservation = conn.run_instances(
            config.default_image_id,
            max_count=count,
            key_name=config.default_key_name,
            instance_type=config.default_instance_type,
            security_groups=config.default_security_groups,
            placement=placement)

        new_instance = new_reservation.instances[0]
import re

from automaton.nectar import connection

images = connection.establish().get_all_images()


def list_all():
    for img in images:
        print('id: {}, name: {}'.format(img.id, img.name))


def list_by_nectar():
    for img in images:
        if img.name.startswith('NeCTAR'):
            print('id: {}, name: {}'.format(img.id, img.name))


def list_by_expression(exp):
    for img in images:
        if re.match(exp, img.name):
            print('id: {}, name: {}'.format(img.id, img.name))


def main():
    list_all()
    print('=' * 100)
    list_by_nectar()
    print('=' * 100)
    list_by_expression(r'^NeCTAR Ubuntu')
    print('=' * 100)