Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
can now associate ips through the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
moomerman committed Oct 28, 2008
1 parent 18661cb commit f2ba3ed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;}

Expand Down
3 changes: 2 additions & 1 deletion snail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@

get '/addresses' do
@addresses = @ec2.describe_addresses
@instances = @ec2.describe_instances.reverse
erb :addresses
end

Expand All @@ -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'
Expand Down
13 changes: 12 additions & 1 deletion views/addresses.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@
<% unless @addresses.empty? %>

<% @addresses.each do |address| %>
<%= address.inspect %>
<b><%= address[:public_ip] %></b>
<% 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 %>
<form action="/address/<%= address[:public_ip] %>/associate" style="display:inline" method="POST">
<select name="instance_id">
<option value="">Associate with...</option>
<% @instances.each do |instance| %>
<option value="<%= instance[:aws_instance_id] %>"><%= instance[:aws_instance_id] %> (<%= instance[:aws_state] %>)</option>
<% end %>
</select>
<input type="submit" value="go">
</form>
<% end %>
<%= link_to image_tag('minus.png', :alt => 'Release Address'), "/address/#{address[:public_ip]}/release", :onclick => "return confirm('Release Address: Are you sure?')" %>
<br/><br/>
Expand Down
3 changes: 2 additions & 1 deletion views/instances.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

<div class="instance<% if i % 2 == 1%> odd<% end %>">
[<b class="state state-<%= instance[:aws_state] %>">
<%= instance[:aws_instance_id] %>
<span title="<%= instance[:aws_instance_id] %>"><%= instance[:aws_state] %></span>
</b>]

<%= link_to instance[:aws_image_id], "/images/search/#{instance[:aws_image_id]}" %>

launched <%= time_ago_or_time_stamp(Time.parse(instance[:aws_launch_time])) %>
Expand Down

0 comments on commit f2ba3ed

Please sign in to comment.