From c99f9e59f71c8faa9674a5aa5db97e88ad9543a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toma=C5=BE=20Muraus?= <kami@k5-storitve.net>
Date: Tue, 26 Oct 2010 20:20:58 +0200
Subject: [PATCH 3/4] Allow user to specify ssh port and username when deploying a node.

---
 libcloud/base.py |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/libcloud/base.py b/libcloud/base.py
index f3235c4..57fb4c7 100644
--- a/libcloud/base.py
+++ b/libcloud/base.py
@@ -631,13 +631,20 @@ class NodeDriver(object):
         or returning a generated password.

         This function may raise a L{DeplyomentException}, if a create_node
-        call was successful, but there is a later error (like SSH failing or
+        call was successful, but there is a later error (like SSH failing or
         timing out).  This exception includes a Node object which you may want
         to destroy if incomplete deployments are not desirable.

         @keyword    deploy: Deployment to run once machine is online and availble to SSH.
         @type       deploy: L{Deployment}

+        @keyword    ssh_username: Optional name of the account which is used when connecting to
+                                  SSH server (default is root)
+        @type       ssh_username: C{str}
+
+        @keyword    ssh_port: Optional SSH server port (default is 22)
+        @type       ssh_port: C{int}
+
         See L{NodeDriver.create_node} for more keyword args.
         """
         # TODO: support ssh keys
@@ -675,9 +682,12 @@ class NodeDriver(object):
               if node.public_ip is not None and node.public_ip != "" and node.state == NodeState.RUNNING:
                   break

+          ssh_username = kwargs.get('ssh_username', 'root')
+          ssh_port = kwargs.get('ssh_port', 22)
+
           client = SSHClient(hostname=node.public_ip[0],
-                              port=22, username='root',
-                              password=password)
+                             port=ssh_port, username=ssh_username,
+                             password=password)
           laste = None
           while time.time() < end:
               laste = None
