Pylint: fix trivial issues 9

fix: undefined-loop-variable - at some places it's fake fail,
 at 2 places was a real problem
Related-bug: #1556791

Change-Id: I321d82cac0a3c031c43fd9e1bcbf9bfaab3b1164
This commit is contained in:
Alexey Stepanov 2016-03-21 12:26:44 +03:00
parent c058667639
commit ee4eaaaf10
4 changed files with 15 additions and 4 deletions

View File

@ -810,6 +810,7 @@ def check_oswl_stat(postgres_actions, nailgun_actions,
q = "select resource_data from oswl_stats where" \
" resource_type = '\"'\"'{0}'\"'\"';".format(resource)
# pylint: disable=undefined-loop-variable
def get_resource():
result = postgres_actions.run_query('nailgun', q)
logger.debug("resource state is {}".format(result))
@ -818,6 +819,7 @@ def check_oswl_stat(postgres_actions, nailgun_actions,
return (
len(json.loads(result)[operation]) >
expected_resource_count[operation][resource])
# pylint: enable=undefined-loop-variable
wait(get_resource, timeout=10,
timeout_msg="resource {} wasn't updated in db".format(resource))

View File

@ -776,8 +776,10 @@ class TestMultipleClusterNets(TestBasic):
'in error state..')
for slave in custom_nodes:
try:
# pylint: disable=undefined-loop-variable
wait(lambda: self.fuel_web.get_nailgun_node_by_devops_node(
slave)['status'] == 'error', timeout=60 * 5)
# pylint: enable=undefined-loop-variable
logger.info('Node {} is in "error" state'.format(slave.name))
except TimeoutError:
raise TimeoutError('Node {} status wasn\'t changed '

View File

@ -1259,10 +1259,12 @@ class VcenterDeploy(TestBasic):
"Current state of Vm {0} is {1}".format(
srv.name, os_conn.get_instance_detail(srv).status))
try:
# pylint: disable=undefined-loop-variable
wait(
lambda:
os_conn.get_instance_detail(srv).status == "ACTIVE",
timeout=60 * 60)
# pylint: enable=undefined-loop-variable
except TimeoutError:
logger.error(
"Current state of Vm {0} is {1}".format(
@ -1376,10 +1378,12 @@ class VcenterDeploy(TestBasic):
"Current state of Vm {0} is {1}".format(
srv.name, os_conn.get_instance_detail(srv).status))
try:
# pylint: disable=undefined-loop-variable
wait(
lambda:
os_conn.get_instance_detail(srv).status == "ACTIVE",
timeout=60 * 60)
# pylint: enable=undefined-loop-variable
except TimeoutError:
logger.error(
"Current state of Vm {0} is {1}".format(

View File

@ -257,8 +257,9 @@ class TestHaFailoverBase(TestBasic):
logger.debug("Current controller nodes are {0}".format(
[i.name for i in devops_controllers]))
checks_number = 10
for resource in resources:
for check_counter in xrange(1, 11):
for check_counter in xrange(1, checks_number + 1):
# 1. Locate where resource is running
active_nodes = self.fuel_web.get_pacemaker_resource_location(
devops_controllers[0].name,
@ -327,8 +328,8 @@ class TestHaFailoverBase(TestBasic):
"restored on {1}".format(
active_nodes[0].name,
new_nodes[0].name))
logger.info("Resource {0} restored "
"{1} times".format(resource, check_counter))
logger.info("Resource {0} restored {1} times".format(
resource, checks_number))
# Assert ha services are ready
self.fuel_web.assert_ha_services_ready(cluster_id)
@ -622,7 +623,7 @@ class TestHaFailoverBase(TestBasic):
slave05 = self.fuel_web.get_nailgun_node_by_name('slave-05')
assert_true(
check_ping(slave05['ip'], DNS, deadline=120, interval=10),
"No Internet access from {0}".format(node['fqdn'])
"No Internet access from {0}".format(slave05['fqdn'])
)
if OPENSTACK_RELEASE == OPENSTACK_RELEASE_UBUNTU:
_ip = self.fuel_web.get_nailgun_node_by_name('slave-05')['ip']
@ -1302,10 +1303,12 @@ class TestHaFailoverBase(TestBasic):
timeout=600, interval=20,
timeout_msg='RabbitMQ cluster was not assembled')
for node in rabbit_slaves:
# pylint: disable=undefined-loop-variable
wait(lambda: count_run_rabbit(node, all_up=True), timeout=60,
interval=10,
timeout_msg='Some nodes did not back to the cluster after'
'10 minutes wait.')
# pylint: enable=undefined-loop-variable
for node in d_ctrls:
with self.fuel_web.get_ssh_for_node(node.name) as remote: