def cluster_command(self): """ Route cluster command to appropriate method in Cluster class """ action = Cluster(self.host, self.port) if self.action == "health": action.cluster_health(self.target_index)
def __init__(self, seed_nodes=[('127.0.0.1', 3000)], use_telnet=False, user=None, password=None): cls = BaseController cls.view = view.CliView() cls.cluster = Cluster(seed_nodes, use_telnet, user, password) # instance vars self.modifiers = set()
def main(): env.check() parser = argparse.ArgumentParser() parser.add_argument("cluster_name") subparsers = parser.add_subparsers(dest='op') parser_scp = subparsers.add_parser('scp') parser_scp.add_argument('key_pair_path') parser_scp.add_argument('from_path') parser_scp.add_argument('to_path') parser_launch = subparsers.add_parser('launch') parser_launch.add_argument('cluster_conf_path') parser_start = subparsers.add_parser('start') parser_stop = subparsers.add_parser('stop') parser_cleanup = subparsers.add_parser('cleanup') parser_status = subparsers.add_parser('status') parser_dns = subparsers.add_parser('dns') parser_ip = subparsers.add_parser('ip') subparsers.add_parser('test') subparsers.add_parser('terminate') args = parser.parse_args() logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) region = os.getenv("AWS_DEFAULT_REGION") cluster = Cluster(args.cluster_name) if args.op == 'launch': try: conf = read_conf(args.cluster_name, args.cluster_conf_path) ClusterLauncher().launch(conf) except botocore.exceptions.WaiterError: logging.error("--x Failed to launch instances, Please check your AWS console, some machines may be already running!") cluster.terminate() cluster.cleanup() elif args.op == "status": print(cluster.status) elif args.op == "test": groups = list(cluster.instances)[0].security_groups for g in groups: try: aws.resource('ec2').SecurityGroup(g['GroupId']).delete() except botocore.exceptions.ClientError as e: print(g['GroupName']) elif args.op == "dns": print([i.public_dns_name for i in cluster.instances]) elif args.op == "ip": print([i.public_ip_address for i in cluster.instances]) elif args.op == "stop": cluster.stop() elif args.op == "start": cluster.start() elif args.op == 'scp': dns_name = list(cluster.instances)[0].public_dns_name key = paramiko.RSAKey.from_private_key_file(args.key_pair_path) ssh = SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname = dns_name, username = '******', pkey = key) scp = SCPClient(ssh.get_transport()) scp.put(args.from_path, args.to_path) scp.close() elif args.op == "terminate": utils.confirm("You are about to terminate the whole cluster.") cluster.terminate() elif args.op == "cleanup": utils.confirm("You are about to terminate and remove the whole cluster.") cluster.cleanup()
parser_launch.add_argument("instances_count") parser_launch.add_argument("key_pair_name") parser_launch.add_argument("cloud_config_path") parser_start = subparsers.add_parser('start') parser_stop = subparsers.add_parser('stop') parser_cleanup = subparsers.add_parser('cleanup') parser_status = subparsers.add_parser('status') parser_dns = subparsers.add_parser('dns') parser_ip = subparsers.add_parser('ip') args = parser.parse_args() logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) region = os.getenv("AWS_DEFAULT_REGION") cluster = Cluster(args.cluster_name) if args.op == 'launch': logging.info("--> Fetching CoreOS etcd discovery token") cloud_config = CloudConfig( open(args.cloud_config_path).read() ).with_new_token(args.instances_count) try: launcher = ClusterLauncher() ami = get_ami(region, args.instance_type) conf = ClusterConf( args.cluster_name, ami, args.key_pair_name, user_data = cloud_config, instances_count = int(args.instances_count),
import sys import os from optparse import OptionParser from lib.cluster import Cluster if __name__ == "__main__": usage = """usage: reset_cluster.py --cong=<name-of-conf> """ parser = OptionParser(usage=usage) parser.add_option("", "--conf", action="store", type="string", dest="conf", default=None, help="name of configuration in conf/ to reset cluster with") arg_parameters = sys.argv[1:] (opts, args) = parser.parse_args(arg_parameters) cluster = Cluster() cluster.reset(opts.conf)
arg_parameters = sys.argv[1:] (opts, args) = parser.parse_args(arg_parameters) if opts.test_id is None: print "You must provide a test identifier to run the test" sys.exit(1) test_run_id = "{}_{}".format(opts.test_id, time.strftime("%Y-%m-%d-%H-%M-%S")) # Create test results directory os.makedirs("performance_results/{}".format(test_run_id)) if opts.reset_sync_gateway: print "Resetting Sync Gateway" cluster = Cluster() mode = cluster.reset("performance/sync_gateway_default_performance.json") print("Running in mode: {}".format(mode)) # Copy provisioning_config to performance_results/ folder shutil.copy("provisioning_config", "performance_results/{}".format(test_run_id)) # Start load generator run_tests( number_pullers=opts.number_pullers, number_pushers=opts.number_pushers, use_gateload=opts.use_gateload, gen_gateload_config=opts.gen_gateload_config, test_id=test_run_id )