本文整理汇总了Python中ccmlib.node.Node.load方法的典型用法代码示例。如果您正苦于以下问题:Python Node.load方法的具体用法?Python Node.load怎么用?Python Node.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ccmlib.node.Node
的用法示例。
在下文中一共展示了Node.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from ccmlib.node import Node [as 别名]
# 或者: from ccmlib.node.Node import load [as 别名]
def load(path, name):
cluster_path = os.path.join(path, name)
filename = os.path.join(cluster_path, 'cluster.conf')
with open(filename, 'r') as f:
data = yaml.load(f)
try:
cassandra_dir = None
if 'cassandra_dir' in data:
cassandra_dir = data['cassandra_dir']
repository.validate(cassandra_dir)
cluster = Cluster(path, data['name'], cassandra_dir=cassandra_dir, create_directory=False)
node_list = data['nodes']
seed_list = data['seeds']
if 'partitioner' in data:
cluster.partitioner = data['partitioner']
if 'config_options' in data:
cluster._config_options = data['config_options']
if 'log_level' in data:
cluster.__log_level = data['log_level']
except KeyError as k:
raise common.LoadError("Error Loading " + filename + ", missing property:" + k)
for node_name in node_list:
cluster.nodes[node_name] = Node.load(cluster_path, node_name, cluster)
for seed_name in seed_list:
cluster.seeds.append(cluster.nodes[seed_name])
return cluster
示例2: load
# 需要导入模块: from ccmlib.node import Node [as 别名]
# 或者: from ccmlib.node.Node import load [as 别名]
def load(path, name):
cluster_path = os.path.join(path, name)
filename = os.path.join(cluster_path, 'cluster.conf')
with open(filename, 'r') as f:
data = yaml.load(f)
try:
install_dir = None
if 'install_dir' in data:
install_dir = data['install_dir']
repository.validate(install_dir)
if install_dir is None and 'cassandra_dir' in data:
install_dir = data['cassandra_dir']
repository.validate(install_dir)
cassandra_version = None
if 'cassandra_version' in data:
cassandra_version = LooseVersion(data['cassandra_version'])
if common.isDse(install_dir):
cluster = DseCluster(path, data['name'], install_dir=install_dir, create_directory=False, derived_cassandra_version=cassandra_version)
else:
cluster = Cluster(path, data['name'], install_dir=install_dir, create_directory=False, derived_cassandra_version=cassandra_version)
node_list = data['nodes']
seed_list = data['seeds']
if 'partitioner' in data:
cluster.partitioner = data['partitioner']
if 'config_options' in data:
cluster._config_options = data['config_options']
if 'dse_config_options' in data:
cluster._dse_config_options = data['dse_config_options']
if 'misc_config_options' in data:
cluster._misc_config_options = data['misc_config_options']
if 'log_level' in data:
cluster.__log_level = data['log_level']
if 'use_vnodes' in data:
cluster.use_vnodes = data['use_vnodes']
if 'datadirs' in data:
cluster.data_dir_count = int(data['datadirs'])
extension.load_from_cluster_config(cluster, data)
except KeyError as k:
raise common.LoadError("Error Loading " + filename + ", missing property:" + k)
for node_name in node_list:
cluster.nodes[node_name] = Node.load(cluster_path, node_name, cluster)
for seed in seed_list:
cluster.seeds.append(seed)
return cluster
示例3: load
# 需要导入模块: from ccmlib.node import Node [as 别名]
# 或者: from ccmlib.node.Node import load [as 别名]
def load(path, name):
cluster_path = os.path.join(path, name)
filename = os.path.join(cluster_path, "cluster.conf")
with open(filename, "r") as f:
data = yaml.load(f)
try:
install_dir = None
if "install_dir" in data:
install_dir = data["install_dir"]
repository.validate(install_dir)
if install_dir is None and "cassandra_dir" in data:
install_dir = data["cassandra_dir"]
repository.validate(install_dir)
if common.isDse(install_dir):
cluster = DseCluster(path, data["name"], install_dir=install_dir, create_directory=False)
else:
cluster = Cluster(path, data["name"], install_dir=install_dir, create_directory=False)
node_list = data["nodes"]
seed_list = data["seeds"]
if "partitioner" in data:
cluster.partitioner = data["partitioner"]
if "config_options" in data:
cluster._config_options = data["config_options"]
if "log_level" in data:
cluster.__log_level = data["log_level"]
if "use_vnodes" in data:
cluster.use_vnodes = data["use_vnodes"]
except KeyError as k:
raise common.LoadError("Error Loading " + filename + ", missing property:" + k)
for node_name in node_list:
cluster.nodes[node_name] = Node.load(cluster_path, node_name, cluster)
for seed_name in seed_list:
cluster.seeds.append(cluster.nodes[seed_name])
return cluster