Exemplo n.º 1
0
    def validate(self, parser, options, args):
        if options.scylla and not options.install_dir:
            parser.error("must specify install_dir using scylla")
        Cmd.validate(self, parser, options, args, cluster_name=True)
        if options.ipprefix and options.ipformat:
            parser.print_help()
            parser.error("%s and %s may not be used together" % (parser.get_option('-i'), parser.get_option('-I')))
        self.nodes = parse_populate_count(options.nodes)
        if self.options.vnodes and self.nodes is None:
            print_("Can't set --vnodes if not populating cluster in this command.")
            parser.print_help()
            sys.exit(1)
        if self.options.snitch and \
            (not isinstance(self.nodes, list) or
             not (self.options.snitch == 'org.apache.cassandra.locator.PropertyFileSnitch' or
                  self.options.snitch == 'org.apache.cassandra.locator.GossipingPropertyFileSnitch')):
            parser.print_help()
            sys.exit(1)

        if not options.version:
            try:
                common.validate_install_dir(options.install_dir)
            except ArgumentError:
                parser.print_help()
                parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir)

            common.assert_jdk_valid_for_cassandra_version(common.get_version_from_build(options.install_dir))
        if common.is_win() and os.path.exists('c:\windows\system32\java.exe'):
            print_("""WARN: c:\windows\system32\java.exe exists.
                This may cause registry issues, and jre7 to be used, despite jdk8 being installed.
                """)
Exemplo n.º 2
0
    def __init__(self, path, name, partitioner=None, install_dir=None, create_directory=True, version=None, verbose=False, snitch='org.apache.cassandra.locator.PropertyFileSnitch', **kwargs):
        self.name = name
        self.id = 0
        self.ipprefix = None
        self.ipformat = None
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self.snitch = snitch
        self._config_options = {}
        self._dse_config_options = {}
        self.__log_level = "INFO"
        self.path = path
        self.__version = None
        self.use_vnodes = False
        # Classes that are to follow the respective logging level
        self._debug = []
        self._trace = []

        if self.name.lower() == "current":
            raise RuntimeError("Cannot name a cluster 'current'.")

        # This is incredibly important for
        # backwards compatibility.
        version = kwargs.get('cassandra_version', version)
        install_dir = kwargs.get('cassandra_dir', install_dir)
        docker_image = kwargs.get('docker_image')
        if create_directory:
            # we create the dir before potentially downloading to throw an error sooner if need be
            os.mkdir(self.get_path())

        if docker_image:
            self.docker_image = docker_image
            self.__install_dir = None
            self.__version = '3.0'  # TODO: add option to read the version from docker image
            return

        try:
            if version is None:
                # at this point, install_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if install_dir is not None:
                    if common.is_win():
                        self.__install_dir = install_dir
                    else:
                        self.__install_dir = os.path.abspath(install_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = self.load_from_repository(version, verbose)
                self.__install_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_install_dir(self.__install_dir)
                self._update_config()
        except:
            if create_directory:
                common.rmdirs(self.get_path())
            raise
        self.debug("Started cluster '{}' version {} installed in {}".format(self.name, self.__version, self.__install_dir))
Exemplo n.º 3
0
    def set_install_dir(self, install_dir=None, version=None, verbose=False):
        if version is None:
            self.__install_dir = install_dir
            common.validate_install_dir(install_dir)
            self.__version = self.__get_version_from_build()
        else:
            dir, v = repository.setup(version, verbose)
            self.__install_dir = dir
            self.__version = v if v is not None else self.__get_version_from_build(
            )
            if not isinstance(self.__version, LooseVersion):
                self.__version = LooseVersion(self.__version)
        self._update_config()
        for node in list(self.nodes.values()):
            node._cassandra_version = self.__version
            node.import_config_files()

        # if any nodes have a data center, let's update the topology
        if any([node.data_center for node in self.nodes.values()]):
            self.__update_topology_files()

        if self.cassandra_version() >= '4':
            self.set_configuration_options({'start_rpc': None},
                                           delete_empty=True,
                                           delete_always=True)
        else:
            self.set_configuration_options(common.CCM_40_YAML_OPTIONS,
                                           delete_empty=True,
                                           delete_always=True)

        return self
    def validate(self, parser, options, args):
        Cmd.validate(self, parser, options, args, cluster_name=True)
        if options.ipprefix and options.ipformat:
            parser.print_help()
            parser.error("%s and %s may not be used together" % (parser.get_option('-i'), parser.get_option('-I')))
        self.nodes = parse_populate_count(options.nodes)
        if self.options.vnodes and self.nodes is None:
            print_("Can't set --vnodes if not populating cluster in this command.")
            parser.print_help()
            exit(1)
        if not options.version:
            try:
                common.validate_install_dir(options.install_dir)
            except ArgumentError:
                parser.print_help()
                parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir)

            if common.get_dse_version(options.install_dir) is not None:
                common.assert_jdk_valid_for_cassandra_version(common.get_dse_cassandra_version(options.install_dir))
            else:
                common.assert_jdk_valid_for_cassandra_version(common.get_version_from_build(options.install_dir))

        if common.is_win() and os.path.exists('c:\windows\system32\java.exe'):
            print_("""WARN: c:\windows\system32\java.exe exists.
                This may cause registry issues, and jre7 to be used, despite jdk8 being installed.
                """)
