Exemple #1
0
class DeploySsh:
    def __init__(self,timeout=3):
        self.client = Client(app.config["SSH_HOST"], app.config["SSH_USER"], app.config["SSH_PASSWORD"])
        self.timeout = timeout

    def add(self, content):
        ret = self.client.exec_script("/root/csfscript/server_ssh/add_auth.py", content,timeout=self.timeout)
        return ret

    def delete(self, content):
        ret = self.client.exec_script("/root/csfscript/server_ssh/del_auth.py", content)
        return True if "ok" in ret else False

    def list(self, content):
        ret = self.client.exec_script("/root/csfscript/server_ssh/list_auth.py", content)
        return json.loads(ret)
Exemple #2
0
class DeploySsh:
    def __init__(self, timeout=3):
        self.client = Client(app.config["SSH_HOST"], app.config["SSH_USER"],
                             app.config["SSH_PASSWORD"])
        self.timeout = timeout

    def add(self, content):
        ret = self.client.exec_script("/root/csfscript/server_ssh/add_auth.py",
                                      content,
                                      timeout=self.timeout)
        return ret

    def delete(self, content):
        ret = self.client.exec_script("/root/csfscript/server_ssh/del_auth.py",
                                      content)
        return True if "ok" in ret else False

    def list(self, content):
        ret = self.client.exec_script(
            "/root/csfscript/server_ssh/list_auth.py", content)
        return json.loads(ret)
Exemple #3
0
def __deploy_database(rid, data):
    r = Release.query.filter(Release.id == rid).one()
    try:

        client = Client(app.config["SSH_HOST"], app.config["SSH_USER"], app.config["SSH_PASSWORD"])

        if u"任务完成" not in client.exec_script("/root/csfscript/dump_data/dump_data.py", data):
            return

        r.is_deployed = True

        log_path = "%s/data_deploy_log/myapp.%s" % (app.root_path, datetime.now().strftime("%Y-%m-%d"))
        Release.add_log(r.id, log_path)
    except Exception, e:
        log.exception(e)
Exemple #4
0
def __deploy_database(rid, data):
    r = Release.query.filter(Release.id == rid).one()
    try:

        client = Client(app.config["SSH_HOST"], app.config["SSH_USER"],
                        app.config["SSH_PASSWORD"])

        if u"任务完成" not in client.exec_script(
                "/root/csfscript/dump_data/dump_data.py", data):
            return

        r.is_deployed = True

        log_path = "%s/data_deploy_log/myapp.%s" % (
            app.root_path, datetime.now().strftime("%Y-%m-%d"))
        Release.add_log(r.id, log_path)
    except Exception, e:
        log.exception(e)
Exemple #5
0
                    "success": False,
                    "error": ""
                }
                results.append(result)

                if Idc_host.query \
                        .filter(Idc_host.ip == _dict["ip"]) \
                        .filter(Idc_host.type_id == _dict["type_id"]) \
                        .count():
                    result["error"] = "%s 已经存在" % _dict["ip"]
                    continue

                idc_host = Idc_host.__update(_dict)

                db.session.add(idc_host)

                result["success"] = True
            except Exception, e:
                traceback.print_exc()
                log.exception(e)

        db.session.commit()
        return results


if __name__ == "__main__":
    client = Client(app.config["SSH_IDC_HOST"], app.config["SSH_IDC_USER"],
                    app.config["SSH_IDC_PASSWORD"])
    client.exec_script("/root/csfscript/host_info/get_host_info.py",
                       "122.144.134.170", False)
Exemple #6
0
            _dicts = [_dicts]

        for _dict in _dicts:
            try:
                result = {"ip": _dict["ip"], "type_id": _dict["type_id"], "success": False, "error": ""}
                results.append(result)

                if Idc_host.query \
                        .filter(Idc_host.ip == _dict["ip"]) \
                        .filter(Idc_host.type_id == _dict["type_id"]) \
                        .count():
                    result["error"] = "%s 已经存在" % _dict["ip"]
                    continue

                idc_host = Idc_host.__update(_dict)

                db.session.add(idc_host)

                result["success"] = True
            except  Exception, e:
                traceback.print_exc()
                log.exception(e)

        db.session.commit()
        return results


if __name__ == "__main__":
    client = Client(app.config["SSH_IDC_HOST"], app.config["SSH_IDC_USER"], app.config["SSH_IDC_PASSWORD"])
    client.exec_script("/root/csfscript/host_info/get_host_info.py", "122.144.134.170", False)