-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProject_Mark1.py
More file actions
862 lines (586 loc) · 32.1 KB
/
Project_Mark1.py
File metadata and controls
862 lines (586 loc) · 32.1 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
import os
#import pyttsx3 as px
import pyautogui as pt
import datetime
import speech_recognition as sr
#*******************************************************
# defineing real time
print("\n\t\t*********** Mark1 Here ***********\n")
#*******************************************************
# taking Command
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("listening...")
audio = r.listen(source)
try:
print("recognizing...")
x = r.recognize_google(audio)
print(x)
except Exception as ep:
print(ep)
px.speak("I didn't understand, say that againg please")
print("I didn't understand, say that again please")
return "None"
return x
#*******************************************************
# Time
def time():
Time = datetime.datetime.now().strftime("%I:%M")
px.speak("The time is")
px.speak(Time)
#********************************************************
# defining current date
def date():
year = int(datetime.datetime.now().year)
month = int(datetime.datetime.now().month)
day = int(datetime.datetime.now().day)
px.speak("The date is")
px.speak(day)
px.speak(month)
px.speak(year)
#********************************************************
# taking screenshot
def screenshot():
img = pt.screenshot()
img.save(r'C:\Users\Hemendra chaudhary\Pictures\Screenshots\\screenshot.png')
px.speak("Screenshot Taken")
#*******************************************************
# WelCome Greetings
def greetings() :
px.speak("Hello sir, welcome back...")
hour = datetime.datetime.now().hour
if hour>=6 and hour<12:
px.speak("Good Morning")
elif hour>=12 and hour<18:
px.speak("Good Afternoon")
elif hour>=18 and hour<24:
px.speak("Good Evening")
else:
px.speak("Good Night")
px.speak("I'm Mark1 here...")
#********************************************************
# configurig hadoop cluster
def hadoop():
print("----------------------------------------------------------------------------\n")
# creating templates for hdfs configuration file of hadoop
file_1 = open("template.xml","w")
file_1.write('<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n\n<!-- Put site-specific property overrides in this file. -->')
file_1.close()
print("Template Created For hdfs Configuration File Of Hadoop")
#px.speak("template created for hdfs configuration file of hadoop")
# creating templates for core configuration file of hadoop
# file_2 = open("core-site.xml","w")
# file_2.write('<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n\n<!-- Put site-specific property overrides in this file. -->')
# file_2.close()
#
# print("Template Created For core Configuration File Of Hadoop")
#px.speak("Template created for core configuration file of hadoop")
#*********************************************************
# configuring hadoop master node
def hadoop_master():
#px.speak("Enter The IP Of Your Master Node")
nn_ip = input("Enter The IP Of Your Master Node: ")
#px.speak("Enter The Port No For Master Node")
nn_port = input("Enter The Port No For Master Node: ")
#px.speak("Enter The Directory For Master Node")
nn_dir = input("Enter The Directory For Master Node: ")
# sending softwares that requires for configurig hadoop setup
#px.speak("sending JDK software")
os.system("scp jdk-8u281-linux-x64.rpm root@{}:/root/".format(nn_ip))
#px.speak("JDK software send Successfully!!")
#px.speak("sending Hadoop Software")
os.system("scp hadoop-1.2.1-1.x86_64.rpm root@{}:/root/".format(nn_ip))
#px.speak("Hadoop software send successfully!!")
# installing Java and Hadoop software
#px.speak("Installing java jdk")
os.system("ssh root@{} rpm -ivh /root/jdk-8u281-linux-x64.rpm".format(nn_ip))
#px.speak("Java installed Successfully!!")
#px.speak("Installing hadoop")
os.system("ssh root@{} rpm -ivh /root/hadoop-1.2.1-1.x86_64.rpm --force".format(nn_ip))
#px.speak("Hadoop installed Successfully!!")
# creating directory
#px.speak("Creating Directory")
os.system("ssh root@{} mkdir /root/{}".format(nn_ip, nn_dir))
print("Directory Created\n")
#px.speak("Directory Created")
file = open("template.xml", "r")
lines = file.readlines()
file.close()
new = "".join(lines)
# configuration of hdfs-site.xml
hdfs = open("hdfs-site.xml", "w")
hdfs.write(new + '\n\n<configuration>\n' + '<property>\n' + '<name>dfs.name.dir</name>\n' + '<value>/{}</value>\n'.format(nn_dir) + '</property>\n' + '</configuration>\n')
hdfs.close()
# configuration of core-site.xml
core = open("core-site.xml", "w")
core.write(new + '\n\n<configuration>\n' + '<property>\n' + '<name>fs.default.name</name>\n' + '<value>hdfs://{}:{}</value>\n'.format(nn_ip, nn_port) + '</property>\n' + '</configuration>\n')
core.close()
# copying configuration templates
#px.speak("Configuring hdfs and core files of Hadoop")
os.system("scp hdfs-site.xml root@{}:/etc/hadoop/hdfs-site.xml".format(nn_ip))
os.system("scp core-site.xml root@{}:/etc/hadoop/core-site.xml".format(nn_ip))
print("\nHadoop Configuration Done!!\n")
#px.speak("Hadoop Configuration Done!!")
# formating directory and starting the service
#px.speak("formatting and starting hadoop service")
os.system("ssh root@{} hadoop namenode -format".format(nn_ip))
os.system("ssh root@{} hadoop-daemon.sh start namenode".format(nn_ip))
print("\nHadoop Service Started Successfully For Master Node!!\n")
#px.speak("Hadoop Service Started Successfully For Master Node!!")
os.system("ssh root@{} jps".format(nn_ip))
#*********************************************************
# configuring hadoop master node
def hadoop_worker():
#px.speak("How many slaves you wanted to create")
no_slaves = int(input("How many slaves you wanted to be created: "))
for i in range(0,no_slaves):
#px.speak("Enter the ip of master")
ip_master = input("Enter the ip of master: ")
#px.speak("enter the port number of master")
port = input("Enter the port number of master : ")
#px.speak("enter the ip of worker")
ip_slave = input("Enter the ip of worker: ")
#px.speak("enter the directory for worker node")
dir = input("Enter the directory for worker node: ")
# sending softwares that requires for configurig hadoop setup
#px.speak("sending JDK software")
os.system("scp jdk-8u281-linux-x64.rpm root@{}:/root/".format(ip_slave))
#px.speak("JDK software send Successfully!!")
#px.speak("sending Hadoop Software")
os.system("scp hadoop-1.2.1-1.x86_64.rpm root@{}:/root/".format(ip_slave))
#px.speak("Hadoop software send successfully!!")
# installing Java and Hadoop software
#px.speak("Installing java jdk")
os.system("ssh root@{} rpm -ivh /root/jdk-8u281-linux-x64.rpm".format(ip_slave))
#px.speak("Java installed Successfully!!")
#px.speak("Installing hadoop")
os.system("ssh root@{} rpm -ivh /root/hadoop-1.2.1-1.x86_64.rpm --force".format(ip_slave))
#px.speak("Hadoop installed Successfully!!")
#px.speak("Creating Directory")
os.system("ssh root@{} mkdir /root/{}".format(ip_slave,dir))
#px.speak("Directory Created")
file = open("template.xml", "r")
lines = file.readlines()
file.close()
new = "".join(lines)
#Configuring hdfs-site for slave
hdfs = open("hdfs-site.xml", "w")
hdfs.write(new +"\n\n<configuration>\n" + "<property>\n" + "<name>dfs.data.dir</name>\n" + "<value>/{}</value>\n".format(dir) + "</property>\n" +"</configuration>\n")
hdfs.close()
#configuring core-site.xml for slave
core = open("core-site.xml", "w")
core.write(new+"\n\n<configuration>\n"+"<property>\n"+"<name>fs.default.name</name>\n"+"<value>hdfs://{}:{}</value>\n".format(ip_master,port) + "</property>\n"+"</configuration>\n")
core.close()
#setting up datanode
#px.speak("Configuring hdfs and core files of Hadoop")
os.system("scp hdfs-site.xml root@{}:/etc/hadoop/hdfs-site.xml".format(ip_slave))
os.system("scp core-site.xml root@{}:/etc/hadoop/core-site.xml".format(ip_slave))
#px.speak("starting Hadoop service")
os.system("ssh root@{} hadoop-daemon.sh start datanode".format(ip_slave))
os.system("ssh root@{} hadoop dfsadmin -report".format(ip_master))
print("\nHadoop Condiguration Done For Worker Node!!\n")
#px.speak("Hadoop Condiguration Done For Worker Node!!")
#px.speak("And conneted successfully to master!!")
#****************************************
#Configuring client
def hadoop_client():
#px.speak("enter the ip of master")
ip_master = input("Enter the ip of Master: ")
#px.speak("enter the port number of master")
port = input("Enter the port number of Master: ")
#px.speak("enter the ip of Client")
ip_client = input("Enter the ip of Client: ")
# sending softwares that requires for configurig hadoop setup
#px.speak("sending JDK software")
os.system("scp jdk-8u281-linux-x64.rpm root@{}:/root/".format(ip_client))
#px.speak("JDK software send Successfully!!")
#px.speak("sending Hadoop Software")
os.system("scp hadoop-1.2.1-1.x86_64.rpm root@{}:/root/".format(ip_client))
#px.speak("Hadoop software send successfully!!")
# installing Java and Hadoop software
#px.speak("Installing java jdk")
os.system("ssh root@{} rpm -ivh /root/jdk-8u281-linux-x64.rpm".format(ip_client))
#px.speak("Java installed Successfully!!")
#px.speak("Installing hadoop")
os.system("ssh root@{} rpm -ivh /root/hadoop-1.2.1-1.x86_64.rpm --force".format(ip_client))
#px.speak("Hadoop installed Successfully!!")
file = open("template.xml", "r")
lines = file.readlines()
file.close()
new = "".join(lines)
#configuring core-site.xml for client
core = open("core-site.xml", "w")
core.write(new+"\n<configuration>\n"+"<property>\n"+"<name>fs.default.name</name>\n"+"<value>hdfs://{}:{}</value>\n".format(ip_master,port) + "</property>\n"+"</configuration>\n")
core.close()
#setting up client
#px.speak("Configuring core files of client")
os.system("scp core-site.xml root@{}:/etc/hadoop/core-site.xml".format(ip_client))
print("\nHadoop Condiguration Done For Client!!\n")
#px.speak("Hadoop Condiguration Done For Client!!")
while True:
print("\n\t\t***********Which Node You Want To Configure**********\n\t\t\t1. Master Node\n\t\t\t2. Worker Node\n\t\t\t3. Client Node\n\t\t\t4. Main Menu\n\t\t\t5. EXIT")
#px.speak("Which Node You Want To Configure")
#px.speak("Master Node")
#px.speak("Worker Node")
#px.speak("Client Node")
#px.speak("Or want to return main menu")
#px.speak("Or else want to exit")
#x = takeCommand().lower()
x = input("Enter Your Choice : ")
if (("master" in x)):
hadoop_master()
elif (("worker" in x)):
hadoop_worker()
elif (("client" in x)):
hadoop_client()
elif (("menu" in x) and ("main" in x)):
#px.speak("returning to main menu")
return 0
elif (("exit" in x)):
#px.speak("exiting")
exit()
#--------------------------------------------------------------
#*******************LVM*******************
def lvm():\
print("----------------------------------------------------------------------------\n")
print("\n\t\t*********Welcome to my LVM*********")
#px.speak("Welcome to my LVM")
#*********************************
#Volume group creation
def create_lvm():
#px.speak("Enter the IP of System Where You Want LVM Partition")
ip_lvm = input("Enter the IP of System Where You Want LVM Partition: ")
#px.speak("Listing the Devices Mounted on This Host")
os.system("ssh root@{} fdisk -l".format(ip_lvm))
#px.speak("Enter Path of Storage Devices(Saperated By Space) i.e /dev/sda")
storages=input("Enter Path of Storage Devices(Saperated By Space) i.e /dev/sda : ").split()
print("\n")
for i in storages:
os.system("ssh root@{} pvcreate {}".format(ip_lvm, i))
#px.speak("Physical Volume Created")
print("\n")
#px.speak("Enter Name of Volume Group")
vg_name=input("Enter Name of Volume Group : ")
cmd = ''
for i in storages:
cmd = cmd + ' ' + i
#volume group created
os.system("ssh root@{} vgcreate {} {}".format(ip_lvm, vg_name, cmd))
#px.speak("Volume Group Created")
print("\n")
#px.speak("Enter Size of Partition")
size=input("Enter Size of Partition :")
#px.speak("Enter the Name of Partition")
name_lvm=input("Enter the Name of Partition :")
print("\n")
#logical volume created
os.system("ssh root@{} lvcreate --size {}G --name {} {}".format(ip_lvm, size, name_lvm, vg_name))
#px.speak("Logical Volume Created")
#formated created volume
os.system("ssh root@{} mkfs.ext4 /dev/{}/{}".format(ip_lvm, vg_name, name_lvm))
#px.speak("Logical Volume Formated")
print("\n")
#Mounting
#px.speak("Ente the Mount Point Name")
mount_point=input("Enter the Mount Point Name : ")
print("\n")
os.system("ssh root@{} mkdir /{}".format(ip_lvm, mount_point))
#px.speak("Mount Point Directory Created")
os.system("ssh root@{} mount /dev/{}/{} /{}".format(ip_lvm,vg_name,name_lvm,mount_point))
#px.speak("Logical Volume Mounted Successfully")
#px.speak("Bingo!! You Have Successfully Created LVM Partition")
print("Bingo!! You Have Successfully Created LVM Partition")
#*****************************************
#Partition extension
def extend_lv():
#px.speak("Enter System IP Where You Want Extend Partition Size")
ip_lvm = input("Enter System IP Where You Want Extend Partition Size: ")
#px.speak("Enter the size")
size = input("Enter the Size: ")
#px.speak("Enter the name of volume group")
vgname = input("Enter the name of Volume Group: ")
#px.speak("Name of partition")
name = input("Name of Partition: ")
#logical volume extended
os.system("ssh root@{} lvextend --size +{}G /dev/{}/{}".format(ip_lvm, size,vgname,name))
#px.speak("Logical Volume Extended")
print("Logical Volume Extended\n\n")
#updating partition table
os.system("ssh root@{} resize2fs /dev/{}/{}".format(ip_lvm, vgname,name))
#px.speak("Logical Volume Formated")
print("Logical Volume Formated\n\n")
#******************************************
#Volume group extension
def extend_vg():
#px.speak("Enter System IP Where You Want To Extend Volume Group")
ip_lvm = input("Enter System IP Where You Want To Extend Volume Group: ")
#px.speak("Listing of devices you have")
os.system("ssh root@{} fdisk -l".format(ip_lvm))
print("\n\n")
#px.speak("Enter new Hard Disk device")
new_hd=input("Enter new HD device (/dev/sdd.../dev/sdc) :# ")
#px.speak("Enter the name of volume group")
vg_name=input("Enter the name of Volume Group :# ")
#physical volume creation
os.system("ssh root@{} pvcreate {}".format(ip_lvm, new_hd))
#px.speak("Physical Volume Created")
#volume group extension
os.system("ssh root@{} vgextend {} {}".format(ip_lvm, vg_name,new_hd))
#px.speak("Volume Group Extended")
#px.speak("Do you want to extend space of Logical Volume")
choice=input("\nDo you want to extend space of LV(Y/N) :").capitalize()
if(choice=="Y"):
#px.speak("Enter size to be extended for partition")
size=int(input("Enter Size to be Extended for Partition :"))
#px.speak("Enter Name of partition")
name=input("Name of Partition :")
#logical volume size provision
os.system("ssh root@{} lvextend --size +{}G /dev/{}/{}".format(ip_lvm, size,vg_name,name))
#px.speak("Logical Volume Extended")
#updating partition table
os.system("ssh root@{} resize2fs /dev/{}/{}".format(ip_lvm, vg_name,name))
#px.speak("Logical Volume Formated")
print("\n")
print("Size of LV increased! by {}".format(size))
#px.speak("Size of Logical Volume Increased! by {} Successfully!!".format(size))
else:
print("Volume Group extended successfully")
#px.speak("Volume group extended successfully")
exit()
while True:
print("\n\t***************What You Want To Do With LVM***************\n\t\t\t1. Create New LVM\n\t\t\t2. Extend Partition Size\n\t\t\t3. Add More Device to Volume Group\n\t\t\t4. Main Menu\n\t\t\t5. EXIT")
#px.speak("What Do Want To Do With LVM")
#px.speak("Create New LVM")
#px.speak("Extend Partition Size")
#px.speak("Add More Device to Volume Group")
#px.speak("Or want to go to main menu")
#px.speak("Or else Want To Exit")
#x = takeCommand().lower()
x = input("Enter Your Choice : ")
if (("create" in x) and ("lvm" in x)):
create_lvm()
elif (("partition" in x) and ("size" in x)):
extend_lv()
elif (("volume" in x) and ("group") in x):
extend_vg()
elif (("menu" in x) and ("main" in x)):
#px.speak("returning to main menu")
return 0
elif (("exit" in x)):
#px.speak("exiting")
exit()
#--------------------------------------------------------------
#************AWS************
def aws():
print("----------------------------------------------------------------------------\n")
print("\t\t***********WELCOME TO AWS CLI***********\n\n")
#px.speak("WelCome To AWS CLI")
#configuring AWS CLI
#px.speak("Configure Your AWS in CLI by Entering Credentials")
os.system("aws configure")
#EC2 service
def ec2_service():
while True:
print("\n\t***************What You Want To Do With EC2 Service***************\n\t\t\t1. Launch Instance\n\t\t\t2. Create Volume\n\t\t\t3. Attach Volume\n\t\t\t4. Privious Menu\n\t\t\t5. EXIT")
#px.speak("What You Want To Do With EC2 Service")
#px.speak("Launch Instance")
#px.speak("Create Volume")
#px.speak("Attach Volume")
#px.speak("Or want to return to previous menu")
#px.speak("Or else Want To Exit")
#x = takeCommand().lower()
x = input("Enter Your Choice : ")
if (("launch" in x) and ("instance" in x)):
print("\n")
#px.speak("Enter Image ID")
image_id = input("Enter Image ID(ami-id) : ")
#px.speak("How Many Instance You Want")
count = input("How Many Instance You Want : ")
#px.speak("Enter your instance type")
instance_type = input("Enter Your Instance Type : ")
#px.speak("Enter key-name")
key_name = input("Enter Key Name : ")
#px.speak("ENter security-group-id")
security_grp = input("Enter Security Group ID : ")
#px.speak("Enter Subnet ID")
subnet_id = input("Enter Subnet ID : ")
#Launching instance
os.system("aws ec2 run-instances --image-id {} --count {} --instance-type {} --key-name {} --security-group-ids {} --subnet-id {}".format(image_id,count,instance_type,key_name,security_grp,subnet_id))
#px.speak("Bingo!! EC2 instance Launch successfully!!")
print("Bingo!! EC2 instance Launch successfully!!")
#Creating volume
elif (("create" in x) and ("volume" in x)):
print("\n")
#px.speak("Enter Image volume type")
voluem_type = input("Enter Image Volume Type : ")
#px.speak("Enter Size of Volume(in GiB)")
size = input("Enter Size Of Volume(in GiB) : ")
#px.speak("Enter Availability Zone")
avl_zone = input("Enter Availability Zone ID : ")
os.system("aws ec2 create-volume --volume-type {} --size {} --availability-zone {}".format(voluem_type,size,avl_zone))
#px.speak("EBS Volume Created Successfully")
print("EBS Volume Created Successfully")
#Attach volume to existing instance
elif (("attach" in x) and ("volume" in x)):
print("\n")
#px.speak("Enter Volume ID")
volume_id = input("Enter Volume ID : ")
#px.speak("Enter instance id where you want to attach the volume")
instance_id = input("Enter Instance ID : ")
#px.speak("Enter Device name which you want to attach")
device_name = input("Enter Device Name : ")
os.system("aws ec2 attach-volume --volume-id {} --instance-id {} --device {}".format(volume_id,instance_id,device_name))
#px.speak("EBS volume Attached Successfully")
print("EBS volume Attached Successfully")
elif (("menu" in x) and ("previous" in x)):
#px.speak("returning to main menu")
return 0
elif ("exit" in x):
#px.speak("exiting")
exit()
while True:
print("----Service List----\n")
#px.speak("Right Now I only access EC2 Service Of AWS")
print("1.EC2\n")
#px.speak("Do you want me to proceed with EC2(yes/no)")
print("Do you want me to proceed with EC2(yes/no)")
#x = takeCommand().lower()
x = input("Ente Your Choice : ")
if ("yes" in x):
ec2_service()
elif ("no" in x):
#px.speak("Returning to main menu")
return 0
#--------------------------------------------------------------
#**********DOCKER***************
def docker():
print("----------------------------------------------------------------------------\n")
print("\t\t***********WELCOME TO DOCKER WORLD!!***********\n\n")
#px.speak("Welcome to Docker world")
while True:
print("\n\t***************What You Want To Do***************\n\t\t\t1. Install The Docker\n\t\t\t2. Go With The Same\n\t\t\t3. Main Menu\n\t\t\t4. EXIT")
#px.speak("What You Want To Do")
#px.speak("Install The Docker")
#px.speak("Go With The Same")
#px.speak("Or want to go to main menu")
#px.speak("Or else Want To Exit")
#x = takeCommand().lower()
x = input("Enter Your Choice : ")
if (("install" in x) and ("docker" in x)):
#px.speak("Enter System IP Where You Want To Configure Docker")
ip = input("Enter System IP Where You Want To Configure Docker : ")
#os.chdir("/etc/yum.repos.d")
#os.system("touch docker-ce.repo")
os.system("scp docker.repo root@{}:/etc/yum.repos.d/docker.repo".format(ip))
#px.speak("Yum configuration for docker is successfully complete!!")
os.system("ssh root@{} yum install docker-ce --nobest -y".format(ip))
#px.speak("Docker-ce Installed Successfully!!")
os.system("ssh root@{} systemctl enable docker --now".format(ip))
#px.speak("Docker service started and enabled successfully!!")
#px.speak("Docker Info")
os.system("ssh root@{} docker info".format(ip))
#print("Visiting website..........")
#webbrowser.open("https://hub.docker.com/search?q=&type=image")
elif (("go" in x) and ("same" in x)):
#px.speak("Enter System IP Where You Want To Docker Operations")
ip = input("Enter System IP Where You Want To Docker Operations : ")
while True:
print("\n\t***************What You Want To Do With Docker***************\n\t\t\t1. Pull An Docker Image\n\t\t\t2. Install A Container\n\t\t\t3. Check Running Container\n\t\t\t4. Shutdown A Container\n\t\t\t5. Start A Container\n\t\t\t6. Privious Menu\n\t\t\t7. EXIT")
#px.speak("What You Want To Do With Docker")
#px.speak("Pull An Docker Image")
#px.speak("Install An Container")
#px.speak("Check Running Container")
#px.speak("Shutdown A Container")
#px.speak("Start A Container")
#px.speak("or want to return to previous menu")
#px.speak("Or else Want To Exit")
#x = takeCommand().lower()
x = input("Enter Your Choice : ")
#iso_image pull
if (("pull" in x) and ("image" in x)):
#px.speak("Enter Docker Image Name i.e (image_name:version)")
image_name = input("Enter Docker Image Name i.e (image_name:version) : ")
os.system("ssh root@{} docker pull {}".format(ip,image_name))
#px.speak("{} Image Pulled Successfully!!".format(image_name))
#installing os
elif (("install" in x) and ("container" in x)):
#px.speak("Enter Docker Image Name i.e (image_name:version)")
image_name = input("Enter Docker Image Name i.e (image_name:version) : ")
os.system("ssh root@{} docker run -dit {}".format(ip,image_name))
#px.speak("Container Installed successfully with the {} image".format(image_name))
#Checking running os
elif (("running" in x) and ("container" in x)):
#px.speak("Checking OS running status on docker")
print("Checking OS running on docker")
os.system("ssh root@{} docker ps".format(ip))
#Shutdown OS
elif (("shutdown" in x) and ("container" in x)):
#px.speak("Showing all the Running Docker Container ID")
print("\nShowing all the Running Docker Container ID\n")
os.system("ssh root@{} docker ps -q".format(ip))
#px.speak("Enter OS name which you want to stop")
os_name=input("Enter OS name : ")
os.system("ssh root@{} docker stop {}".format(ip,os_name))
#px.speak("Docker container stopped successfully!!")
#Starting os
elif (("start" in x) and ("container" in x)):
#px.speak("Showing all containers ID")
os.system("ssh root@{} docker ps -a -q".format(ip))
#px.speak("Enter OS name which you want to start")
os_name=input("Enter OS name : ")
os.system("ssh root@{} docker start {}".format(ip,os_name))
os.system("ssh root@{} docker attach {}".format(ip,os_name))
elif (("previous" in x) and ("menu" in x)):
#px.speak("returning to previous menu")
return 0
elif ("exit" in x):
#px.speak("exiting")
exit()
elif (("menu" in x) and ("main" in x)):
#px.speak("returning to main menu")
return 0
elif (("exit" in x)):
#px.speak("exiting")
exit()
#greetings()
if __name__ == "__main__" :
while True:
print("\n\t\t\t***************MAIN MENU***************\n\t\t\t")
#x = takeCommand().lower()
#if (("you" in x) and ("how" in x)):
#px.speak("I am very good")
#print("I am very good")
#px.speak("your help will help me some way")
#print("your help will help me some way :)")
#px.speak("what can I do for you, sir ?")
#print("what can I do for you, sir ?")
#elif (("what" in x) and ("can" in x) and ("do" in x)):
print("\n\t***************What You Want Me To Do For You***************\n\t\t\t1. Hadoop Configuration\n\t\t\t2. LVM Partition\n\t\t\t3. AWS\n\t\t\t4. Docker\n\t\t\t5. EXIT\n")
#px.speak("Today I can integrate four Technologies for you")
#px.speak("which technology you want to configure")
#px.speak("Hadoop")
#px.speak("LVM Partition")
#px.speak("AWS")
#px.speak("And Docker")
#px.speak("Or else you want me to exit")
x = input("Enter Your Choice : ")
if ("hadoop" in x):
#px.speak("configurig Hadoop Cluster")
print("\n\t\t\t***************CONFIGURINING HADOOP CLUSTER***************\n\t\t\t")
hadoop()
elif (("lvm" in x) and ("partition" in x)):
#px.speak("creating LVM Partition")
print("\n\t\t\t***************LVM PARTITION***************\n\t\t\t")
lvm()
elif("aws" in x):
#px.speak("opening AWS console")
print("\n\t\t\t***************AWS***************\n\t\t\t")
aws()
elif ("docker" in x):
#px.speak("configurig Docker")
print("\n\t\t\t***************DOCKER***************\n\t\t\t")
docker()
elif ("exit" in x):
#px.speak("exiting")
exit()