Skip to content

Commit

Permalink
Removed obsolete print_ssh commands; added USAGE output, cleaned-up s…
Browse files Browse the repository at this point in the history
…ome obsolete TODO comments
  • Loading branch information
mattinasi committed Jul 12, 2011
1 parent 8946de1 commit a0a95ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
23 changes: 9 additions & 14 deletions lcaws.rb
Expand Up @@ -28,22 +28,22 @@ def get_web_proxy_config(ecc, instances, args)
app_count = 0 app_count = 0
proxy_config = Array.new proxy_config = Array.new


# get running web and app instances
apps = ecc.get_app_instances(instances, "running") apps = ecc.get_app_instances(instances, "running")
webs = ecc.get_web_instances(instances, "running") webs = ecc.get_web_instances(instances, "running")

# TODO: remove non-running instances from apps and webs


# sort by the number appended to the name # sort by the number appended to the name
apps.sort! {|a,b| a.name[3..-1].to_i <=> b.name[3..-1].to_i} apps.sort! {|a,b| a.name[3..-1].to_i <=> b.name[3..-1].to_i}
webs.sort! {|a,b| a.name[3..-1].to_i <=> b.name[3..-1].to_i} webs.sort! {|a,b| a.name[3..-1].to_i <=> b.name[3..-1].to_i}


# make sure the ration of web to apps is correct
if webs.size * APPS_PER_WEB != apps.size if webs.size * APPS_PER_WEB != apps.size
puts "Environment Imbalance Error: there must be #{APPS_PER_WEB} app servers for each web server. Currently there are #{webs.size} webs and #{apps.size} apps" puts "Environment Imbalance Error: there must be #{APPS_PER_WEB} app servers for each web server. Currently there are #{webs.size} webs and #{apps.size} apps"
return nil return nil
end end


# allocate the app servers to the web servers
app_index = 0 app_index = 0

webs.each_with_index do |web_instance, index| webs.each_with_index do |web_instance, index|
proxy_config[index] = Hash.new proxy_config[index] = Hash.new
proxy_config[index][:name] = web_instance.name proxy_config[index][:name] = web_instance.name
Expand Down Expand Up @@ -138,14 +138,6 @@ def create_database_configs(ecc, instances, args)
slave_config.each { |x| puts x.inspect + "\n\n ##########"} slave_config.each { |x| puts x.inspect + "\n\n ##########"}
end end


def print_ssh_commands(ecc, instances, args)
puts "SSH commands (apps)"
LcAws.print_ssh_commands(ecc.get_app_instances(instances))

puts "SSH commands (loadgen)"
LcAws.print_ssh_commands(ecc.get_loadgen_instances(instances))
end

def stop_apps(ecc, instances, args) def stop_apps(ecc, instances, args)
puts "Stopping all app servers..." puts "Stopping all app servers..."
ecc.stop_app_servers ecc.stop_app_servers
Expand Down Expand Up @@ -275,9 +267,12 @@ def create_envfile(ecc, instances, args)




def print_usage def print_usage
# puts self.public_methods.sort puts "USAGE: ruby lcaws.rb <command>"
# puts "USAGE: ruby lcaws.rb [list][web-proxy][ssh-commands][stop-apps][start-apps][show-apps][open-apps][stop-loadgens][start-loadgens][show-loadgens][open-loadgens][open-webs][show-dbs][scp-loadgen-results][create-envfile]\n"+ puts "where <command> is one of the following methods: \n"+
# " There should be at least one command. If more than one command is specified then commands are executed in order" " create_envfile, create_web_proxy_config, create_database_configs, list_instances, \n"+
" start_apps, stop_apps, show_apps, open_app_terminals, \n" +
" start_loadgens, stop_loadgens, open_loadgen_termials, \n"+
" start_webs, stop_webs, show_webs, open_web_terminals\n"
end end


############### ###############
Expand Down
23 changes: 1 addition & 22 deletions lib/lcec2.rb
Expand Up @@ -165,7 +165,7 @@ def get_rds_instances_by_name(name_filter)
all_instances = get_rds_instances all_instances = get_rds_instances
filtered_instances = Array.new filtered_instances = Array.new
all_instances.each do |instance| all_instances.each do |instance|
# check if the name matches AND the state matches the filter provided # check if the name matches
if !instance.name.nil? and instance.name.include?(name_filter) if !instance.name.nil? and instance.name.include?(name_filter)
filtered_instances << instance filtered_instances << instance
else else
Expand Down Expand Up @@ -272,27 +272,6 @@ def add_app_instances(num, zone, names, ami = DEFAULT_APP_AMI)
add_instances(num,names,'app', opts) add_instances(num,names,'app', opts)
end end


#
# printing helpful commands
#
def print_proxy_members(instances = nil)
apps = get_app_instances(instances)
apps.each do |instance|
puts "# #{instance.name}" if instance.running?
puts "BalancerMember http://#{instance.private_dns_name}:8080" if instance.running?
end
end

def self.print_ssh_commands(instances)
instances.each do |instance|
if instance.keyname == ""
puts "ssh -i intuit-baseline.pem ea@#{instance.dns_name}" if instance.running?
else
puts "ssh -i #{instance.keyname}.pem root@#{instance.dns_name}" if instance.running?
end
end
end

private private


def get_instance_blob def get_instance_blob
Expand Down
4 changes: 2 additions & 2 deletions scripts/add_perf_instances.rb
Expand Up @@ -7,11 +7,11 @@


# add 2 web, 12 app to us-east1-b # add 2 web, 12 app to us-east1-b
ecc.add_web_instances(2, "us-east-1b", ["web01", "web02"]) ecc.add_web_instances(2, "us-east-1b", ["web01", "web02"])
#ecc.add_app_instances(12, "us-east-1b", ["app001", "app002", "app003", "app004", "app005", "app006", "app007", "app008", "app009", "app010", "app011", "app012"]) ecc.add_app_instances(12, "us-east-1b", ["app001", "app002", "app003", "app004", "app005", "app006", "app007", "app008", "app009", "app010", "app011", "app012"])


# add 2 web, 12 app to us-east1-c # add 2 web, 12 app to us-east1-c
ecc.add_web_instances(2, "us-east-1c", ["web03", "web04"]) ecc.add_web_instances(2, "us-east-1c", ["web03", "web04"])
#ecc.add_app_instances(12, "us-east-1c", ["app013", "app014", "app015", "app016", "app017", "app018", "app019", "app020", "app021", "app022", "app023", "app024"]) ecc.add_app_instances(12, "us-east-1c", ["app013", "app014", "app015", "app016", "app017", "app018", "app019", "app020", "app021", "app022", "app023", "app024"])


# ensure they were added # ensure they were added


Expand Down

0 comments on commit a0a95ed

Please sign in to comment.