[Freeipa-devel] [patch]pytest-multihost: Add external_ip parameter to specify external_ip when using openstack

Niranjan mrniranjan at fedoraproject.org
Thu Nov 17 13:39:52 UTC 2016


Greetings,

When using pytest multihost to connect with hosts provisioned in
openstack, it's required to have ability for the test to use floating ip[external
ip]. This patch adds another attribute external_ip parameter under hosts .


Regards
Niranjan
-------------- next part --------------
From d9285c75a2ff9545bdac13018156b40d06432cbd Mon Sep 17 00:00:00 2001
From: Niranjan MR <mrniranjan at fedoraproject.org>
Date: Thu, 13 Oct 2016 20:38:12 +0530
Subject: [PATCH 1/2] Add external_ip parameter

Used in cases where openstack is used and
where there are 2 sets of ip's: internal
and external ip(floating).

Signed-off-by: Niranjan MR <mrniranjan at fedoraproject.org>
---
 pytest_multihost/host.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pytest_multihost/host.py b/pytest_multihost/host.py
index 826372d8a6a6ff80a4f07660298568be6e74435d..32f632b81eaa511fa7011d5aa99ae3170f745bf1 100644
--- a/pytest_multihost/host.py
+++ b/pytest_multihost/host.py
@@ -28,7 +28,8 @@ class BaseHost(object):
     command_prelude = ''
 
     def __init__(self, domain, hostname, role, ip=None,
-                 external_hostname=None, username=None, password=None,
+                 external_hostname=None, external_ip=None, 
+                 username=None, password=None,
                  test_dir=None, host_type=None):
         self.host_type = host_type
         self.domain = domain
@@ -58,6 +59,7 @@ class BaseHost(object):
         self.external_hostname = str(external_hostname or hostname)
 
         self.netbios = self.domain.name.split('.')[0].upper()
+        self.external_ip = str(external_ip)
 
         self.logger_name = '%s.%s.%s' % (
             self.__module__, type(self).__name__, shortname)
@@ -81,7 +83,6 @@ class BaseHost(object):
             if not self.ip:
                 raise RuntimeError('Could not determine IP address of %s' %
                                    self.external_hostname)
-
         self.host_key = None
         self.ssh_port = 22
 
@@ -126,12 +127,14 @@ class BaseHost(object):
         username = dct.pop('username', None)
         password = dct.pop('password', None)
         host_type = dct.pop('host_type', 'default')
+        external_ip = dct.pop('external_ip', None)
 
         check_config_dict_empty(dct, 'host %s' % hostname)
 
         return cls(domain, hostname, role,
                    ip=ip,
                    external_hostname=external_hostname,
+                   external_ip=external_ip,
                    username=username,
                    password=password,
                    host_type=host_type)
-- 
1.8.3.1

-------------- next part --------------
From 96cf1cd68ab7ba8ce30a64fbc0725624e1014b00 Mon Sep 17 00:00:00 2001
From: Niranjan MR <mrniranjan at fedoraproject.org>
Date: Mon, 17 Oct 2016 09:21:30 +0530
Subject: [PATCH 2/2] Add external_ip parameter for tests

Signed-off-by: Niranjan MR <mrniranjan at fedoraproject.org>
---
 test_pytestmultihost/test_localhost.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test_pytestmultihost/test_localhost.py b/test_pytestmultihost/test_localhost.py
index c51a2eaa66d15fcd631f2c15a4347ff39094396e..7658da09a386db92c6be4771f54b403189cf223a 100644
--- a/test_pytestmultihost/test_localhost.py
+++ b/test_pytestmultihost/test_localhost.py
@@ -30,6 +30,7 @@ def get_conf_dict():
                         'external_hostname': 'localhost',
                         'ip': '127.0.0.1',
                         'role': 'local',
+                        'external_ip': '127.0.0.1'
                     },
                     {
                         'name': 'localhost',
@@ -37,6 +38,7 @@ def get_conf_dict():
                         'ip': '127.0.0.1',
                         'username': '__nonexisting_test_username__',
                         'role': 'badusername',
+                        'external_ip': '127.0.0.1'
                     },
                     {
                         'name': 'localhost',
@@ -45,6 +47,7 @@ def get_conf_dict():
                         'username': 'root',
                         'password': 'BAD PASSWORD',
                         'role': 'badpassword',
+                        'external_ip': '127.0.0.1'
                     },
                 ],
             },
-- 
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 328 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20161117/339e2088/attachment.sig>


More information about the Freeipa-devel mailing list