deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/11] git commit: CIMI: Added '/driver' route to CIMI client
Date Mon, 27 Feb 2012 16:44:47 GMT
Updated Branches:
  refs/heads/master f5983903d -> a66340c71


CIMI: Added '/driver' route to CIMI client

This route will handle driver and provider change.
User is now able to select the DC driver which will be used
to Client<->CIMI server communication. Driver and provider
configuration will be stored in session object and overide
the default basic HTTP auth credentials.


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

Branch: refs/heads/master
Commit: 7aa3b4a630fded50ba476da4059a7eeccfafedda
Parents: 5cf4f2b
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Feb 23 14:47:29 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Feb 24 16:40:02 2012 +0100

----------------------------------------------------------------------
 clients/cimi/app.rb |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7aa3b4a6/clients/cimi/app.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/app.rb b/clients/cimi/app.rb
index a8c3459..510fd33 100644
--- a/clients/cimi/app.rb
+++ b/clients/cimi/app.rb
@@ -28,6 +28,13 @@ module CIMI::Frontend
     use CIMI::Frontend::VolumeConfiguration
     use CIMI::Frontend::VolumeImage
     use CIMI::Frontend::Volume
+    use Rack::Session::Cookie
+
+    helpers CIMI::Frontend::Helper
+
+    before do
+      @_flash, session[:_flash] = session[:_flash], nil if session[:_flash]
+    end
 
     configure do
       enable :logging
@@ -45,6 +52,28 @@ module CIMI::Frontend
     get '/cimi' do
       redirect '/cimi/cloudEntryPoint'
     end
+
+    get '/driver' do
+      unless params[:driver]
+        flash[:error] = "You need to choose driver"
+        redirect(back) && return
+      end
+      session[:provider] = param_if_not_nil(params, :provider)
+      session[:driver] = param_if_not_nil(params, :driver)
+      session[:username] = param_if_not_nil(params, :username)
+      session[:password] = param_if_not_nil(params, :password)
+      flash[:success] = "You're now using #{session[:driver].to_s.upcase}"
+      redirect back
+    end
+
+    private
+
+    def param_if_not_nil(params, param)
+      return false if params[param].nil?
+      return false if params[param].strip.empty?
+      return params[param].strip
+    end
+
   end
 
 end


Mime
View raw message