コード例 #1
0
ファイル: WebBack.py プロジェクト: hao707822882/Bichon
 def back(self, savePath, parentPath, needBack):
     '''
         savePath:备份文件保存的路径
         parentPath:需要备份的父路径
         needBack:需要备份的父目录
     '''
     tr = ExecUtil.execCommand(" tar czvf " + savePath + " -C " + parentPath + " " + needBack)
コード例 #2
0
 def back(self, savePath, parentPath, needBack):
     '''
         savePath:备份文件保存的路径
         parentPath:需要备份的父路径
         needBack:需要备份的父目录
     '''
     tr = ExecUtil.execCommand(" tar czvf " + savePath + " -C " +
                               parentPath + " " + needBack)
コード例 #3
0
 def yumInstall(self):
     child = pexpect.spawnu('yum groupinstall " NFS file server"')
     child.expect('(?i)Is this ok [y/N]:')
     child.sendline('y')
     child.expect('Complete!')
     child.close()
     self.writeConfig()
     ExecUtil.execCommand("/etc/init.d/rpcbind start  ")
     ExecUtil.execCommand("/etc/init.d/nfs start")
     ExecUtil.execCommand("chkconfig nfs on")
     ExecUtil.execCommand("chkconfig rpcbind on")
コード例 #4
0
ファイル: SSHManager.py プロジェクト: hao707822882/Bichon
 def initSSHKey(self):
     home = ExecUtil.execCommand("echo ~")[1]
     if not os.path.exists(home + "/.ssh/id_rsa"):
         child = pexpect.spawnu('ssh-keygen')
         child.expect('(?i)(/root/.ssh/id_rsa):')
         child.sendline('\r')
         child.expect('(?i)Enter passphrase (empty for no passphrase):')
         child.sendline('\r')
         child.expect('(?i)Enter same passphrase again:')
         child.sendline('\r')
         child.expect('(?i)+-----------------+')
         child.close()
コード例 #5
0
 def openByPort(self, port):
     return ExecUtil.execCommandList(["iptables -A INPUT -p tcp --dport " + port + " -j ACCEPT",
                                      "iptables -A OUTPUT -p tcp --sport " + port + " -j ACCEPT"])
コード例 #6
0
 def openWeb(self):
     return ExecUtil.execCommandList(["iptables -A INPUT -p tcp --dport 80 -j ACCEPT",
                                      "iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT"])
コード例 #7
0
 def dropAll(self):
     ExecUtil.execCommandList(
         ["iptables -P INPUT DROP", "iptables -P FORWARD DROP", "iptables -P OUTPUT DROP", "service iptables save "])
コード例 #8
0
 def limitIp(self, ip, port):
     return ExecUtil.execCommandList([
         "iptables -A INPUT -s " + ip + " -p tcp --dport " + port +
         " -j DROP"
     ])
コード例 #9
0
 def openByPort(self, port):
     return ExecUtil.execCommandList([
         "iptables -A INPUT -p tcp --dport " + port + " -j ACCEPT",
         "iptables -A OUTPUT -p tcp --sport " + port + " -j ACCEPT"
     ])
コード例 #10
0
 def downloadFile(self, downloadPath):
     filename = os.path.basename(downloadPath)
     return ExecUtil.execCommand("wget -O " + downloadPath + " " +
                                 Config.softServer + filename)
コード例 #11
0
 def back(self, user, pwd, db, savePath):
     ExecUtil.execCommand(" mysqldump -u" + user + " -p" + pwd +
                          " -B --skip-lock-tables  " + db + " |gzip  > " +
                          savePath + "/" + db + "`/bin/date +%F`.back.gz")
コード例 #12
0
 def downloadTar(self):
     down_rt = ExecUtil.execCommand("wget -O " + self.downloadSavePath + " " + self.downloadPath)
コード例 #13
0
ファイル: ExecModule.py プロジェクト: hao707822882/Bichon
 def execCmd(self, cmd):
     return ExecUtil.execCommand(cmd)
