使用web页面实现oracle的安装和测试详解编程语言

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>oracle测试</title> 
    <style> 
        #div1{ 
            position: fixed; 
            height: 400px; 
            width: 700px; 
            margin-top: 100px; 
            margin-left: 300px; 
            background-color: antiquewhite; 
            z-index: 1000; 
 
        } 
        #div1 input{ 
            width: 100px; 
            height: 75px; 
            margin: 50px; 
            border-radius: 15px; 
        } 
        #div2{ 
            position: absolute; 
            top: 50%; 
            left: 50%; 
            margin-top: -67.5px; 
            margin-left: -122.5px; 
            z-index: 1001; 
            width: 245px; 
            height: 135px; 
            background-color: silver; 
            overflow: scroll; 
            font-weight: bolder; 
        } 
        .hide{ 
            display: none; 
        } 
        .submit_right{ 
            float: right; 
        } 
    </style> 
</head> 
<body> 
    <div id="div1"> 
        <input type="button" value="连接虚拟机" onclick="func1()"> 
        <input type="button" value="安装oracle" onclick="func2()"> 
        <input type="button" value="优化oracle" onclick="func3()"> 
        <input type="button" value="初始化数据" onclick="func4()"> 
        <input type="button" value="测试TPM" onclick="func5()"> 
    </div> 
    <div id="div2" class="hide"> 
        <form action="/app1/home/" method="post"> 
            地址: <input type="text" name="ip_address"><br/> 
            用户: <input type="text" name="user_name"><br/> 
            密码: <input type="password" name="user_pwd"><br/> 
            端口: <input type="text" name="user_port"><br/> 
            <input class="submit_right" type="submit" value="提交"> 
            <input class="submit_right" type="button" value="取消" onclick="hide_ele()"> 
            <input class="submit_right" type="reset" value="清空"> 
        </form> 
    </div> 
 
    <div id="div3" class="hide"> 
        <form action="/app1/home/" method="post"> 
            地址: <input type="text" name="ip_address"><br/> 
            用户: <input type="text" name="user_name"><br/> 
            密码: <input type="password" name="user_pwd"><br/> 
            端口: <input type="text" name="user_port"><br/> 
            <input class="submit_right" type="submit" value="提交"> 
            <input class="submit_right" type="button" value="取消" onclick="hide_ele()"> 
            <input class="submit_right" type="reset" value="清空"> 
        </form> 
    </div> 
    <script> 
        function func1() { 
            var ele = document.getElementById("div2"); 
            ele.classList.remove("hide") 
 
        } 
        function hide_ele() { 
            var ele = document.getElementById("div2"); 
            ele.classList.add("hide") 
        } 
    </script> 
</body> 
</html> 

  

views

def home(request): 
    if request.method.lower() == "post": 
        host_add = request.POST.get("ip_address") 
        user_name = request.POST.get("user_name") 
        user_pwd = request.POST.get("user_pwd") 
        user_port = int(request.POST.get("user_port")) 
 
        ret = core.change_mem(host_add,user_name,user_pwd,user_port) 
        return HttpResponse(ret) 
    return render(request,"home.html") 

  

core

import sys 
sys.path.append("D://python3//lib//site-packages") 
import cx_Oracle 
import paramiko 
class all(object): 
    def __init__(self,host_add,user_name,user_pwd,user_port): 
        self.host_add = host_add 
        self.user_name = user_name 
        self.user_pwd = user_pwd 
        self.user_port = user_port 
 
    def change_mem(self): 
        pass 
 
 
class oracle(all): 
    def __init__(self,host_add,user_name,user_pwd,user_port,sys_pwd,data_num,log_num,log_size): 
        super(oracle,self).__init__(host_add,user_name,user_pwd,user_port) 
        self.sys_pwd = sys_pwd 
        self.data_num = data_num 
        self.log_num = log_num 
        self.log_size = log_size 
         
         
    def change_oracle_mem(self): 
        pass 
     
    def change_oracle_datafile(self): 
        pass 
     
    def change_oracle_logfile(self): 
        pass 
     
     
 
 
 
 
 
 
 
def change_mem(host_add,user_name,user_pwd,user_port): 
    try: 
        ssh = paramiko.SSHClient() 
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
        ssh.connect(hostname=host_add,port=user_port,username=user_name,password=user_pwd) 
    except Exception as e: 
        ret = "登陆失败" + str(e) 
        return ret 
    else: 
        # return "登陆成功" 
        # stdin, stdout, stderr = ssh.exec_command("sed -i '$ a vm.nr_hugepages = 30820' /root/test1.conf") 
        # stdin, stdout, stderr = ssh.exec_command("sed -i '$ a *   soft   memlock  90596966' /root/test1.conf") 
        # stdin, stdout, stderr = ssh.exec_command("sed -i '$ a *   soft   memlock  90596966' /root/test1.conf") 
        stdin, stdout, stderr = ssh.exec_command("cat /root/test1.conf | grep 'vm.nr_hugepages = 310820'") 
        stdin, stdout, stderr = ssh.exec_command("echo $?") 
        res = str(stdout.read(),encoding="utf-8").strip("/n") 
        res1 = str(0) 
        print(res,res1,sep="-----------") 
        print(res,type(res),sep="-------------------") 
        if res == "0": 
            print("ok") 
        else: 
            print("xxx") 
        ssh.close() 

  

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/20838.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论