def cluster(self, connection=None): if connection is None: cluster = LocalCluster(self.connection, self.save_connection) else: cluster = LocalCluster(connection, False) return cluster.read()
def cluster(self, connection=None): """ Get information about the local cluster. """ if connection is None: cluster = LocalCluster(self.connection, self.save_connection) else: cluster = LocalCluster(connection, False) return cluster.read()
def stop(self, args, config, connection): status = self.status(args, config, connection, internal=True) if status == 'down': print("MarkLogic server on {0} appears to be {1}.".format( connection.host, status)) else: if 'cluster' in args: hostname = connection.host if hostname == 'localhost': hostname = socket.gethostname() cluster = LocalCluster(connection=connection).read() print("Shutting down cluster...") cluster.shutdown() else: hostname = connection.host if hostname == 'localhost': hostname = socket.gethostname() host = Host(hostname, connection=connection).read() if host.group_name() is None: ml = MarkLogic(connection) if len(ml.hosts()) == 1: host = Host(ml.hosts()[0], connection=connection).read() else: print("Failed to identify host:", ml.hosts()) sys.exit(1) print("Shutting down host: " + host.host_name()) host.shutdown() status = self.status(args, config, connection, internal=True) while status == 'up': time.sleep(2) status = self.status(args, config, connection, internal=True)
def read(self): conn = self.connection cluster = LocalCluster(connection=conn).read() print("Read local cluster: {}".format(cluster.cluster_name())) x = cluster.security_version() x = cluster.effective_version() x = cluster.cluster_id() x = cluster.cluster_name() x = cluster.ssl_fips_enabled() x = cluster.xdqp_ssl_certificate() x = cluster.xdqp_ssl_private_key() x = cluster.bootstrap_hosts() # FIXME: #x = cluster.foreign_cluster_id() #x = cluster.foreign_cluster_name() x = cluster.language_baseline() x = cluster.opsdirector_log_level() x = cluster.opsdirector_metering() x = cluster.opsdirector_session_endpoint() self.readClass("Groups", Group, max_read=5) self.readClass("Hosts", Host, max_read=5) self.readClass("Databases", Database, max_read=5) self.readClass("Forests", Forest, max_read=5) self.readClass("Servers", Server) self.readClass("Roles", Role, max_read=5) self.readClass("Users", User, max_read=5) self.readPrivileges() return
def bootstrap_hosts(self, args, config, connection): cluster = LocalCluster(connection=connection) cluster.read() hosts = [] for host in cluster.bootstrap_hosts(): hosts.append(host.host_name()) print(json.dumps(hosts, sort_keys=True, indent=2))
def stop(self, args, config, connection): status = self.status(args, config, connection, internal=True) if status == 'down': print("MarkLogic server on {0} appears to be {1}.".format( connection.host, status)) else: if 'cluster' in args: hostname = connection.host if hostname == 'localhost': hostname = socket.gethostname() cluster = LocalCluster(connection=connection).read() print("Shutting down cluster...") cluster.shutdown() else: hostname = connection.host if hostname == 'localhost': hostname = socket.gethostname() host = Host(hostname, connection=connection).read() print("Shutting down host...") host.shutdown() status = self.status(args, config, connection, internal=True) while status == 'up': time.sleep(2) status = self.status(args, config, connection, internal=True)
def couple(self, args, config, connection): cluster = LocalCluster(connection=connection) cluster.read() try: username, password = re.split(":", args['couple_credentials']) except ValueError: print("--couple-credentials value must be 'user:password':", args['couple_credentials']) sys.exit(1) altconn = Connection(args['host'], HTTPDigestAuth(username, password)) altcluster = LocalCluster(connection=altconn) cluster.couple(altcluster, connection=connection, other_cluster_connection=altconn)
def join(self, args, config, connection): cluster = LocalCluster(connection=connection) cluster.read() self.logger.info("Initializing {0}...".format(args['host'])) MarkLogic.instance_init(args['host']) host = Host(args['host']) self.logger.info("Joining cluster...") cluster.add_host(host)
def modify(self, args, config, connection): cluster = LocalCluster(connection=connection) if args['json'] is not None: cluster = self._read() self._properties(cluster, args) print("Modify cluster...") cluster.update(connection=connection)
def test_ssl_certificate_pems(self): cluster = LocalCluster(connection=self.connection) version = cluster.version() if (version.startswith("4") or version.startswith("5") or version.startswith("6") or version.startswith("7") or version.startswith("8.0-1") or version.startswith("8.0-2") or version.startswith("8.0-3") or version.startswith("8.0-4")): pass else: self._test_ssl_certificate_pems()
def restart(self, args, config, connection): status = self.status(args, config, connection, internal=True) if status == 'down': print("MarkLogic server on {0} appears to be {1}.".format( connection.host, status)) else: if 'cluster' in args: hostname = connection.host if hostname == 'localhost': hostname = socket.gethostname() cluster = LocalCluster(connection=connection).read() print("Restarting cluster...") cluster.restart() else: hostname = connection.host if hostname == 'localhost': hostname = socket.gethostname() host = Host(hostname, connection=connection).read() print("Restarting host...") host.restart()
def create(self, args, config, connection): name = args['name'] host = args['forest_host'] if args['json'] is not None: forest = self._read(name, args['json'], connection=connection) name = forest.forest_name() host = forest.host() else: forest = Forest(name, host, connection=connection) if forest.exists(): self.logger.error("Forest already exists: {0}".format(name)) sys.exit(1) self._properties(forest, args) dbname = forest.database() # Strip out properties that we know the server will reject cluster = LocalCluster(connection) cluster.read() if cluster.security_version() is None: for key in ['database-replication', 'failover-enable']: if key in forest._config: del (forest._config[key]) self.logger.debug( "Ignoring {0}, not supported by server".format(key)) if dbname is not None: database = Database(dbname) database.read(connection) else: database = None self.logger.info("Create forest {0}...".format(name)) forest.create(connection=connection) if database is not None: database.add_forest_name(forest.forest_name()) database.update(connection)
def leave(self, args, config, connection): cluster = LocalCluster(connection=connection) cluster.read() self.logger.info("Removing {0} from cluster...".format(args['host'])) cluster.remove_host(args['host'])
def get(self, args, config, connection): cluster = LocalCluster(connection=connection) cluster.read() self.jprint(cluster)
def test_version(self): cluster = LocalCluster(connection=self.connection) status = cluster.view("status") version = status["local-cluster-status"]["version"] assert version is not None
def test_status_view(self): cluster = LocalCluster(connection=self.connection) status = cluster.view("status") assert status is not None