You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2011/08/09 13:05:55 UTC

svn commit: r1155306 - in /incubator/deltacloud/trunk: client/lib/base_object.rb client/lib/deltacloud.rb server/views/firewalls/index.xml.haml server/views/firewalls/show.xml.haml

Author: mfojtik
Date: Tue Aug  9 11:05:54 2011
New Revision: 1155306

URL: http://svn.apache.org/viewvc?rev=1155306&view=rev
Log:
Client: Fixed destroy operation on firewall resource

Modified:
    incubator/deltacloud/trunk/client/lib/base_object.rb
    incubator/deltacloud/trunk/client/lib/deltacloud.rb
    incubator/deltacloud/trunk/server/views/firewalls/index.xml.haml
    incubator/deltacloud/trunk/server/views/firewalls/show.xml.haml

Modified: incubator/deltacloud/trunk/client/lib/base_object.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/base_object.rb?rev=1155306&r1=1155305&r2=1155306&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/base_object.rb (original)
+++ incubator/deltacloud/trunk/client/lib/base_object.rb Tue Aug  9 11:05:54 2011
@@ -149,7 +149,7 @@ module DeltaCloud
         @actions = []
       end
 
-      # This trigger is called right after action. 
+      # This trigger is called right after action.
       # This method does nothing inside ActionObject
       # but it can be redifined and used in meta-programming
       def action_trigger(action)
@@ -314,14 +314,14 @@ module DeltaCloud
         DeltaCloud::API.class_eval("class #{class_name} < DeltaCloud::#{parent_class}; end")
         @defined_classes << class_name
       end
-      
+
       DeltaCloud::API.const_get(parent.classify).const_get(name.classify)
     end
 
     def self.guess_model_type(response)
       response = Nokogiri::XML(response.to_s)
-      return :action if ((response/'//actions').length == 1) and ((response/'//state').length == 0)
-      return :stateful if ((response/'//actions').length == 1) and ((response/'//state').length == 1)
+      return :action if ((response/'//actions').length >= 1) and ((response/'//state').length == 0)
+      return :stateful if ((response/'//actions').length >= 1) and ((response/'//state').length >= 1)
       return :base
     end
 

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=1155306&r1=1155305&r2=1155306&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Tue Aug  9 11:05:54 2011
@@ -213,7 +213,7 @@ module DeltaCloud
         # If there are actions, add they to ActionObject/StateFullObject
         if attribute.name == 'actions'
           (attribute/'link').each do |link|
-            (obj.add_run_action!(item['id'], link) && next) if link[:rel] == 'run' 
+            (obj.add_run_action!(item['id'], link) && next) if link[:rel] == 'run'
             obj.add_action_link!(item['id'], link)
           end && next
         end

Modified: incubator/deltacloud/trunk/server/views/firewalls/index.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/firewalls/index.xml.haml?rev=1155306&r1=1155305&r2=1155306&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/firewalls/index.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/firewalls/index.xml.haml Tue Aug  9 11:05:54 2011
@@ -2,6 +2,9 @@
 %firewalls
   - @firewalls.each do |firewall|
     %firewall{:href => firewall_url(firewall.id), :id => firewall.id}
+      %actions
+        %link{ :rel => :destroy, :href => destroy_firewall_url(firewall.id), :method => :delete, :id => firewall.id}
+        %link{ :rel => :add_rule, :href => "#{firewall_url(firewall.name)}/rules", :method => :post, :id => firewall.id}
       - firewall.attributes.select{ |attr| attr != :id && attr!= :rules}.each do |attribute|
         - haml_tag("#{attribute}".tr('-', '_'), :<) do
           - if [:name, :description].include?(attribute)
@@ -12,6 +15,8 @@
       %rules
         - firewall.rules.each do |rule|
           %rule{:id => rule.id}
+          %actions
+            %link{ :rel => :rule, :href => "#{firewall_url(firewall.name)}/#{rule.id}", :method => :delete, :id =>rule.id, :rel => :destroy }
             - rule.attributes.select{|attr| attr != :sources && attr != :id}.each do |rule_attrib|
               - haml_tag("#{rule_attrib}".tr('-', '_'), :<) do
                 - haml_concat rule.send(rule_attrib)
@@ -20,4 +25,4 @@
                 - if source[:type] == "group"
                   %source{:name => source[:name], :type=> source[:type], :owner=> source[:owner]}
                 - else
-                  %source{:prefix => source[:prefix], :address=> source[:address], :family=>source[:family], :type => source[:type]}
\ No newline at end of file
+                  %source{:prefix => source[:prefix], :address=> source[:address], :family=>source[:family], :type => source[:type]}

Modified: incubator/deltacloud/trunk/server/views/firewalls/show.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/firewalls/show.xml.haml?rev=1155306&r1=1155305&r2=1155306&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/firewalls/show.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/firewalls/show.xml.haml Tue Aug  9 11:05:54 2011
@@ -1,5 +1,8 @@
 !!! XML
 %firewall{:href => firewall_url(@firewall.id), :id => @firewall.id}
+  %actions
+    %link{ :rel => :destroy, :href => destroy_firewall_url(@firewall.id), :method => :delete}
+    %link{ :rel => :update, :href => "#{firewall_url(@firewall_name)}/rules", :method => :post}
   - @firewall.attributes.select{ |attr| attr != :id && attr!= :rules}.each do |attribute|
     - haml_tag("#{attribute}".tr('-', '_'), :<) do
       - if [:name, :description].include?(attribute)
@@ -10,6 +13,8 @@
   %rules
     - @firewall.rules.each do |rule|
       %rule{:href => firewall_url(@firewall.id) + '/' + rule.id, :id => rule.id}
+        %actions
+          %link{ :rel => :destroy, :href => "#{firewall_url(@firewall.name)}/#{rule.id}", :method => :delete}
         - rule.attributes.select{|attr| attr != :sources && attr != :id}.each do |rule_attrib|
           - haml_tag("#{rule_attrib}".tr('-', '_'), :<) do
             - haml_concat rule.send(rule_attrib)