def create_forests(self): conn = Connection(self.host, HTTPDigestAuth(self.adminuser, self.adminpass)) self.marklogic = MarkLogic(conn) if self.failhost is None and self.failover != "none": print("Invalid configuration, specify failover-host for failover:", self.failover) sys.exit(1) if self.hosts is None: host_names = self.marklogic.hosts() else: host_names = self.hosts exists = [] host_index = 0 for host_name in host_names: host_index += 1 for count in range(1,self.forests + 1): name = self.prefix + "-" + str(host_index) + "-" + str(count) forest = Forest(name, host_name, conn) if forest.exists(): exists.append(host_name + ":" + name) if len(exists) != 0: print("Abort: forest(s) already exist:") for f in exists: print(" ", f) sys.exit(1) host_index = 0 for host_name in host_names: host_index += 1 for count in range(self.start,self.start + self.forests): name = self.prefix + "-" + str(host_index) + "-" + str(count) forest = Forest(name, host_name, conn) if self.data_dir is not None: forest.set_data_directory(self.data_dir) if self.large_data_dir is not None: forest.set_large_data_directory(self.large_data_dir) if self.fast_data_dir is not None: forest.set_fast_data_directory(self.fast_data_dir) if self.failhost is not None: forest.set_failover(self.failover) forest.set_failover_host_names(self.failhost) if self.database is not None: forest.set_database(self.database) print("Create forest " + name + " on " + host_name) if self.dry_run: print(json.dumps(forest.marshal(), sort_keys=True, indent=2)) else: forest.create() print("Finished")