summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-07-27 08:21:01 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-07-27 08:21:01 -0600
commit8f164f7b703c10bcb48b09ba15a2e0e37104becc (patch)
tree0b802a3a3b8470994290b0a9f64eb59d1e7c8420
parentcae0d0b8df79a5bbbe04cc000abe7e0945c74089 (diff)
Changes to enable overriding the OSCreds for tests.
JIRA: FUNCTEST-847 Change-Id: I36d1add82cdb13a2c8252495fd6df8e05dab837b Signed-off-by: spisarski <s.pisarski@cablelabs.com>
-rw-r--r--snaps/openstack/os_credentials.py6
-rw-r--r--snaps/openstack/tests/openstack_tests.py7
2 files changed, 11 insertions, 2 deletions
diff --git a/snaps/openstack/os_credentials.py b/snaps/openstack/os_credentials.py
index 0cecfa5..c93133a 100644
--- a/snaps/openstack/os_credentials.py
+++ b/snaps/openstack/os_credentials.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from neutronclient.common.utils import str2bool
-
+import numbers
from snaps import file_utils
from snaps.openstack.utils import glance_utils, keystone_utils
@@ -165,9 +165,13 @@ class ProxySettings:
"""
self.host = kwargs.get('host')
self.port = kwargs.get('port')
+ if self.port and isinstance(self.port, numbers.Number):
+ self.port = str(self.port)
self.https_host = kwargs.get('https_host', self.host)
self.https_port = kwargs.get('https_port', self.port)
+ if self.https_port and isinstance(self.https_port, numbers.Number):
+ self.https_port = str(self.https_port)
self.ssh_proxy_cmd = kwargs.get('ssh_proxy_cmd')
diff --git a/snaps/openstack/tests/openstack_tests.py b/snaps/openstack/tests/openstack_tests.py
index 67269c6..927b5b3 100644
--- a/snaps/openstack/tests/openstack_tests.py
+++ b/snaps/openstack/tests/openstack_tests.py
@@ -48,7 +48,7 @@ DEFAULT_IMAGE_FORMAT = 'qcow2'
def get_credentials(os_env_file=None, proxy_settings_str=None,
- ssh_proxy_cmd=None, dev_os_env_file=None):
+ ssh_proxy_cmd=None, dev_os_env_file=None, overrides=None):
"""
Returns the OpenStack credentials object. It first attempts to retrieve
them from a standard OpenStack source file. If that file is None, it will
@@ -58,6 +58,8 @@ def get_credentials(os_env_file=None, proxy_settings_str=None,
:param ssh_proxy_cmd: the SSH proxy command for your environment (optional)
:param dev_os_env_file: the YAML file to retrieve both the OS credentials
and proxy settings
+ :param overrides: dict() containing values to override the credentials
+ found and passed in.
:return: the SNAPS credentials object
"""
if os_env_file:
@@ -130,6 +132,9 @@ def get_credentials(os_env_file=None, proxy_settings_str=None,
'cacert': config.get('cacert'),
'region_name': config.get('region_name')}
+ if overrides and isinstance(overrides, dict):
+ creds_dict.update(overrides)
+
os_creds = OSCreds(**creds_dict)
logger.info('OS Credentials = %s', os_creds)
return os_creds