deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/2] git commit: EC2 frontend minor fixed and improvements
Date Mon, 28 May 2012 13:02:30 GMT
EC2 frontend minor fixed and improvements

Signed-off-by: Michal fojtik <mfojtik@redhat.com>


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/cabbe9ba
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/cabbe9ba
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/cabbe9ba

Branch: refs/heads/master
Commit: cabbe9ba374e34cf0b143a5b07056c4d46b60615
Parents: d88ee48
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Mon May 28 10:51:02 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon May 28 15:02:36 2012 +0200

----------------------------------------------------------------------
 server/lib/ec2/query_parser.rb                  |    4 +++-
 server/lib/ec2/server.rb                        |   12 +++++++++++-
 server/lib/ec2/views/describe_images.haml       |    2 +-
 server/lib/ec2/views/describe_instance_set.haml |    7 ++++---
 server/lib/ec2/views/error.haml                 |    4 ++++
 5 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cabbe9ba/server/lib/ec2/query_parser.rb
----------------------------------------------------------------------
diff --git a/server/lib/ec2/query_parser.rb b/server/lib/ec2/query_parser.rb
index 8d2abc9..8050119 100644
--- a/server/lib/ec2/query_parser.rb
+++ b/server/lib/ec2/query_parser.rb
@@ -100,10 +100,12 @@ module Deltacloud::EC2
 
   class QueryParser
 
+    class InvalidAction < StandardError; end
+
     def self.parse(params, request_id)
       parser = new(request_id, params)
       unless parser.valid_action?
-        raise 'Invalid action (%s)' % parser.action
+        raise InvalidAction.new('Invalid action (%s)' % parser.action)
       else
         ActionHandler.new(parser)
       end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cabbe9ba/server/lib/ec2/server.rb
----------------------------------------------------------------------
diff --git a/server/lib/ec2/server.rb b/server/lib/ec2/server.rb
index d229c94..9b045e4 100644
--- a/server/lib/ec2/server.rb
+++ b/server/lib/ec2/server.rb
@@ -44,13 +44,23 @@ module Deltacloud::EC2
     set :version, Deltacloud[:version]
     set :root_url, Deltacloud[:root_url]
     set :root, File.join(File.dirname(__FILE__), '..', '..')
+    set :views, File.join(File.dirname(__FILE__), 'views')
+
+    error Deltacloud::EC2::QueryParser::InvalidAction do
+      status 400
+      haml :error, :locals => { :code => 'InvalidAction', :message => 'The requested
action is not valid for this web service' }
+    end
 
     after do
       headers 'Server' => 'Apache-Deltacloud-EC2/' + settings.version
     end
 
     get '/' do
-      content_type :xml
+      headers 'Connection' => 'close'
+      unless params['Action']
+        redirect settings.root_url, 301
+        halt
+      end
       ec2_action = QueryParser.parse(params, request_id)
       ec2_action.perform!(credentials, driver)
       ec2_action.to_xml(self)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cabbe9ba/server/lib/ec2/views/describe_images.haml
----------------------------------------------------------------------
diff --git a/server/lib/ec2/views/describe_images.haml b/server/lib/ec2/views/describe_images.haml
index a49a5ee..2dd5978 100644
--- a/server/lib/ec2/views/describe_images.haml
+++ b/server/lib/ec2/views/describe_images.haml
@@ -4,7 +4,7 @@
       %imageId=item.id
       %imageState=item.state.downcase
       %imageOwnerId=item.owner_id
-      %architecture item.architecture
+      %architecture=item.architecture
       %imageType machine
       %name=item.name
       %description=item.description

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cabbe9ba/server/lib/ec2/views/describe_instance_set.haml
----------------------------------------------------------------------
diff --git a/server/lib/ec2/views/describe_instance_set.haml b/server/lib/ec2/views/describe_instance_set.haml
index b8c7c1c..7a6a7b8 100644
--- a/server/lib/ec2/views/describe_instance_set.haml
+++ b/server/lib/ec2/views/describe_instance_set.haml
@@ -4,13 +4,14 @@
       %instanceId=item.id
       %imageId=item.image_id
       %instanceType=item.instance_profile.name
-      %launchTime=item.launch_time
+      %launchTime=item.launch_time || Time.now.to_s
       %ipAddress=item.public_addresses.first.address
       %privateIpAddress=item.public_addresses.first.address
       %dnsName=item.public_addresses.first.address
       %privateDnsName=item.private_addresses.first.address
-      %architecture=item.instance_profile.architecture
-      %keyName=item.keyname
+      %architecture=item.instance_profile.architecture || 'i386'
+      - if item.keyname
+        %keyName=item.keyname
       %instanceState
         %code=instance_state_code(item.state.downcase)
         %name=item.state.downcase

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/cabbe9ba/server/lib/ec2/views/error.haml
----------------------------------------------------------------------
diff --git a/server/lib/ec2/views/error.haml b/server/lib/ec2/views/error.haml
new file mode 100644
index 0000000..9b07c73
--- /dev/null
+++ b/server/lib/ec2/views/error.haml
@@ -0,0 +1,4 @@
+%Response
+  %Errors
+    %Code=code
+    %Message=message


Mime
View raw message