summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/lab-reconfiguration/reconfigUcsNet.py146
-rw-r--r--utils/opnfv-artifacts.py79
-rw-r--r--utils/push-test-logs.sh2
-rw-r--r--utils/test/dashboard/dashboard/common/elastic_access.py2
-rw-r--r--utils/test/dashboard/dashboard/conf/testcases.py2
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana/utility.py3
-rw-r--r--utils/test/dashboard/dashboard/functest/format.py22
-rw-r--r--utils/test/dashboard/dashboard/mongo2elastic/main.py22
-rw-r--r--utils/test/dashboard/kibana_cleanup.py17
-rwxr-xr-xutils/test/reporting/functest/reporting-tempest.py8
-rwxr-xr-xutils/test/reporting/functest/reporting-vims.py4
-rw-r--r--utils/test/reporting/functest/testCase.py33
-rw-r--r--utils/test/reporting/utils/reporting_utils.py28
-rw-r--r--utils/test/testapi/htmlize/htmlize.py6
-rw-r--r--utils/test/testapi/update/templates/utils.py2
15 files changed, 209 insertions, 167 deletions
diff --git a/utils/lab-reconfiguration/reconfigUcsNet.py b/utils/lab-reconfiguration/reconfigUcsNet.py
index 4c08f3dc9..0dd902f6d 100755
--- a/utils/lab-reconfiguration/reconfigUcsNet.py
+++ b/utils/lab-reconfiguration/reconfigUcsNet.py
@@ -22,8 +22,10 @@
# -p PASSWORD, --password=PASSWORD
# [Mandatory] Account Password for UCSM Login
# -f FILE, --file=FILE
-# [Optional] Yaml file with network config you want to set for POD
-# If not present only current network config will be printed
+# [Optional] Yaml file with network config you
+# want to set for POD
+# If not present only current network config
+# will be printed
#
import getpass
@@ -32,12 +34,14 @@ import platform
import yaml
import time
import sys
-from UcsSdk import *
-from collections import defaultdict
+from UcsSdk import LsmaintAck, LsPower, LsServer, OrgOrg
+from UcsSdk import UcsHandle, VnicEther, VnicEtherIf, YesOrNo
+
POD_PREFIX = "POD-2"
INSTALLER = "POD-21"
+
def getpassword(prompt):
if platform.system() == "Linux":
return getpass.unix_getpass(prompt=prompt)
@@ -51,7 +55,8 @@ def get_servers(handle=None):
"""
Return list of servers
"""
- orgObj = handle.GetManagedObject(None, OrgOrg.ClassId(), {OrgOrg.DN : "org-root"})[0]
+ orgObj = handle.GetManagedObject(
+ None, OrgOrg.ClassId(), {OrgOrg.DN: "org-root"})[0]
servers = handle.GetManagedObject(orgObj, LsServer.ClassId())
for server in servers:
if server.Type == 'instance' and POD_PREFIX in server.Dn:
@@ -63,10 +68,10 @@ def set_boot_policy(handle=None, server=None, policy=None):
Modify Boot policy of server
"""
obj = handle.GetManagedObject(None, LsServer.ClassId(), {
- LsServer.DN: server.Dn})
+ LsServer.DN: server.Dn})
handle.SetManagedObject(obj, LsServer.ClassId(), {
- LsServer.BOOT_POLICY_NAME: policy} )
- print " Configured boot policy: {}".format(policy)
+ LsServer.BOOT_POLICY_NAME: policy})
+ print(" Configured boot policy: {}".format(policy))
def ack_pending(handle=None, server=None):
@@ -74,30 +79,32 @@ def ack_pending(handle=None, server=None):
Acknowledge pending state of server
"""
handle.AddManagedObject(server, LsmaintAck.ClassId(), {
- LsmaintAck.DN: server.Dn + "/ack",
- LsmaintAck.DESCR:"",
- LsmaintAck.ADMIN_STATE:"trigger-immediate",
- LsmaintAck.SCHEDULER:"",
- LsmaintAck.POLICY_OWNER:"local"}, True)
- print " Pending-reboot -> Acknowledged."
+ LsmaintAck.DN: server.Dn + "/ack",
+ LsmaintAck.DESCR: "",
+ LsmaintAck.ADMIN_STATE: "trigger-immediate",
+ LsmaintAck.SCHEDULER: "",
+ LsmaintAck.POLICY_OWNER: "local"}, True)
+ print(" Pending-reboot -> Acknowledged.")
def boot_server(handle=None, server=None):
"""
Boot server (when is in power-off state)
"""
- obj = handle.GetManagedObject(None, LsServer.ClassId(), {LsServer.DN: server.Dn})
+ obj = handle.GetManagedObject(
+ None, LsServer.ClassId(), {LsServer.DN: server.Dn})
handle.AddManagedObject(obj, LsPower.ClassId(), {
- LsPower.DN: server.Dn + "/power",
- LsPower.STATE:"admin-up"}, True)
- print " Booting."
+ LsPower.DN: server.Dn + "/power",
+ LsPower.STATE: "admin-up"}, True)
+ print(" Booting.")
def get_vnics(handle=None, server=None):
"""
Return list of vnics for given server
"""
- vnics = handle.ConfigResolveChildren(VnicEther.ClassId(), server.Dn, None, YesOrNo.TRUE)
+ vnics = handle.ConfigResolveChildren(
+ VnicEther.ClassId(), server.Dn, None, YesOrNo.TRUE)
return vnics.OutConfigs.GetChild()
@@ -105,28 +112,36 @@ def get_network_config(handle=None):
"""
Print current network config
"""
- print "\nCURRENT NETWORK CONFIG:"
- print " d - default, t - tagged"
+ print("\nCURRENT NETWORK CONFIG:")
+ print(" d - default, t - tagged")
for server in get_servers(handle):
- print ' {}'.format(server.Name)
- print ' Boot policy: {}'.format(server.OperBootPolicyName)
+ print(' {}'.format(server.Name))
+ print(' Boot policy: {}'.format(server.OperBootPolicyName))
for vnic in get_vnics(handle, server):
- print ' {}'.format(vnic.Name)
- print ' {}'.format(vnic.Addr)
- vnicIfs = handle.ConfigResolveChildren(VnicEtherIf.ClassId(), vnic.Dn, None, YesOrNo.TRUE)
+ print(' {}'.format(vnic.Name))
+ print(' {}'.format(vnic.Addr))
+ vnicIfs = handle.ConfigResolveChildren(
+ VnicEtherIf.ClassId(), vnic.Dn, None, YesOrNo.TRUE)
for vnicIf in vnicIfs.OutConfigs.GetChild():
if vnicIf.DefaultNet == 'yes':
- print ' Vlan: {}d'.format(vnicIf.Vnet)
+ print(' Vlan: {}d'.format(vnicIf.Vnet))
else:
- print ' Vlan: {}t'.format(vnicIf.Vnet)
+ print(' Vlan: {}t'.format(vnicIf.Vnet))
-def add_interface(handle=None, lsServerDn=None, vnicEther=None, templName=None, order=None, macAddr=None):
+def add_interface(handle=None,
+ lsServerDn=None,
+ vnicEther=None,
+ templName=None,
+ order=None,
+ macAddr=None):
"""
Add interface to server specified by server.DN name
"""
- print " Adding interface: {}, template: {}, server.Dn: {}".format(vnicEther, templName, lsServerDn)
- obj = handle.GetManagedObject(None, LsServer.ClassId(), {LsServer.DN:lsServerDn})
+ print(" Adding interface: {}, template: {}, server.Dn: {}".format(
+ vnicEther, templName, lsServerDn))
+ obj = handle.GetManagedObject(
+ None, LsServer.ClassId(), {LsServer.DN: lsServerDn})
vnicEtherDn = lsServerDn + "/ether-" + vnicEther
params = {
VnicEther.STATS_POLICY_NAME: "default",
@@ -146,8 +161,9 @@ def remove_interface(handle=None, vnicEtherDn=None):
"""
Remove interface specified by Distinguished Name (vnicEtherDn)
"""
- print " Removing interface: {}".format(vnicEtherDn)
- obj = handle.GetManagedObject(None, VnicEther.ClassId(), {VnicEther.DN:vnicEtherDn})
+ print(" Removing interface: {}".format(vnicEtherDn))
+ obj = handle.GetManagedObject(
+ None, VnicEther.ClassId(), {VnicEther.DN: vnicEtherDn})
handle.RemoveManagedObject(obj)
@@ -165,32 +181,37 @@ def set_network(handle=None, yamlFile=None):
Configure VLANs on POD according specified network
"""
# add interfaces and bind them with vNIC templates
- print "\nRECONFIGURING VNICs..."
+ print("\nRECONFIGURING VNICs...")
pod_data = read_yaml_file(yamlFile)
network = pod_data['network']
for index, server in enumerate(get_servers(handle)):
# Assign template to interface
for iface, data in network.iteritems():
- add_interface(handle, server.Dn, iface, data['template'], data['order'], data['mac-list'][index])
+ add_interface(handle, server.Dn, iface, data['template'], data[
+ 'order'], data['mac-list'][index])
- # Remove other interfaces which have not assigned required vnic template
+ # Remove other interfaces which have not assigned required vnic
+ # template
vnics = get_vnics(handle, server)
for vnic in vnics:
- if not any(data['template'] in vnic.OperNwTemplName for iface, data in network.iteritems()):
+ if not any(data['template'] in vnic.OperNwTemplName for
+ iface, data in network.iteritems()):
remove_interface(handle, vnic.Dn)
- print " {} removed, template: {}".format(vnic.Name, vnic.OperNwTemplName)
+ print(" {} removed, template: {}".format(
+ vnic.Name, vnic.OperNwTemplName))
# Set boot policy template
- if not INSTALLER in server.Dn:
+ if INSTALLER not in server.Dn:
set_boot_policy(handle, server, pod_data['boot-policy'])
if __name__ == "__main__":
- print "\n*** SKIPING RECONFIGURATION.***\n"
+ print("\n*** SKIPING RECONFIGURATION.***\n")
sys.exit(0)
# Latest urllib2 validate certs by default
- # The process wide "revert to the old behaviour" hook is to monkeypatch the ssl module
+ # The process wide "revert to the old behaviour" hook is to monkeypatch
+ # the ssl module
# https://bugs.python.org/issue22417
import ssl
if hasattr(ssl, '_create_unverified_context'):
@@ -198,14 +219,15 @@ if __name__ == "__main__":
try:
handle = UcsHandle()
parser = optparse.OptionParser()
- parser.add_option('-i', '--ip',dest="ip",
- help="[Mandatory] UCSM IP Address")
- parser.add_option('-u', '--username',dest="userName",
- help="[Mandatory] Account Username for UCSM Login")
- parser.add_option('-p', '--password',dest="password",
- help="[Mandatory] Account Password for UCSM Login")
- parser.add_option('-f', '--file',dest="yamlFile",
- help="[Optional] Yaml file contains network config you want to set on UCS POD1")
+ parser.add_option('-i', '--ip', dest="ip",
+ help="[Mandatory] UCSM IP Address")
+ parser.add_option('-u', '--username', dest="userName",
+ help="[Mandatory] Account Username for UCSM Login")
+ parser.add_option('-p', '--password', dest="password",
+ help="[Mandatory] Account Password for UCSM Login")
+ parser.add_option('-f', '--file', dest="yamlFile",
+ help=("[Optional] Yaml file contains network "
+ "config you want to set on UCS POD1"))
(options, args) = parser.parse_args()
if not options.ip:
@@ -215,26 +237,27 @@ if __name__ == "__main__":
parser.print_help()
parser.error("Provide UCSM UserName")
if not options.password:
- options.password=getpassword("UCSM Password:")
+ options.password = getpassword("UCSM Password:")
handle.Login(options.ip, options.userName, options.password)
# Change vnic template if specified in cli option
- if (options.yamlFile != None):
+ if (options.yamlFile is not None):
set_network(handle, options.yamlFile)
time.sleep(5)
- print "\nWait until Overall Status of all nodes is OK..."
- timeout = time.time() + 60*10 #10 minutes timeout
+ print("\nWait until Overall Status of all nodes is OK...")
+ timeout = time.time() + 60 * 10 # 10 minutes timeout
while True:
list_of_states = []
for server in get_servers(handle):
if server.OperState == "power-off":
- boot_server(handle,server)
+ boot_server(handle, server)
if server.OperState == "pending-reboot":
- ack_pending(handle,server)
+ ack_pending(handle, server)
list_of_states.append(server.OperState)
- print " {}, {} seconds remains.".format(list_of_states, round(timeout-time.time()))
+ print(" {}, {} seconds remains.".format(
+ list_of_states, round(timeout - time.time())))
if all(state == "ok" for state in list_of_states):
break
if time.time() > timeout:
@@ -246,11 +269,12 @@ if __name__ == "__main__":
handle.Logout()
- except Exception, err:
+ except Exception as err:
handle.Logout()
- print "Exception:", str(err)
- import traceback, sys
- print '-'*60
+ print("Exception:", str(err))
+ import traceback
+ import sys
+ print('-' * 60)
traceback.print_exc(file=sys.stdout)
- print '-'*60
+ print('-' * 60)
sys.exit(1)
diff --git a/utils/opnfv-artifacts.py b/utils/opnfv-artifacts.py
index 876efedba..2f2cc41ba 100644
--- a/utils/opnfv-artifacts.py
+++ b/utils/opnfv-artifacts.py
@@ -28,56 +28,55 @@ from apiclient.errors import HttpError
import argparse
import json
-import os
import sys
api = {
- 'projects': {},
- 'docs': {},
- 'releases': {},
+ 'projects': {},
+ 'docs': {},
+ 'releases': {},
}
releases = [
- 'arno.2015.1.0',
- 'arno.2015.2.0',
- 'brahmaputra.1.0',
+ 'arno.2015.1.0',
+ 'arno.2015.2.0',
+ 'brahmaputra.1.0',
]
# List of file extensions to filter out
ignore_extensions = [
- '.buildinfo',
- '.woff',
- '.ttf',
- '.svg',
- '.eot',
- '.pickle',
- '.doctree',
- '.js',
- '.png',
- '.css',
- '.gif',
- '.jpeg',
- '.jpg',
- '.bmp',
+ '.buildinfo',
+ '.woff',
+ '.ttf',
+ '.svg',
+ '.eot',
+ '.pickle',
+ '.doctree',
+ '.js',
+ '.png',
+ '.css',
+ '.gif',
+ '.jpeg',
+ '.jpg',
+ '.bmp',
]
parser = argparse.ArgumentParser(
- description='OPNFV Artifacts JSON Generator')
+ description='OPNFV Artifacts JSON Generator')
parser.add_argument(
- '-k',
- dest='key',
- default='',
- help='API Key for Google Cloud Storage')
+ '-k',
+ dest='key',
+ default='',
+ help='API Key for Google Cloud Storage')
parser.add_argument(
- '-p',
- default=None,
- dest='pretty',
- action='store_const',
- const=2,
- help='pretty print the output')
+ '-p',
+ default=None,
+ dest='pretty',
+ action='store_const',
+ const=2,
+ help='pretty print the output')
# Parse and assign arguments
args = parser.parse_args()
@@ -130,7 +129,6 @@ def has_logs(gerrit_review):
return False
-
def has_ignorable_extension(filename):
for extension in ignore_extensions:
if filename.lower().endswith(extension):
@@ -148,11 +146,11 @@ def get_results(key):
files = storage.objects().list(bucket='artifacts.opnfv.org',
fields='nextPageToken,'
'items('
- 'name,'
- 'mediaLink,'
- 'updated,'
- 'contentType,'
- 'size'
+ 'name,'
+ 'mediaLink,'
+ 'updated,'
+ 'contentType,'
+ 'size'
')')
while (files is not None):
sites = files.execute()
@@ -173,7 +171,8 @@ def get_results(key):
project = site_split[0]
name = '/'.join(site_split[1:])
- proxy = "http://build.opnfv.org/artifacts.opnfv.org/%s" % site['name']
+ proxy = "http://build.opnfv.org/artifacts.opnfv.org/%s" % site[
+ 'name']
if name.endswith('.html'):
href = "http://artifacts.opnfv.org/%s" % site['name']
href_type = 'view'
@@ -183,7 +182,7 @@ def get_results(key):
gerrit = has_gerrit_review(site_split)
logs = False # has_logs(gerrit)
- documentation = has_documentation(site_split)
+ # documentation = has_documentation(site_split)
release = has_release(site_split)
category = 'project'
diff --git a/utils/push-test-logs.sh b/utils/push-test-logs.sh
index 09861c45f..5e428d07b 100644
--- a/utils/push-test-logs.sh
+++ b/utils/push-test-logs.sh
@@ -28,7 +28,7 @@ node_list=(\
'ericsson-virtual4' 'ericsson-virtual5' \
'arm-pod1' 'arm-pod3' \
'huawei-pod1' 'huawei-pod2' 'huawei-pod3' 'huawei-pod4' 'huawei-pod5' \
-'huawei-pod6' 'huawei-pod7' 'huawei-pod12'\
+'huawei-pod6' 'huawei-pod7' 'huawei-pod12' \
'huawei-virtual1' 'huawei-virtual2' 'huawei-virtual3' 'huawei-virtual4')
diff --git a/utils/test/dashboard/dashboard/common/elastic_access.py b/utils/test/dashboard/dashboard/common/elastic_access.py
index aaf776f7a..eb29ce879 100644
--- a/utils/test/dashboard/dashboard/common/elastic_access.py
+++ b/utils/test/dashboard/dashboard/common/elastic_access.py
@@ -30,7 +30,7 @@ def publish_docs(url, creds=None, body=None):
def _get_docs_nr(url, creds=None, body=None):
res_data = _get('{}/_search?size=0'.format(url), creds=creds, body=body)
- print type(res_data), res_data
+ print(type(res_data), res_data)
return res_data['hits']['total']
diff --git a/utils/test/dashboard/dashboard/conf/testcases.py b/utils/test/dashboard/dashboard/conf/testcases.py
index ff801b4c9..98ce20984 100644
--- a/utils/test/dashboard/dashboard/conf/testcases.py
+++ b/utils/test/dashboard/dashboard/conf/testcases.py
@@ -21,4 +21,4 @@ def get_format(project, case):
if __name__ == '__main__':
fmt = get_format('functest', 'vping_ssh')
- print fmt
+ print(fmt)
diff --git a/utils/test/dashboard/dashboard/elastic2kibana/utility.py b/utils/test/dashboard/dashboard/elastic2kibana/utility.py
index 55578bd8c..40d9202a6 100644
--- a/utils/test/dashboard/dashboard/elastic2kibana/utility.py
+++ b/utils/test/dashboard/dashboard/elastic2kibana/utility.py
@@ -2,7 +2,8 @@ import json
from jinja2 import Environment, PackageLoader
-env = Environment(loader=PackageLoader('dashboard', 'elastic2kibana/templates'))
+env = Environment(loader=PackageLoader('dashboard',
+ 'elastic2kibana/templates'))
env.filters['jsonify'] = json.dumps
diff --git a/utils/test/dashboard/dashboard/functest/format.py b/utils/test/dashboard/dashboard/functest/format.py
index ef485bae0..75d361ff8 100644
--- a/utils/test/dashboard/dashboard/functest/format.py
+++ b/utils/test/dashboard/dashboard/functest/format.py
@@ -6,7 +6,8 @@ def _convert_value(value):
def _convert_duration(duration):
- if (isinstance(duration, str) or isinstance(duration, unicode)) and ':' in duration:
+ if ((isinstance(duration, str) or
+ isinstance(duration, unicode)) and ':' in duration):
hours, minutes, seconds = duration.split(":")
hours = _convert_value(hours)
minutes = _convert_value(minutes)
@@ -42,11 +43,11 @@ def format_normal(testcase):
testcase_tests = float(testcase_details['tests'])
testcase_failures = float(testcase_details['failures'])
if testcase_tests != 0:
- testcase_details['success_percentage'] = 100 * (testcase_tests - testcase_failures) / testcase_tests
+ testcase_details['success_percentage'] = 100 * \
+ (testcase_tests - testcase_failures) / testcase_tests
else:
testcase_details['success_percentage'] = 0
-
return found
@@ -115,28 +116,33 @@ def format_onos(testcase):
"""
testcase_details = testcase['details']
- if 'FUNCvirNet' not in testcase_details or 'FUNCvirNetL3' not in testcase_details:
+ if ('FUNCvirNet' not in testcase_details or
+ 'FUNCvirNetL3' not in testcase_details):
return False
funcvirnet_details = testcase_details['FUNCvirNet']['status']
- funcvirnet_stats = _get_statistics(funcvirnet_details, ('Case result',), ('PASS', 'FAIL'))
+ funcvirnet_stats = _get_statistics(
+ funcvirnet_details, ('Case result',), ('PASS', 'FAIL'))
funcvirnet_passed = funcvirnet_stats['PASS']
funcvirnet_failed = funcvirnet_stats['FAIL']
funcvirnet_all = funcvirnet_passed + funcvirnet_failed
funcvirnetl3_details = testcase_details['FUNCvirNetL3']['status']
- funcvirnetl3_stats = _get_statistics(funcvirnetl3_details, ('Case result',), ('PASS', 'FAIL'))
+ funcvirnetl3_stats = _get_statistics(
+ funcvirnetl3_details, ('Case result',), ('PASS', 'FAIL'))
funcvirnetl3_passed = funcvirnetl3_stats['PASS']
funcvirnetl3_failed = funcvirnetl3_stats['FAIL']
funcvirnetl3_all = funcvirnetl3_passed + funcvirnetl3_failed
testcase_details['FUNCvirNet'] = {
- 'duration': _convert_duration(testcase_details['FUNCvirNet']['duration']),
+ 'duration':
+ _convert_duration(testcase_details['FUNCvirNet']['duration']),
'tests': funcvirnet_all,
'failures': funcvirnet_failed
}
testcase_details['FUNCvirNetL3'] = {
- 'duration': _convert_duration(testcase_details['FUNCvirNetL3']['duration']),
+ 'duration':
+ _convert_duration(testcase_details['FUNCvirNetL3']['duration']),
'tests': funcvirnetl3_all,
'failures': funcvirnetl3_failed
}
diff --git a/utils/test/dashboard/dashboard/mongo2elastic/main.py b/utils/test/dashboard/dashboard/mongo2elastic/main.py
index 688f55f7d..e33252df2 100644
--- a/utils/test/dashboard/dashboard/mongo2elastic/main.py
+++ b/utils/test/dashboard/dashboard/mongo2elastic/main.py
@@ -27,7 +27,8 @@ parser.add_argument('-ld', '--latest-days',
metavar='N',
help='get entries old at most N days from mongodb and'
' parse those that are not already in elasticsearch.'
- ' If not present, will get everything from mongodb, which is the default')
+ ' If not present, will get everything from mongodb,'
+ ' which is the default')
args = parser.parse_args()
CONF = APIConfig().parse(args.config_file)
@@ -37,6 +38,7 @@ tmp_docs_file = './mongo-{}.json'.format(uuid.uuid4())
class DocumentVerification(object):
+
def __init__(self, doc):
super(DocumentVerification, self).__init__()
self.doc = doc
@@ -55,8 +57,8 @@ class DocumentVerification(object):
for key, value in self.doc.items():
if key in mandatory_fields:
if value is None:
- logger.info("Skip testcase '%s' because field '%s' missing" %
- (self.doc_id, key))
+ logger.info("Skip testcase '%s' because field "
+ "'%s' missing" % (self.doc_id, key))
self.skip = True
else:
mandatory_fields.remove(key)
@@ -131,10 +133,12 @@ class DocumentPublisher(object):
self._publish()
def _publish(self):
- status, data = elastic_access.publish_docs(self.elastic_url, self.creds, self.doc)
+ status, data = elastic_access.publish_docs(
+ self.elastic_url, self.creds, self.doc)
if status > 300:
logger.error('Publish record[{}] failed, due to [{}]'
- .format(self.doc, json.loads(data)['error']['reason']))
+ .format(self.doc,
+ json.loads(data)['error']['reason']))
def _fix_date(self, date_string):
if isinstance(date_string, dict):
@@ -163,7 +167,8 @@ class DocumentsPublisher(object):
def export(self):
if self.days > 0:
- past_time = datetime.datetime.today() - datetime.timedelta(days=self.days)
+ past_time = datetime.datetime.today(
+ ) - datetime.timedelta(days=self.days)
query = '''{{
"project_name": "{}",
"case_name": "{}",
@@ -182,7 +187,7 @@ class DocumentsPublisher(object):
try:
subprocess.check_call(cmd)
return self
- except Exception, err:
+ except Exception as err:
logger.error("export mongodb failed: %s" % err)
self._remove()
exit(-1)
@@ -217,7 +222,8 @@ class DocumentsPublisher(object):
}}'''.format(self.project, self.case, self.days)
else:
raise Exception('Update days must be non-negative')
- self.existed_docs = elastic_access.get_docs(self.elastic_url, self.creds, body)
+ self.existed_docs = elastic_access.get_docs(
+ self.elastic_url, self.creds, body)
return self
def publish(self):
diff --git a/utils/test/dashboard/kibana_cleanup.py b/utils/test/dashboard/kibana_cleanup.py
index ee0190049..7e3662c29 100644
--- a/utils/test/dashboard/kibana_cleanup.py
+++ b/utils/test/dashboard/kibana_cleanup.py
@@ -9,7 +9,8 @@ from dashboard.common import elastic_access
logger = logging.getLogger('clear_kibana')
logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler('/var/log/{}.log'.format('clear_kibana'))
-file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s'))
+file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: '
+ '%(message)s'))
logger.addHandler(file_handler)
@@ -21,12 +22,17 @@ def delete_all(url, es_creds):
if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Delete saved kibana searches, visualizations and dashboards')
- parser.add_argument('-e', '--elasticsearch-url', default='http://localhost:9200',
- help='the url of elasticsearch, defaults to http://localhost:9200')
+ parser = argparse.ArgumentParser(
+ description=('Delete saved kibana searches, '
+ 'visualizations and dashboards'))
+ parser.add_argument('-e', '--elasticsearch-url',
+ default='http://localhost:9200',
+ help=('the url of elasticsearch, '
+ 'defaults to http://localhost:9200'))
parser.add_argument('-u', '--elasticsearch-username', default=None,
- help='The username with password for elasticsearch in format username:password')
+ help=('The username with password for elasticsearch '
+ 'in format username:password'))
args = parser.parse_args()
base_elastic_url = args.elasticsearch_url
@@ -38,4 +44,3 @@ if __name__ == '__main__':
for url in urls:
delete_all(url, es_creds)
-
diff --git a/utils/test/reporting/functest/reporting-tempest.py b/utils/test/reporting/functest/reporting-tempest.py
index 5d6bcc062..6e6585a32 100755
--- a/utils/test/reporting/functest/reporting-tempest.py
+++ b/utils/test/reporting/functest/reporting-tempest.py
@@ -44,7 +44,7 @@ for version in rp_utils.get_config('general.versions'):
response = urlopen(request)
k = response.read()
results = json.loads(k)
- except URLError, e:
+ except URLError as e:
logger.error("Error code: %s" % e)
test_results = results['results']
@@ -73,9 +73,9 @@ for version in rp_utils.get_config('general.versions'):
nb_tests_run = result['details']['tests']
nb_tests_failed = result['details']['failures']
if nb_tests_run != 0:
- success_rate = 100*((int(nb_tests_run) -
- int(nb_tests_failed)) /
- int(nb_tests_run))
+ success_rate = 100 * ((int(nb_tests_run) -
+ int(nb_tests_failed)) /
+ int(nb_tests_run))
else:
success_rate = 0
diff --git a/utils/test/reporting/functest/reporting-vims.py b/utils/test/reporting/functest/reporting-vims.py
index 2077d2a4a..b236b8963 100755
--- a/utils/test/reporting/functest/reporting-vims.py
+++ b/utils/test/reporting/functest/reporting-vims.py
@@ -51,7 +51,7 @@ for version in versions:
response = urlopen(request)
k = response.read()
results = json.loads(k)
- except URLError, e:
+ except URLError as e:
logger.error("Error code: %s" % e)
test_results = results['results']
@@ -91,7 +91,7 @@ for version in versions:
result['pr_step_ok'] = 0
if nb_step != 0:
- result['pr_step_ok'] = (float(nb_step_ok)/nb_step)*100
+ result['pr_step_ok'] = (float(nb_step_ok) / nb_step) * 100
try:
logger.debug("Scenario %s, Installer %s"
% (s_result[1]['scenario'], installer))
diff --git a/utils/test/reporting/functest/testCase.py b/utils/test/reporting/functest/testCase.py
index 8d90fc861..df0874e0b 100644
--- a/utils/test/reporting/functest/testCase.py
+++ b/utils/test/reporting/functest/testCase.py
@@ -36,14 +36,14 @@ class TestCase(object):
'moon': 'Moon',
'copper': 'Copper',
'security_scan': 'Security',
- 'multisite':'Multisite',
- 'domino':'Domino',
- 'odl-sfc':'SFC',
- 'onos_sfc':'SFC',
- 'parser':'Parser',
- 'connection_check':'Health (connection)',
- 'api_check':'Health (api)',
- 'snaps_smoke':'SNAPS' }
+ 'multisite': 'Multisite',
+ 'domino': 'Domino',
+ 'odl-sfc': 'SFC',
+ 'onos_sfc': 'SFC',
+ 'parser': 'Parser',
+ 'connection_check': 'Health (connection)',
+ 'api_check': 'Health (api)',
+ 'snaps_smoke': 'SNAPS'}
try:
self.displayName = display_name_matrix[self.name]
except:
@@ -131,14 +131,14 @@ class TestCase(object):
'moon': 'moon_authentication',
'copper': 'copper-notification',
'security_scan': 'security',
- 'multisite':'multisite',
- 'domino':'domino-multinode',
- 'odl-sfc':'functest-odl-sfc',
- 'onos_sfc':'onos_sfc',
- 'parser':'parser-basics',
- 'connection_check':'connection_check',
- 'api_check':'api_check',
- 'snaps_smoke':'snaps_smoke'
+ 'multisite': 'multisite',
+ 'domino': 'domino-multinode',
+ 'odl-sfc': 'functest-odl-sfc',
+ 'onos_sfc': 'onos_sfc',
+ 'parser': 'parser-basics',
+ 'connection_check': 'connection_check',
+ 'api_check': 'api_check',
+ 'snaps_smoke': 'snaps_smoke'
}
try:
return test_match_matrix[self.name]
@@ -147,4 +147,3 @@ class TestCase(object):
def getDisplayName(self):
return self.displayName
-
diff --git a/utils/test/reporting/utils/reporting_utils.py b/utils/test/reporting/utils/reporting_utils.py
index da979531b..fc5d188af 100644
--- a/utils/test/reporting/utils/reporting_utils.py
+++ b/utils/test/reporting/utils/reporting_utils.py
@@ -93,8 +93,8 @@ def getApiResults(case, installer, scenario, version):
response = urlopen(request)
k = response.read()
results = json.loads(k)
- except URLError, e:
- print 'No kittez. Got an error code:', e
+ except URLError as e:
+ print('No kittez. Got an error code:', e)
return results
@@ -115,8 +115,8 @@ def getScenarios(case, installer, version):
k = response.read()
results = json.loads(k)
test_results = results['results']
- except URLError, e:
- print 'Got an error code:', e
+ except URLError as e:
+ print('Got an error code:', e)
if test_results is not None:
test_results.reverse()
@@ -132,8 +132,8 @@ def getScenarios(case, installer, version):
exclude_virtual_pod = get_config('functest.exclude_virtual')
exclude_noha = get_config('functest.exclude_noha')
if ((exclude_virtual_pod and "virtual" in r['pod_name']) or
- (exclude_noha and "noha" in r['scenario'])):
- print "exclude virtual pod results..."
+ (exclude_noha and "noha" in r['scenario'])):
+ print("exclude virtual pod results...")
else:
scenario_results[r['scenario']].append(r)
@@ -164,8 +164,8 @@ def getScenarioStatus(installer, version):
response.close()
results = json.loads(k)
test_results = results['results']
- except URLError, e:
- print 'Got an error code:', e
+ except URLError as e:
+ print('Got an error code:', e)
scenario_results = {}
result_dict = {}
@@ -198,7 +198,7 @@ def getNbtestOk(results):
if "PASS" in v:
nb_test_ok += 1
except:
- print "Cannot retrieve test status"
+ print("Cannot retrieve test status")
return nb_test_ok
@@ -269,10 +269,10 @@ def getJenkinsUrl(build_tag):
url_base = get_config('functest.jenkins_url')
try:
build_id = [int(s) for s in build_tag.split("-") if s.isdigit()]
- url_id = build_tag[8:-(len(build_id)+3)] + "/" + str(build_id[0])
+ url_id = build_tag[8:-(len(build_id) + 3)] + "/" + str(build_id[0])
jenkins_url = url_base + url_id + "/console"
except:
- print 'Impossible to get jenkins url:'
+ print('Impossible to get jenkins url:')
return jenkins_url
@@ -282,7 +282,7 @@ def getScenarioPercent(scenario_score, scenario_criteria):
try:
score = float(scenario_score) / float(scenario_criteria) * 100
except:
- print 'Impossible to calculate the percentage score'
+ print('Impossible to calculate the percentage score')
return score
@@ -330,8 +330,8 @@ def get_percent(four_list, ten_list):
def _test():
status = getScenarioStatus("compass", "master")
- print "status:++++++++++++++++++++++++"
- print json.dumps(status, indent=4)
+ print("status:++++++++++++++++++++++++")
+ print(json.dumps(status, indent=4))
# ----------------------------------------------------------
diff --git a/utils/test/testapi/htmlize/htmlize.py b/utils/test/testapi/htmlize/htmlize.py
index 075e31f79..b8c4fb43f 100644
--- a/utils/test/testapi/htmlize/htmlize.py
+++ b/utils/test/testapi/htmlize/htmlize.py
@@ -39,12 +39,14 @@ if __name__ == '__main__':
parser.add_argument('-ru', '--resource-listing-url',
type=str,
required=False,
- default='http://testresults.opnfv.org/test/swagger/spec.json',
+ default=('http://testresults.opnfv.org'
+ '/test/swagger/spec.json'),
help='Resource Listing Spec File')
parser.add_argument('-au', '--api-declaration-url',
type=str,
required=False,
- default='http://testresults.opnfv.org/test/swagger/spec',
+ default=('http://testresults.opnfv.org'
+ '/test/swagger/spec'),
help='API Declaration Spec File')
parser.add_argument('-o', '--output-directory',
required=True,
diff --git a/utils/test/testapi/update/templates/utils.py b/utils/test/testapi/update/templates/utils.py
index a18ff0389..4254fee34 100644
--- a/utils/test/testapi/update/templates/utils.py
+++ b/utils/test/testapi/update/templates/utils.py
@@ -44,5 +44,5 @@ def main(method, parser):
args = parser.parse_args()
try:
method(args)
- except AssertionError, msg:
+ except AssertionError as msg:
print(msg)