diff --git a/public/style.css b/public/style.css index c8361a5..7c43684 100644 --- a/public/style.css +++ b/public/style.css @@ -21,7 +21,7 @@ body { #ft {background-color:#cccccc; padding:5px;} -#instances .state {color:yellow; margin-bottom:10px;} +#instances .state {color:orange; margin-bottom:10px;} #instances .state-terminated {color:red;} #instances .state-running {color:green;} diff --git a/snail.rb b/snail.rb index 8131a91..fb05546 100755 --- a/snail.rb +++ b/snail.rb @@ -85,6 +85,7 @@ get '/addresses' do @addresses = @ec2.describe_addresses + @instances = @ec2.describe_instances.reverse erb :addresses end @@ -99,7 +100,7 @@ redirect '/addresses' end -get '/address/*/associate/:instance_id' do +post '/address/*/associate' do ip_address = request.path_info.split('/')[2] @ec2.associate_address(params[:instance_id], ip_address) redirect '/addresses' diff --git a/views/addresses.erb b/views/addresses.erb index 216c42a..c41f3d3 100644 --- a/views/addresses.erb +++ b/views/addresses.erb @@ -6,9 +6,20 @@ <% unless @addresses.empty? %> <% @addresses.each do |address| %> - <%= address.inspect %> + <%= address[:public_ip] %> <% unless address[:instance_id].blank? %> + associated with <%= link_to address[:instance_id], "/instances#address[:instance_id]" %> <%= link_to image_tag('cancel.png', :alt => 'Disassociate Address'), "/address/#{address[:public_ip]}/disassociate", :onclick => "return confirm('Disassociate Address: Are you sure?')" %> + <% else %> +
<% end %> <%= link_to image_tag('minus.png', :alt => 'Release Address'), "/address/#{address[:public_ip]}/release", :onclick => "return confirm('Release Address: Are you sure?')" %>