import requests
import json
import shutil
+import re
from git import Repo
def create_neutron_subnet(neutron_client, name, cidr, net_id):
json_body = {'subnets': [{'name': name, 'cidr': cidr,
- 'ip_version': 4, 'network_id': net_id}]}
+ 'ip_version': 4, 'network_id': net_id}]}
try:
subnet = neutron_client.create_subnet(body=json_body)
return subnet['subnets'][0]['id']
def create_glance_image(glance_client, image_name, file_path, public=True):
if not os.path.isfile(file_path):
- print "Error: file "+file_path+" does not exist."
+ print "Error: file " + file_path + " does not exist."
return False
try:
with open(file_path) as fimage:
except:
return None
+
def delete_volume(cinder_client, volume_id, forced=False):
try:
if forced:
# ################ CINDER #################
def get_security_groups(neutron_client):
try:
- security_groups = neutron_client.list_security_groups()['security_groups']
+ security_groups = neutron_client.list_security_groups()[
+ 'security_groups']
return security_groups
except:
return None
return os.environ['NODE_NAME']
except KeyError:
if logger:
- logger.error("Unable to retrieve the POD name from environment.Using pod name 'unknown-pod'")
+ logger.error(
+ "Unable to retrieve the POD name from environment.Using pod name 'unknown-pod'")
return "unknown-pod"
return ci_env_var
+def get_resolvconf_ns():
+ nameservers = []
+ rconf = open("/etc/resolv.conf", "r")
+ line = rconf.readline()
+ while line:
+ ip = re.search(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b", line)
+ if ip:
+ nameservers.append(ip.group())
+ line = rconf.readline()
+ return nameservers
+
+
def isTestRunnable(test, functest_yaml):
# check getTestEnv(test) and CI env var
# check installer, controller and options
def set_ssh_user(self, ssh_user):
self.config['ssh_user'] = ssh_user
+ def set_nameservers(self, nameservers):
+ if 0 < len(nameservers):
+ self.config['dns_subnet_1'] = nameservers[0]
+ if 1 < len(nameservers):
+ self.config['dns_subnet_2'] = nameservers[1]
+
def set_logger(self, logger):
self.logger = logger
if self.logger:
self.logger.info("Launching the cloudify-manager deployment")
- script = "set -e; "
+ script = "set -e; "
script += "source " + self.testcase_dir + "venv_cloudify/bin/activate; "
script += "cd " + self.testcase_dir + "; "
script += "cfy init -r; "
logger.info("vIMS functional test Start Time:'%s'" % (
datetime.datetime.fromtimestamp(start_time_ts).strftime(
'%Y-%m-%d %H:%M:%S')))
+ nameservers = functest_utils.get_resolvconf_ns()
+ resolvconf = ""
+ for ns in nameservers:
+ resolvconf += "\nnameserver " + ns
if dns_ip != "":
- script = 'echo -e "nameserver ' + dns_ip + \
- '\nnameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf; '
+ script = 'echo -e "nameserver ' + dns_ip + resolvconf + '" > /etc/resolv.conf; '
script += 'source /etc/profile.d/rvm.sh; '
script += 'cd ' + VIMS_TEST_DIR + '; '
script += 'rake test[' + \
cfy.set_external_network_name(ext_net)
+ ns = functest_utils.get_resolvconf_ns()
+ if ns:
+ cfy.set_nameservers(ns)
+
logger.info("Prepare virtualenv for cloudify-cli")
cmd = "chmod +x " + VIMS_DIR + "create_venv.sh"
functest_utils.execute_command(cmd, logger)