示例#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
示例#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
示例#3
0
文件: node.py 项目: EnigmaCurry/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
示例#4
0
文件: node.py 项目: 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
示例#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
示例#6
0
文件: node.py 项目: EnigmaCurry/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
示例#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
示例#8
0
文件: node.py 项目: 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
示例#9
0
文件: repository.py 项目: kapyar/ccm
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
示例#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
示例#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
示例#12
0
 def get_cassandra_dir(self):
     common.validate_cassandra_dir(self.__cassandra_dir)
     return self.__cassandra_dir
示例#13
0
 def get_cassandra_dir(self):
     common.validate_cassandra_dir(self.__cassandra_dir)
     return self.__cassandra_dir