Exemplo n.º 5
0
    def __init__(
        self,
        path,
        name,
        partitioner=None,
        install_dir=None,
        create_directory=True,
        version=None,
        verbose=False,
        **kwargs
    ):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self._dse_config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        self.use_vnodes = False
        # Classes that are to follow the respective logging level
        self._debug = []
        self._trace = []

        if self.name.lower() == "current":
            raise RuntimeError("Cannot name a cluster 'current'.")

        ##This is incredibly important for
        ##backwards compatibility.
        if "cassandra_version" in kwargs:
            version = kwargs["cassandra_version"]
        if "cassandra_dir" in kwargs:
            install_dir = kwargs["cassandra_dir"]
        if create_directory:
            # we create the dir before potentially downloading to throw an error sooner if need be
            os.mkdir(self.get_path())

        try:
            if version is None:
                # at this point, install_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if install_dir is not None:
                    if common.is_win():
                        self.__install_dir = install_dir
                    else:
                        self.__install_dir = os.path.abspath(install_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = self.load_from_repository(version, verbose)
                self.__install_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_install_dir(self.__install_dir)
                self._update_config()
        except:
            if create_directory:
                common.rmdirs(self.get_path())
            raise
Exemplo n.º 6
0
    def __init__(self,
                 path,
                 name,
                 partitioner=None,
                 install_dir=None,
                 create_directory=True,
                 version=None,
                 verbose=False,
                 **kwargs):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self._dse_config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        self.use_vnodes = False
        # Classes that are to follow the respective logging level
        self._debug = []
        self._trace = []
        self.data_dir_count = 1

        if self.name.lower() == "current":
            raise RuntimeError("Cannot name a cluster 'current'.")

        # This is incredibly important for
        # backwards compatibility.
        if 'cassandra_version' in kwargs:
            version = kwargs['cassandra_version']
        if 'cassandra_dir' in kwargs:
            install_dir = kwargs['cassandra_dir']
        if create_directory:
            # we create the dir before potentially downloading to throw an error sooner if need be
            os.mkdir(self.get_path())

        try:
            if version is None:
                # at this point, install_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if install_dir is not None:
                    if common.is_win():
                        self.__install_dir = install_dir
                    else:
                        self.__install_dir = os.path.abspath(install_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = self.load_from_repository(version, verbose)
                self.__install_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build(
                )

            if create_directory:
                common.validate_install_dir(self.__install_dir)
                self._update_config()
        except:
            if create_directory:
                common.rmdirs(self.get_path())
            raise
    def validate(self, parser, options, args):
        Cmd.validate(self, parser, options, args, cluster_name=True)
        if options.ipprefix and options.ipformat:
            parser.print_help()
            parser.error("%s and %s may not be used together" % (parser.get_option('-i'), parser.get_option('-I')))
        self.nodes = parse_populate_count(options.nodes)
        if self.options.vnodes and self.nodes is None:
            print_("Can't set --vnodes if not populating cluster in this command.")
            parser.print_help()
            exit(1)
        if not options.version:
            try:
                common.validate_install_dir(options.install_dir)
            except ArgumentError:
                parser.print_help()
                parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir)

            if common.get_dse_version(options.install_dir) is not None:
                common.assert_jdk_valid_for_cassandra_version(common.get_dse_cassandra_version(options.install_dir))
            else:
                common.assert_jdk_valid_for_cassandra_version(common.get_version_from_build(options.install_dir))

        if common.is_win() and os.path.exists('c:\windows\system32\java.exe'):
            print_("""WARN: c:\windows\system32\java.exe exists.
                This may cause registry issues, and jre7 to be used, despite jdk8 being installed.
                """)
Exemplo n.º 8
0
def elassandra_version_directory(version, elassandra_version):
    dir = directory_name(version)
    if os.path.exists(dir):
        try:
            validate_install_dir(os.path.join(dir, 'elassandra-%s' % elassandra_version))
            return dir
        except ArgumentError:
            rmdirs(dir)
            return None
    else:
        return None
Exemplo n.º 9
0
def version_directory(version):
    dir = directory_name(version)
    if os.path.exists(dir):
        try:
            validate_install_dir(dir)
            return dir
        except ArgumentError as e:
            rmdirs(dir)
            return None
    else:
        return None
Exemplo n.º 10
0
def version_directory(version):
    dir = directory_name(version)
    if os.path.exists(dir):
        try:
            validate_install_dir(dir)
            return dir
        except ArgumentError:
            rmdirs(dir)
            return None
    else:
        return None
Exemplo n.º 11
0
def version_directory(version):
    version = version.replace(':', '_') # handle git branches like 'git:trunk'.
    dir = os.path.join(__get_dir(), version)
    if os.path.exists(dir):
        try:
            validate_install_dir(dir)
            return dir
        except ArgumentError as e:
            shutil.rmtree(dir)
            return None
    else:
        return None
Exemplo n.º 12
0
def version_directory(version):
    version = version.replace(':',
                              '_')  # handle git branches like 'git:trunk'.
    dir = os.path.join(__get_dir(), version)
    if os.path.exists(dir):
        try:
            validate_install_dir(dir)
            return dir
        except ArgumentError as e:
            shutil.rmtree(dir)
            return None
    else:
        return None
Exemplo n.º 13
0
def dtest_config(request):
    dtest_config = DTestConfig()
    dtest_config.setup(request)

    # if we're on mac, check that we have the required loopback interfaces before doing anything!
    check_required_loopback_interfaces_available()

    try:
        if dtest_config.cassandra_dir is not None:
            validate_install_dir(dtest_config.cassandra_dir)
    except Exception as e:
        pytest.exit("{}. Did you remember to build C*? ('ant clean jar')".format(e))

    yield dtest_config
Exemplo n.º 14
0
def dtest_config(request):
    dtest_config = DTestConfig()
    dtest_config.setup(request)

    # if we're on mac, check that we have the required loopback interfaces before doing anything!
    check_required_loopback_interfaces_available()

    try:
        if dtest_config.cassandra_dir is not None:
            validate_install_dir(dtest_config.cassandra_dir)
    except Exception as e:
        pytest.exit("{}. Did you remember to build C*? ('ant clean jar')".format(e))

    yield dtest_config
Exemplo n.º 15
0
 def validate(self, parser, options, args):
     Cmd.validate(self, parser, options, args, cluster_name=True)
     if options.ipprefix and options.ipformat:
         parser.print_help()
         parser.error("%s and %s may not be used together" % (parser.get_option('-i'), parser.get_option('-I')))
     self.nodes = parse_populate_count(options.nodes)
     if self.options.vnodes and self.nodes is None:
         print_("Can't set --vnodes if not populating cluster in this command.")
         parser.print_help()
         exit(1)
     if not options.version:
         try:
             common.validate_install_dir(options.install_dir)
         except ArgumentError:
             parser.print_help()
             parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir)
