Port from Python2 to Python3
Change-Id: I99bdc541f28781665b751b05de5605a54f766497
This commit is contained in:
parent
db26c6ebae
commit
519a0ce9f0
|
@ -100,7 +100,7 @@ class Periodic_TestManager(os_service.Service):
|
|||
|
||||
def start(self):
|
||||
tasks = CONF.periodic_tests
|
||||
for key in tasks.keys():
|
||||
for key in list(tasks.keys()):
|
||||
interval, task_name = tasks[key], key
|
||||
if int(interval) > 0:
|
||||
period_task = Periodic_Task(task_name)
|
||||
|
|
|
@ -49,8 +49,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
|
|||
# The information whether the API call is being performed against the
|
||||
# public API is required for some other components. Saving it to the
|
||||
# WSGI environment is reasonable thereby.
|
||||
env['is_public_api'] = any(map(lambda pattern: re.match(pattern, path),
|
||||
self.public_api_routes))
|
||||
env['is_public_api'] = any([re.match(pattern, path) for pattern in self.public_api_routes])
|
||||
|
||||
if env['is_public_api']:
|
||||
return self._app(env, start_response)
|
||||
|
|
|
@ -200,7 +200,7 @@ class CloudpulseException(Exception):
|
|||
# kwargs doesn't match a variable in the message
|
||||
# log the issue and the kwargs
|
||||
LOG.exception(_LE('Exception in string format operation'))
|
||||
for name, value in kwargs.iteritems():
|
||||
for name, value in kwargs.items():
|
||||
LOG.error(_LE("%(name)s: %(value)s") %
|
||||
{'name': name, 'value': value})
|
||||
try:
|
||||
|
|
|
@ -39,12 +39,12 @@ def getcallargs(function, *args, **kwargs):
|
|||
# The function may not actually be a method or have im_self.
|
||||
# Typically seen when it's stubbed with mox.
|
||||
if inspect.ismethod(function) and hasattr(function, 'im_self'):
|
||||
keyed_args[argnames[0]] = function.im_self
|
||||
keyed_args[argnames[0]] = function.__self__
|
||||
else:
|
||||
keyed_args[argnames[0]] = None
|
||||
|
||||
remaining_argnames = filter(lambda x: x not in keyed_args, argnames)
|
||||
keyed_args.update(dict(zip(remaining_argnames, args)))
|
||||
remaining_argnames = [x for x in argnames if x not in keyed_args]
|
||||
keyed_args.update(dict(list(zip(remaining_argnames, args))))
|
||||
|
||||
if defaults:
|
||||
num_defaults = len(defaults)
|
||||
|
|
|
@ -65,7 +65,7 @@ testthreads = []
|
|||
def delete_old_entries():
|
||||
tasks = CONF.periodic_tests
|
||||
num_tests = CONF.database.max_db_entries
|
||||
num_range = len([key for key in tasks.keys() if int(tasks[key]) > 0])
|
||||
num_range = len([key for key in list(tasks.keys()) if int(tasks[key]) > 0])
|
||||
conn = dbapi.get_backend()
|
||||
conn.delete_old_tests(num_range, num_tests)
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ from oslo_utils import excutils
|
|||
import paramiko
|
||||
|
||||
if sys.version_info.major == 3:
|
||||
from past.builtins import basestring
|
||||
from past.builtins import str
|
||||
|
||||
import six
|
||||
|
||||
|
@ -376,14 +376,14 @@ def temporary_mutation(obj, **kwargs):
|
|||
NOT_PRESENT = object()
|
||||
|
||||
old_values = {}
|
||||
for attr, new_value in kwargs.items():
|
||||
for attr, new_value in list(kwargs.items()):
|
||||
old_values[attr] = get(obj, attr, NOT_PRESENT)
|
||||
set_value(obj, attr, new_value)
|
||||
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
for attr, old_value in old_values.items():
|
||||
for attr, old_value in list(old_values.items()):
|
||||
if old_value is NOT_PRESENT:
|
||||
delete(obj, attr)
|
||||
else:
|
||||
|
@ -582,7 +582,7 @@ def allow_logical_names():
|
|||
def raise_exception_invalid_scheme(url):
|
||||
valid_schemes = ['http', 'https']
|
||||
|
||||
if not isinstance(url, basestring):
|
||||
if not isinstance(url, str):
|
||||
raise exception.Urllib2InvalidScheme(url=url)
|
||||
|
||||
scheme = url.split(':')[0]
|
||||
|
|
|
@ -31,7 +31,7 @@ class CpulseLock(object):
|
|||
self.conductor_id = conductor_id
|
||||
|
||||
def acquire(self, retry=True, times=10):
|
||||
for num in xrange(0, times):
|
||||
for num in range(0, times):
|
||||
lock_id = objects.CpulseLock.create(self.cpulse_test.name,
|
||||
self.conductor_id)
|
||||
if lock_id is None:
|
||||
|
|
|
@ -81,7 +81,7 @@ class Credentials(object):
|
|||
elif name == 'TENANT_NAME':
|
||||
self.rc_tenant_name = value
|
||||
else:
|
||||
print('Error: rc file does not exist %s' % (openrc_file))
|
||||
print(('Error: rc file does not exist %s' % (openrc_file)))
|
||||
success = False
|
||||
elif not no_env:
|
||||
# no openrc file passed - we assume the variables have been
|
||||
|
@ -89,7 +89,7 @@ class Credentials(object):
|
|||
# just check that they are present
|
||||
for varname in ['OS_USERNAME', 'OS_AUTH_URL', 'OS_TENANT_NAME']:
|
||||
if varname not in os.environ:
|
||||
print('Warning: %s is missing' % (varname))
|
||||
print(('Warning: %s is missing' % (varname)))
|
||||
success = False
|
||||
if success:
|
||||
self.rc_username = os.environ['OS_USERNAME']
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# W0621: Redefining name %s from outer scope
|
||||
# pylint: disable=W0603,W0621
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import getpass
|
||||
import inspect
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import copy
|
||||
import errno
|
||||
|
@ -80,7 +80,7 @@ def _print_greenthreads():
|
|||
|
||||
|
||||
def _print_nativethreads():
|
||||
for threadId, stack in sys._current_frames().items():
|
||||
for threadId, stack in list(sys._current_frames().items()):
|
||||
print(threadId)
|
||||
traceback.print_stack(stack)
|
||||
print()
|
||||
|
|
|
@ -457,7 +457,7 @@ def _find_facility_from_conf():
|
|||
facility = facility_names.get(CONF.syslog_log_facility)
|
||||
|
||||
if facility is None:
|
||||
valid_facilities = facility_names.keys()
|
||||
valid_facilities = list(facility_names.keys())
|
||||
consts = ['LOG_AUTH', 'LOG_AUTHPRIV', 'LOG_CRON', 'LOG_DAEMON',
|
||||
'LOG_FTP', 'LOG_KERN', 'LOG_LPR', 'LOG_MAIL', 'LOG_NEWS',
|
||||
'LOG_AUTH', 'LOG_SYSLOG', 'LOG_USER', 'LOG_UUCP',
|
||||
|
@ -659,7 +659,7 @@ class ContextFormatter(logging.Formatter):
|
|||
context = getattr(local.store, 'context', None)
|
||||
if context:
|
||||
d = _dictify_context(context)
|
||||
for k, v in d.items():
|
||||
for k, v in list(d.items()):
|
||||
setattr(record, k, v)
|
||||
|
||||
# NOTE(sdague): default the fancier formatting params
|
||||
|
|
|
@ -156,7 +156,7 @@ class _PeriodicTasksMeta(type):
|
|||
except AttributeError:
|
||||
cls._periodic_spacing = {}
|
||||
|
||||
for value in cls.__dict__.values():
|
||||
for value in list(cls.__dict__.values()):
|
||||
if getattr(value, '_periodic_task', False):
|
||||
cls._add_periodic_task(value)
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ class ProcessLauncher(object):
|
|||
|
||||
cfg.CONF.reload_config_files()
|
||||
for service in set(
|
||||
[wrap.service for wrap in self.children.values()]):
|
||||
[wrap.service for wrap in list(self.children.values())]):
|
||||
service.reset()
|
||||
|
||||
for pid in self.children:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from hostObj import HostObject
|
||||
from .hostObj import HostObject
|
||||
import os
|
||||
import yaml
|
||||
|
||||
|
@ -26,7 +26,7 @@ class os_cfg_reader(object):
|
|||
try:
|
||||
fp = open(abs_path)
|
||||
except IOError as e:
|
||||
print("Error while opening the file...%s" % e)
|
||||
print(("Error while opening the file...%s" % e))
|
||||
return
|
||||
|
||||
try:
|
||||
|
@ -34,12 +34,12 @@ class os_cfg_reader(object):
|
|||
# print "self.hostYamlObj: ", self.hostYamlObj,
|
||||
# dir(self.hostYamlObj)
|
||||
except yaml.error.YAMLError as perr:
|
||||
print("Error while parsing...%s" % perr)
|
||||
print(("Error while parsing...%s" % perr))
|
||||
return
|
||||
|
||||
def setOpenstackNodeIp(self):
|
||||
# print self.hostYamlObj
|
||||
for key in self.hostYamlObj.keys():
|
||||
for key in list(self.hostYamlObj.keys()):
|
||||
name = key
|
||||
ip = self.hostYamlObj[key]["ip"]
|
||||
hostname = key
|
||||
|
@ -62,10 +62,10 @@ class os_cfg_reader(object):
|
|||
|
||||
def printHostList(self):
|
||||
for hostObj in self.openstack_host_list:
|
||||
print("IP - %s" % (hostObj.getIp()))
|
||||
print("HOST - %s" % (hostObj.getHost()))
|
||||
print("USER - %s" % (hostObj.getUser()))
|
||||
print("NAGIOS RUNNING - %s" % (str(hostObj.isNagiosRunning())))
|
||||
print(("IP - %s" % (hostObj.getIp())))
|
||||
print(("HOST - %s" % (hostObj.getHost())))
|
||||
print(("USER - %s" % (hostObj.getUser())))
|
||||
print(("NAGIOS RUNNING - %s" % (str(hostObj.isNagiosRunning()))))
|
||||
|
||||
def generate_ansible_config(self, os_obj_list):
|
||||
f = open('/var/sec_hc/ansible_hosts', 'w+')
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
from openstack_node import openstack_node_obj
|
||||
|
||||
from .openstack_node import openstack_node_obj
|
||||
import yaml
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ class openstack_node_info_reader(object):
|
|||
|
||||
def get_host_list(self):
|
||||
openstack_host_list = []
|
||||
for key in self.hostYamlObj.keys():
|
||||
for key in list(self.hostYamlObj.keys()):
|
||||
name = key
|
||||
ip = self.hostYamlObj[key]["ip"]
|
||||
hostname = key
|
||||
|
@ -60,8 +60,8 @@ class openstack_node_info_reader(object):
|
|||
def get_galera_details(self):
|
||||
galera = {}
|
||||
print(self.hostYamlObj)
|
||||
for key in self.hostYamlObj.keys():
|
||||
if 'galerauser' in self.hostYamlObj[key].keys():
|
||||
for key in list(self.hostYamlObj.keys()):
|
||||
if 'galerauser' in list(self.hostYamlObj[key].keys()):
|
||||
|
||||
galera['username'] = self.hostYamlObj[key]['galerauser']
|
||||
galera['password'] = self.hostYamlObj[key]['galerapassword']
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from cloudpulse.openstack.api import keystone_session
|
||||
from cloudpulse.openstack.api.nova_api import NovaHealth
|
||||
from cloudpulse.operator.ansible.openstack_node_info_reader import \
|
||||
|
@ -272,7 +272,7 @@ class operator_scenario(base.Scenario):
|
|||
docker_failed = ""
|
||||
|
||||
res['output'] = res['output'].split('\n')
|
||||
output = filter(lambda x: not re.match(r'^\s*$', x), res['output'])
|
||||
output = [x for x in res['output'] if not re.match(r'^\s*$', x)]
|
||||
|
||||
for line in output:
|
||||
line = line.split('|')
|
||||
|
@ -348,7 +348,7 @@ class operator_scenario(base.Scenario):
|
|||
# Handle ceph status in luminous, result should be picked form
|
||||
# 'status' instead of 'overall_status'
|
||||
if len(ceph_json['health']['summary']) and \
|
||||
'summary' in ceph_json['health']['summary'][0].keys() \
|
||||
'summary' in list(ceph_json['health']['summary'][0].keys()) \
|
||||
and 'mon health preluminous compat warning' in \
|
||||
ceph_json['health']['summary'][0]['summary']:
|
||||
overall_status = ceph_json['health']['status']
|
||||
|
@ -401,7 +401,7 @@ class operator_scenario(base.Scenario):
|
|||
','.join(nova_hypervisor_list[2]))
|
||||
res = execute(anscmd)
|
||||
res['output'] = res['output'].split('\n')
|
||||
output = filter(lambda x: not re.match(r'^\s*$', x), res['output'])
|
||||
output = [x for x in res['output'] if not re.match(r'^\s*$', x)]
|
||||
for line in output:
|
||||
if "SUCCESS" not in line:
|
||||
failed_hosts = failed_hosts + line.split('|')[0]
|
||||
|
|
|
@ -88,7 +88,7 @@ class TestCase(base.BaseTestCase):
|
|||
def config(self, **kw):
|
||||
"""Override config options for a test."""
|
||||
group = kw.pop('group', None)
|
||||
for k, v in kw.iteritems():
|
||||
for k, v in kw.items():
|
||||
CONF.set_override(k, v, group)
|
||||
|
||||
def path_get(self, project_file=None):
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
import mock
|
||||
|
||||
fakeAuthTokenHeaders = {'X-User-Id': u'773a902f022949619b5c2f32cd89d419',
|
||||
'X-Roles': u'admin, ResellerAdmin, _member_',
|
||||
'X-Project-Id': u'5588aebbcdc24e17a061595f80574376',
|
||||
fakeAuthTokenHeaders = {'X-User-Id': '773a902f022949619b5c2f32cd89d419',
|
||||
'X-Roles': 'admin, ResellerAdmin, _member_',
|
||||
'X-Project-Id': '5588aebbcdc24e17a061595f80574376',
|
||||
'X-Project-Name': 'test',
|
||||
'X-User-Name': 'test',
|
||||
'X-Auth-Token': u'5588aebbcdc24e17a061595f80574376',
|
||||
'X-Forwarded-For': u'10.10.10.10, 11.11.11.11',
|
||||
'X-Service-Catalog': u'{test: 12345}',
|
||||
'X-Auth-Token': '5588aebbcdc24e17a061595f80574376',
|
||||
'X-Forwarded-For': '10.10.10.10, 11.11.11.11',
|
||||
'X-Service-Catalog': '{test: 12345}',
|
||||
'X-Auth-Url': 'fake_auth_url',
|
||||
'X-Identity-Status': 'Confirmed',
|
||||
'X-User-Domain-Name': 'domain',
|
||||
|
|
|
@ -160,12 +160,12 @@ def create_parsed_yaml(yaml_file):
|
|||
try:
|
||||
fp = open(yaml_file)
|
||||
except IOError as ioerr:
|
||||
print("Failed to open file %s [%s]" % (yaml_file, ioerr))
|
||||
print(("Failed to open file %s [%s]" % (yaml_file, ioerr)))
|
||||
raise IOError(ioerr)
|
||||
try:
|
||||
parsed = yaml.safe_load(fp)
|
||||
except yaml.error.YAMLError as perr:
|
||||
print("Failed to parse %s [%s]" % (yaml_file, perr))
|
||||
print(("Failed to parse %s [%s]" % (yaml_file, perr)))
|
||||
return None
|
||||
fp.close()
|
||||
return parsed
|
||||
|
|
|
@ -101,7 +101,7 @@ class FunctionalTest(base.DbTestCase):
|
|||
:param path_prefix: prefix of the url path
|
||||
"""
|
||||
full_path = path_prefix + path
|
||||
print('%s: %s %s' % (method.upper(), full_path, params))
|
||||
print(('%s: %s %s' % (method.upper(), full_path, params)))
|
||||
response = getattr(self.app, "%s_json" % method)(
|
||||
str(full_path),
|
||||
params=params,
|
||||
|
@ -110,7 +110,7 @@ class FunctionalTest(base.DbTestCase):
|
|||
extra_environ=extra_environ,
|
||||
expect_errors=expect_errors
|
||||
)
|
||||
print('GOT:%s' % response)
|
||||
print(('GOT:%s' % response))
|
||||
return response
|
||||
|
||||
def put_json(self, path, params, expect_errors=False, headers=None,
|
||||
|
@ -181,13 +181,13 @@ class FunctionalTest(base.DbTestCase):
|
|||
:param path_prefix: prefix of the url path
|
||||
"""
|
||||
full_path = path_prefix + path
|
||||
print('DELETE: %s' % (full_path))
|
||||
print(('DELETE: %s' % (full_path)))
|
||||
response = self.app.delete(str(full_path),
|
||||
headers=headers,
|
||||
status=status,
|
||||
extra_environ=extra_environ,
|
||||
expect_errors=expect_errors)
|
||||
print('GOT:%s' % response)
|
||||
print(('GOT:%s' % response))
|
||||
return response
|
||||
|
||||
def get_json(self, path, expect_errors=False, headers=None,
|
||||
|
@ -220,7 +220,7 @@ class FunctionalTest(base.DbTestCase):
|
|||
all_params.update(params)
|
||||
if q:
|
||||
all_params.update(query_params)
|
||||
print('GET: %s %r' % (full_path, all_params))
|
||||
print(('GET: %s %r' % (full_path, all_params)))
|
||||
response = self.app.get(full_path,
|
||||
params=all_params,
|
||||
headers=headers,
|
||||
|
@ -228,7 +228,7 @@ class FunctionalTest(base.DbTestCase):
|
|||
expect_errors=expect_errors)
|
||||
if not expect_errors:
|
||||
response = response.json
|
||||
print('GOT:%s' % response)
|
||||
print(('GOT:%s' % response))
|
||||
return response
|
||||
|
||||
def validate_link(self, link, bookmark=False):
|
||||
|
|
|
@ -66,11 +66,11 @@ class TestContextHook(base.TestCase):
|
|||
|
||||
class TestNoExceptionTracebackHook(api_base.FunctionalTest):
|
||||
|
||||
TRACE = [u'Traceback (most recent call last):',
|
||||
u' File "/opt/stack/cloudpulse/cloudpulse/openstack',
|
||||
u'/common/rpc/amqp.py",',
|
||||
TRACE = ['Traceback (most recent call last):',
|
||||
' File "/opt/stack/cloudpulse/cloudpulse/openstack',
|
||||
'/common/rpc/amqp.py",',
|
||||
' line 434, in _process_data\\n **args)',
|
||||
u' File "/opt/stack/cloudpulse/cloudpulse/openstack/common/rpc/'
|
||||
' File "/opt/stack/cloudpulse/cloudpulse/openstack/common/rpc/'
|
||||
'dispatcher.py", line 172, in dispatch\\n result ='
|
||||
' getattr(proxyobj, method)(context, **kwargs)']
|
||||
MSG_WITHOUT_TRACE = "Test exception message."
|
||||
|
|
|
@ -37,8 +37,8 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'cloudpulse'
|
||||
copyright = u'2013, OpenStack Foundation'
|
||||
project = 'cloudpulse'
|
||||
copyright = '2013, OpenStack Foundation'
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
add_function_parentheses = True
|
||||
|
@ -67,8 +67,8 @@ htmlhelp_basename = '%sdoc' % project
|
|||
latex_documents = [
|
||||
('index',
|
||||
'%s.tex' % project,
|
||||
u'%s Documentation' % project,
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
'%s Documentation' % project,
|
||||
'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
|
|
|
@ -5,7 +5,7 @@ description-file =
|
|||
README.rst
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = http://www.openstack.org/
|
||||
home-page = https://git.openstack.org/cgit/openstack/cloudpulse
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Information Technology
|
||||
|
@ -13,10 +13,9 @@ classifier =
|
|||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.3
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: 3.7
|
||||
|
||||
[files]
|
||||
packages =
|
||||
|
|
Loading…
Reference in New Issue