コード例 #1
0
def webServer(sshIp=""):
    while True:
        os.system("tput clear")
        size = os.get_terminal_size()

        os.system("tput setaf 6; tput setab 0")
        os.system("tput clear")
        print("Webserver actions".center(size.columns))
        os.system("tput setaf 7; tput setab 0")

        speech.speak("here are the services provided")
        print(webserverval)
        speech.speak("What can i do for you?")
        opt = recog.voice_rec()
        opt = opt.lower()

        if "install" or "download" in opt:
            speech.speak("installing web server")
            os.system(f"{sshIp} dnf install httpd")

        elif "start" or "launch" in opt:
            speech.speak("starting web server")
            os.system(f"{sshIp} systemctl enable --now httpd")
            print("Web server started")

        elif "restart" or "again" in opt:
            speech.speak("restarting web server")
            os.system(f"{sshIp} systemctl restart httpd")
            print("Web server restarted")

        elif "stop" or "pause" in opt and "server" or "web" in opt:
            speech.speak("stopping web server")
            os.system(f"{sshIp} systemctl stop httpd")
            print("Web server stopped")

        elif "exit" or "quit" or "back" in opt:
            return

        else:
            print("Invalid request")
            speech.speak("invalid request")
        os.system("tput clear")
コード例 #2
0
def dockerMenu(sshIp=""):
    while True:
        out = ""

        os.system("tput clear")
        size = os.get_terminal_size()

        os.system("tput setaf 6; tput setab 0")
        os.system("clear")
        print("Docker Operations".center(size.columns))
        os.system("tput setaf 7; tput setab 0")

        speech.speak("Here are the services provided")
        print(docker)

        speech.speak("What can i do for you?")
        subOpt = recog.voice_rec()
        subOpt = subOpt.lower()

        out = ""
        os.system("tput reset")
        if "create" or "new" in subOpt and "container" or "containers" in subOpt:
            speech.speak("Creating container...")
            out = startContainer(sshIp)

        elif "pull" or "download" in subOpt and "image" or "images" in subOpt:
            speech.speak("Pulling Image...")
            out = pullImg(sshIp)

        elif "running" in subOpt and "container" in subOpt:
            speech.speak("These are the running containers...")
            out = operate("container", "ls", sshIp)

        elif "list" or "show" in subOpt and "container" or "containers" in subOpt:
            speech.speak("Listing all containers...")
            out = operate("container", "ls -a", sshIp)

        elif "list" or "show" in subOpt and "os" or "images" in subOpt:
            speech.speak("Listing all images...")
            out = operate("image", "ls", sshIp)

        elif "start" or "launch" in subOpt and "container" or "containers" in subOpt:
            speech.speak("please enter container name or id")
            cnameId = input("Enter container name or id: ")
            speech.speak("Starting container...")
            out = operate("container", "start", cnameId, sshIp)
            speech.speak("container started...")

        elif "stop" or "pause" in subOpt and "container" or "containers" in subOpt:
            speech.speak("please enter container name or id")
            cnameId = input("Enter container name or id")
            out = operate("container", "stop", cnameId, sshIp)
            speech.speak("container stopped...")

        elif "delete" or "terminate" in subOpt and "container" or "containers":
            speech.speak("please enter container name or id")
            cnameId = input("Enter container name or id: ")
            out = operate("container", "rm -f", cnameId, sshIp)
            speech.speak("container terminated...")

        elif "execute" or "run" in subOpt and "mannual" or "mannually" in subOpt:
            cnameId = input("Enter container name or id: ")
            cmd = input("Enter the command you want to run: ")
            cnameId = f"{cnameId} {cmd}"
            out = operate("container", "exec -it", cnameId, sshIp)

        elif "exit" or "quit" or "back" in subOpt:
            return

        else:
            print("Invalid request")
            speech.speak("invalid request")
        os.system("tput clear")

        print(out)
