deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From efcas...@gmail.com
Subject [PATCH] Allows to specify a username when running a comman - DTACLOUD-458
Date Fri, 08 Feb 2013 11:04:51 GMT
From: efcasado <efcasado@gmail.com>

---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    2 +-
 server/lib/deltacloud/runner.rb                 |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 64f827c..2c86651 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -302,7 +302,7 @@ module Deltacloud
           target = instance(credentials, :id => opts[:id])
           param = {}
           param[:credentials] = {
-            :username => 'root', # Default for EC2 Linux instances
+            :username => (opts[:username]) ? opts[:username] : 'root', # Default for EC2
Linux instances
           }
           param[:port] = opts[:port] || '22'
           param[:ip] = opts[:ip] || target.public_addresses.first.address
diff --git a/server/lib/deltacloud/runner.rb b/server/lib/deltacloud/runner.rb
index aa13fa9..7a5d98d 100644
--- a/server/lib/deltacloud/runner.rb
+++ b/server/lib/deltacloud/runner.rb
@@ -69,6 +69,7 @@ module Deltacloud
       def execute(command)
         @command = command
         config = ssh_config(@network, @credentials, @key)
+        username = (@credentials[:username]) ? @credentials[:username] : 'root'
         begin
           session = nil
 	  # Default timeout for connecting to an instance.
@@ -77,7 +78,7 @@ module Deltacloud
 	  # Please keep in mind that the HTTP request timeout is set to 60
 	  # seconds, so you need to fit into this time
           Timeout::timeout(20) do
-            session = Net::SSH.start(@network.ip, 'root', config)
+            session = Net::SSH.start(@network.ip, username, config)
           end
           session.open_channel do |channel|
             channel.on_data do |ch, data|
-- 
1.7.10.2 (Apple Git-33)


Mime
View raw message