Пример #1
0
def image_distribute(deployment, image_name):
    """Distribute an image available on the head region to the other regions
    """
    dep = deployments[deployment]

    head_region = dep.head.region
    other_regions = [r.region for r in dep.regions if r.region != head_region]
    connections = ec2.connect_all(*other_regions)

    if not ec2.list_images(ec2.connect(head_region), image_name):
        print 'image "%s" does not exist on %s!' % (image_name, head_region)
        return

    regions_tocopy = []
    for region, conn in connections.iteritems():
        images = ec2.list_images(conn)
        print "%s:" % (region)
        needcopy = True
        for img in images:
            if img.name == image_name:
                print "\talready available:", img
                needcopy = False
                break
        if needcopy:
            print "\tcopying..."
            regions_tocopy.append(conn)
    for conn in regions_tocopy:
        ec2.copy_image(conn, image_name, head_region)
Пример #2
0
def image_distribute(deployment, image_name):
    """Distribute an image available on the head region to the other regions
    """
    dep = deployments[deployment]

    head_region = dep.head.region
    other_regions = [r.region for r in dep.regions if r.region != head_region]
    connections = ec2.connect_all(*other_regions)

    if not ec2.list_images(ec2.connect(head_region), image_name):
        print 'image "%s" does not exist on %s!' %(image_name, head_region)
        return

    regions_tocopy = []
    for region, conn in connections.iteritems():
        images = ec2.list_images(conn)
        print '%s:' % (region)
        needcopy = True
        for img in images:
            if img.name == image_name:
                print "\talready available:", img
                needcopy = False
                break
        if needcopy:
            print "\tcopying..."
            regions_tocopy.append(conn)
    for conn in regions_tocopy:
        ec2.copy_image(conn, image_name, head_region)
Пример #3
0
def image_from_head(deployment, image_name):
    """Create a new snapshot image from head
    """
    dep = deployments[deployment]
    head_region = dep.head.region
    connection = ec2.connect(head_region)
    ec2.create_snapshot_image(connection, "head", image_name)
Пример #4
0
def image_from_head(deployment, image_name):
    """Create a new snapshot image from head
    """
    dep = deployments[deployment]
    head_region = dep.head.region
    connection = ec2.connect(head_region)
    ec2.create_snapshot_image(connection, 'head', image_name)