incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@redhat.com
Subject [PATCH] Restores delete firewall rule semantics:
Date Mon, 27 Jun 2011 14:22:18 GMT
From: marios <marios@redhat.com>

DELETE /api/firewalls/:firewall/:rule_id

Signed-off-by: marios <marios@redhat.com>
---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    2 +-
 server/server.rb                                |   31 ++++++++++------------
 server/views/firewalls/show.html.haml           |    3 +-
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 53f95b6..4e182a3 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -640,7 +640,7 @@ module Deltacloud
 #--
         def delete_firewall_rule(credentials, opts={})
           ec2 = new_client(credentials)
-          firewall = opts[:id]
+          firewall = opts[:firewall]
           protocol, from_port, to_port, addresses, groups = firewall_rule_params(opts[:rule_id])
           safely do
             ec2.manage_security_group_ingress(firewall, from_port, to_port, protocol, "revoke",
addresses, groups)
diff --git a/server/server.rb b/server/server.rb
index 104ea9c..913f632 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -996,6 +996,19 @@ get "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/firewalls/:firewall/new_rule"
   end
 end
 
+#delete a firewall rule
+delete '/api/firewalls/:firewall/:rule' do
+  opts = {}
+  opts[:firewall] = params[:firewall]
+  opts[:rule_id] = params[:rule]
+  driver.delete_firewall_rule(credentials, opts)
+  respond_to do |format|
+    format.html {redirect firewall_url(params[:firewall])}
+    format.xml {204}
+    format.json {204}
+  end
+end
+
 #FIREWALLS
 collection :firewalls do
   description "Allow user to define firewall rules for an instance (ec2 security groups)
eg expose ssh access [port 22, tcp]."
@@ -1075,20 +1088,4 @@ collection :firewalls do
     end
   end
 
-#delete a firewall rule DELETE /api/firewalls/:firewall/rule - with param rule_id
-  operation :rule, :method => :delete, :member => true do
-    description 'Delete the specified firewall rule from the given firewall'
-    param :firewall, :required, :string
-    param :rule_id,  :required, :string
-    with_capability :delete_firewall_rule
-    control do
-      driver.delete_firewall_rule(credentials, params)
-      respond_to do |format|
-        format.html {redirect firewall_url(params[:id])}
-        format.xml {204}
-        format.json {204}
-      end
-    end
-  end
-
-end #firewalls
+end
diff --git a/server/views/firewalls/show.html.haml b/server/views/firewalls/show.html.haml
index b77aaa4..53edf53 100644
--- a/server/views/firewalls/show.html.haml
+++ b/server/views/firewalls/show.html.haml
@@ -36,9 +36,8 @@
             type: #{source[:type]}, family: #{source[:family]}, address: #{source[:address]},
prefix: #{source[:prefix]}
             %br
       %dd
-        %form{ :action => "#{firewall_url(@firewall.name)}/rule", :method => :post}
+        %form{ :action => "#{firewall_url(@firewall.name)}/#{rule.id}", :method =>
:post}
           %input{:type => "hidden", :name => "_method", :value => "delete"}
-          %input{:type => "hidden", :name => "rule_id", :value => rule.id}
           %input{:type => :submit, :value => "Delete Rule"}
   %dd
     = link_to_action 'Delete Firewall', destroy_firewall_url(@firewall.name), :delete
-- 
1.7.3.4


Mime
View raw message