forked from valtmanir/Cloudefigo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Manage-cmd.py
30 lines (25 loc) · 890 Bytes
/
Manage-cmd.py
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
#!/usr/bin/python
__author__ = 'nirv'
from Chef.ConfigurationManagement import ChefClient
from AWS.EC2 import EC2
def get_menu():
return ("\n----- Secure Cloud Management Console -----\n"
"1. Launch secure instance\n"
"2. Locate not managed instances\n"
"3. Exit\n"
"Your choise: ")
ec2 = EC2(False, "us-east-1")
chef = ChefClient()
while True:
response = raw_input(get_menu())
if response == '1':
ec2.create_secure_instance("ami-c65be9ae","t1.micro","Secure Instance") # ami-c65be9ae is Ubuntu 14
elif response == '2':
ec2_instances = ec2.get_all_running_instance_names()
chef_nodes = chef.get_all_nodes()
print "Not managed nodes list: "
for ec2_instance in ec2_instances:
if ec2_instance not in chef_nodes:
print ec2_instance
else:
exit()