-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcloud_module.py
More file actions
199 lines (178 loc) · 7.29 KB
/
cloud_module.py
File metadata and controls
199 lines (178 loc) · 7.29 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import os
import subprocess as sp
from greeting_module import close
def multi_cloud():
os.system("clear")
sp.getoutput("pulseaudio --start")
os.system("figlet 'Multi-Cloud Services'")
os.system("espeak-ng 'We are providing Multi Cloud services'")
print("""
1. Amazon Web Services(AWS)
2. Google Cloud Platform(GCP)
3. Go back
4. Exit
""")
os.system("tput setaf 3")
cloud_choice=int(input())
os.system("clear")
if(cloud_choice==1):
aws()
elif(cloud_choice==2):
gcp()
elif(cloud_choice==3):
return
elif(cloud_choice==4):
close()
os.system("clear")
def aws():
while(True):
sp.getoutput("pulseaudio --start")
os.system("figlet ' AWS'")
os.system("espeak-ng 'Use amazon web services'")
print("""
1. Launch Ec2 instance
2. List all the instances
3. Stop an instance
4. Start an instance
5. Terminate a instance
6. Create a S3 bucket
7. List all the buckets
8. Sync bucket with a local directory
9. Go back
10.Exit
""")
os.system("tput setaf 4")
ch=int(input())
os.system("clear")
if(ch==1):
os.system("figlet Details\n")
print("\n\nEnter the details!!\n")
os.system("espeak-ng 'Enter the details'")
print("\nOS name")
os.system("espeak-ng 'Enter the OS name'")
os_name=input()
x=sp.getstatusoutput("aws ec2 run-instances --image-id ami-026669ec456129a70 --count 1 --instance-type t2.micro --key-name os_key --security-groups default")
if(x[0]==0):
print('\nInstance Launched!!!\n')
os.system("espeak-ng 'Instance launched please check your AWS account'")
else:
print("\nSomething went wrong!!")
os.system("clear")
elif(ch==2):
os.system('aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId,AZ:Placement.AvailabilityZone,Name:Tags[0].Value,State:State.Name}" --output text')
print("\n\nPress 1 to go back")
e=input()
if(e==1):
multi_cloud()
elif(ch==3):
os.system("figlet Details")
os.system("espeak-ng 'Stop an instance")
os.system("figlet Details\n")
print("\n\nEnter the details!!\n")
os.system("espeak-ng 'Enter the details'")
print("\nOS name")
os.system("espeak-ng 'Enter the instance id'")
os.system('aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId,AZ:Placement.AvailabilityZone,Name:Tags[0].Value,State:State.Name}" --output text')
ins_id=input()
x=sp.getoutput("aws ec2 stop-instances --instance-id {0}".format(ins_id))
if(x[0]==0):
print("\nInstance Stopped!!!\n")
os.system("espeak-ng 'Instance stopped please check your AWS account'")
else:
print("\nSomething went wrong!!")
os.system("clear")
elif(ch==4):
os.system("figlet Details")
os.system("espeak-ng 'Start an instance")
os.system("figlet Details\n")
print("\n\nEnter the details!!\n")
os.system("espeak-ng 'Enter the details'")
print("\nOS name")
os.system("espeak-ng 'Enter the instance id'")
os.system('aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId,AZ:Placement.AvailabilityZone,Name:Tags[0].Value,State:State.Name}" --output text')
ins_id=input()
x=sp.getoutput("aws ec2 start-instances --instance-id {0}".format(ins_id))
if(x[0]==0):
print("\nInstance Started!!!\n")
os.system("espeak-ng 'Instance started please check your AWS account'")
else:
print("\nSomething went wrong!!")
os.system("clear")
elif(ch==5):
os.system("figlet Details")
os.system("espeak-ng 'Terminate an instance")
os.system("figlet Details\n")
print("\n\nEnter the details!!\n")
os.system("espeak-ng 'Enter the details'")
print("\nOS name")
os.system("espeak-ng 'Enter the instance id'")
os.system('aws ec2 describe-instances --query "Reservations[*].Instances[*].{Instance:InstanceId,AZ:Placement.AvailabilityZone,Name:Tags[0].Value,State:State.Name}" --output text')
ins_id=input()
x=sp.getstatusoutput("aws ec2 terminate-instances --instance-id {0}".format(ins_id))
if(x[0]==0):
print("\nInstance Terminated!!!\n")
os.system("espeak-ng 'Instance terminated please check your AWS account'")
else:
print("\nSomething went wrong!!")
os.system("clear")
elif(ch==6):
os.system("figlet Details\n")
print("\n\nEnter the details!!\n")
os.system("espeak-ng 'Enter the details'")
print("\nEnter the bucket name")
os.system("espeak-ng 'Enter the Bucket name(Should be unique in a region'")
os_name=input()
x=sp.getoutput('aws s3api create-bucket --bucket bucket9425 --create-bucket-configuration LocationConstraint=ap-south-1 --query {"Location:Location"} --output text')
if(x[0]==0):
print("\nBucket created!!!\n")
os.system("espeak-ng 'Bucket created please check your AWS account'")
else:
print("\nSomething went wrong!!")
os.system("clear")
elif(ch==7):
os.system("aws s3api list-buckets --query 'Buckets[*].{Name:Name,CreationDate: CreationDate}' --output text")
print("\n\nPress 1 to go back")
e=input()
if(e==1):
multi_cloud()
elif(ch==8):
os.system("figlet Details\n")
print("\n\nEnter the details!!\n")
os.system("espeak-ng 'Enter the details'")
print("\nEnter the directory path")
os.system("espeak-ng 'Enter the Directory path'")
dir_path=input()
print("\nBucket name")
os.system("aws s3api list-buckets --query 'Buckets[*].{Name:Name,CreationDate: CreationDate}' --output text")
os.system("espeak-ng 'Enter the Bucket name'")
buc_name=input()
x=sp.getstatusoutput("aws s3 sync {0} s3://{1}".format(dir_path,buc_name))
if(x[0]==0):
print("\nBucket synced!!!\n")
os.system("espeak-ng 'Bucket synced please check your AWS account'")
else:
print("\nSomething went wrong!!")
os.system("clear")
elif(ch==9):
multi_cloud()
break
elif(ch==10):
close()
break
os.system("clear")
def gcp():
while(True):
sp.getoutput("pulseaudio --start")
os.system("figlet ' GCP'")
os.system("espeak-ng 'Use Google Cloud Platform'")
print("""
*****Work in Progress***
1. Go back
2. Exit
""")
o=int(input())
if o==1:
multi_cloud()
else:
close()
os.system("clear")