File size: 1,951 Bytes
15f5485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

num_cassandra_east = 1
num_regular_east = 0
num_cassandra_west = 0
num_regular_west = 0

from common_funcs import *

from time import sleep
from os import system

#todo-verify

eastAMI = "ami-4dad7424"#BOLTON: ami-8ee848e7"# OLDER: "ami-7268b01b"
westAMI = "ami-ecf17ddc"

eastInstanceIPs = []
westInstanceIPs = []

def make_ec2_east(n):
    if n == 0:
        return
    global eastAMI
    f = raw_input("EAST: spinning up %d instances; okay? " % n)

    if f != "Y" and f != "y":
        exit(-1)

    system("ec2-run-instances %s -n %d -g 'lipstick' --t m1.large -k 'suna-real'" % (eastAMI, n))

def make_ec2_west(n):
    if n == 0:
        return
    global westAMI
    f = raw_input("WEST: spinning up %d instances; okay? " % n)

    if f != "Y" and f != "y":
        exit(-1)

    system("ec2-run-instances %s -n %d -g 'lipstick' --t m1.large --region us-west-2 -k 'watson' -b '/dev/sdb=ephemeral0' -b '/dev/sdc=ephemeral1'" % (westAMI, n))

def get_instances():
    global eastInstanceIPs
    global westInstanceIPs

    system("rm instances.txt")
    system("ec2-describe-instances --region us-east-1 >> instances.txt")
    system("ec2-describe-instances --region us-west-2 >> instances.txt")

    ret = []

    for line in open("instances.txt"):
        line = line.split()
        if line[0] == "INSTANCE":
            ip = line[3]
            if ip == "terminated":
                continue
            status = line[5]
            if status.find("shutting") != -1:
                continue
            region = line[10]
            ret.append((ip, region))

    #OUTPUT all-hosts.txt, cassandra-hosts.txt, lipstick-hosts.txt, east-cassandra-hosts.txt, east-lipstick-hosts.txt, west-cassandra-hosts.txt west-lipstick-hosts.txt

    system("rm instances.txt")

    return ret

def make_instancefile(name, hosts):
    f = open("hosts/"+name, 'w')
    for host in hosts:
        f.write("%s\n" % (host))
    f.close


launch_cassandra_ring()