コード例 #3
0
def static_part():
    while True:
        os.system("tput clear")
        size = os.get_terminal_size()
        os.system("tput setaf 6; tput setab 0")
        os.system("clear")
        print("Partitions".center(size.columns))
        os.system("tput setaf 7; tput setab 0")

        speech.speak("here are the services provided")
        print(partition)
        speech.speak("What can i do for you?")
        opt = recog.voice_rec()
        opt = opt.lower()

        if "list" or "show" in opt:
            os.system("fdisk -l")

        elif "create" or "make" or "new" in opt:
            speech.speak("enter the device name")
            device = input("Enter the Device name: ")

            speech.speak("primary or extended")
            p_type = input(
                "Which type of partition you want to create? [p(Primary)/e(Extended)]: "
            ).lower()

            speech.speak("enter partition number")
            number = input(
                "Enter the partition number (leave empty for default): ")

            speech.speak("enter first sector")
            start = input("Enter the First sector (leave empty for default): ")

            speech.speak("input last sector")
            end = input("Enter the Last sector (leave empty for default): ")
            os.system(
                f"printf 'n\n{p_type}\n{number}\n{start}\n{end}\nw\n' | fdisk {device}"
            )

        elif "delete" or "remove" in opt:
            speech.speak("enter the device name")
            device = input("Enter the Device name: ")
            os.system(f"printf 'd\nw\n' | fdisk {device}")

        elif "mount" or "connect" in opt:
            speech.speak("enter the device name")
            device = input("Enter the Device name: ")

            speech.speak("enter the path of directory")
            path = input("Enter the Directory path: ")
            os.system(f"mount {device} {path}")
            print(f"{device} mounted to {path} directory.")

        elif "format" in opt:
            speech.speak("enter the device name")
            device = input("Enter the Device name: ")
            os.system(f"mkfs.ext4 {device}")

        elif "exit" or "quit" or "back" in opt:
            return

        else:
            print("Invalid request")
            speech.speak("invalid request")
        os.system("tput clear")
コード例 #4
0
def logical_vol():
    while True:
        os.system("clear")
        size = os.get_terminal_size()

        os.system("tput setaf 6; tput setab 0")
        os.system("clear")
        print("Logical Volume Management".center(size.columns))
        speech.speak("Welcome to the logical volume management")
        os.system("tput setaf 7; tput setab 0")

        speech.speak("Here are the services provided")
        print(lvm_part)
        speech.speak("What can i do for you?")
        x = recog.voice_rec()
        x = x.lower()

        if "show" or "check" or "list" in x and "partitions" or "partition" or "storage" in x:
            speech.speak("listing partitions")
            os.system("fdisk -l")

        elif "create" or "make" or "new" in x and "physical" or "volumes" or "volumes" in x:
            while True:
                speech.speak("enter name of storage")
                pv1 = input("Enter the name of storage: ")
                os.system(f"pvcreate {pv1}")

                speech.speak("Do you want to create another Physical Volume")
                another = input(
                    "Do you want to create another PV [Y/N]: ").lower()
                if another == 'y':
                    pass
                else:
                    exit()

        elif "display" or "show" in x and "physical" in x:
            speech.speak("enter the name of the storage")
            pv = input("Enter the name of storage: ")
            os.system(f"pvdisplay {pv}")

        elif "extend" or "create" in x and "volume" in x:
            speech.speak("Here are the services provided")
            print("""
            Create new Volume Group
            Extend Volume Group
            """)
            speech.speak("What can i do for you?")

            vg = recog.voice_rec()
            vg = vg.lower()

            if "create" or 'make' in vg:
                speech.speak("give a name to volume group")
                vgn = input("Give name to the VG: ")

                speech.speak("enter name of physical volume")
                pvn = input("Enter the name of PV: ")
                os.system(f"vgcreate {vgn} {pvn}")

            elif "extend" or "increase" in vg:
                speech.speak("Enter the name of existing volume group")
                vgn = input("Enter the name of existing VG: ")

                speech.speak("Enter the name of physical volume")
                pvn = input("Enter the name of the PV: ")
                os.system(f"vgextend {vgn} {pvn}")

        elif "display" or "show" in x and "group" in x:
            speech.speak("Enter the name of existing volume group")
            vgn = input("Enter the name of VG: ")
            os.system(f"vgdisplay {vgn}")

        elif "manage" or "create" or "make" in x and "logical" in x:
            speech.speak("Here are the services provided")
            print("""
            Create new Logical Volume
            Extend Logical Volume
            Format the Logical Volume
            """)

            speech.speak("What can i do for you?")

            lv = recog.voice_rec()
            lv = lv.lower()

            if "create" or "make" in lv:
                speech.speak("enter size of logical volume")
                size = input("Enter size for your LV: ")

                speech.speak("give a name to logical volume")
                lvn = input("Give name to your LV: ")

                speech.speak("enter the name of volume group")
                vgn = input("Enter name of the VG: ")
                os.system(f"lvcreate --size {size} --name{lvn} {vgn}")

            elif "extend" or "increase" in lv:
                speech.speak("enter the name of logical")
                lvn = input("Enter the name of your LV: ")

                speech.speak("enter the name of volume group")
                vgn = input("Enter name of the VG: ")
                os.system(f"lvextend --size {size} /dev/{vgn}/{lvn}")

            elif "format" or "clear" in lv:
                speech.speak("enter the name of the volume group")
                vgn = input("Enter the name of VG:")

                speech.speak("enter the name of logical volume")
                lvn = input("Enter the name of LV:")

                os.system(f"mkfs.ext4  /dev/{vgn}/{lvn}")
                print("Partiton formatted....\n")

                speech.speak("Do you want to mount Logical volume")
                mout = input("Do you want to mount LV [Y/N]: ").upper()

                if mout == "Y":
                    speech.speak("enter the folder path")
                    path = input(
                        "Enter path of folder where you want to mount : ")
                    print("Creating directory")
                    os.system(f'mkdir {path}')
                    print("\nMounting Now ....\n")
                    mntout = os.system(f"mount /dev/{vgn}/{lvn} {path}")
                else:
                    exit()

        elif "display" or "show" in x and "logical" in x:
            speech.speak("listing logical volumes")
            os.system("lvdisplay")

        elif "exit" or "quit" or "back" in x:
            return

        else:
            print("Invalid request")
            speech.speak("invalid request")
        os.system("tput clear")
