incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1153086 - in /incubator/deltacloud/trunk: server/lib/deltacloud/helpers/ server/tests/drivers/mock/ server/views/instances/ tests/ec2/ tests/ec2/step_definitions/
Date Tue, 02 Aug 2011 10:05:52 GMT
Author: mfojtik
Date: Tue Aug  2 10:05:50 2011
New Revision: 1153086

URL: http://svn.apache.org/viewvc?rev=1153086&view=rev
Log:
Added type to address element to indicate kind of address (MAC, IPv4, hostname)

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
    incubator/deltacloud/trunk/server/tests/drivers/mock/instances_test.rb
    incubator/deltacloud/trunk/server/views/instances/show.xml.haml
    incubator/deltacloud/trunk/tests/ec2/instances.feature
    incubator/deltacloud/trunk/tests/ec2/step_definitions/instances_steps.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb?rev=1153086&r1=1153085&r2=1153086&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb Tue Aug
 2 10:05:50 2011
@@ -247,4 +247,17 @@ module ApplicationHelper
     end
   end
 
+  def format_address(address, opts={})
+    address_type = case address
+                    when /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?$/; :ipv4
+                    when /^(\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2})?$/; :mac
+                    else :hostname
+                  end
+    capture_haml do
+      haml_tag :address, { :type => address_type }.merge(opts) do
+        haml_concat address
+      end
+    end
+  end
+
 end

Modified: incubator/deltacloud/trunk/server/tests/drivers/mock/instances_test.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/tests/drivers/mock/instances_test.rb?rev=1153086&r1=1153085&r2=1153086&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/tests/drivers/mock/instances_test.rb (original)
+++ incubator/deltacloud/trunk/server/tests/drivers/mock/instances_test.rb Tue Aug  2 10:05:50
2011
@@ -197,10 +197,12 @@ module DeltacloudUnitTest
       (instance/'public_addreses').should_not == nil
       (instance/'public_addresses/address').to_a.size.should > 0
       (instance/'public_addresses/address').first.text.should_not == ""
+      (instance/'public_addresses/address').first[:type].should == "hostname"
 
       (instance/'private_addresses').should_not == nil
       (instance/'private_addresses/address').to_a.size.should > 0
       (instance/'private_addresses/address').first.text.should_not == ""
+      (instance/'private_addresses/address').first[:type].should == "hostname"
 
       (instance/'actions/link').to_a.size.should > 0
       (instance/'actions/link').each do |link|

Modified: incubator/deltacloud/trunk/server/views/instances/show.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/instances/show.xml.haml?rev=1153086&r1=1153085&r2=1153086&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/instances/show.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/instances/show.xml.haml Tue Aug  2 10:05:50 2011
@@ -33,16 +33,13 @@
     %public_addresses<
       - @instance.public_addresses.each do |address|
         - if address.class.eql?(Hash) and address[:address]!=""
-          %address{ :port => address[:port], :type => address[:type], :mac => address[:mac]
}<
-            =address[:address]
+          =format_address(address[:address], :port => address[:port], :type => address[:type],
:mac => address[:mac])
         - elsif address.class.eql?(String)
-          %address<
-            =address
+          =format_address(address)
   - if @instance.private_addresses
     %private_addresses<
       - @instance.private_addresses.each do |address|
-        %address<
-          =address
+        =format_address(address)
   - if @instance.firewalls
     %firewalls<
       - @instance.firewalls.each do |firewall|

Modified: incubator/deltacloud/trunk/tests/ec2/instances.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/ec2/instances.feature?rev=1153086&r1=1153085&r2=1153086&view=diff
==============================================================================
--- incubator/deltacloud/trunk/tests/ec2/instances.feature (original)
+++ incubator/deltacloud/trunk/tests/ec2/instances.feature Tue Aug  2 10:05:50 2011
@@ -72,6 +72,7 @@ Feature: Managing instances
     | state | RUNNING |
     Then client should get some instances
     And each instance should have 'state' element set to 'RUNNING'
+    And each instance should have address type set to "hostname"
 
   Scenario: Get details about first instance
     Given URI /api/instances exists

Modified: incubator/deltacloud/trunk/tests/ec2/step_definitions/instances_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/ec2/step_definitions/instances_steps.rb?rev=1153086&r1=1153085&r2=1153086&view=diff
==============================================================================
--- incubator/deltacloud/trunk/tests/ec2/step_definitions/instances_steps.rb (original)
+++ incubator/deltacloud/trunk/tests/ec2/step_definitions/instances_steps.rb Tue Aug  2 10:05:50
2011
@@ -64,6 +64,13 @@ Then /^this instance should be in '(.+)'
   output_xml.xpath('/instance/state').first.text.should == state
 end
 
+Then /^each instance should have address type set to "([^"]*)"$/ do |t|
+  puts output_xml
+  output_xml.xpath('/instances/instance/public_addresses/address').first[:type].should ==
t
+  output_xml.xpath('/instances/instance/private_addresses/address').first[:type].should ==
t
+end
+
+
 When /^client want to create a new instance$/ do
 end
 



Mime
View raw message