Skip to content

Instantly share code, notes, and snippets.

@oldsharp
Created December 18, 2013 07:55
Show Gist options
  • Save oldsharp/8018782 to your computer and use it in GitHub Desktop.
Save oldsharp/8018782 to your computer and use it in GitHub Desktop.
a simple sample-script to create cassandra cluster
#!/usr/bin/env python
import os
import shutil
import ccmlib.cluster
CLEAR = True
NODE_NUM = 4
CLUSTER_NAME = 'mushroom'
WORKSPACE = '/path/to/.ccm'
CASSANDR_DIR = '/path/to/apache-cassandra-1.2.2-src'
if __name__ == '__main__':
os.makedirs(WORKSPACE)
cluster = ccmlib.cluster.Cluster(WORKSPACE, CLUSTER_NAME, cassandra_dir=CASSANDR_DIR)
cluster.set_log_level('INFO')
try:
print 'populating'
cluster.populate(NODE_NUM)
cluster.start()
print 'populate OK'
except Exception as e:
raise
finally:
if CLEAR:
cluster.remove()
shutil.rmtree(WORKSPACE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment