def main(): print "Using configuration file: %s" % config.get('Internal', 'last_location') print print "Welcome to DataStax' Cassandra Cluster Launcher!" print " The easiest way to get Apache Cassandra up and running in Amazon's EC2" print " in under 5 minutes!" print global cli_options cli_options = common.parse_cli_options(options_tree) # Required handle for log purposes and future shared EC2 purposes check_cascading_options('handle') # Prompt the user with any outstanding running clusters if (check_cascading_options('aws_access_key_id')[0] == '"' or check_cascading_options('aws_secret_access_key')[0] == '"' or check_cascading_options('aws_access_key_id')[0] == "'" or check_cascading_options('aws_secret_access_key')[0] == "'"): sys.stderr.write("None of the configurations should be wrapped in quotes.\n") sys.stderr.write(" EC2:aws_access_key_id or EC2:aws_secret_access_key appears to be.\n") sys.exit(1) if not cli_options['CLI_noprompts']: ec2.terminate_cluster(check_cascading_options('aws_access_key_id'), check_cascading_options('aws_secret_access_key'), config.get('EC2', 'placement'), check_cascading_options('handle'), prompt_continuation=True) start_time = time.time() # Get basic information for both Community and Enterprise clusters clustername = check_cascading_options('clustername') clustername = "'%s'" % clustername.replace("'", "") # Ensure totalnodes > 0 ignore_command_line = False while True: totalnodes = check_cascading_options('totalnodes', int, ignore_command_line=ignore_command_line) if totalnodes > 0: break else: config.set('Cassandra', 'totalnodes') ignore_command_line = True version = check_cascading_options('version', choices=['Community', 'Enterprise']).title() user_data = '--clustername %s --totalnodes %s --version %s' % (clustername, totalnodes, version) if version == 'Enterprise': ignore_command_line = False while True: # Get additional information for Enterprise clusters username = check_cascading_options('username', ignore_command_line=ignore_command_line) password = check_cascading_options('password', password=True, ignore_command_line=ignore_command_line) print "Confirming credentials..." if confirm_authentication(username, password): break else: config.set('Cassandra', 'username') config.set('Cassandra', 'password') ignore_command_line = True print "Authentication to DataStax server failed. Please try again." # Check the number of Analytics Nodes that will launch ignore_command_line = False while True: analyticsnodes = check_cascading_options('analyticsnodes', int, ignore_command_line=ignore_command_line) if analyticsnodes <= totalnodes: break else: print "Overallocation of the chosen %d nodes" % (totalnodes) # Clear the previous cfsreplicationfactor config.set('Cassandra', 'analyticsnodes') ignore_command_line = True # Check the number of Search Nodes that will launch ignore_command_line = False while True: searchnodes = check_cascading_options('searchnodes', int, ignore_command_line=ignore_command_line) if analyticsnodes + searchnodes <= totalnodes: break else: print "Overallocation of the chosen %d nodes" % (totalnodes) # Clear the previous cfsreplicationfactor config.set('Cassandra', 'searchnodes') ignore_command_line = True user_data += ' --username %s --password %s --analyticsnodes %s --searchnodes %s' % (username, password, analyticsnodes, searchnodes) # If Hadoop enabled nodes are launching, check the CFS replication factor if analyticsnodes > 0: ignore_command_line = False while True: cfsreplicationfactor = check_cascading_options('cfsreplicationfactor', int, ignore_command_line=ignore_command_line) if 1 <= cfsreplicationfactor and cfsreplicationfactor <= analyticsnodes: break else: print "1 <= CFS Replication Factor <= Number of Analytics Nodes" # Clear the previous cfsreplicationfactor config.set('Cassandra', 'cfsreplicationfactor') ignore_command_line = True user_data += ' --cfsreplicationfactor %s' % (cfsreplicationfactor) print # Included for the experimental DemoService that requires demoservice.py to always be running demotime = -1 if config.get('Cassandra', 'demo') == 'True': print "Your configuration file is set to launch a demo cluster for a specified time." demotime = check_cascading_options('demotime', float) print "If the demo service is running, this cluster will live for %s hour(s)." % demotime print if check_cascading_options('installopscenter', optional=True) == 'False': user_data += ' --opscenter no' if check_cascading_options('release', optional=True): user_data += ' --release %s' % check_cascading_options('release') opscenterinterface = 8888 if check_cascading_options('opscenterinterface', optional=True): opscenterinterface = check_cascading_options('opscenterinterface') user_data += ' --opscenterinterface %s' % opscenterinterface # DataStax AMI specific options and formatting image = check_cascading_options('datastax_ami', optional=True) if not image: image = 'ami-fd23ec94' tag = '{0} - DataStaxAMI Time: {1} Size: {2}'.format(check_cascading_options('handle'), time.strftime("%m-%d-%y %H:%M", time.localtime()), totalnodes) user = '******' # Launch the cluster instance_type = check_cascading_options('instance_type', choices=['m1.large', 'm1.xlarge', 'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge']) clusterinfo = ec2.create_cluster(check_cascading_options('aws_access_key_id'), check_cascading_options('aws_secret_access_key'), totalnodes, image, tag, KEY_PAIR, instance_type, config.get('EC2', 'placement'), PEM_HOME, user_data, cli_options['CLI_noprompts'], opscenterinterface) # Save IPs global private_ips global public_ips private_ips, public_ips, reservation = clusterinfo # Log clusterinfo running_log(reservation, demotime) if check_cascading_options('installopscenter', optional=True) != 'False': # Print OpsCenter url print "OpsCenter Address:" print "http://%s:%s" % (public_ips[0], opscenterinterface) print "Note: You must wait 60 seconds after Cassandra becomes active to access OpsCenter." print start_priming(user) if version == 'Enterprise': global seed_index realtimenodes = totalnodes - analyticsnodes - searchnodes seed_index = [0, realtimenodes, realtimenodes + analyticsnodes] seed_index.reverse() global node_types node_type = 'c' node_types = {'c': [], 'a':[], 's':[]} print 'Primed Connection Strings:' for i, node in enumerate(public_ips): if version == 'Enterprise' and i in seed_index: if seed_index.index(i) == 0: print 'Search (Solr) Nodes:' node_type = 's' if seed_index.index(i) == 1: print 'Analytics (Hadoop) Nodes:' node_type = 'a' if seed_index.index(i) == 2: print 'Realtime (Cassandra) Nodes:' node_type = 'c' node_types[node_type].append(i) print ' {0} -i {1} -o UserKnownHostsFile={2} {3}@{4}'.format(config.get('System', 'ssh'), PEM_FILE, HOST_FILE, user, node) print print 'Installing DataStax SSH on the cluster...' install_datastax_ssh(user) if cli_options['CLI_qa']: print 'Uploading smoke tests on the cluster...' upload_smoke_tests(user) print 'Setting up the hosts file for the cluster...' install_hosts_appending(user) install_opsc_agents(user) end_time = int(time.time() - start_time) print 'Total Elapsed Time: %s minutes %s seconds' % (end_time / 60, end_time % 60) print if not cli_options['CLI_noprompts']: ec2.terminate_cluster(check_cascading_options('aws_access_key_id'), check_cascading_options('aws_secret_access_key'), config.get('EC2', 'placement'), check_cascading_options('handle')) else: # Ensure the agents have time to start # installing before exiting the program time.sleep(10)
def main(): print "Using configuration file: %s" % config.get("Internal", "last_location") print print "Welcome to DataStax' Cassandra Cluster Launcher!" print " The easiest way to get Apache Cassandra up and running in Amazon's EC2" print " in under 5 minutes!" print global cli_options cli_options = common.parse_cli_options(options_tree) # Required handle for log purposes and future shared EC2 purposes check_cascading_options("handle") # Prompt the user with any outstanding running clusters if ( check_cascading_options("aws_access_key_id")[0] == '"' or check_cascading_options("aws_secret_access_key")[0] == '"' or check_cascading_options("aws_access_key_id")[0] == "'" or check_cascading_options("aws_secret_access_key")[0] == "'" ): sys.stderr.write("None of the configurations should be wrapped in quotes.\n") sys.stderr.write(" EC2:aws_access_key_id or EC2:aws_secret_access_key appears to be.\n") sys.exit(1) if not cli_options["CLI_noprompts"]: ec2.terminate_cluster( check_cascading_options("aws_access_key_id"), check_cascading_options("aws_secret_access_key"), config.get("EC2", "placement"), check_cascading_options("handle"), prompt_continuation=True, ) start_time = time.time() # Get basic information for both Community and Enterprise clusters clustername = check_cascading_options("clustername") clustername = "'%s'" % clustername.replace("'", "") # Ensure totalnodes > 0 ignore_command_line = False while True: totalnodes = check_cascading_options("totalnodes", int, ignore_command_line=ignore_command_line) if totalnodes > 0: break else: config.set("Cassandra", "totalnodes") ignore_command_line = True version = check_cascading_options("version", choices=["Community", "Enterprise"]).title() user_data = "--clustername %s --totalnodes %s --version %s" % (clustername, totalnodes, version) if version == "Enterprise": ignore_command_line = False while True: # Get additional information for Enterprise clusters username = check_cascading_options("username", ignore_command_line=ignore_command_line) password = check_cascading_options("password", password=True, ignore_command_line=ignore_command_line) print "Confirming credentials..." if confirm_authentication(username, password): break else: config.set("Cassandra", "username") config.set("Cassandra", "password") ignore_command_line = True print "Authentication to DataStax server failed. Please try again." # Check the number of Analytics Nodes that will launch ignore_command_line = False while True: analyticsnodes = check_cascading_options("analyticsnodes", int, ignore_command_line=ignore_command_line) if analyticsnodes <= totalnodes: break else: print "Overallocation of the chosen %d nodes" % (totalnodes) # Clear the previous cfsreplicationfactor config.set("Cassandra", "analyticsnodes") ignore_command_line = True # Check the number of Search Nodes that will launch ignore_command_line = False while True: searchnodes = check_cascading_options("searchnodes", int, ignore_command_line=ignore_command_line) if analyticsnodes + searchnodes <= totalnodes: break else: print "Overallocation of the chosen %d nodes" % (totalnodes) # Clear the previous cfsreplicationfactor config.set("Cassandra", "searchnodes") ignore_command_line = True user_data += " --username %s --password %s --analyticsnodes %s --searchnodes %s" % ( username, password, analyticsnodes, searchnodes, ) # If Hadoop enabled nodes are launching, check the CFS replication factor if analyticsnodes > 0: ignore_command_line = False while True: cfsreplicationfactor = check_cascading_options( "cfsreplicationfactor", int, ignore_command_line=ignore_command_line ) if 1 <= cfsreplicationfactor and cfsreplicationfactor <= analyticsnodes: break else: print "1 <= CFS Replication Factor <= Number of Analytics Nodes" # Clear the previous cfsreplicationfactor config.set("Cassandra", "cfsreplicationfactor") ignore_command_line = True user_data += " --cfsreplicationfactor %s" % (cfsreplicationfactor) print # Included for the experimental DemoService that requires demoservice.py to always be running demotime = -1 if config.get("Cassandra", "demo") == "True": print "Your configuration file is set to launch a demo cluster for a specified time." demotime = check_cascading_options("demotime", float) print "If the demo service is running, this cluster will live for %s hour(s)." % demotime print if check_cascading_options("installopscenter", optional=True) == "False": user_data += " --opscenter no" if check_cascading_options("release", optional=True): user_data += " --release %s" % check_cascading_options("release") opscenterinterface = 8888 if check_cascading_options("opscenterinterface", optional=True): opscenterinterface = check_cascading_options("opscenterinterface") user_data += " --opscenterinterface %s" % opscenterinterface # DataStax AMI specific options and formatting image = check_cascading_options("datastax_ami", optional=True) if not image: image = "ami-6139e708" tag = "{0} - DataStaxAMI Time: {1} Size: {2}".format( check_cascading_options("handle"), time.strftime("%m-%d-%y %H:%M", time.localtime()), totalnodes ) user = "******" # Launch the cluster instance_type = check_cascading_options( "instance_type", choices=["m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge"] ) clusterinfo = ec2.create_cluster( check_cascading_options("aws_access_key_id"), check_cascading_options("aws_secret_access_key"), totalnodes, image, tag, KEY_PAIR, instance_type, config.get("EC2", "placement"), PEM_HOME, user_data, cli_options["CLI_noprompts"], opscenterinterface, ) # Save IPs global private_ips global public_ips private_ips, public_ips, reservation = clusterinfo # Log clusterinfo running_log(reservation, demotime) if check_cascading_options("installopscenter", optional=True) != "False": # Print OpsCenter url print "OpsCenter Address:" print "http://%s:%s" % (public_ips[0], opscenterinterface) print "Note: You must wait 60 seconds after Cassandra becomes active to access OpsCenter." print start_priming(user) if version == "Enterprise": global seed_index realtimenodes = totalnodes - analyticsnodes - searchnodes seed_index = [0, realtimenodes, realtimenodes + analyticsnodes] seed_index.reverse() global node_types node_type = "c" node_types = {"c": [], "a": [], "s": []} print "Primed Connection Strings:" for i, node in enumerate(public_ips): if version == "Enterprise" and i in seed_index: if seed_index.index(i) == 0: print "Search (Solr) Nodes:" node_type = "s" if seed_index.index(i) == 1: print "Analytics (Hadoop) Nodes:" node_type = "a" if seed_index.index(i) == 2: print "Realtime (Cassandra) Nodes:" node_type = "c" node_types[node_type].append(i) print " {0} -i {1} -o UserKnownHostsFile={2} {3}@{4}".format( config.get("System", "ssh"), PEM_FILE, HOST_FILE, user, node ) print print "Installing DataStax SSH on the cluster..." install_datastax_ssh(user) if cli_options["CLI_qa"]: print "Uploading smoke tests on the cluster..." upload_smoke_tests(user) print "Setting up the hosts file for the cluster..." install_hosts_appending(user) print "Setting up datastax_s3_store and datastax_s3_restore capabilities..." setup_s3_store_and_restore(user) install_opsc_agents(user) end_time = int(time.time() - start_time) print "Total Elapsed Time: %s minutes %s seconds" % (end_time / 60, end_time % 60) print if not cli_options["CLI_noprompts"]: ec2.terminate_cluster( check_cascading_options("aws_access_key_id"), check_cascading_options("aws_secret_access_key"), config.get("EC2", "placement"), check_cascading_options("handle"), ) else: # Ensure the agents have time to start # installing before exiting the program time.sleep(10)
def main(): print "Using configuration file: %s" % config.get('Internal', 'last_location') print print "Welcome to DataStax' Cassandra Cluster Launcher!" print " The easiest way to get Apache Cassandra up and running in Amazon's EC2" print " in under 5 minutes!" print global cli_options cli_options = common.parse_cli_options(options_tree) # Required handle for log purposes and future shared EC2 purposes check_cascading_options('handle') # Prompt the user with any outstanding running clusters if (check_cascading_options('aws_access_key_id')[0] == '"' or check_cascading_options('aws_secret_access_key')[0] == '"' or check_cascading_options('aws_access_key_id')[0] == "'" or check_cascading_options('aws_secret_access_key')[0] == "'"): sys.stderr.write("None of the configurations should be wrapped in quotes.\n") sys.stderr.write(" EC2:aws_access_key_id or EC2:aws_secret_access_key appears to be.\n") sys.exit(1) if not cli_options['CLI_noprompts']: ec2.terminate_cluster(check_cascading_options('aws_access_key_id'), check_cascading_options('aws_secret_access_key'), config.get('EC2', 'placement'), check_cascading_options('handle'), prompt_continuation=True) start_time = time.time() # Get basic information for both Community and Enterprise clusters clustername = check_cascading_options('clustername') clustername = "'%s'" % clustername.replace("'", "") # Ensure totalnodes > 0 ignore_command_line = False while True: totalnodes = check_cascading_options('totalnodes', int, ignore_command_line=ignore_command_line) if totalnodes > 0: break else: config.set('Cassandra', 'totalnodes') ignore_command_line = True version = check_cascading_options('version', choices=['Community', 'Enterprise']).title() user_data = '--clustername %s --totalnodes %s --version %s' % (clustername, totalnodes, version) if version == 'Enterprise': ignore_command_line = False while True: # Get additional information for Enterprise clusters username = check_cascading_options('username', ignore_command_line=ignore_command_line) password = check_cascading_options('password', password=True, ignore_command_line=ignore_command_line) print "Confirming credentials..." if confirm_authentication(username, password): break else: config.set('Cassandra', 'username') config.set('Cassandra', 'password') ignore_command_line = True print "Authentication to DataStax server failed. Please try again." # Check the number of Analytics Nodes that will launch ignore_command_line = False while True: analyticsnodes = check_cascading_options('analyticsnodes', int, ignore_command_line=ignore_command_line) if analyticsnodes <= totalnodes: break else: print "Overallocation of the chosen %d nodes" % (totalnodes) # Clear the previous cfsreplicationfactor config.set('Cassandra', 'analyticsnodes') ignore_command_line = True # Check the number of Search Nodes that will launch ignore_command_line = False while True: searchnodes = check_cascading_options('searchnodes', int, ignore_command_line=ignore_command_line) if analyticsnodes + searchnodes <= totalnodes: break else: print "Overallocation of the chosen %d nodes" % (totalnodes) # Clear the previous cfsreplicationfactor config.set('Cassandra', 'searchnodes') ignore_command_line = True user_data += ' --username %s --password %s --analyticsnodes %s --searchnodes %s' % (username, password, analyticsnodes, searchnodes) # If Hadoop enabled nodes are launching, check the CFS replication factor if analyticsnodes > 0: ignore_command_line = False while True: cfsreplicationfactor = check_cascading_options('cfsreplicationfactor', int, ignore_command_line=ignore_command_line) if 1 <= cfsreplicationfactor and cfsreplicationfactor <= analyticsnodes: break else: print "1 <= CFS Replication Factor <= Number of Analytics Nodes" # Clear the previous cfsreplicationfactor config.set('Cassandra', 'cfsreplicationfactor') ignore_command_line = True user_data += ' --cfsreplicationfactor %s' % (cfsreplicationfactor) print # Included for the experimental DemoService that requires demoservice.py to always be running demotime = 0 if config.get('Cassandra', 'demo') == 'True': print "Your configuration file is set to launch a demo cluster for a specified time." demotime = check_cascading_options('demotime', float) print "If demosercie is running, this cluster will live for %s seconds(s)." % demotime print if check_cascading_options('installopscenter', optional=True) == 'False': user_data += ' --opscenter no' if check_cascading_options('release', optional=True): user_data += ' --release %s' % check_cascading_options('release') opscenterinterface = 8888 if check_cascading_options('opscenterinterface', optional=True): opscenterinterface = check_cascading_options('opscenterinterface') user_data += ' --opscenterinterface %s' % opscenterinterface # DataStax AMI specific options and formatting image = check_cascading_options('datastax_ami', optional=True) if not image: image = 'ami-6139e708' tag = '{0} - DataStaxAMI Time: {1} Size: {2}'.format(check_cascading_options('handle'), time.strftime("%m-%d-%y %H:%M", time.localtime()), totalnodes) user = '******' # Launch the cluster instance_type = check_cascading_options('instance_type', choices=['m1.large', 'm1.xlarge', 'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge']) clusterinfo = ec2.create_cluster(check_cascading_options('aws_access_key_id'), check_cascading_options('aws_secret_access_key'), totalnodes, image, tag, KEY_PAIR, instance_type, config.get('EC2', 'placement'), PEM_HOME, user_data, cli_options['CLI_noprompts'], opscenterinterface) # Save IPs global private_ips global public_ips private_ips, public_ips, reservation = clusterinfo # Log clusterinfo if check_cascading_options('result_directory', optional=True): result_directory = check_cascading_options('result_directory') user_data += ' --result_directory %s' % result_directory launch_id = str(uuid.uuid4()) if check_cascading_options('launch_id', optional=True): launch_id = check_cascading_options('launch_id') user_data += ' --launch_id %s' % launch_id if not os.path.exists(result_directory): os.mkdir(result_directory) tmpfile = os.path.join(result_directory, "%s.tmp" % launch_id) dstfile = os.path.join(result_directory, "%s.results" % launch_id) with open(tmpfile, 'w') as f: f.write("reservation_id=%s\n" % reservation.id) f.write("ttl_seconds=%s\n" % demotime) f.write("launch_time=%s\n" % time.time()) if check_cascading_options('installopscenter', optional=True) != 'False': f.write("opsc_ip=%s\n" % public_ips[0]) f.write("opsc_port=%s\n" % opscenterinterface) os.rename(tmpfile, dstfile) if check_cascading_options('installopscenter', optional=True) != 'False': # Print OpsCenter url url = "http://%s:%s" % (public_ips[0], opscenterinterface) print "OpsCenter URL: %s" % url print "Note: You must wait 60 seconds after Cassandra becomes active to access OpsCenter." print if cli_options['CLI_qa']: print "OPSCENTER_IP:%s" % public_ips[0] print "OPSCENTER_PORT:%s" % opscenterinterface start_priming(user) if version == 'Enterprise': global seed_index realtimenodes = totalnodes - analyticsnodes - searchnodes seed_index = [0, realtimenodes, realtimenodes + analyticsnodes] seed_index.reverse() global node_types node_type = 'c' node_types = {'c': [], 'a':[], 's':[]} print 'Primed Connection Strings:' for i, node in enumerate(public_ips): if version == 'Enterprise' and i in seed_index: if seed_index.index(i) == 0: print 'Search (Solr) Nodes:' node_type = 's' if seed_index.index(i) == 1: print 'Analytics (Hadoop) Nodes:' node_type = 'a' if seed_index.index(i) == 2: print 'Realtime (Cassandra) Nodes:' node_type = 'c' node_types[node_type].append(i) print ' {0} -i {1} -o UserKnownHostsFile={2} {3}@{4}'.format(config.get('System', 'ssh'), PEM_FILE, HOST_FILE, user, node) print print 'Installing DataStax SSH on the cluster...' install_datastax_ssh(user) if cli_options['CLI_qa']: print 'Uploading smoke tests on the cluster...' upload_smoke_tests(user) print 'Setting up the hosts file for the cluster...' install_hosts_appending(user) print 'Setting up datastax_s3_store and datastax_s3_restore capabilities...' setup_s3_store_and_restore(user) install_opsc_agents(user) end_time = int(time.time() - start_time) print 'Total Elapsed Time: %s minutes %s seconds' % (end_time / 60, end_time % 60) print if not cli_options['CLI_noprompts']: ec2.terminate_cluster(check_cascading_options('aws_access_key_id'), check_cascading_options('aws_secret_access_key'), config.get('EC2', 'placement'), check_cascading_options('handle')) else: # Ensure the agents have time to start # installing before exiting the program time.sleep(10)