Ejemplo n.º 1
0
def hadoop_master():
    nn_ip = input(
        "Enter the IP of the system which you want to cofigure as Hadoop Master :- "
    )
    #nn_username = input("Enter the username :- ")
    #os.system("ssh {0} ".format(nn_ip))
    #os.system("git clone --quiet https://github.com/Ajaypathak372/arth-team-task1.git > /dev/null")
    #os.system("ssh {0} python3 -u- < ~/master/master.py".format(nn_ip)")
    os.system(
        "scp -r ./Hadoop-files/master {}:/root > /dev/null".format(nn_ip))
    os.system("ssh {0} python3 ~/master/master.py".format(nn_ip))
    os.system("rm -rf ~/master")
    accessories.wait()
Ejemplo n.º 2
0
def hadoop_slave():
    dn_ip = []
    dn = int(input("How many DataNodes(Slaves) you want to configure :-  "))
    for i in range(0, dn):
        ip = input(
            "Enter the IP Address of the DataNode(Slave) {} :- ".format(i + 1))
        dn_ip.append(ip)
        #dn_username = input("Enter the username :- ")
    for j in dn_ip:
        #os.system("git clone --quiet https://github.com/Ajaypathak372/arth-team-task1.git > /dev/null")
        os.system("scp -r ./Hadoop-files/slave {}:/root > /dev/null".format(j))
        print("Configuring Datanode {} ".format(j))
        os.system("ssh {0} python3 ~/slave/slave.py".format(j))
        os.system("rm -rf ~/slave")
    accessories.wait()
Ejemplo n.º 3
0
def s3():
    while True:
            os.system("clear")
            print("""
            [1] : Create New S3 Bucket
            [2] : Delete S3 bucket
            [3] : Upload object in S3 bucket
            [4] : Delete object in S3 bucket
            [5] : Delete S3 bucket
            [6] : Back
            """)
            bucket_ch = input("Enter your Choice :- ")
            if int(bucket_ch) == 1:
                s3_name = input("Enter S3 bucket name that must be unique: ")
                #region = input("Enter name of region: ")
                print("Creating S3 Bucket.....")
                os.system('aws s3api create-bucket --bucket {} --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1'.format(s3_name))
                print("S3 bucket created successfully....")
                accessories.wait()
            elif int(bucket_ch) == 2:
                s3_name = input("Enter S3 Bucket name: ")
                print("Deleting S3 bucket...")
                os.system("aws s3api delete-bucket --bucket {} --region ap-south-1".format(s3_name))
                print("Successfully deleted S3 bucket.....")
                accessories.wait()
            elif int(bucket_ch) == 3:
                object_name = input("Enter Object name (with full path) to put inside S3 bucket: ")
                s3_name = input("Enter S3 Bucket name: ")
                print("Uploading object....")
                os.system('aws s3 cp {0} s3://{1} --acl public-read'.format(object_name , s3_name))
                print("Successfully uploaded object in S3 bucket...")
                accessories.wait()
            elif int(bucket_ch) == 4:
                s3_name = input("Enter S3 bucket name: ")
                object_name = input("Enter object name: ")
                print("Deleting object....")
                os.system('aws s3 rm s3://{}/{}'.format(s3_name , object_name))
                print("Successfully deleted object...")
                accessories.wait()
            elif int(bucket_ch) == 5:
                s3_name = input("Enter name of bucket: ")
                region = input("Enter region name: ")
                print("Deleting S3 Bucket....")
                os.system("aws s3api delete-bucket --bucket {} --region {}".format(s3_name,region))
                print("Successfully S3 bucket successfully....")
                accessories.wait()
            elif int(bucket_ch) == 6:
                break
