You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/06/27 16:22:17 UTC
Restore firewall rule delete semantics
This patch restores the original firewall rule semantics:
DELETE /api/firewalls/:firewall/:rule_id
Currently this is achieved with:
DELETE /api/firewalls/:firewall/rule?rule_id=xyz
(because I wanted to leverage the Rabbit DSL - autodocs, param validation)
thanks to Chris Lalancette for bringing this up,
marios
Re: [PATCH] Restores delete firewall rule semantics:
Posted by "marios@redhat.com" <ma...@redhat.com>.
Hi Chris, sorry for the delay -
at first I was sceptical about the usefulness of exposing the rule URI
since it doesn't make sense to 'retrieve' (GET) a single rule. However I
agree that it makes sense to expose the rule URI as we have a 'DELETE
rule_id' operation. I'll send an updated patch and will commit as soon
as you ack that,
marios
On 30/06/11 23:44, Chris Lalancette wrote:
> On 06/27/11 - 05:22:18PM, marios@redhat.com wrote:
>> From: marios<ma...@redhat.com>
>>
>> DELETE /api/firewalls/:firewall/:rule_id
>>
>> Signed-off-by: marios<ma...@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(-)
>
> Hey Marios,
> Sorry for the long delay here. This patch is most of what I would like
> to see, though there is one thing missing. In the XML for the firewall rule,
> I think we should export the URL for the rule as well, similar to how blobs
> have a full URL. Something like this (untested) patch?
>
Re: [PATCH] Restores delete firewall rule semantics:
Posted by Chris Lalancette <cl...@redhat.com>.
On 06/27/11 - 05:22:18PM, marios@redhat.com wrote:
> From: marios <ma...@redhat.com>
>
> DELETE /api/firewalls/:firewall/:rule_id
>
> Signed-off-by: marios <ma...@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(-)
Hey Marios,
Sorry for the long delay here. This patch is most of what I would like
to see, though there is one thing missing. In the XML for the firewall rule,
I think we should export the URL for the rule as well, similar to how blobs
have a full URL. Something like this (untested) patch?
--
Chris Lalancette
[PATCH] Restores delete firewall rule semantics:
Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>
DELETE /api/firewalls/:firewall/:rule_id
Signed-off-by: marios <ma...@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