def run(self): """ """ config_remotes = self.gather_config_remotes() to_delete = [] to_add = [x for x in config_remotes.keys() if not x in env.git_reverse] for value, name in env.git_reverse.items(): if name == 'origin': continue if not value in config_remotes: test = get_answer( "The remote %s %s isn't in your servers.ini. Do you want to remove it?" % (name, value)) if test: to_delete.append(name) for name in to_delete: execute('local.git.rm_remote', remote_name=name) for value in to_add: name = get_remote_name(value, config_remotes[value]) execute('local.git.add_remote', remote_name=name, user_and_host=value)
def _add_remote(self, name=None): if not env.host_string in env.git_reverse: name = functions.get_remote_name(env.host_string, self.config_section, name=name) execute('local.git.add_remote', remote_name=name, user_and_host=env.host_string) return name
def run(self, **kwargs): """ """ assert not env.hosts if not env.get("joyent_account"): print "To use the joyent api you must add a joyent_account value to your env" sys.exit(1) setup_name = "setup.%s" % kwargs.get("type") task = functions.get_task_instance(setup_name) default_dataset = DEFAULT_DATASET default_package = DEFAULT_PACKAGE if task: if hasattr(task, "dataset"): default_dataset = task.dataset if hasattr(task, "server_size"): default_package = task.server_size else: print "I don't know how to add a %s server" % kwargs.get("type") sys.exit(1) location = kwargs.get("data_center") if not location and env.get("joyent_default_data_center"): location = env.joyent_default_data_center elif not location: print "You must supply an data_center argument or add a joyent_default_data_center attribute to your env" sys.exit(1) key_name = raw_input("Enter your ssh key name: ") key_id = "/%s/keys/%s" % (env.joyent_account, key_name) allow_agent = env.get("allow_agent", False) sdc = DataCenter(location=location, key_id=key_id, allow_agent=allow_agent) name = functions.get_remote_name(None, task.config_section, name=kwargs.get("name")) new_args = { "name": name, "dataset": kwargs.get("data_set", default_dataset), "metadata": kwargs.get("metadata", {}), "tags": kwargs.get("tags", {}), "package": kwargs.get("package", default_package), } machine = sdc.create_machine(**new_args) public_ip = machine.public_ips[0] print "added machine %s" % public_ip host_string = "admin@%s" % public_ip print "waiting for machine to be ready" while machine.status() != "running": print "." time.sleep(5) print "done" execute(setup_name, name=name, hosts=[host_string])
def run(self, **kwargs): """ """ assert not env.hosts if not env.get('joyent_account'): print "To use the joyent api you must add a joyent_account value to your env" sys.exit(1) setup_name = 'setup.%s' % kwargs.get('type') task = functions.get_task_instance(setup_name) default_dataset = DEFAULT_DATASET default_package = DEFAULT_PACKAGE if task: if hasattr(task, 'dataset'): default_dataset = task.dataset if hasattr(task, 'server_size'): default_package = task.server_size else: print "I don't know how to add a %s server" % kwargs.get('type') sys.exit(1) location = kwargs.get('data_center') if not location and env.get('joyent_default_data_center'): location = env.joyent_default_data_center elif not location: print "You must supply an data_center argument or add a joyent_default_data_center attribute to your env" sys.exit(1) key_name = raw_input('Enter your ssh key name: ') key_id = '/%s/keys/%s' % ( env.joyent_account, key_name) sdc = DataCenter(location=location, key_id=key_id) name = functions.get_remote_name(None, task.config_section, name=kwargs.get('name')) new_args = { 'name' : name, 'dataset' : kwargs.get('data_set', default_dataset), 'metadata' : kwargs.get('metadata', {}), 'tags' : kwargs.get('tags', {}), 'package' : kwargs.get('package', default_package) } machine = sdc.create_machine(**new_args) public_ip = machine.public_ips[0] print "added machine %s" % public_ip host_string = 'admin@%s' % public_ip print "waiting for machine to be ready" while machine.status() != 'running': print '.' time.sleep(5) print 'done' execute(setup_name, name=name, hosts=[host_string])
def run(self): config_remotes = self.gather_config_remotes() to_delete = [] to_add = [ x for x in config_remotes.keys() if not x in env.git_reverse ] for value, name in env.git_reverse.items(): if name == 'origin': continue if not value in config_remotes: test = get_answer("The remote %s %s isn't in your servers.ini. Do you want to remove it?" %(name, value)) if test: to_delete.append(name) for name in to_delete: execute('local.git.rm_remote', remote_name=name) for value in to_add: name = get_remote_name(value, config_remotes[value]) execute('local.git.add_remote', remote_name=name, user_and_host=value)
def run(self, **kwargs): assert not env.hosts conn = get_ec2_connection(server_type='ec2', **kwargs) type = kwargs.get('type') setup_name = 'setup.%s' % type instance_type = DEFAULT_INSTANCE_TYPE ami_id = kwargs.get('ami_id') if not ami_id: ami_id = DEFAULT_AMI task = functions.get_task_instance(setup_name) if task: if hasattr(task, 'instance_type'): instance_type = task.instance_type if hasattr(task, 'ami'): ami_id = task.ami else: print "I don't know how to add a %s server" % type sys.exit(1) amzn = env.get('AWS_CREDENTIAL', os.path.join(env.deploy_path, 'amazon.ini')) parser = ConfigParser() parser.read(amzn) key_name = parser.get('amazon-aws', 'ec2-key-name') key_file = parser.get('amazon-aws', 'ec2-key-file') if not key_name: print "Sorry. You need to create key pair with create_key first." sys.exit(1) elif not os.path.exists(key_file): print( "I find key %s in server.ini file, but the key file is not" " on its location %s. There is something wrong. Please fix " "it, or recreate key pair" % (key_name, key_file)) sys.exit(1) image = conn.get_image(ami_id) security_group = get_security_group(conn, task.config_section) name = functions.get_remote_name(None, task.config_section, name=kwargs.get('name')) SERVER = { 'image_id': image.id, 'instance_type': instance_type, 'security_groups': [security_group], 'key_name': key_name, } reservation = conn.run_instances(**SERVER) print reservation instance = reservation.instances[0] while instance.state != 'running': time.sleep(5) instance.update() print "...instance state: %s" % (instance.state) conn.create_tags([instance.id], {"Name": name}) if not kwargs.get('static_ip', False): ip = instance.ip_address else: elastic_ip = conn.allocate_address() print "...Elastic IP %s allocated" % elastic_ip elastic_ip.associate(instance.id) ip = elastic_ip.public_ip print "...EC2 instance is successfully created." print "...wait 5 seconds for the server to be ready" print "...while waiting, you may want to note down the following info" time.sleep(5) print "..." print "...Instance using image: %s" % image.name print "...Added into security group: %s" % security_group.name print "...Instance ID: %s" % instance.id print "...Public IP: %s" % ip host_string = 'ubuntu@%s' % instance.public_dns_name execute(setup_name, name=name, hosts=[host_string])
def run(self, **kwargs): assert not env.hosts conn = get_ec2_connection(server_type='ec2', **kwargs) type = kwargs.get('type') setup_name = 'setup.%s' % type instance_type = DEFAULT_INSTANCE_TYPE ami_id = kwargs.get('ami_id') if not ami_id: ami_id = DEFAULT_AMI task = functions.get_task_instance(setup_name) if task: if hasattr(task, 'instance_type'): instance_type = task.instance_type if hasattr(task, 'ami'): ami_id = task.ami else: print "I don't know how to add a %s server" % type sys.exit(1) amzn = env.get('AWS_CREDENTIAL', os.path.join(env.deploy_path, 'amazon.ini')) parser = ConfigParser() parser.read(amzn) key_name = parser.get('amazon-aws', 'ec2-key-name') key_file = parser.get('amazon-aws', 'ec2-key-file') if not key_name: print "Sorry. You need to create key pair with create_key first." sys.exit(1) elif not os.path.exists(key_file): print ("I find key %s in server.ini file, but the key file is not" " on its location %s. There is something wrong. Please fix " "it, or recreate key pair" % (key_name, key_file)) sys.exit(1) image = conn.get_image(ami_id) security_group = get_security_group(conn, task.config_section) name = functions.get_remote_name(None, task.config_section, name=kwargs.get('name')) SERVER = { 'image_id': image.id, 'instance_type': instance_type, 'security_groups': [security_group], 'key_name': key_name,} reservation = conn.run_instances(**SERVER) print reservation instance = reservation.instances[0] while instance.state != 'running': time.sleep(5) instance.update() print "...instance state: %s" % (instance.state) conn.create_tags([instance.id], {"Name": name}) if not kwargs.get('static_ip', False): ip = instance.ip_address else: elastic_ip = conn.allocate_address() print "...Elastic IP %s allocated" % elastic_ip elastic_ip.associate(instance.id) ip = elastic_ip.public_ip print "...EC2 instance is successfully created." print "...wait 5 seconds for the server to be ready" print "...while waiting, you may want to note down the following info" time.sleep(5) print "..." print "...Instance using image: %s" % image.name print "...Added into security group: %s" %security_group.name print "...Instance ID: %s" % instance.id print "...Public IP: %s" % ip host_string = 'ubuntu@%s' % instance.public_dns_name execute(setup_name, name=name, hosts=[host_string])
def run(self, **kwargs): """ """ assert not env.hosts if not env.get('joyent_account'): print "To use the joyent api you must add a joyent_account value to your env" sys.exit(1) setup_name = 'setup.%s' % kwargs.get('type') task = functions.get_task_instance(setup_name) default_dataset = DEFAULT_DATASET default_package = DEFAULT_PACKAGE if task: if hasattr(task, 'dataset'): default_dataset = task.dataset if hasattr(task, 'server_size'): default_package = task.server_size else: print "I don't know how to add a %s server" % kwargs.get('type') sys.exit(1) location = kwargs.get('data_center') if not location and env.get('joyent_default_data_center'): location = env.joyent_default_data_center elif not location: print "You must supply an data_center argument or add a joyent_default_data_center attribute to your env" sys.exit(1) key_name = raw_input('Enter your ssh key name: ') key_id = '/%s/keys/%s' % (env.joyent_account, key_name) allow_agent = env.get('allow_agent', False) sdc = DataCenter(location=location, key_id=key_id, allow_agent=allow_agent) name = functions.get_remote_name(None, task.config_section, name=kwargs.get('name')) new_args = { 'name': name, 'dataset': kwargs.get('data_set', default_dataset), 'metadata': kwargs.get('metadata', {}), 'tags': kwargs.get('tags', {}), 'package': kwargs.get('package', default_package) } machine = sdc.create_machine(**new_args) public_ip = machine.public_ips[0] print "added machine %s" % public_ip host_string = 'admin@%s' % public_ip print "waiting for machine to be ready" while machine.status() != 'running': print '.' time.sleep(5) print 'done' execute(setup_name, name=name, hosts=[host_string])