Exemplo n.º 16
0
 def validate(self, parser, options, args):
     Cmd.validate(self, parser, options, args, cluster_name=True)
     if options.ipprefix and options.ipformat:
         parser.print_help()
         parser.error("%s and %s may not be used together" % (parser.get_option('-i'), parser.get_option('-I')))
     self.nodes = parse_populate_count(options.nodes)
     if self.options.vnodes and self.nodes is None:
         print_("Can't set --vnodes if not populating cluster in this command.")
         parser.print_help()
         exit(1)
     if not options.version:
         try:
             common.validate_install_dir(options.install_dir)
         except ArgumentError:
             parser.print_help()
             parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir)
Exemplo n.º 17
0
    def set_install_dir(self, install_dir=None, version=None, verbose=False):
        if version is None:
            self.__install_dir = install_dir
            common.validate_install_dir(install_dir)
            self.__version = self.__get_version_from_build()
        else:
            dir, v = repository.setup(version, verbose)
            self.__install_dir = dir
            self.__version = v if v is not None else self.__get_version_from_build()
        self._update_config()
        for node in list(self.nodes.values()):
            node.import_config_files()

        # if any nodes have a data center, let's update the topology
        if any([node.data_center for node in self.nodes.values()]):
            self.__update_topology_files()

        return self
