deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: Core: Fixed run_on_instance view and wrong capability checking
Date Thu, 24 May 2012 14:05:09 GMT
Updated Branches:
  refs/heads/master aa7c79be7 -> 4954fb82b


Core: Fixed run_on_instance view and wrong capability checking


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

Branch: refs/heads/master
Commit: 4954fb82bd99f994a2d4c0fe4227f52f519221b9
Parents: aa7c79b
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu May 24 16:05:03 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu May 24 16:05:03 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/collections/instances.rb    |   10 +++-
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb   |    8 ++-
 server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb |    2 +-
 server/views/instances/run_command.html.haml      |   48 ++++++++--------
 4 files changed, 40 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4954fb82/server/lib/deltacloud/collections/instances.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/instances.rb b/server/lib/deltacloud/collections/instances.rb
index 27e0c80..933ecaf 100644
--- a/server/lib/deltacloud/collections/instances.rb
+++ b/server/lib/deltacloud/collections/instances.rb
@@ -31,6 +31,13 @@ module Deltacloud::Collections
       @keys = driver.keys(credentials) if driver.class.has_feature? :instances, :authentication_key
     end
 
+    get route_for('/instances/:id/run') do
+      respond_to do |format|
+        @instance = driver.instances(credentials, :id => params[:id]).first
+        format.html {haml :"instances/run_command" }
+      end
+    end
+
     collection :instances do
 
       standard_show_operation
@@ -86,8 +93,7 @@ module Deltacloud::Collections
         control { instance_action(:destroy) }
       end
 
-      action :run, :with_capability => :run_instance do
-        param :id,          :string,  :required
+      action :run, :with_capability => :run_on_instance do
         param :cmd,         :string,  :required, [], "Shell command to run on instance"
         param :private_key, :string,  :optional, [], "Private key in PEM format for authentication"
         param :password,    :string,  :optional, [], "Password used for authentication"

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4954fb82/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 0ef0395..856f159 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -16,6 +16,8 @@
 
 require 'aws'
 
+require_relative '../../runner'
+
 class Instance
   attr_accessor :keyname
   attr_accessor :authn_error
@@ -768,7 +770,11 @@ module Deltacloud
                     when :s3 then Aws::S3
                     when :mon then Aws::Mon
                   end
-          klass.new(credentials.user, credentials.password, {:server => endpoint_for_service(type),
:connection_mode => :per_thread})
+          klass.new(credentials.user, credentials.password, {
+            :server => endpoint_for_service(type),
+            :connection_mode => :per_thread,
+            :logger => ENV['RACK_ENV'] == 'test' ? Logger.new('/dev/null') : Logger.new(STDOUT)
+          })
         end
 
         def default_image_owner

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4954fb82/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
index 62af399..0b73317 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
@@ -16,6 +16,7 @@
 # Author: Dies Koper <diesk@fast.au.fujitsu.com>
 
 require_relative 'fgcp_client'
+require_relative '../../runner'
 require 'openssl'
 require 'xmlsimple'
 
@@ -381,7 +382,6 @@ class FgcpDriver < Deltacloud::BaseDriver
   end
 
   def run_on_instance(credentials, opts={})
-p opts
     target = instance(credentials, opts)
     safely do
       param = {}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4954fb82/server/views/instances/run_command.html.haml
----------------------------------------------------------------------
diff --git a/server/views/instances/run_command.html.haml b/server/views/instances/run_command.html.haml
index d42fc04..73a267a 100644
--- a/server/views/instances/run_command.html.haml
+++ b/server/views/instances/run_command.html.haml
@@ -1,25 +1,25 @@
-%h1
-  Run command on 
-  = @instance.name || @instance.id
+=header "Run a command on #{@instance.name}"
+=subheader "#{@instance.id}"
 
-%form{ :action => run_instance_url(@instance.id), :method => :post }
-  %p
-    %label{ :for => :cmd } Desired command:
-    %input{ :name => :cmd, :value => "", :type => :text}
-  %p
-    %fieldset{ :'data-role' => :fieldcontain}
-      %legend Target instance IP address:
-      - (@instance.public_addresses | @instance.private_addresses).each_with_index do |ip,
idx|
-        %label{ :for => ip.address }= "#{ip.address}"
-        %input{ :name => :ip, :value => ip.address, :id => ip.address, :type =>
:radio, :'data-theme' => 'b', :checked => idx == 0 || nil}/
-  %p
-    %label{ :for => :port } Target port:
-    %input{ :name => "port", :size => 5, :value => "22", :type => :text}
-  %p
-    %label{ :for => :private_key } Private key:
-  %p
-    %small Leave private key blank if using password authentication method
-  %p
-    %textarea{ :name => :private_key, :cols => 65, :rows => 20 }
-  %p
-    %input{ :type => :submit, :value => "Execute" }
+%div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
+  %form{ :action => api_url_for('/instances/%s/run' % @instance.id), :method => :post
}
+    %p
+      %label{ :for => :cmd } Desired command:
+      %input{ :name => :cmd, :value => "", :type => :text}
+    %p
+      %fieldset{ :'data-role' => :fieldcontain}
+        %legend Target instance IP address:
+        - (@instance.public_addresses | @instance.private_addresses).each_with_index do |ip,
idx|
+          %label{ :for => ip.address }= "#{ip.address}"
+          %input{ :name => :ip, :value => ip.address, :id => ip.address, :type =>
:radio, :'data-theme' => 'b', :checked => idx == 0 || nil}/
+    %p
+      %label{ :for => :port } Target port:
+      %input{ :name => "port", :size => 5, :value => "22", :type => :text}
+    %p
+      %label{ :for => :private_key } Private key:
+    %p
+      %small Leave private key blank if using password authentication method
+    %p
+      %textarea{ :name => :private_key, :cols => 65, :rows => 20 }
+    %p
+      %input{ :type => :submit, :value => "Execute" }


Mime
View raw message