コード例 #14
0
ファイル: MysqlInstaller.py プロジェクト: hao707822882/Bichon
            info.append(install)
        except Exception , e:
            install=self.getInfo("yum install mysql*",False,"yum install mysql* false")
            info.append(install)
            return info
        try:
            self.writeConfig()
            install=self.getInfo("write config",True,"write config ok")
            info.append(install)
        except Exception , e:
            install=self.getInfo("write config",False,"write config false")
            info.append(install)
            return info


        rt=ExecUtil.execCommand("service mysqld restart")
        if rt[0]==0:
            install=self.getInfo("service mysqld restart",True,rt[1])
            info.append(install)
        else:
            install=self.getInfo("service mysqld restart",False,rt[1])
            info.append(install)
            return info

        rt=ExecUtil.execCommand("mysqladmin -u root password " + Config.mysqlRoot)
        if rt[0]==0:
            install=self.getInfo("mysqladmin -u root password "+Config.mysqlRoot,True,rt[1])
            info.append(install)
        else:
            install=self.getInfo("mysqladmin -u root password "+Config.mysqlRoot,False,rt[1])
            info.append(install)
コード例 #15
0
            info.append(install)
        except Exception, e:
            install = self.getInfo("yum install mysql*", False,
                                   "yum install mysql* false")
            info.append(install)
            return info
        try:
            self.writeConfig()
            install = self.getInfo("write config", True, "write config ok")
            info.append(install)
        except Exception, e:
            install = self.getInfo("write config", False, "write config false")
            info.append(install)
            return info

        rt = ExecUtil.execCommand("service mysqld restart")
        if rt[0] == 0:
            install = self.getInfo("service mysqld restart", True, rt[1])
            info.append(install)
        else:
            install = self.getInfo("service mysqld restart", False, rt[1])
            info.append(install)
            return info

        rt = ExecUtil.execCommand("mysqladmin -u root password " +
                                  Config.mysqlRoot)
        if rt[0] == 0:
            install = self.getInfo(
                "mysqladmin -u root password " + Config.mysqlRoot, True, rt[1])
            info.append(install)
        else:
コード例 #16
0
 def limitIp(self, ip, port):
     return ExecUtil.execCommandList(["iptables -A INPUT -s " + ip + " -p tcp --dport " + port + " -j DROP"])
コード例 #17
0
 def make(self):
     tar_rt = ExecUtil.execCommand("tar zxvf " + self.downloadSavePath + " -C " + self.installPath)
コード例 #18
0
 def dropAll(self):
     ExecUtil.execCommandList([
         "iptables -P INPUT DROP", "iptables -P FORWARD DROP",
         "iptables -P OUTPUT DROP", "service iptables save "
     ])
コード例 #19
0
ファイル: MysqlBack.py プロジェクト: hao707822882/Bichon
 def back(self, user, pwd, db, savePath):
     ExecUtil.execCommand(
         " mysqldump -u" + user + " -p" + pwd + " -B --skip-lock-tables  " + db + " |gzip  > " + savePath + "/" + db + "`/bin/date +%F`.back.gz")
コード例 #20
0
 def writeConfig(self):
     f = open("/etc/profile", 'a')
     f.write('export MAVEN_HOME=' + self.installPath + "/maven")
     f.write("export PATH=$MAVEN_HOME/bin:$PATH")
     f.close()
     source_rt = ExecUtil.execCommand("source /etc/profile")
コード例 #21
0
 def openWeb(self):
     return ExecUtil.execCommandList([
         "iptables -A INPUT -p tcp --dport 80 -j ACCEPT",
         "iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT"
     ])
コード例 #22
0
ファイル: File.py プロジェクト: hao707822882/Bichon
 def downloadFile(self,downloadPath):
     filename=os.path.basename(downloadPath)
     return ExecUtil.execCommand("wget -O " + downloadPath + " " + Config.softServer+filename)
コード例 #23
0
ファイル: Yum.py プロジェクト: hao707822882/Bichon
 def updateYumToAli(self):
     return ExecUtil.execCommandList(
         ["mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup",
          "wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo",
          "yum makecache"])