Exemplo n.º 18
0
    def __init__(self, path, name, partitioner=None, install_dir=None, create_directory=True, version=None, verbose=False, **kwargs):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self._dse_config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        self.use_vnodes = False

        ##This is incredibly important for
        ##backwards compatibility.
        if 'cassandra_version' in kwargs:
            version = kwargs['cassandra_version']
        if 'cassandra_dir' in kwargs:
            install_dir = kwargs['cassandra_dir']
        if create_directory:
            # we create the dir before potentially downloading to throw an error sooner if need be
            os.mkdir(self.get_path())

        try:
            if version is None:
                # at this point, install_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if install_dir is not None:
                    if common.is_win():
                        self.__install_dir = install_dir
                    else:
                        self.__install_dir = os.path.abspath(install_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = self.load_from_repository(version, verbose)
                self.__install_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_install_dir(self.__install_dir)
                self._update_config()
        except:
            if create_directory:
                shutil.rmtree(self.get_path())
            raise
Exemplo n.º 19
0
    def validate(self, parser, options, args):
        if options.scylla and not options.install_dir:
            parser.error("must specify install_dir using scylla")
        Cmd.validate(self, parser, options, args, cluster_name=True)
        if options.ipprefix and options.ipformat:
            parser.print_help()
            parser.error("%s and %s may not be used together" % (parser.get_option('-i'), parser.get_option('-I')))
        self.nodes = parse_populate_count(options.nodes)
        if self.options.vnodes and self.nodes is None:
            print_("Can't set --vnodes if not populating cluster in this command.")
            parser.print_help()
            sys.exit(1)
        if self.options.snitch and \
            (not isinstance(self.nodes, list) or
             not (self.options.snitch == 'org.apache.cassandra.locator.PropertyFileSnitch' or
                  self.options.snitch == 'org.apache.cassandra.locator.GossipingPropertyFileSnitch')):
            parser.print_help()
            sys.exit(1)

        if not options.version and not options.docker_image:
            try:
                common.validate_install_dir(options.install_dir)
            except ArgumentError:
                parser.print_help()
                parser.error("%s is not a valid cassandra directory. You must define a cassandra dir or version." % options.install_dir)

            common.assert_jdk_valid_for_cassandra_version(common.get_version_from_build(options.install_dir))
        if common.is_win() and os.path.exists('c:\windows\system32\java.exe'):
            print_("""WARN: c:\windows\system32\java.exe exists.
                This may cause registry issues, and jre7 to be used, despite jdk8 being installed.
                """)

        if options.scylla_core_package_uri:
            os.environ['SCYLLA_CORE_PACKAGE'] = options.scylla_core_package_uri
        if options.scylla_tools_java_package_uri:
            os.environ['SCYLLA_TOOLS_JAVA_PACKAGE'] = options.scylla_tools_java_package_uri
            # TODO: remove this export eventually, it's for backward
            # compatibility with the previous name
            os.environ['SCYLLA_JAVA_TOOLS_PACKAGE'] = options.scylla_tools_java_package_uri
        if options.scylla_jmx_package_uri:
            os.environ['SCYLLA_JMX_PACKAGE'] = options.scylla_jmx_package_uri
Exemplo n.º 20
0
 def get_install_dir(self):
     common.validate_install_dir(self.__install_dir)
     return self.__install_dir