Example #1
0
 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()
             # Make sure it's back up
             status = self.status(args,config,connection,internal=True)
             while status != 'up':
                 time.sleep(2)
                 status = self.status(args,config,connection,internal=True)
         else:
             hostname = connection.host
             if hostname == 'localhost':
                 hostname = socket.gethostname()
             host = Host(hostname,connection=connection).read()
             print("Restarting host...")
             host.restart()
             # Make sure it's back up
             status = self.status(args,config,connection,internal=True)
             while status != 'up':
                 time.sleep(2)
                 status = self.status(args,config,connection,internal=True)
Example #2
0
    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 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 cluster(self, connection=None):
        if connection is None:
            cluster = LocalCluster(self.connection, self.save_connection)
        else:
            cluster = LocalCluster(connection, False)

        return cluster.read()
Example #5
0
 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))
Example #6
0
    def cluster(self, connection=None):
        if connection is None:
            cluster = LocalCluster(self.connection, self.save_connection)
        else:
            cluster = LocalCluster(connection, False)

        return cluster.read()
Example #7
0
    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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
    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()
Example #11
0
    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)
Example #12
0
    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)
Example #13
0
    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)
Example #14
0
    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()
Example #15
0
    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()
Example #16
0
    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()
Example #17
0
    def test_ssl_certificate_pems(self):
        connection = Connection.make_connection(tc.hostname, tc.admin, tc.password)
        cluster = LocalCluster(connection=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")):
            pass
        else:
            self._test_ssl_certificate_pems()
Example #18
0
    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)
Example #19
0
    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()
Example #20
0
    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)
Example #21
0
    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 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 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 _read(self, jsonfile):
     jf = open(jsonfile).read()
     data = json.loads(jf)
     cluster = LocalCluster.unmarshal(data)
     return cluster
Example #25
0
 def test_lookup(self):
     cluster = LocalCluster.lookup(self.connection)
     assert cluster is not None
Example #26
0
 def test_status_view(self):
     cluster = LocalCluster(connection=self.connection)
     status = cluster.view("status")
     assert status is not None
Example #27
0
 def test_version(self):
     cluster = LocalCluster(connection=self.connection)
     status = cluster.view("status")
     version = status["local-cluster-status"]["version"]
     assert version is not None
Example #28
0
    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 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
Example #30
0
    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 get(self, args, config, connection):
     cluster = LocalCluster(connection=connection)
     cluster.read()
     self.jprint(cluster)
Example #32
0
 def get(self, args, config, connection):
     cluster = LocalCluster(connection=connection)
     cluster.read()
     self.jprint(cluster)
Example #33
0
 def _read(self, jsonfile):
     jf = open(jsonfile).read()
     data = json.loads(jf)
     cluster = LocalCluster.unmarshal(data)
     return cluster
    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'])