Skip to content

Commit

Permalink
Merge pull request #6 from gaius-r/integrate1
Browse files Browse the repository at this point in the history
Main Push 4 : Added Docker, LVM and ML; fixed file path issue in ML
  • Loading branch information
gaius-r authored Nov 8, 2020
2 parents 3d829a6 + b650b25 commit d885e87
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 50 deletions.
48 changes: 48 additions & 0 deletions Lvmautomate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
import platform

def lvmAuto():

if platform.system() == 'Windows':
print("Current OS is Windows. This Code Block is compatible only with UNIX based systems.")
input("Press Enter to return to menu...")
return

while True :
os.system("clear")
print("\t\tpress 1: to make LVM partition")
print("\t\tpress 2: to exit")

ch = input("enter your choice : ")

if ch == "1":
pv1 = input("enter name/path of the disk 1 : ")
pv2 = input("enter name/path of the disk 2 : ")
os.system("pvcreate /dev/{}".format(pv1))
os.system("pvcreate /dev/{}".format(pv2))
vgn = input("enter name for your vg : ")
os.system("vgcreate {} /dev/{} /dev/{}".format(vgn,pv1,pv2))
lvsize = input("enter size of your lv : ")
lvname = input("enter name of your lv : ")
os.system("lvcreate --size +{} --name {} {}".format(lvsize,lvname,vgn))
os.system("tput setaf 3")
print("successfully createed logical volume..")
os.system("tput setaf 7")
os.system("lvdisplay /dev/{}/{}".format(vgn,lvname))
input("press enter to format your lv {}".format(lvname))
os.system("mkfs.ext4 /dev/{}/{}".format(vgn,lvname))
print("succesfully formatted you lv {}".format(lvname))
input("press enter to make folder where u want to mount your lv")
folder = input("enter name for your folder : ")
os.system("mkdir /{}".format(folder))
print("mounting your lv {} to the /{} folder".format(lvname,folder))
os.system("mount /dev/{}/{} /{}".format(vgn,lvname,folder))
print("successfully mounted ur lv {} to /{} folder".format(lvname,folder))

elif ch == "2":
break

else :
print("Invalid choice")
input()
return
31 changes: 31 additions & 0 deletions Salary_Data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
YearsExperience,Salary
1.1,39343.00
1.3,46205.00
1.5,37731.00
2.0,43525.00
2.2,39891.00
2.9,56642.00
3.0,60150.00
3.2,54445.00
3.2,64445.00
3.7,57189.00
3.9,63218.00
4.0,55794.00
4.0,56957.00
4.1,57081.00
4.5,61111.00
4.9,67938.00
5.1,66029.00
5.3,83088.00
5.9,81363.00
6.0,93940.00
6.8,91738.00
7.1,98273.00
7.9,101302.00
8.2,113812.00
8.7,109431.00
9.0,105582.00
9.5,116969.00
9.6,112635.00
10.3,122391.00
10.5,121872.00
Binary file removed __pycache__/automation.cpython-38.pyc
Binary file not shown.
Binary file removed __pycache__/ec2.cpython-38.pyc
Binary file not shown.
Binary file removed __pycache__/menu.cpython-38.pyc
Binary file not shown.
118 changes: 118 additions & 0 deletions docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import os
import platform

def dockerMenu():

if platform.system() == 'Windows':
print("Current OS is Windows. This Code Block is compatible only with Red Hat Enterprise Linux.")
input("Press Enter to return to menu...")
return

print("\t\t\tWhat do you want to do? \n")
print("\t\t1 : Install docker")
print("\t\t2 : Start docker service")
print("\t\t3 : Stop docker service")
print("\t\t4 : View docker info")
print("\t\t5 : View active containers")
print("\t\t6 : View all containers")
print("\t\t7 : View downloaded images")
print("\t\t8 : Pull an image")
print("\t\t9 : Launch a container")
print("\t\t10 : Stop a container")
print("\t\t11 : Start a container")
print("\t\t12 : Remove an image")
print("\t\t13 : Remove a container")
print("\t\t0 : Exit")
print()
while(True):
option=int(input("\n\tEnter your choice : "))

if (option==1):
if not os.system("{} rpm -q docker-ce"):
print("\tDocker is already installed. Exiting installation...")
else:
print("\tInstalling Docker...")
file=open("/etc/yum.repos.d/docker-ce_install.repo","a")
dockrepo = "[docker]\nbaseurl=https://download.docker.com/linux/centos/7/x86_64/stable/\ngpgcheck=0\n"
file.write(dockrepo)
file.close()
os.system("yum install docker-ce --nobest")

elif (option==2):
os.system("systemctl start docker")