Ejemplo n.º 4
0
def aws_menu():
    while True:
        os.system("clear")
        accessories.figlet("AWS Menu", "starwars", 3)
        os.system("tput bold")
        os.system("tput setaf 2")
        print("""
        Which service you want to use ?\n
        [1] : Install AWS CLI 
        [2] : Configure AWS CLI with your AWS account
        [3] : EC2
        [4] : EBS
        [5] : S3
        [6] : Return to Main Menu
        [7] : Exit
        """)
        os.system("tput sgr 0")
        opt_4 = int(input("Enter your choice : "))
        if opt_4 == 1:
            os.system("""
            if ls /usr/local | grep aws-cli > /dev/null
            then echo 'AWS CLI is already installed'
            else
            echo 'Installing AWS CLI......'
            curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" > /dev/null
            unzip awscliv2.zip > /dev/null
            sudo ./aws/install > /dev/null
            if aws --version | grep aws
            then echo 'AWS CLI is successfully installed'
            else echo 'Could not able to install AWS CLI'
            fi 
            fi
            """)
            accessories.wait()
        elif opt_4 == 2:
            print(
                "Note : To configure AWS CLI you need to have an IAM user created in your AWS account"
            )
            opt_4_1 = input("Enter your IAM user profile name :- ")
            print("Enter your IAM user credentials and details below")
            os.system("aws configure")
            print("AWS CLI configured to use for {} user".format(opt_4_1))
            accessories.wait()
        elif opt_4 == 3:
            aws.ec2()
        elif opt_4 == 4:
            aws.ebs()
        elif opt_4 == 5:
            aws.s3()
        elif opt_4 == 6:
            break
        elif opt_4 == 7:
            exit()
        else:
            print("Invalid choice!!!")
            accessories.wait()
Ejemplo n.º 5
0
def ebs():
    while True:
        os.system("clear")
        print("""
        [1] : Create new Volume
        [2] : Attach Volume to Specific Instance
        [3] : Dettach Volume
        [4] : Delete Volume
        [5] : Show Volumes
        [6] : Mount and Partition
        [7] : Back
        """)
        vol_ch = input("Enter your Choice: ")
        if int(vol_ch) == 1:
            az = input("Enter Availablity Zone to Create EBS Volume: ")
            ebs_size = input("Enter Size to create EBS Volume: ")
            print("Creating New Volume ....")
            os.system('aws ec2 create-volume --availability-zone {} --size {}'.format(az , ebs_size))
            print("New Volume Created Successfully....")
            accessories.wait()
        elif int(vol_ch) == 2:
                ebs_vid = input("Enter EBS Volume ID to Attach to EC2 Instance: ")
                ec2_id = input("Enter EC2 Instance ID to attach EBS Volume: ")
                print("Attaching Volume to instance.....")
                os.system('aws ec2 attach-volume --volume-id {} --instance-id {} --device /dev/sdg'.format(ebs_vid , ec2_id))
                print("Successfully Volume attached to the instance.......")
                accessories.wait() 
        elif int(vol_ch) == 3:
                v_id = input("Enter volume id: ")
                print("Detaching Volume.......")
                os.system("aws ec2 detach-volume --volume-id {}".format(v_id))
                print("Volume Dettached Successfully.....")
                accessories.wait()
        elif int(vol_ch) == 4:
                 v_id = input("Enter volume id: ")
                 print("Deleting Volume....")
                 os.system("aws ec2 delete-volume --volume-id {}".format(v_id))
                 print("Successfully deleted Volume...")
                 accessories.wait()
        elif int(vol_ch) == 5:
                os.system("aws ec2  describe-volumes")
                accessories.wait()
        elif int(vol_ch) == 6:
               ip = input("Enter Public IP of EC2: ")
               ky = input("Enter Private Key Name For Login Into EC2 : ")
               os.system('ssh -l ec2-user {} -i {}.pem sudo fdisk -l'.format(ip , ky))
               na = input("\nEnter Partition Name: ")
               nb = input("Enter directory name: ") 
               os.system("ssh -l ec2-user {} -i {}.pem sudo mkdir {}".format(ip,ky,nb))
               os.system('ssh -l ec2-user {} -i {}.pem sudo mkfs.ext4 {}'.format(ip , ky , na))
               os.system('ssh -l ec2-user {} -i {}.pem sudo mount {}  {}'.format(ip , ky , na,nb))
               os.system('ssh -l ec2-user {} -i {}.pem sudo df -hT'.format(ip , ky))
               accessories.wait()
        elif int(vol_ch) == 7:
                break
