From f2ba3edd5c74dd9a0ba74b963cb7782e0878cd4c Mon Sep 17 00:00:00 2001 From: Richard Taylor Date: Tue, 28 Oct 2008 16:38:20 +0000 Subject: [PATCH] can now associate ips through the interface --- public/style.css | 2 +- snail.rb | 3 ++- views/addresses.erb | 13 ++++++++++++- views/instances.erb | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) 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?')" %>

diff --git a/views/instances.erb b/views/instances.erb index 5d7446e..50ab3b4 100644 --- a/views/instances.erb +++ b/views/instances.erb @@ -7,9 +7,10 @@
[ + <%= instance[:aws_instance_id] %> <%= instance[:aws_state] %> ] - + <%= link_to instance[:aws_image_id], "/images/search/#{instance[:aws_image_id]}" %> launched <%= time_ago_or_time_stamp(Time.parse(instance[:aws_launch_time])) %>