elif (option==3):
os.system("systemctl stop docker")

elif (option==4):
os.system("docker info")

elif (option==5):
os.system("docker ps")

elif (option==6):
os.system("docker ps -a")

elif (option==7):
os.system("docker images")

elif (option==8):
image=input("\tEnter image name: ")
version=input("\tEnter image version (optional): ")
if image:
if version != "" :
os.system("docker pull {}:{}".format(image,version))
else :
os.system("docker pull {}".format(image))
else:
print("\n\tNo image name entered!")

elif (option==9):
img = input("\tEnter image name: ")
ver = input("\tEnter image version (optional): ")
name = input("\tEnter container name: ")
if image:
if version != "" :
os.system("docker run -it --name {} {}:{}".format(name,image,version))
else :
os.system("docker run -it --name {} {}".format(name,image))
else:
print("\n\tNo image name entered!")

elif (option==10):
name_id = input("\tEnter container name or id: ")
if name_id :
os.system("docker stop {}".format(name_id))
else :
print("\tPlease enter a container name/ID!")

elif (option==11):
name_id = input("\tEnter container name or ID: ")
if name_id :
os.system("docker start {}".format(name_id))
else :
print("\tPlease enter a container name/ID!")

elif(option==12):
img = input("\tEnter image name: ")
ver = input("\tEnter image version (optional): ")
if img:
if ver != "" :
os.system("docker rmi {}:{} --force".format(img,ver))
else:
os.system("docker rmi {} --force".format(img))
else:
print("\tPlease enter an image name!")

elif (option==13):
name_id = input("\tEnter container name or ID: ")
if name_id :
os.system("docker rm {}".format(name_id))
else :
print("\tPlease enter a container name/ID!")

elif (option==0):
break
else:
print("\tInvalid choice!\n")
return
4 changes: 1 addition & 3 deletions ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,4 @@ def ec2menu(prof):
else:
print("Invalid choice!!! Choose from 1-15 or Q to exit.\n")
return




36 changes: 13 additions & 23 deletions menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import os
import ec2
import docker
import Lvmautomate
import ml

from subprocess import PIPE, run, check_output,call

import ec2
Expand Down Expand Up @@ -144,43 +148,29 @@ def awsMenu():
return


# function to launch Hadoop cluster
def lchadoop():
return


# function to launch Docker containers
def lcdocker():
return


# function to simulate ML models
def simml():
return


# add more functions if required below -


while True:
print("\n\t\t\t\t-------------------\
\n\t\t\t\t| TECH STACK MENU |\
\n\t\t\t\t-------------------\n")

# Add menu options based on your requirement or idea. These are just temporary for now.
# Based on added menu options, create functions too with additional elif statements.
print("1. AWS CLI\t 2. Configure Hadoop\t3. Configure Docker\n4. Simulate ML Model\n")
print("Press Q to quit.\n")
print("1. AWS CLI \t2. Configure Hadoop \t3. Configure Docker\
\n4. Simulate ML Model\t5. Create LVM Partition\
\nOptions 3 and 4 executable only in a UNIX Machine...")
print("\nPress Q to quit.\n")
choice = input("> ")

if choice == '1':
awsMenu()
elif choice == '2':
lchadoop()
continue
elif choice == '3':
lcdocker()
docker.dockerMenu()
elif choice == '4':
simml()
ml.mlModel()
elif choice == '5':
Lvmautomate.lvmAuto()
elif choice == 'Q' or choice == 'q':
break
else:
Expand Down
27 changes: 16 additions & 11 deletions ml.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import pandas
dataset=pandas.read_csv('/root/Salary_Data.csv')
y=dataset['Salary']
x=dataset['YearsExperience']
from sklearn.linear_model import LinearRegression
x=x.values
x=x.reshape(-1,1)
model=LinearRegression()
model.fit(x,y)
exp=input('\t\t\t\tEnter Value to Predict from DataSet :- ')
print('\t\t\t\tPredicted Value is :- ', end='')
print(model.predict([[float(exp)]]))
print()


def mlModel():
dataset = pandas.read_csv(r"pythonMenuStack\Salary_Data.csv")
print(dataset.head())
y = dataset['Salary']
x = dataset['YearsExperience']
x = x.values
x = x.reshape(-1, 1)
model = LinearRegression()
model.fit(x, y)
exp = input('\t\t\t\tEnter Value to Predict from DataSet :- ')
print('\t\t\t\tPredicted Value is :- ', end='')
print(model.predict([[float(exp)]]))
print()
return
13 changes: 0 additions & 13 deletions mlmodel.py

This file was deleted.

0 comments on commit d885e87

Please sign in to comment.