Ejemplo n.º 6
0
def ec2():
        while True:
            os.system("clear")
            print("""
            [1] : Create New EC2 Instance
            [2] : Start Specific Instance
            [3] : Stop Instance
            [4] : Terminate Instance
            [5] : Show all instances
            [6] : Security Groups
            [7] : Back
            """)
            ec2_ch = input("Enter your choice :- ")
            if int(ec2_ch) == 1:
                ami = input("Enter AMI id to Launch Instance: ")
                instance_type = input("Enter Instance type: ")
                count = input("Enter Number of Instances to launch: ")
                subnet_id = input("Enter Subnet id: ")
                sg_id1 = input("Enter Security Group Id to attach to the Instance: ")
                key = input("Enter Key to attach to ec2 Instance: ")
                print("Launching New EC2 Instance.....")
                os.system('aws ec2 run-instances --image-id {} --instance-type {} --count {} --subnet-id {} --security-group-ids {} --key-name {}'.format(ami , instance_type , count ,subnet_id, sg_id1 , key))
                print("Instance launched Successfully......")
                accessories.wait()
            elif int(ec2_ch) == 3:
                id = input("Enter Instance id to stop Ec2 instances: ")
                print("Stopping Instance.......")
                os.system("aws ec2 stop-instances --instance-ids {}".format(id))
                print("Insatnce stopped Successfully....")
                accessories.wait()
            elif int(ec2_ch) == 2:
                id = input("Enter Instance id to start Ec2 instances: ")
                print("Starting Instance.....")
                os.system("aws ec2 start-instances --instance-ids {}".format(id))
                print("Instance Started successfully......")
                accessories.wait()
            elif int(ec2_ch) == 4:
                id = input("Enter Instance id to terminate Ec2 instances: ")
                print("Terminating instance...")
                os.system("aws ec2 terminate-instances --instance-ids {}".format(id))
                print("Instance terminated successfully.....")
                accessories.wait()
            elif int(ec2_ch) == 5:
                print("Showing Instances....")
                os.system("aws ec2 describe-instances")
                accessories.wait()
            elif int(ec2_ch) == 6:
                print("""
                [1] : Create new security group
                [2] : Delete Security group
                [3] : Add Ingress Rules
                [4] : Show Security Groups
                [5] : Back
                """)
                sg_ch1 = input("Enter your choice: ")
                if int(sg_ch1) == 1:
                    sg_name = input("Enter Security group Name: ")
                    sg_des = input("Enter Security group description: ")
                    print("Creating New Security group....")
                    os.system("aws ec2 create-security-group --group-name {0} --description {1}".format(sg_name,sg_des))
                    print("Successfully created security group....")
                    accessories.wait()
                elif int(sg_ch1) == 2:
                    sg_id=input("Enter Security group id you want to delete:  ")
                    print("Deleting Security group...")
                    os.system("aws ec2 delete-security-group --group-id {}".format(sg_id))
                    print("Successfully deleted Security group....")
                    accessories.wait()
                elif int(sg_ch1) == 3:
                    sg_id = input("Enter Security Group ID : ")
                    ip_protocol = input("Enter IP Protocol: ")
                    port_no = input("Enter Port No: ")
                    cidr=input("Input Ip Ranges : ")
                    print("Authorizing Security group....")
                    os.system("aws ec2 authorize-security-group-ingress --group-id {} --protocol {} --port {} --cidr {}".format(sg_id , ip_protocol , port_no , cidr))
                    print("Sucessfully authorize security group...")
                    accessories.wait()
                elif int(sg_ch1) == 4:
                    sg_id2 = input("Enter group id : ")
                    sg_name1 = input("Enter name of Security Group: ")
                    os.system("aws ec2 describe-security-groups --group-ids {} --group-names {}".format(sg_id2,sg_name1))
                    accessories.wait()
                elif int(sg_ch1) == 5:
                    continue
            elif int(ec2_ch) == 7:
                break
