add insecure openstack connection support
diff --git a/scripts/prepare.sh b/scripts/prepare.sh
index 1f47f20..5bdd91a 100644
--- a/scripts/prepare.sh
+++ b/scripts/prepare.sh
@@ -89,6 +89,9 @@
}
function prepare() {
+ if [ "$OS_INSECURE" -eq "1" ] ; then
+ fi
+
lookup_for_objects
if [ -z "$img_id" ] ; then
diff --git a/wally/discover/discover.py b/wally/discover/discover.py
index 957ecbe..b1feb80 100644
--- a/wally/discover/discover.py
+++ b/wally/discover/discover.py
@@ -75,7 +75,8 @@
'name': openrc_dict['username'],
'passwd': openrc_dict['password'],
'tenant': openrc_dict['tenant_name'],
- 'auth_url': openrc_dict['os_auth_url']}
+ 'auth_url': openrc_dict['os_auth_url'],
+ 'insecure': openrc_dict.get('insecure', False)}
env_name = clusters_info['fuel']['openstack_env']
env_f_name = env_name
diff --git a/wally/run_test.py b/wally/run_test.py
index 43e4e43..487fd49 100755
--- a/wally/run_test.py
+++ b/wally/run_test.py
@@ -307,9 +307,9 @@
if not start_vms.is_connected():
os_creds = get_OS_credentials(cfg, ctx)
else:
- os_creds = {}
+ os_creds = None
- conn = start_vms.nova_connect(**os_creds)
+ conn = start_vms.nova_connect(os_creds)
for ip, vm_id in start_vms.find_vms(conn, vm_name_pattern):
conn_url = "ssh://{user}@{ip}::{key}".format(user=user_name,
ip=ip,
@@ -321,39 +321,39 @@
def get_OS_credentials(cfg, ctx):
creds = None
- tenant = None
+ os_creds = None
if 'openstack' in cfg.clouds:
os_cfg = cfg.clouds['openstack']
if 'OPENRC' in os_cfg:
logger.info("Using OS credentials from " + os_cfg['OPENRC'])
- user, passwd, tenant, auth_url = utils.get_creds_openrc(os_cfg['OPENRC'])
+ creds_tuple = utils.get_creds_openrc(os_cfg['OPENRC'])
+ os_creds = start_vms.OSCreds(*creds_tuple)
elif 'ENV' in os_cfg:
logger.info("Using OS credentials from shell environment")
- user, passwd, tenant, auth_url = start_vms.ostack_get_creds()
+ os_creds = start_vms.ostack_get_creds()
elif 'OS_TENANT_NAME' in os_cfg:
logger.info("Using predefined credentials")
- tenant = os_cfg['OS_TENANT_NAME'].strip()
- user = os_cfg['OS_USERNAME'].strip()
- passwd = os_cfg['OS_PASSWORD'].strip()
- auth_url = os_cfg['OS_AUTH_URL'].strip()
+ os_creds = start_vms.OSCreds(os_cfg['OS_USERNAME'].strip(),
+ os_cfg['OS_PASSWORD'].strip(),
+ os_cfg['OS_TENANT_NAME'].strip(),
+ os_cfg['OS_AUTH_URL'].strip(),
+ os_cfg.get('OS_INSECURE', False))
- if tenant is None and 'fuel' in cfg.clouds and \
+ if os_creds is None and 'fuel' in cfg.clouds and \
'openstack_env' in cfg.clouds['fuel'] and \
ctx.fuel_openstack_creds is not None:
logger.info("Using fuel creds")
- creds = ctx.fuel_openstack_creds
- elif tenant is None:
+ creds = start_vms.OSCreds(**ctx.fuel_openstack_creds)
+ elif os_creds is None:
logger.error("Can't found OS credentials")
raise utils.StopTestError("Can't found OS credentials", None)
if creds is None:
- creds = {'name': user,
- 'passwd': passwd,
- 'tenant': tenant,
- 'auth_url': auth_url}
+ creds = os_creds
- logger.debug("OS_CREDS: user={name} tenant={tenant} auth_url={auth_url}".format(**creds))
+ logger.debug(("OS_CREDS: user={0.name} tenant={0.tenant}" +
+ "auth_url={0.auth_url} insecure={0.insecure}").format(creds))
return creds
@@ -389,9 +389,9 @@
if not start_vms.is_connected():
os_creds = get_OS_credentials(cfg, ctx)
else:
- os_creds = {}
+ os_creds = None
- nova = start_vms.nova_connect(**os_creds)
+ nova = start_vms.nova_connect(os_creds)
params.update(config)
params.update(get_vm_keypair(cfg))
@@ -401,7 +401,7 @@
if not config.get('skip_preparation', False):
logger.info("Preparing openstack")
- start_vms.prepare_os_subpr(nova, params=params, **os_creds)
+ start_vms.prepare_os_subpr(nova, params, os_creds)
new_nodes = []
old_nodes = ctx.nodes[:]
diff --git a/wally/start_vms.py b/wally/start_vms.py
index 1457da6..432594a 100644
--- a/wally/start_vms.py
+++ b/wally/start_vms.py
@@ -5,6 +5,7 @@
import os.path
import logging
import subprocess
+import collections
from concurrent.futures import ThreadPoolExecutor
@@ -28,50 +29,61 @@
return NOVA_CONNECTION is not None
+OSCreds = collections.namedtuple("OSCreds",
+ ["name", "passwd",
+ "tenant", "auth_url", "insecure"])
+
+
def ostack_get_creds():
if STORED_OPENSTACK_CREDS is None:
- env = os.environ.get
- name = env('OS_USERNAME')
- passwd = env('OS_PASSWORD')
- tenant = env('OS_TENANT_NAME')
- auth_url = env('OS_AUTH_URL')
- return name, passwd, tenant, auth_url
+ return OSCreds(os.environ.get('OS_USERNAME'),
+ os.environ.get('OS_PASSWORD'),
+ os.environ.get('OS_TENANT_NAME'),
+ os.environ.get('OS_AUTH_URL'),
+ os.environ.get('OS_INSECURE', False))
else:
return STORED_OPENSTACK_CREDS
-def nova_connect(name=None, passwd=None, tenant=None, auth_url=None):
+def nova_connect(os_creds=None):
global NOVA_CONNECTION
global STORED_OPENSTACK_CREDS
if NOVA_CONNECTION is None:
- if name is None:
- name, passwd, tenant, auth_url = ostack_get_creds()
+ if os_creds is None:
+ os_creds = ostack_get_creds()
else:
- STORED_OPENSTACK_CREDS = (name, passwd, tenant, auth_url)
+ STORED_OPENSTACK_CREDS = os_creds
- NOVA_CONNECTION = n_client('1.1', name, passwd, tenant, auth_url)
+ NOVA_CONNECTION = n_client('1.1',
+ os_creds.name,
+ os_creds.passwd,
+ os_creds.tenant,
+ os_creds.auth_url,
+ insecure=os_creds.insecure)
return NOVA_CONNECTION
-def cinder_connect(name=None, passwd=None, tenant=None, auth_url=None):
+def cinder_connect(os_creds=None):
global CINDER_CONNECTION
global STORED_OPENSTACK_CREDS
if CINDER_CONNECTION is None:
- if name is None:
- name, passwd, tenant, auth_url = ostack_get_creds()
+ if os_creds is None:
+ os_creds = ostack_get_creds()
else:
- STORED_OPENSTACK_CREDS = (name, passwd, tenant, auth_url)
- CINDER_CONNECTION = c_client(name, passwd, tenant, auth_url)
+ STORED_OPENSTACK_CREDS = os_creds
+ CINDER_CONNECTION = c_client(os_creds.name,
+ os_creds.passwd,
+ os_creds.tenant,
+ os_creds.auth_url,
+ insecure=os_creds.insecure)
return CINDER_CONNECTION
-def prepare_os_subpr(nova, params, name=None,
- passwd=None, tenant=None,
- auth_url=None):
- if name is None:
- name, passwd, tenant, auth_url = ostack_get_creds()
+def prepare_os_subpr(nova, params, os_creds):
+ if os_creds is None:
+ os_creds = ostack_get_creds()
MAX_VM_PER_NODE = 8
serv_groups = " ".join(map(params['aa_group_name'].format,
@@ -81,10 +93,11 @@
env = os.environ.copy()
env.update(dict(
- OS_USERNAME=name,
- OS_PASSWORD=passwd,
- OS_TENANT_NAME=tenant,
- OS_AUTH_URL=auth_url,
+ OS_USERNAME=os_creds.name,
+ OS_PASSWORD=os_creds.passwd,
+ OS_TENANT_NAME=os_creds.tenant,
+ OS_AUTH_URL=os_creds.auth_url,
+ OS_INSECURE="1" if os_creds.insecure else "0",
FLAVOR_NAME=params['flavor']['name'],
FLAVOR_RAM=str(params['flavor']['ram_size']),
diff --git a/wally/utils.py b/wally/utils.py
index 64ddd84..2011a98 100644
--- a/wally/utils.py
+++ b/wally/utils.py
@@ -302,7 +302,7 @@
def get_creds_openrc(path):
fc = open(path).read()
- echo = 'echo "$OS_TENANT_NAME:$OS_USERNAME:$OS_PASSWORD@$OS_AUTH_URL"'
+ echo = 'echo "$OS_INSECURE:$OS_TENANT_NAME:$OS_USERNAME:$OS_PASSWORD@$OS_AUTH_URL"'
msg = "Failed to get creads from openrc file"
with log_error(msg):
@@ -311,12 +311,13 @@
msg = "Failed to get creads from openrc file: " + data
with log_error(msg):
data = data.strip()
- user, tenant, passwd_auth_url = data.split(':', 2)
+ insecure_str, user, tenant, passwd_auth_url = data.split(':', 3)
+ insecure = (insecure_str in ('1', 'True', 'true'))
passwd, auth_url = passwd_auth_url.rsplit("@", 1)
assert (auth_url.startswith("https://") or
auth_url.startswith("http://"))
- return user, passwd, tenant, auth_url
+ return user, passwd, tenant, auth_url, insecure
os_release = collections.namedtuple("Distro", ["distro", "release", "arch"])