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 2012/05/23 13:04:20 UTC
git commit: Allow user to chose target ip for run_on_instance
Updated Branches:
refs/heads/master e6312c3e9 -> aa7c79be7
Allow user to chose target ip for run_on_instance
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/aa7c79be
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/aa7c79be
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/aa7c79be
Branch: refs/heads/master
Commit: aa7c79be75f5636138209a266bc3e69a732715b5
Parents: e6312c3
Author: Dies Koper <di...@fast.au.fujitsu.com>
Authored: Mon May 21 10:02:59 2012 +1000
Committer: Michal fojtik <mf...@redhat.com>
Committed: Wed May 23 13:02:52 2012 +0200
----------------------------------------------------------------------
server/lib/deltacloud/collections/instances.rb | 2 ++
server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 2 +-
server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb | 3 ++-
.../lib/deltacloud/drivers/gogrid/gogrid_driver.rb | 2 +-
.../drivers/rackspace/rackspace_driver.rb | 2 +-
server/views/instances/run_command.html.haml | 11 ++++++++++-
server/views/instances/show.html.haml | 2 +-
7 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/server/lib/deltacloud/collections/instances.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/instances.rb b/server/lib/deltacloud/collections/instances.rb
index 05348a8..27e0c80 100644
--- a/server/lib/deltacloud/collections/instances.rb
+++ b/server/lib/deltacloud/collections/instances.rb
@@ -91,6 +91,8 @@ module Deltacloud::Collections
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"
+ param :ip, :string, :optional, [], "IP address of target instance"
+ param :port, :string, :optional, ['22'], "Target port"
control do
@output = driver.run_on_instance(credentials, params)
respond_to do |format|
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/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 b55132e..0ef0395 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -255,7 +255,7 @@ module Deltacloud
:username => 'root', # Default for EC2 Linux instances
}
param[:port] = opts[:port] || '22'
- param[:ip] = target.public_addresses.first.address
+ param[:ip] = opts[:ip] || target.public_addresses.first.address
param[:private_key] = (opts[:private_key].length > 1) ? opts[:private_key] : nil
safely do
Deltacloud::Runner.execute(opts[:cmd], param)
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/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 2248039..62af399 100644
--- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
+++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver.rb
@@ -381,11 +381,12 @@ class FgcpDriver < Deltacloud::BaseDriver
end
def run_on_instance(credentials, opts={})
+p opts
target = instance(credentials, opts)
safely do
param = {}
param[:port] = opts[:port] || '22'
- param[:ip] = target.public_addresses.first.address
+ param[:ip] = opts[:ip] || target.public_addresses.first.address
param[:credentials] = { :username => target.username }
if opts[:private_key] and opts[:private_key].length > 1
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
index 6469312..06e4b3b 100644
--- a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
+++ b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
@@ -145,7 +145,7 @@ class GogridDriver < Deltacloud::BaseDriver
}
param[:credentials].merge!({ :password => opts[:password]}) if opts[:password].length>0
param[:port] = opts[:port] || '22'
- param[:ip] = target.public_addresses.first.address
+ param[:ip] = opts[:ip] || target.public_addresses.first.address
Deltacloud::Runner.execute(opts[:cmd], param)
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
index ca1c236..1412cf5 100644
--- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
+++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
@@ -125,7 +125,7 @@ class RackspaceDriver < Deltacloud::BaseDriver
:password => opts[:password]
}
param[:port] = opts[:port] || '22'
- param[:ip] = target.public_addresses.first.address
+ param[:ip] = opts[:ip] || target.public_addresses.first.address
safely do
Deltacloud::Runner.execute(opts[:cmd], param)
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/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 68e5046..d42fc04 100644
--- a/server/views/instances/run_command.html.haml
+++ b/server/views/instances/run_command.html.haml
@@ -1,12 +1,21 @@
%h1
Run command on
- = @instance.id
+ = @instance.name || @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
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/aa7c79be/server/views/instances/show.html.haml
----------------------------------------------------------------------
diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml
index c820408..0f4cc0a 100644
--- a/server/views/instances/show.html.haml
+++ b/server/views/instances/show.html.haml
@@ -59,6 +59,6 @@
- @instance.actions.each do |action|
=link_to_action action, self.send(:"#{action}_instance_url", @instance.id), instance_action_method(action)
- if @instance.state=="RUNNING" and driver.respond_to?(:run_on_instance)
- =link_to_action 'run script', "#{run_instance_url(@instance.id)};id=#{@instance.id}", :get
+ =link_to_action 'run command', "#{run_instance_url(@instance.id)};id=#{@instance.id}", :get
- if @instance.can_create_image?
=link_to_action 'Create Image', api_url_for("images/new?instance_id=#{@instance.id}"), :get