Ejemplo n.º 7
0
def partitions():
    while True:
        os.system("clear")
        accessories.figlet("LVM", "Roman", 4)
        os.system("tput bold")
        os.system("tput setaf 2")
        print("""
        Select from the options below\n
        [1] : Create Physical Volume
        [2] : Create Volume Group
        [3] : Create Logical Partition
        [4] : Format partitions
        [5] : Extend Partition Size
        [6] : Reduce Partition Size
        [7] : Extend Volume Group Size
        [8] : Return to main menu
        [9] : Exit
        """)
        os.system("tput sgr 0")
        opt_6 = int(input("Enter your choice :- "))
        if opt_6 == 1:
            n = input(
                "Enter the number which you want to create Physical Volume: ")
            for i in range(int(n)):
                n1 = input("Enter {} disk name: ".format(i))
                os.system("pvcreate {}".format(n1))
                os.system("pvdisplay {}".format(n1))
        elif opt_6 == 2:
            c = input("Enter the name of Volume group: ")
            os.system("vgcreate {0} {1}".format(c, n1))
            os.system("vgdisplay {0}".format(c))
        elif opt_6 == 3:
            s = input("Enter the size of LV: ")
            n2 = input("Enter the name of LV: ")
            vg = input("Enter name of volume group: ")
            os.system("lvcreate --size {0}G --name {1} {2}".format(s, n2, vg))
            os.system("lvdisplay {0}".format(n2))
        elif opt_6 == 4:
            print("""
            Select format type
            [1] : mkfs.ext4
            [2] : resize2fs
            [3] : Back
            """)
            fmt_ch = input("Enter your choice: ")
            if int(fmt_ch) == 1:
                vg = input("Enter name of volume group: ")
                lv = input("Enter name of logical VOlume: ")
                os.system("mkfs.ext4 /dev/{0}/{1}".format(vg, lv))
            elif int(fmt_ch) == 2:
                vg1 = input("Enter name of volume group: ")
                lv1 = input("Enter name of logical VOlume: ")
                os.system("resize2fs /dev/{0}/{1}".format(vg1, lv1))
                os.system("df -H")
            elif int(fmt_ch) == 3:
                continue
        elif opt_6 == 5:
            e = input("Please enter the Volume Group Name :- ")
            g = input(
                "Please enter your Paraition Name (for example sdd2) :- ")
            l = int(input("Enter how much size you want to increase: "))
            os.system("lvextend --size +{}G /dev/{}/{}".format(l, e, g))
            os.system("resize2fs /dev/{}/{}".format(e, g))
            accessories.wait()
        elif opt_6 == 6:
            e = input("Please enter the Volume Group Name :- ")
            g = input("Please enter your Paraition Name(for example sdd2): ")
            l = int(input("Enter how much size you want to reduce: "))
            os.system("lvreduce -r -L --size +{}G /dev/{}/{}".format(l, e, g))
            accessories.wait()
        elif opt_6 == 7:
            y = input("Enter the Partition Name you want to increase: ")
            os.system("vgextend {} /dev/{}".format(e, y))
            accessories.wait()
        elif opt_6 == 8:
            break
        elif opt_6 == 9:
            exit()
        else:
            print("Invalid choice!!!")
Ejemplo n.º 8
0
def webserver():
    while True:
        os.system("clear")
        accessories.figlet("HTTPD   WebServer", "Banner3-D", 6)
        os.system("tput bold")
        os.system("tput setaf 2")
        print("""
	Select from the options below\n
        [1] : Install HTTPD Webserver
        [2] : Start/Stop HTTPD services
        [3] : Start/Stop HTTPD services permanently
        [4] : Create a webpage
        [5] : Return to main menu
        [6] : Exit
        """)
        os.system("tput sgr 0")
        opt_5 = int(input("Enter your choice :- "))
        if opt_5 == 1:
            os.system("""
            if rpm -q httpd | grep httpd
then echo "HTTPD WebServer Package is already installed"
else 
echo "Installing Apache HTTPD Webserver....."
yum install httpd -y > /dev/null
echo "HTTPD successfully Installed"
fi
            """)
            accessories.wait()
        elif opt_5 == 2:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_5_2 = int(input("Enter your choice :- "))
            if opt_5_2 == 1:
                os.system("systemctl start httpd")
                print("HTTPD services started successfully")
                accessories.wait()
            elif opt_5_2 == 2:
                os.system("systemctl stop httpd")
                print("HTTPD services stopped successfully")
                accessories.wait()
            elif opt_5_2 == 3:
                continue
        elif opt_5 == 3:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_5_3 = int(input("Enter your choice :- "))
            if opt_5_3 == 1:
                os.system("systemctl enable httpd")
                print(
                    "HTTPD services started permanently and no need to restart on every boot"
                )
                accessories.wait()
            elif opt_5_3 == 2:
                os.system("systemctl disable httpd")
                print(
                    "HTTPD services has disabled and need to be restart on every boot"
                )
                accessories.wait()
            elif opt_5_3 == 3:
                continue
        elif opt_5 == 4:
            opt_5_4 = input(
                "Want to copy the webpage or create a new one[y/n] :- ")
            if opt_5_4 == 'y':
                page = input("Enter the webpage name with full path :- ")
                os.system("cp -rf {} /var/www/html".format(page))
                print("WebPage copied successfully")
                accessories.wait()
            elif opt_5_4 == 'n':
                page = input(
                    "Enter the webpage name(with .html extension) :- ")
                print(
                    repr(
                        "Note : To give newline in the text use \n between the text and for tab use \t"
                    ))
                data = input("Enter the text ih HTML :- ")
                os.system("printf '{1}' >> /var/www/html/{0}".format(
                    page, data))
                print("webpage created !!")
                accessories.wait()
        elif opt_5 == 5:
            break
        elif opt_5 == 6:
            exit()
        else:
            print("Invalid choice!!!")
            accessories.wait()