コード例 #5
0
def hadoop():
    while True:

        size = os.get_terminal_size()

        os.system("tput setaf 6; tput setab 0")
        os.system("tput clear")
        print("Hadoop configuration and operations".center(size.columns))
        os.system("tput setaf 7; tput setab 0")

        speech.speak("here are the services provided")
        print(mainPrmt)
        speech.speak("What can i do for you?")
        opt = recog.voice_rec()
        opt = opt.lower()

        os.system("tput clear")
        if "download" or "install" in opt and "hadoop" in opt:
            speech.speak("downloading and installing hadoop")
            os.system(
                "wget https://archive.apache.org/dist/hadoop/core/hadoop-1.2.1/hadoop-1.2.1-1.x86_64.rpm"
            )
            os.system("rpm -i hadoop-1.2.1-1.x86_64.rpm --force")
            speech.speak("hadoop installed")
            os.system("tput clear")

        elif "download" or "install" in opt and "jdk" or "java" in opt:
            speech.speak("downloading and installing java JDK")
            os.system(
                "wget 35.244.242.82/yum/java/el7/x86_64/jdk-8u171-linux-x64.rpm"
            )
            os.system("rpm -i jdk-8u171-linux-x64.rpm")
            speech.speak("jdk installed")
            os.system("tput clear")

        elif check(opt) and "data" in opt:
            while True:
                speech.speak("here are the services provided")
                print("""
                Setup Data-node
                Start Data-node
                Stop Data-node
                Format Data-node
                Go back""")

                speech.speak("What can i do for you?")
                d = recog.voice_rec()
                d = d.lower()

                if "setup" or "configure" in d and "data" or "node" in d:
                    speech.speak("please enter ip address of name node")
                    ip = input("Enter the IP address of Name-node")
                    speech.speak("please enter port number")
                    port = int(input("Enter the port number"))

                    datafile1 = """<?xml version=\"1.0\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>\n<!-- Put site-specific property overrides in this file. -->\n<configuration>\n<property>\n<name>dfs.data.dir</name>\n<value>/datanode</value>\n</property>\n</configuration>\n"""

                    datafile2 = f"""<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<!-- Put site-specific property overrides in this file. -->\n<configuration>\n<property>\n<name>fs.default.name</name>\n<value>hdfs://{ip}:{port}</value>\n</property>\n</configuration>\n"""

                    hdfsfile = open("/etc/hadoop/hdfs-site.xml", "w")
                    os.system("mkdir /datanode")
                    if hdfsfile:
                        print(
                            "hdfs-site.xml created succesfully ..... now writing in file.....\n"
                        )
                        hdfsfile.writelines(datafile1)
                        print(
                            "hdfs-site.xml written successfully..... now closing file"
                        )
                        hdfsfile.close()

                    corefile = open("/etc/hadoop/core-site.xml", "w")
                    if corefile:
                        print(
                            "core-site.xml created succesfully ..... now writing in file.....\n"
                        )
                        corefile.writelines(datafile2)
                        print(
                            "core-site.xml written successfully..... now closing file"
                        )
                        corefile.close()

                    print("Hadoop Data-node setup successful")
                    speech.speak("Hadoop Data node setup successful")

                elif "start" in d and "data" or "node" in d:
                    speech.speak("Starting data node")
                    os.system("hadoop-daemon.sh start datanode")
                    print("Data-node started..")
                    speech.speak("data node started")

                elif "data" or "node" in d and "stop" in d:
                    speech.speak("stopping data node")
                    os.system("hadoop-daemon.sh stop datanode")
                    print("Data-node stopped..")
                    speech.speak("data node stopped")

                elif "data" or "node" in d and "format" in d:
                    os.system("hadoop datanode -format")
                    print("Data-node formatted..")
                    speech.speak("data node formatted")

                elif "back" or "exit" or "stop" in d:
                    os.system("tput clear")
                    return

                else:
                    speech.speak("invalid command")
                    os.system("tput clear")
                    continue

                input("Press Enter to continue")

        elif check(opt) and "name" in opt:
            while True:
                speech.speak("here are the services provided")
                print("""
                Setup Name-node
                Start Name-node
                Stop Name-node
                Format Name-node
                Check report
                Go back""")

                speech.speak("What can i do for you?")
                n = recog.voice_rec()
                n = n.lower()

                if "setup" or "configure" in n and "name" or "node" in n:
                    speech.speak("enter IP address")
                    ip = input(
                        "Enter the IP (By default 0.0.0.0 will be added): ")
                    if len(ip) > 0:
                        pass
                    else:
                        ip = "0.0.0.0"
                    speech.speak("enter post number")
                    port = int(input("Enter the port number: "))

                    datafile3 = """<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<!-- Put site-specific property overrides in this file. -->\n<configuration>\n<property>\n<name>dfs.name.dir</name>\n<value>/namenode</value>\n</property>\n</configuration>\n"""

                    datafile4 = f"""<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<!-- Put site-specific property overrides in this file. -->\n<configuration>\n<property>\n<name>fs.default.name</name>\n<value>hdfs://{ip}:{port}</value>\n</property>\n</configuration>\n"""

                    hdfsfile = open("/etc/hadoop/hdfs-site.xml", "w")
                    os.system("mkdir /natanode")
                    if hdfsfile:
                        print(
                            "hdfs-site.xml created succesfully ..... now writing in file.....\n"
                        )
                        hdfsfile.writelines(datafile3)
                        print(
                            "hdfs-site.xml written successfully..... now closing file"
                        )
                        hdfsfile.close()

                    corefile = open("/etc/hadoop/core-site.xml", "w")
                    if corefile:
                        print(
                            "core-site.xml created succesfully ..... now writing in file.....\n"
                        )
                        corefile.writelines(datafile4)
                        print(
                            "core-site.xml written successfully..... now closing file"
                        )
                        corefile.close()

                    print("Hadoop Name-node setup successful")
                    speech.speak("hadoop name node setup successful")

                elif "start" or "run" in n and "name" or "node" in n:
                    speech.speak("Starting name node")
                    os.system("hadoop-daemon.sh start namenode")
                    print("Name-node started")
                    speech.speak("name node started")

                elif "stop" or "pause" in n and "name" or "node" in n:
                    speech.speak("stopping name node")
                    os.system("hadoop-daemon.sh stop namenode")
                    print("Name-node stopped")
                    speech.speak("name node stopped")

                elif "format" or "clear" in n and "name" or "node" in n:
                    speech.speak("formatting name node")
                    os.system("hadoop namenode -format")
                    speech.speak("name node formatted")

                elif "admin" or "report" or "detail" in n:
                    speech.speak("here are the details")
                    os.system("hadoop dfsadmin -report")

                elif "exit" or "stop" or "back" in n:
                    os.system("tput clear")
                    return

                else:
                    speech.speak("invalid command")
                    os.system("tput clear")
                    continue

                input("Press Enter to continue")

        elif check(opt) and "client" in opt:
            while True:
                speech.speak("here are the services provided")
                print("""
                Setup Client-node
                Change block-size and Replication-factor
                See files in hadoop cluster
                Upload file in hadoop cluster
                Remove the file from hadoop
                Go back""")

                speech.speak("What can i do for you?")
                c = recog.voice_rec()
                c = c.lower()

                if "setup" or "start" in c and "client" in c:
                    ip = input("Enter the IP address of Name-node: ")
                    speech.speak("Enter ip address")
                    port = int(input("Enter the port number: "))
                    speech.speak("Enter port number")

                    datafile5 = f"""<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<!-- Put site-specific property overrides in this file. -->\n<configuration>\n<property>\n<name>fs.default.name</name>\n<value>hdfs://{ip}:{port}</value>\n</property>\n</configuration>\n"""

                    corefile = open("/etc/hadoop/core-site.xml", "w")
                    if corefile:
                        print(
                            "core-site.xml created succesfully ..... now writing in file.....\n"
                        )
                        corefile.writelines(datafile5)
                        print(
                            "core-site.xml written successfully..... now closing file"
                        )
                        corefile.close()

                    print("Hadoop Client-node setup successful")

                elif "replication" or "block" or "backup" in c:
                    speech.speak("Enter replication factor")
                    replication_factor = input(
                        "Enter the Replication-factor: ")
                    speech.speak("Enter block size in bytes")
                    block_size = input("Enter the block-size (in bytes): ")

                    datafile6 = f"""<?xml version="1.0"?>\n<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>\n<configuration>\n<property>\n<name>dfs.replication</name>\n<value>{replication_factor}</value>\n</property>\n<property>\n<name>dfs.block.size</name>\n<value>{block_size}</value>\n</property>\n</configuration>\n"""

                    hdfsfile = open("/etc/hadoop/hdfs-site.xml", "w")
                    if hdfsfile:
                        print(
                            "hdfs-site.xml created succesfully ..... now writing in file.....\n"
                        )
                        hdfsfile.writelines(datafile6)
                        print(
                            "hdfs-site.xml written successfully..... now closing file"
                        )
                        hdfsfile.close()

                    speech.speak("replication factor and block size changed")

                elif "see" and "files" in c:
                    speech.speak("files in hadoop cluster are")
                    os.system("hadoop fs -ls /")

                elif "upload" or "put" in c:
                    speech.speak("Enter name of the file")
                    name = input("Enter the name of the file: ")
                    os.system(f"hadoop.fs -put {name} /")

                elif "remove" or "delete" in c:
                    speech.speak(
                        "Enter the name of the file you want to remove")
                    name = input(
                        "Enter the name of the file you want to remove: ")
                    os.system(f"hadoop.fs -rm /{name}")

                elif "exit" or "stop" or "back" in c:
                    os.system("tput clear")
                    return

                else:
                    speech.speak("invalid command")
                    os.system("tput clear")
                    continue

                input("Press Enter to continue")

        elif "exit" or "quit" or "back" in opt:
            return

        else:
            print("Invalid request")
            speech.speak("invalid request")
        os.system("tput clear")
コード例 #6
0
if __name__ == "__main__":
    text = '''
    Docker Management
    Amazon Web Services
    Hadoop Configuration
    Webserver Configuration
    Yum Configuration
    Manage Logical Volumes
    Manage static partitions'''

    sshIp = ""
    print('Do you want to do ssh? Say (yes/no)')
    speech.speak("Do you want to do ssh?")
    sleep(2)
    isSsh = recog.voice_rec()
    isSsh.lower()

    while True:
        size = os.get_terminal_size()

        os.system("tput setaf 6; tput setab 0")
        os.system("clear")
        print("Welcome to the menu".center(size.columns))
        os.system("tput setaf 7; tput setab 0")
        speech.speak("Welcome to the menu!")

        if "yes" in isSsh:
            sshIp = input('Enter the ssh IP or domain: ')
            speech.speak("Please enter IP address")
            sshIp = f"ssh {sshIp}"