Ejemplo n.º 1
0
    def __init__(self, path, name, partitioner=None, cassandra_dir=None, create_directory=True, cassandra_version=None, verbose=False):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        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 cassandra_version is None:
                # at this point, cassandra_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if cassandra_dir is not None:
                    if common.is_win():
                        self.__cassandra_dir = cassandra_dir
                    else:
                        self.__cassandra_dir = os.path.abspath(cassandra_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = repository.setup(cassandra_version, verbose)
                self.__cassandra_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_cassandra_dir(self.__cassandra_dir)
                self.__update_config()
        except:
            if create_directory:
                shutil.rmtree(self.get_path())
            raise
Ejemplo n.º 2
0
    def __init__(self, path, name, partitioner=None, cassandra_dir=None, create_directory=True, cassandra_version=None, verbose=False):
        self.name = name
        self.nodes = {}
        self.seeds = []
        self.partitioner = partitioner
        self._config_options = {}
        self.__log_level = "INFO"
        self.__path = path
        self.__version = None
        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 cassandra_version is None:
                # at this point, cassandra_dir should always not be None, but
                # we keep this for backward compatibility (in loading old cluster)
                if cassandra_dir is not None:
                    if common.is_win():
                        self.__cassandra_dir = cassandra_dir
                    else:
                        self.__cassandra_dir = os.path.abspath(cassandra_dir)
                    self.__version = self.__get_version_from_build()
            else:
                dir, v = repository.setup(cassandra_version, verbose)
                self.__cassandra_dir = dir
                self.__version = v if v is not None else self.__get_version_from_build()

            if create_directory:
                common.validate_cassandra_dir(self.__cassandra_dir)
                self.__update_config()
        except:
            if create_directory:
                shutil.rmtree(self.get_path())
            raise
Ejemplo n.º 3
0
 def get_cassandra_dir(self):
     """
     Returns the path to the cassandra source directory used by this node.
     """
     if self.__cassandra_dir is None:
         return self.cluster.get_cassandra_dir()
     else:
         common.validate_cassandra_dir(self.__cassandra_dir)
         return self.__cassandra_dir
Ejemplo n.º 4
0
Archivo: node.py Proyecto: jsanda/ccm
 def get_cassandra_dir(self):
     """
     Returns the path to the cassandra source directory used by this node.
     """
     if self.__cassandra_dir is None:
         return self.cluster.get_cassandra_dir()
     else:
         common.validate_cassandra_dir(self.__cassandra_dir)
         return self.__cassandra_dir
Ejemplo n.º 5
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_cassandra_dir(dir)
            return dir
        except ArgumentError as e:
            shutil.rmtree(dir)
            return None
    else:
        return None
Ejemplo n.º 6
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     """
     Sets the path to the cassandra source directory for use by this node.
     """
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         if cassandra_dir is not None:
             common.validate_cassandra_dir(cassandra_dir)
     else:
         dir, v = setup(cassandra_version, verbose=verbose)
         self.__cassandra_dir = dir
     self.import_config_files()
     return self
Ejemplo n.º 7
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         common.validate_cassandra_dir(cassandra_dir)
         self.__version = self.__get_version_from_build()
     else:
         dir, v = repository.setup(cassandra_version, verbose)
         self.__cassandra_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()
     return self
Ejemplo n.º 8
0
Archivo: node.py Proyecto: jsanda/ccm
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     """
     Sets the path to the cassandra source directory for use by this node.
     """
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         if cassandra_dir is not None:
             common.validate_cassandra_dir(cassandra_dir)
     else:
         dir, v = setup(cassandra_version, verbose=verbose)
         self.__cassandra_dir = dir
     self.import_config_files()
     return self
Ejemplo n.º 9
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_cassandra_dir(dir)
            return dir
        except ArgumentError as e:
            shutil.rmtree(dir)
            return None
    else:
        return None
Ejemplo n.º 10
0
 def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
     if cassandra_version is None:
         self.__cassandra_dir = cassandra_dir
         common.validate_cassandra_dir(cassandra_dir)
         self.__version = self.__get_version_from_build()
     else:
         dir, v = repository.setup(cassandra_version, verbose)
         self.__cassandra_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
Ejemplo n.º 11
0
    def set_cassandra_dir(self, cassandra_dir=None, cassandra_version=None, verbose=False):
        if cassandra_version is None:
            self.__cassandra_dir = cassandra_dir
            common.validate_cassandra_dir(cassandra_dir)
            self.__version = self.__get_version_from_build()
        else:
            dir, v = repository.setup(cassandra_version, verbose)
            self.__cassandra_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
Ejemplo n.º 12
0
 def get_cassandra_dir(self):
     common.validate_cassandra_dir(self.__cassandra_dir)
     return self.__cassandra_dir
Ejemplo n.º 13
0
 def get_cassandra_dir(self):
     common.validate_cassandra_dir(self.__cassandra_dir)
     return self.__cassandra_dir