Ejemplo n.º 9
0
def docker():
    while True:
        os.system("clear")
        accessories.figlet("Docker", "Blocks", 6)
        os.system("tput bold")
        os.system("tput setaf 2")
        print("""
        [1] : Install Docker
        [2] : Start/Stop Docker Services Temporialy
        [3] : Start/Stop Docker Services Permanently
        [4] : Launch Containers
        [5] : Start/Stop a container
        [6] : List all running containers
        [7] : List all stopped containers
        [8] : List all Saved Docker Images
        [9] : Remove all stopped containers
        [10] : Remove all running containers
        [11] : Remove images
        [12] : To see the details of an container 
        [13] : Return to main menu
        [14] : Exit
        """)
        os.system("tput sgr 0")
        opt_3 = int(input("Enter your choice :- "))
        if opt_3 == 1:
            os.system("""
            if rpm -q docker-ce | grep docker
then echo "Docker Package is already installed"
else 
echo "Docker Package is not installed"
echo "Installing Docker......"
echo "Configuring yum for Docker"
cat <<EOF > /etc/yum.repos.d/docker.repo
[docker-repo]
name=Docker Configuration Repository
baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/
gpgcheck=0
EOF
yum install -y docker-ce --nobest > /dev/null
fi
            """)
            accessories.wait()
        elif opt_3 == 2:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_3_2 = int(input("Enter your choice :- "))
            if opt_3_2 == 1:
                os.system("systemctl start docker --now")
                print("Docker services started successfully")
                accessories.wait()
            elif opt_3_2 == 2:
                os.system("systemctl stop docker")
                print("Docker services stopped successfully")
                accessories.wait()
            elif opt_3_2 == 3:
                continue
        elif opt_3 == 3:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_3_3 = int(input("Enter your choice :- "))
            if opt_3_3 == 1:
                os.system("systemctl enable docker")
                print(
                    "Docker services started permanently means docker services will automatically start when system boots"
                )
                accessories.wait()
            elif opt_3_3 == 2:
                os.system("systemctl stop docker")
                print(
                    "Docker services are disabled and will not start on boot and have to start everytime when system boots"
                )
                accessories.wait()
            elif opt_3_3 == 3:
                continue
        elif opt_3 == 4:
            print("""
            [1] : Launch container in background
            [2] : Launch container with mapped port and attached volume
            [3] : Get the terminal of a running container
            [4] : Run commands inside the docker container
            [5] : Back
            """)
            opt_3_4 = int(input("Enter your choice :- "))
            if opt_3_4 == 1:
                cont_name = input("Enter the name for the container :- ")
                image = input(
                    "Enter the name of the docker image with tag (or for latest just give image name):- "
                )
                os.system("docker run -dit --name {0} {1}".format(
                    cont_name, image))
                print("container is running in background")
                accessories.wait()
            elif opt_3_4 == 2:
                cont_name = input("Enter the name for the container :- ")
                image = input(
                    "Enter the name of the docker image with tag (or for latest just give image name):- "
                )
                cont_port = input(
                    "Enter the port number of the container to be mapped :- ")
                port = input(
                    "Enter the free port number used to access the container :- "
                )
                vol = input(
                    "Enter the directory name with path to be mounted with the container :- "
                )
                cont_vol = input(
                    "Enter the directory name with path in the container which is to be mounted :- "
                )
                os.system(
                    "docker run -dit -p {2}:{3} -v {4}:{5} --name {0} {1}".
                    format(cont_name, image, port, cont_port, vol, cont_vol))
                print("container is running in background")
                accessories.wait()
            elif opt_3_4 == 3:
                cont_name = input("Enter the container's name or id :- ")
                os.system("docker exec -it {} /bin/bash".format(cont_name))
            elif opt_3_4 == 4:
                cont_name = input("Enter the container's name or id :- ")
                cmd = input("Enter the command :- ")
                os.system("docker exec -it {0} /bin/bash -c {1}".format(
                    cont_name, cmd))
            elif opt_3_4 == 5:
                continue
            else:
                print("Invalid choice!!!")
                accessories.wait()
        elif opt_3 == 5:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_3_5 = int(input("Enter your choice :- "))
            if opt_3_5 == 1:
                cont_name = input("Enter the container's name or id :- ")
                os.system("docker start {}".format(cont_name))
                accessories.wait()
            elif opt_3_5 == 2:
                cont_name = input("Enter the container's name or id :- ")
                os.system("docker stop {}".format(cont_name))
                accessories.wait()
            elif opt_3_5 == 3:
                continue
        elif opt_3 == 6:
            os.system("docker ps")
            accessories.wait()
        elif opt_3 == 7:
            os.system("docker ps -a")
            accessories.wait()
        elif opt_3 == 8:
            os.system("docker images -a")
            accessories.wait()
        elif opt_3 == 9:
            os.system("docker rm -f $(docker ps -aq)")
            print("All Stopped containers has been removed")
            accessories.wait()
        elif opt_3 == 10:
            os.system("docker rm -f $(docker ps -q)")
            print("All Running containers has been removed")
            accessories.wait()
        elif opt_3 == 11:
            print("""
            [1] : Remove an image
            [2] : Remove all images
            [3] : Back
            """)
            opt_3_11 = int(input("Enter your choice :- "))
            if opt_3_11 == 1:
                image_name = input("Enter the image name or id :- ")
                os.system("docker rmi -f {}".format(image_name))
                accessories.wait()
            elif opt_3_11 == 1:
                os.system("docker rmi $(docker images -aq)")
                accessories.wait()
            elif opt_3_11 == 3:
                continue
        elif opt_3 == 12:
            cont_name = input("Enter the container's name or id :- ")
            os.system("docker inspect {}".format(cont_name))
            accessories.wait()
        elif int(opt_3) == 13:
            break
        elif int(opt_3) == 14:
            exit()
        else:
            print("Invalid choice!!!")
            accessories.wait()
