Ejemplo n.º 1
0
    def init_users(self):
        """mongod --fork --port %s --bind_ip 0.0.0.0 --logappend --logpath %s --dbpath %s --pidfilepath %s"""
        command = config["config"]["create_users"] % (
            self.config["service"]["port"], self.config["data"]["log_path"],
            self.config["data"]["data_path"], self.config["data"]["pidfile"])
        print(command)
        subprocess.call(command.split())
        # run script add user admin
        replace = {
            "__port__": self.config["service"]["port"],
            "__user__": config["accounts"]["admin"]["username"],
            "__pass__": config["accounts"]["admin"]["password"]
        }
        fman.search_replace(config["add"]["admin"], replace,
                            config["add"]["tmp_admin"])
        subprocess.call(["mongo", config["add"]["tmp_admin"]])

        replace = {
            "__port__": self.config["service"]["port"],
            "__user__": config["accounts"]["other"]["username"],
            "__pass__": config["accounts"]["other"]["password"],
            "__db__": config["accounts"]["other"]["db"]
        }
        fman.search_replace(config["add"]["user"], replace,
                            config["add"]["tmp_user"])
        subprocess.call(["mongo", config["add"]["tmp_user"]])

        subprocess.call(["pkill", "mongod"])
Ejemplo n.º 2
0
 def add(self):
     replace = {
         "__port__": self.config["service"]["port"],
         "__user__": config["accounts"]["admin"]["username"],
         "__pass__": config["accounts"]["admin"]["password"],
         "__port__": self.config["service"]["port"],
         "__list_hosts__": str(config["slaves"])
     }
     fman.search_replace(config["add"]["hosts"], replace,
                         config["add"]["tmp_hosts"])
     subprocess.call(["mongo", config["add"]["tmp_hosts"]])
Ejemplo n.º 3
0
 def add(self):
     string = []
     for slave in config["slaves"]:
         string.append("%s:%s" % (slave, config["hosts"][slave]["service"]["port"]))
     replace = {
         "__port__" : self.config["service"]["port"],
         "__user__" : config["accounts"]["admin"]["username"],
         "__pass__" : config["accounts"]["admin"]["password"],
         "__port__" : self.config["service"]["port"],
         "__list_hosts__" : str(string)
     }
     fman.search_replace(config["add"]["hosts"], replace, config["add"]["tmp_hosts"])
     subprocess.call(["mongo", "--port", self.config["service"]["port"], config["add"]["tmp_hosts"]])
Ejemplo n.º 4
0
    def create_cluster(self):
        self.create_keyfile()
        self.send_keyfile()
        """mongod --fork --keyFile %s --replSet %s --bind_ip 0.0.0.0 --port %s  --logappend --logpath %s --dbpath %s --pidfilepath %s"""
        command = config["config"]["create_cluster"] % (
            KEYPATH, config["repl_name"], self.config["service"]["port"],
            self.config["data"]["log_path"], self.config["data"]["data_path"],
            self.config["data"]["pidfile"])
        subprocess.call(command.split())

        replace = {
            "__port__": self.config["service"]["port"],
            "__user__": config["accounts"]["admin"]["username"],
            "__pass__": config["accounts"]["admin"]["password"],
            "__replName__": config["repl_name"],
            "__host__": self.host
        }
        fman.search_replace(config["add"]["init"], replace,
                            config["add"]["tmp_init"])
        subprocess.call(["mongo", config["add"]["tmp_init"]])