Replace % formatting by str.format method
Change: %s by {:s}, %d by {:d} in string and use .format method for formatting
Closes-bug: #1552139
Change-Id: Ic9bdf9200fa89fa7c78f2806a7b94e3eee914cf9
This commit is contained in:
@@ -125,7 +125,7 @@ class OpenStackActions(common.Common):
|
|||||||
with open(scenario, "r+") as f:
|
with open(scenario, "r+") as f:
|
||||||
scenario = f.read()
|
scenario = f.read()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.info("Error opening file: %s" % exc)
|
logger.info("Error opening file: {:s}".format(exc))
|
||||||
raise Exception()
|
raise Exception()
|
||||||
image_id = self._get_cirros_image().id
|
image_id = self._get_cirros_image().id
|
||||||
security_group[self.keystone.tenant_id] =\
|
security_group[self.keystone.tenant_id] =\
|
||||||
@@ -315,7 +315,7 @@ class OpenStackActions(common.Common):
|
|||||||
def get_md5sum(self, file_path, controller_ssh, vm_ip, creds=()):
|
def get_md5sum(self, file_path, controller_ssh, vm_ip, creds=()):
|
||||||
logger.info("Get file md5sum and compare it with previous one")
|
logger.info("Get file md5sum and compare it with previous one")
|
||||||
out = self.execute_through_host(
|
out = self.execute_through_host(
|
||||||
controller_ssh, vm_ip, "md5sum %s" % file_path, creds)
|
controller_ssh, vm_ip, "md5sum {:s}".format(file_path), creds)
|
||||||
return out['stdout']
|
return out['stdout']
|
||||||
|
|
||||||
def execute_through_host(self, ssh, vm_host, cmd, creds=()):
|
def execute_through_host(self, ssh, vm_host, cmd, creds=()):
|
||||||
|
|||||||
@@ -616,13 +616,13 @@ class EnvironmentModel(object):
|
|||||||
wait(
|
wait(
|
||||||
lambda: not
|
lambda: not
|
||||||
admin_remote.execute(
|
admin_remote.execute(
|
||||||
"grep 'Fuel node deployment' '%s'" % log_path
|
"grep 'Fuel node deployment' '{:s}'".format(log_path)
|
||||||
)['exit_code'],
|
)['exit_code'],
|
||||||
timeout=(float(settings.PUPPET_TIMEOUT))
|
timeout=(float(settings.PUPPET_TIMEOUT))
|
||||||
)
|
)
|
||||||
result = admin_remote.execute(
|
result = admin_remote.execute(
|
||||||
"grep 'Fuel node deployment "
|
"grep 'Fuel node deployment "
|
||||||
"complete' '%s'" % log_path)['exit_code']
|
"complete' '{:s}'".format(log_path))['exit_code']
|
||||||
if result != 0:
|
if result != 0:
|
||||||
raise Exception('Fuel node deployment failed.')
|
raise Exception('Fuel node deployment failed.')
|
||||||
self.bootstrap_image_check()
|
self.bootstrap_image_check()
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ class FuelWebClient(object):
|
|||||||
self.ssl_configure(cluster_id)
|
self.ssl_configure(cluster_id)
|
||||||
|
|
||||||
if not cluster_id:
|
if not cluster_id:
|
||||||
raise Exception("Could not get cluster '%s'" % name)
|
raise Exception("Could not get cluster '{:s}'".format(name))
|
||||||
# TODO: rw105719
|
# TODO: rw105719
|
||||||
# self.client.add_syslog_server(
|
# self.client.add_syslog_server(
|
||||||
# cluster_id, self.environment.get_host_node_ip(), port)
|
# cluster_id, self.environment.get_host_node_ip(), port)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class ContrailPlugin(TestBasic):
|
|||||||
def _prepare_contrail_plugin(self, slaves=None, pub_net=False):
|
def _prepare_contrail_plugin(self, slaves=None, pub_net=False):
|
||||||
"""Copy necessary packages to the master node and install them"""
|
"""Copy necessary packages to the master node and install them"""
|
||||||
|
|
||||||
self.env.revert_snapshot("ready_with_%d_slaves" % slaves)
|
self.env.revert_snapshot("ready_with_{:d}_slaves".format(slaves))
|
||||||
|
|
||||||
with self.env.d_env.get_admin_remote() as remote:
|
with self.env.d_env.get_admin_remote() as remote:
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,8 @@ class TestLmaCollectorPlugin(TestBasic):
|
|||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
plugin_name = plugin['name']
|
plugin_name = plugin['name']
|
||||||
plugin_version = plugin['version']
|
plugin_version = plugin['version']
|
||||||
msg = "Plugin '%s' couldn't be found. Test aborted" % plugin_name
|
msg = "Plugin '{:s}' couldn't be found. " \
|
||||||
|
"Test aborted".format(plugin_name)
|
||||||
assert_true(
|
assert_true(
|
||||||
self.fuel_web.check_plugin_exists(cluster_id, plugin_name),
|
self.fuel_web.check_plugin_exists(cluster_id, plugin_name),
|
||||||
msg)
|
msg)
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class TestAdminNode(TestBasic):
|
|||||||
with self.env.d_env.get_admin_remote() as remote:
|
with self.env.d_env.get_admin_remote() as remote:
|
||||||
ps_output = remote.execute('ps ax')['stdout']
|
ps_output = remote.execute('ps ax')['stdout']
|
||||||
astute_master = filter(lambda x: 'astute master' in x, ps_output)
|
astute_master = filter(lambda x: 'astute master' in x, ps_output)
|
||||||
logger.info("Found astute processes: %s" % astute_master)
|
logger.info("Found astute processes: {:s}".format(astute_master))
|
||||||
assert_equal(len(astute_master), 1)
|
assert_equal(len(astute_master), 1)
|
||||||
astute_workers = filter(lambda x: 'astute worker' in x, ps_output)
|
astute_workers = filter(lambda x: 'astute worker' in x, ps_output)
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ class VmBackedWithCephMigrationBasic(TestBasic):
|
|||||||
neutron=True,
|
neutron=True,
|
||||||
scenario='./fuelweb_test/helpers/instance_initial_scenario',
|
scenario='./fuelweb_test/helpers/instance_initial_scenario',
|
||||||
label=net_name)
|
label=net_name)
|
||||||
logger.info("Srv is currently in status: %s" % srv.status)
|
logger.info("Srv is currently in status: {:s}".format(srv.status))
|
||||||
|
|
||||||
# Prepare to DHCP leases checks
|
# Prepare to DHCP leases checks
|
||||||
net_name = self.fuel_web.get_cluster_predefined_networks_name(
|
net_name = self.fuel_web.get_cluster_predefined_networks_name(
|
||||||
@@ -648,7 +648,7 @@ class VmBackedWithCephMigrationBasic(TestBasic):
|
|||||||
logger.info("Assigning floating ip to server")
|
logger.info("Assigning floating ip to server")
|
||||||
floating_ip = os.assign_floating_ip(srv)
|
floating_ip = os.assign_floating_ip(srv)
|
||||||
srv_host = os.get_srv_host_name(srv)
|
srv_host = os.get_srv_host_name(srv)
|
||||||
logger.info("Server is on host %s" % srv_host)
|
logger.info("Server is on host {:s}".format(srv_host))
|
||||||
|
|
||||||
wait(lambda: tcp_ping(floating_ip.ip, 22), timeout=120)
|
wait(lambda: tcp_ping(floating_ip.ip, 22), timeout=120)
|
||||||
|
|
||||||
@@ -723,12 +723,12 @@ class VmBackedWithCephMigrationBasic(TestBasic):
|
|||||||
neutron=True,
|
neutron=True,
|
||||||
scenario='./fuelweb_test/helpers/instance_initial_scenario',
|
scenario='./fuelweb_test/helpers/instance_initial_scenario',
|
||||||
label=net_name)
|
label=net_name)
|
||||||
logger.info("Srv is currently in status: %s" % srv.status)
|
logger.info("Srv is currently in status: {:s}".format(srv.status))
|
||||||
|
|
||||||
logger.info("Assigning floating ip to server")
|
logger.info("Assigning floating ip to server")
|
||||||
floating_ip = os.assign_floating_ip(srv)
|
floating_ip = os.assign_floating_ip(srv)
|
||||||
srv_host = os.get_srv_host_name(srv)
|
srv_host = os.get_srv_host_name(srv)
|
||||||
logger.info("Server is on host %s" % srv_host)
|
logger.info("Server is on host {:s}".format(srv_host))
|
||||||
|
|
||||||
self.show_step(13)
|
self.show_step(13)
|
||||||
logger.info("Create volume")
|
logger.info("Create volume")
|
||||||
@@ -766,7 +766,7 @@ class VmBackedWithCephMigrationBasic(TestBasic):
|
|||||||
remote,
|
remote,
|
||||||
floating_ip.ip, 'sudo mount /dev/vdb /mnt', creds)
|
floating_ip.ip, 'sudo mount /dev/vdb /mnt', creds)
|
||||||
|
|
||||||
logger.info("out of mounting volume is: %s" % out['stdout'])
|
logger.info("out of mounting volume is: {:s}".format(out['stdout']))
|
||||||
|
|
||||||
with self.fuel_web.get_ssh_for_node("slave-01") as remote:
|
with self.fuel_web.get_ssh_for_node("slave-01") as remote:
|
||||||
out = os.execute_through_host(
|
out = os.execute_through_host(
|
||||||
@@ -879,8 +879,10 @@ class CheckCephPartitionsAfterReboot(TestBasic):
|
|||||||
|
|
||||||
if before_reboot_partitions != after_reboot_partitions:
|
if before_reboot_partitions != after_reboot_partitions:
|
||||||
logger.info("Partitions don`t match")
|
logger.info("Partitions don`t match")
|
||||||
logger.info("Before reboot: %s" % before_reboot_partitions)
|
logger.info("Before reboot: "
|
||||||
logger.info("After reboot: %s" % after_reboot_partitions)
|
"{:s}".format(before_reboot_partitions))
|
||||||
|
logger.info("After reboot: "
|
||||||
|
"{:s}".format(after_reboot_partitions))
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
self.show_step(10, node)
|
self.show_step(10, node)
|
||||||
@@ -900,8 +902,10 @@ class CheckCephPartitionsAfterReboot(TestBasic):
|
|||||||
|
|
||||||
if before_reboot_partitions != after_reboot_partitions:
|
if before_reboot_partitions != after_reboot_partitions:
|
||||||
logger.info("Partitions don`t match")
|
logger.info("Partitions don`t match")
|
||||||
logger.info("Before reboot: %s" % before_reboot_partitions)
|
logger.info("Before reboot: "
|
||||||
logger.info("After reboot: %s" % after_reboot_partitions)
|
"{:s}".format(before_reboot_partitions))
|
||||||
|
logger.info("After reboot: "
|
||||||
|
"{:s}".format(after_reboot_partitions))
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
self.show_step(13, node)
|
self.show_step(13, node)
|
||||||
|
|||||||
@@ -149,19 +149,19 @@ class RhHA(TestBasic):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if settings.RH_SERVER_URL:
|
if settings.RH_SERVER_URL:
|
||||||
reg_command = reg_command + " --serverurl={0}".format(
|
reg_command += " --serverurl={0}".format(
|
||||||
settings.RH_SERVER_URL)
|
settings.RH_SERVER_URL)
|
||||||
|
|
||||||
if settings.RH_REGISTERED_ORG_NAME:
|
if settings.RH_REGISTERED_ORG_NAME:
|
||||||
reg_command = reg_command + " --org={0}".format(
|
reg_command += " --org={0}".format(
|
||||||
settings.RH_REGISTERED_ORG_NAME)
|
settings.RH_REGISTERED_ORG_NAME)
|
||||||
|
|
||||||
if settings.RH_RELEASE:
|
if settings.RH_RELEASE:
|
||||||
reg_command = reg_command + " --release={0}".format(
|
reg_command += " --release={0}".format(
|
||||||
settings.RH_RELEASE)
|
settings.RH_RELEASE)
|
||||||
|
|
||||||
if settings.RH_ACTIVATION_KEY:
|
if settings.RH_ACTIVATION_KEY:
|
||||||
reg_command = reg_command + " --activationkey={0}".format(
|
reg_command += " --activationkey={0}".format(
|
||||||
settings.RH_ACTIVATION_KEY)
|
settings.RH_ACTIVATION_KEY)
|
||||||
|
|
||||||
if settings.RH_POOL_HASH:
|
if settings.RH_POOL_HASH:
|
||||||
@@ -495,16 +495,16 @@ class RhHA(TestBasic):
|
|||||||
:param hostname: Old compute hostname.
|
:param hostname: Old compute hostname.
|
||||||
"""
|
"""
|
||||||
cmd = ("source ~/openrc && for i in $(nova service-list | "
|
cmd = ("source ~/openrc && for i in $(nova service-list | "
|
||||||
"awk '/%s/{print $2}'); do nova service-delete $i; "
|
"awk '/{:s}/{{print $2}}'); do nova service-delete $i; "
|
||||||
"done" % hostname)
|
"done".format(hostname))
|
||||||
result = remote.execute(cmd)
|
result = remote.execute(cmd)
|
||||||
logger.debug(result)
|
logger.debug(result)
|
||||||
asserts.assert_equal(result['exit_code'], 0, 'Can not remove '
|
asserts.assert_equal(result['exit_code'], 0, 'Can not remove '
|
||||||
'old nova computes')
|
'old nova computes')
|
||||||
|
|
||||||
cmd = ("source ~/openrc && for i in $(neutron agent-list | "
|
cmd = ("source ~/openrc && for i in $(neutron agent-list | "
|
||||||
"awk '/%s/{print $2}'); do neutron agent-delete $i; "
|
"awk '/{:s}/{{print $2}}'); do neutron agent-delete $i; "
|
||||||
"done" % hostname)
|
"done".format(hostname))
|
||||||
result = remote.execute(cmd)
|
result = remote.execute(cmd)
|
||||||
logger.debug(result)
|
logger.debug(result)
|
||||||
asserts.assert_equal(result['exit_code'], 0, 'Can not remove '
|
asserts.assert_equal(result['exit_code'], 0, 'Can not remove '
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def make_snapshot_if_step_fail(func):
|
|||||||
case_name = getattr(func, '_base_class', None)
|
case_name = getattr(func, '_base_class', None)
|
||||||
step_num = getattr(func, '_step_num', None)
|
step_num = getattr(func, '_step_num', None)
|
||||||
config_name = getattr(func, '_config_case_group', None)
|
config_name = getattr(func, '_config_case_group', None)
|
||||||
description = "Failed in method '%s'." % func.__name__
|
description = "Failed in method '{:s}'.".format(func.__name__)
|
||||||
if args[0].env is not None:
|
if args[0].env is not None:
|
||||||
try:
|
try:
|
||||||
create_diagnostic_snapshot(args[0].env,
|
create_diagnostic_snapshot(args[0].env,
|
||||||
|
|||||||
@@ -526,8 +526,11 @@ class PuppetLog(AbstractLog):
|
|||||||
line = record.get('line', None)
|
line = record.get('line', None)
|
||||||
if not (log and time and line):
|
if not (log and time and line):
|
||||||
continue
|
continue
|
||||||
IO.output("%s %s %s" % (self.node_name(log),
|
IO.output("{name:s} {time:s} {line:s}".format(
|
||||||
time.isoformat(), line))
|
name=self.node_name(log),
|
||||||
|
time=time.isoformat(),
|
||||||
|
line=line
|
||||||
|
))
|
||||||
|
|
||||||
def sort_log(self):
|
def sort_log(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user