Ejemplo n.º 10
0
def linux():
    #cmd = input("Enter the command you want to run :- ")
    #cmd_out = os.system(" {} ".format(cmd))
    #return cmd_out
    while True:
        os.system("clear")
        accessories.figlet("Linux", "Poison", 4)
        os.system("tput bold")
        os.system("tput setaf 2")
        print("""
        Select from the options below\n
        [1] : Know system date and time
        [2] : See calender
        [3] : Know current directory
        [4] : Create an empty file
        [5] : Create a directory
        [6] : See the content of a file 
        [7] : Write some data in a file
        [8] : Copy a file/directory
        [9] : Move a file
        [10] : Move a directory
        [11] : Check OS details
        [12] : Know the IP of this System
        [13] : See how much RAM is free
        [14] : see the CPU details
        [15] : See all the partitions and disks attached to this system
        [16] : See the details of all the Filesystems
        [17] : Return to main menu
        [18] : Exit
        """)
        os.system("tput sgr o")
        cmd = input("Enter your choice :- ")
        if int(cmd) == 1:
            os.system("date")
            accessories.wait()
        elif int(cmd) == 2:
            os.system("cal")
            accessories.wait()
        elif int(cmd) == 3:
            os.system("pwd")
            accessories.wait()
        elif int(cmd) == 4:
            file_name = input(
                "Enter the path with file name where the file has to be created :- "
            )
            #file_path = input("Enter the path to the directory where you want to create the file :- ")
            os.system("touch {}".format(file_name))
            accessories.wait()
        elif int(cmd) == 5:
            dir_name = input("Enter the directory name :- ")
            os.system("mkdir -p {}".format(dir_name))
            accessories.wait()
        elif int(cmd) == 6:
            file_path = input("Enter the path with the file name :- ")
            os.system("cat {}".format(file_path))
            accessories.wait()
        elif int(cmd) == 7:
            print("""
            [1] : To overwrite the data
            [2] : To append the data
            [3] : Back
            """)
            ch_7 = int(input("Enter your choice :- "))
            if ch_7 == 1:
                file_name = input("Enter the file name :- ")
                print(
                    repr(
                        "Note : To give newline in the text use \n between the text and for tab use \t"
                    ))
                data = input("Enter the text :- ")
                os.system("printf '{1}' > {0}".format(file_name, data))
                accessories.wait()
            elif ch_7 == 2:
                file_name = input("Enter the file name :- ")
                print(
                    repr(
                        "Note : To give newline in the text use \n between the text and for tab use \t"
                    ))
                data = input("Enter the text :- ")
                os.system("printf '{1}' >> {0}".format(file_name, data))
                accessories.wait()
            elif ch_7 == 3:
                continue
        elif int(cmd) == 8:
            src = input(
                "Enter the path of the file/directory which you want to copy :- "
            )
            dest = input("Enter the destination Path :- ")
            os.system("cp -rf {0} {1}".format(src, dest))
            accessories.wait()
        elif int(cmd) == 9:
            src = input(
                "Enter the path of the file which you want to move :- ")
            dest = input("Enter the destination Path :- ")
            os.system("mv -f {0} {1}".format(src, dest))
            accessories.wait()
        elif int(cmd) == 10:
            src = input(
                "Enter the path of the directory which you want to move :- ")
            dest = input("Enter the destination Path:- ")
            os.system("mv -rf {0} {1}".format(src, dest))
            accessories.wait()
        elif int(cmd) == 11:
            print(os.system("cat /etc/os-release"))
            accessories.wait()
        elif int(cmd) == 12:
            os.system("""
            if ifconfig | grep enp0s3 > /dev/null
            then ifconfig enp0s3 | grep inet* | head -n +1 | cut -c 14-26
            else 
            if ifconfig | grep eth0 > /dev/null
            then ifconfig eth0 | grep inet* | head -n +1 | cut -c 14-26
            else echo "Unknown Network Card (NIC)"
            fi
            fi""")
            accessories.wait()
        elif int(cmd) == 13:
            os.system("free -h")
            accessories.wait()
        elif int(cmd) == 14:
            os.system("lscpu")
            accessories.wait()
        elif int(cmd) == 15:
            os.system("fdisk -lL")
            accessories.wait()
        elif int(cmd) == 16:
            os.system("df -hT")
            accessories.wait()
        elif int(cmd) == 17:
            break
        elif int(cmd) == 18:
            exit()
        else:
            print("Invalid choice!!!")
            accessories.wait()
Ejemplo n.º 11
0
def hadoop():
    while True:
        os.system("clear")
        accessories.figlet("Hadoop Menu", "Train", 5)
        os.system("tput bold")
        os.system("tput setaf 2")
        print("""
        [1] : Install Hadoop
        [2] : To setup hadoop master
        [3] : To setup hadoop DataNodes(Slaves)
        [4] : Configure hadoop client
        [5] : See Hadoop Cluster details
        [6] : Upload data to hadoop cluster
        [7] : Read data from hadoop cluster
        [8] : Delete data from hadoop cluster
        [9] : Limit the size of Datanode storage
        [10] : Start/Stop Hadoop master
        [11] : Start/Stop Hadoop DataNode
        [12] : Return to main menu
        [13] : Exit
        """)
        os.system("tput sgr 0")
        opt_2 = input("Enter your choice :- ")
        if int(opt_2) == 1:
            #os.system("git clone --quiet https://github.com/Ajaypathak372/arth-team-task1.git > /dev/null")
            os.system("bash ./hadoop")
            accessories.wait()
        elif int(opt_2) == 2:
            hadoop_master()
        elif int(opt_2) == 3:
            hadoop_slave()
        elif int(opt_2) == 4:
            client_ip = input(
                "Enter the IP of the system which you want to cofigure as Hadoop Client :- "
            )
            #os.system("git clone --quiet https://github.com/Ajaypathak372/arth-team-task1.git > /dev/null")
            os.system(
                "scp -r ./Hadoop-files/client {}:/root > /dev/null".format(
                    client_ip))
            os.system("ssh {0} python3 ~/client/client.py".format(client_ip))
        elif int(opt_2) == 5:
            opt_2_4 = input(
                "Enter the NameNode IP or any DataNode IP associated with Hadoop Cluster :- "
            )
            print("Hadoop Cluster details are ......")
            os.system("ssh {} hadoop dfsadmin -report".format(opt_2_4))
            accessories.wait()
        elif int(opt_2) == 6:
            client_ip = input("Enter Client IP :- ")
            file_name = input(
                "Enter the file name (with path) you want to upload :- ")
            os.system("ssh {0} hadoop fs -put {1} /".format(
                client_ip, file_name))
            print("File Successfully uploaded")
            accessories.wait()
        elif int(opt_2) == 7:
            client_ip = input("Enter Client IP :- ")
            file_name = input(
                "Enter the file name whose data you want to read :- ")
            os.system("ssh {0} hadoop fs -cat /{1}".format(
                client_ip, file_name))
            accessories.wait()
        elif int(opt_2) == 8:
            client_ip = input("Enter Client IP :- ")
            file_name = input("Enter the file name you want to delete :- ")
            os.system("ssh {0} hadoop fs -rm /{1}".format(
                client_ip, file_name))
            print("File Successfully deleted")
            accessories.wait()
        elif int(opt_2) == 9:
            print("""
            [1] : Extend the Storage
            [2] : Reduce the Storage
            [3] : Back
            """)
            limit = input("Enter your choice :- ")
            if limit == 1:
                ip = input("Enter the DataNode storage IP :- ")
                os.system('ssh {} df -hT'.format(ip))
                ex = input("How much you want to extend? : ")
                vg = input("Enter Your Volume Group Name : ")
                lv = input("Enter Your Logical Volume Name : ")
                os.system('ssh {} lvextend --size {} /dev/{}/{}'.format(
                    ip, ex, vg, lv))
                print("Data Node Storage Sucessfully Extended")
                os.system('ssh {} resize2fs  /dev/{}/{}'.format(ip, vg, lv))
                os.system('ssh {} df -hT'.format(ip))
                accessories.wait()
            elif limit == 2:
                accessories.wait()
            elif limit == 3:
                continue
        elif int(opt_2) == 10:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_2_10 = int(input("Enter your choice :- "))
            if opt_2_10 == 1:
                nn_ip = input("Enter the NameNode IP :- ")
                os.system(
                    "ssh {} hadoop-daemon.sh start namenode".format(nn_ip))
                print("NameNode Started Successfully")
                accessories.wait()
            elif opt_2_10 == 2:
                nn_ip = input("Enter the NameNode IP :- ")
                os.system(
                    "ssh {} hadoop-daemon.sh stop namenode".format(nn_ip))
                print("NameNode Stopped Successfully")
                accessories.wait()
            elif opt_2_10 == 3:
                continue
        elif int(opt_2) == 11:
            print("""
            [1] : Start
            [2] : Stop
            [3] : Back
            """)
            opt_2_11 = int(input("Enter your choice :- "))
            if opt_2_11 == 1:
                nn_ip = input("Enter the DataNode IP :- ")
                os.system(
                    "ssh {} hadoop-daemon.sh start datanode".format(nn_ip))
                print("DataNode Started Successfully")
                accessories.wait()
            elif opt_2_11 == 2:
                nn_ip = input("Enter the DataNode IP :- ")
                os.system(
                    "ssh {} hadoop-daemon.sh stop datanode".format(nn_ip))
                print("DataNode Stopped Successfully")
                accessories.wait()
            elif opt_2_11 == 3:
                continue
        elif int(opt_2) == 12:
            break
        elif int(opt_2) == 13:
            exit()
        else:
            print("Invalid Choice!!!")
            accessories.wait()
Ejemplo n.º 12
0
    print("""
    select from the options below\n
    Press 1 : To Run Some Basic linux commands (RHEL 8)
    Press 2 : To setup Hadoop Cluster
    Press 3 : For using Docker
    Press 4 : To use some AWS services
    Press 5 : To configure WebServer
    Press 6 : Create Partitions 
    Press 7 : Exit
	""")

    ch = input("\tEnter your choice :-  ")
    os.system("tput sgr 0")
    if int(ch) == 1:
        linux()
    elif int(ch) == 2:
        hadoop()
    elif int(ch) == 3:
        docker()
    elif int(ch) == 4:
        aws_menu()
    elif int(ch) == 5:
        webserver()
    elif int(ch) == 6:
        partitions()
    elif int(ch) == 7:
        exit()
    else:
        print("Invalid Choice !!!")
        accessories.wait()