Merge "flake8 everything"
This commit is contained in:
commit
1bcef6a78b
|
@ -30,7 +30,7 @@ def per(percent, value):
|
|||
|
||||
|
||||
def remaining(avail, total):
|
||||
return "(%dMB/%dMB)" % (avail/1024, total/1024)
|
||||
return "(%dMB/%dMB)" % (avail / 1024, total / 1024)
|
||||
|
||||
|
||||
def interpret_output_df(output):
|
||||
|
@ -67,9 +67,11 @@ def interpret_output_df(output):
|
|||
if used + avail != total:
|
||||
return (1, '[WARN] Used + Avail. != Total space')
|
||||
elif avail < per(crit_percent, total):
|
||||
return (2, "[ERR] Ceph df avail. critical %s" % remaining(avail, total))
|
||||
return (2, "[ERR] Ceph df avail. critical %s" %
|
||||
remaining(avail, total))
|
||||
elif avail < per(warn_percent, total):
|
||||
return (1, "[WARN] Ceph df avail. waring %s" % remaining(avail, total))
|
||||
return (1, "[WARN] Ceph df avail. waring %s" %
|
||||
remaining(avail, total))
|
||||
else:
|
||||
return (0, "[OK] Ceph df avail. seems good %s" %
|
||||
remaining(avail, total))
|
||||
|
|
|
@ -106,11 +106,11 @@ class Novautils(object):
|
|||
endpoint_url = urlparse.urlparse(url)
|
||||
except Exception as e:
|
||||
utils.unknown("you must provide an endpoint_url in the form"
|
||||
+ "<scheme>://<url>/ (%s)" % e)
|
||||
"<scheme>://<url>/ (%s)" % e)
|
||||
scheme = endpoint_url.scheme
|
||||
if scheme is None:
|
||||
utils.unknown("you must provide an endpoint_url in the form"
|
||||
+ "<scheme>://<url>/ (%s)" % e)
|
||||
"<scheme>://<url>/ (%s)" % e)
|
||||
catalog_url = None
|
||||
try:
|
||||
catalog_url = urlparse.urlparse(
|
||||
|
@ -147,10 +147,10 @@ class Novautils(object):
|
|||
self.notifications.append("Found '%s' present %d time(s)"
|
||||
% (volume_name, count))
|
||||
else:
|
||||
self.msgs.append("Found '%s' present %d time(s). "
|
||||
% (volume_name, count)
|
||||
+ "Won't create test volume. "
|
||||
+ "Please check and delete.")
|
||||
self.msgs.append("Found '%s' present %d time(s). " %
|
||||
(volume_name, count) +
|
||||
"Won't create test volume. "
|
||||
"Please check and delete.")
|
||||
|
||||
def create_volume(self, volume_name, size, availability_zone, volume_type):
|
||||
if not self.msgs:
|
||||
|
@ -179,7 +179,7 @@ class Novautils(object):
|
|||
self.volume.get()
|
||||
except Exception as e:
|
||||
self.msgs.append("Problem getting the status of "
|
||||
+ "the volume: %s" % e)
|
||||
"the volume: %s" % e)
|
||||
break
|
||||
|
||||
def delete_volume(self):
|
||||
|
@ -195,8 +195,8 @@ class Novautils(object):
|
|||
while not deleted and not self.msgs:
|
||||
time.sleep(1)
|
||||
if timer >= timeout:
|
||||
self.msgs.append("Could not delete the volume within"
|
||||
+ "%d seconds" % timer)
|
||||
self.msgs.append("Could not delete the volume within "
|
||||
"%d seconds" % timer)
|
||||
break
|
||||
timer += 1
|
||||
try:
|
||||
|
@ -232,13 +232,14 @@ def _check_cinder_volume():
|
|||
|
||||
parser.add_argument('--endpoint_type', metavar='endpoint_type', type=str,
|
||||
default="publicURL",
|
||||
help='Endpoint type in the catalog request. '
|
||||
+ 'Public by default.')
|
||||
help="""Endpoint type in the catalog request. """
|
||||
"""Public by default.""")
|
||||
|
||||
parser.add_argument('--force_delete', action='store_true',
|
||||
help='If matching volumes are found, delete them and '
|
||||
+ 'add a notification in the message instead of '
|
||||
+ 'getting out in critical state.')
|
||||
help="""If matching volumes are found, delete """
|
||||
"""them and add a notification in the """
|
||||
"""message instead of getting out in """
|
||||
"""critical state.""")
|
||||
|
||||
parser.add_argument('--api_version', metavar='api_version', type=str,
|
||||
default='1',
|
||||
|
@ -246,13 +247,13 @@ def _check_cinder_volume():
|
|||
|
||||
parser.add_argument('--timeout', metavar='timeout', type=int,
|
||||
default=120,
|
||||
help='Max number of second to create/delete a volume '
|
||||
+ '(120 by default).')
|
||||
help="""Max number of second to create/delete a """
|
||||
"""volume (120 by default).""")
|
||||
|
||||
parser.add_argument('--volume_name', metavar='volume_name', type=str,
|
||||
default="monitoring_test",
|
||||
help='Name of the volume to create '
|
||||
+ '(monitoring_test by default)')
|
||||
help="""Name of the volume to create """
|
||||
"""(monitoring_test by default)""")
|
||||
|
||||
parser.add_argument('--volume_size', metavar='volume_size', type=int,
|
||||
default=1,
|
||||
|
|
|
@ -69,11 +69,11 @@ def mangle_url(orig_url, url):
|
|||
endpoint_url = urlparse.urlparse(url)
|
||||
except Exception as e:
|
||||
utils.unknown("you must provide an endpoint_url in the form"
|
||||
+ "<scheme>://<url>/ (%s)\n" % e)
|
||||
"<scheme>://<url>/ (%s)\n" % e)
|
||||
scheme = endpoint_url.scheme
|
||||
if scheme is None:
|
||||
utils.unknown("you must provide an endpoint_url in the form"
|
||||
+ "<scheme>://<url>/ (%s)\n" % e)
|
||||
"<scheme>://<url>/ (%s)\n" % e)
|
||||
catalog_url = urlparse.urlparse(orig_url)
|
||||
|
||||
port = endpoint_url.port
|
||||
|
@ -114,8 +114,8 @@ class Novautils(object):
|
|||
dt = datetime.datetime.utcnow()
|
||||
td = dt - epoch
|
||||
# return td.total_seconds()
|
||||
return int((td.microseconds + (td.seconds + td.days * 24 * 3600)
|
||||
* 10**6) / 1e6)
|
||||
return int((td.microseconds +
|
||||
(td.seconds + td.days * 24 * 3600) * 10**6) / 1e6)
|
||||
|
||||
def check_connection(self, force=False):
|
||||
if not self.connection_done or force:
|
||||
|
@ -149,14 +149,14 @@ class Novautils(object):
|
|||
count += 1
|
||||
if count > 0:
|
||||
if delete:
|
||||
self.notifications.append("Found %d ip(s): %s"
|
||||
% (count, '{' + ', '.join(
|
||||
found_ips) + '}'))
|
||||
self.notifications.append("Found %d ip(s): %s" %
|
||||
(count, '{' + ', '.join(
|
||||
found_ips) + '}'))
|
||||
else:
|
||||
self.msgs.append("Found %d ip(s): %s. "
|
||||
% (count, ', '.join(found_ips))
|
||||
+ "Won't create test floating ip. "
|
||||
+ "Please check and delete.")
|
||||
self.msgs.append("Found %d ip(s): %s. " %
|
||||
(count, ', '.join(found_ips)) +
|
||||
"Won't create test floating ip. "
|
||||
"Please check and delete.")
|
||||
|
||||
def get_network_id(self, router_name):
|
||||
if not self.msgs:
|
||||
|
@ -197,10 +197,10 @@ def fip_type(string):
|
|||
|
||||
def _check_neutron_floating_ip():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Check an Floating ip creation. Note that it is able '
|
||||
+ 'to delete *all* floating ips from a account, so '
|
||||
+ 'ensure that nothing important is running on the '
|
||||
+ 'specified account.')
|
||||
description="""Check an Floating ip creation. Note that it is """
|
||||
"""able to delete *all* floating ips from a account, """
|
||||
"""so ensure that nothing important is running on """
|
||||
"""the specified account.""")
|
||||
parser.add_argument('--auth_url', metavar='URL', type=str,
|
||||
default=os.getenv('OS_AUTH_URL'),
|
||||
help='Keystone URL')
|
||||
|
@ -222,26 +222,28 @@ def _check_neutron_floating_ip():
|
|||
|
||||
parser.add_argument('--endpoint_type', metavar='endpoint_type', type=str,
|
||||
default="publicURL",
|
||||
help='Endpoint type in the catalog request. '
|
||||
+ 'Public by default.')
|
||||
help="""Endpoint type in the catalog request. """
|
||||
"""Public by default.""")
|
||||
|
||||
parser.add_argument('--force_delete', action='store_true',
|
||||
help='If matching floating ip are found, delete them '
|
||||
+ 'and add a notification in the message instead of '
|
||||
+ 'getting out in critical state.')
|
||||
help="""If matching floating ip are found, delete """
|
||||
"""them and add a notification in the message"""
|
||||
""" instead of getting out in critical """
|
||||
"""state.""")
|
||||
|
||||
parser.add_argument('--timeout', metavar='timeout', type=int,
|
||||
default=120,
|
||||
help='Max number of second to create/delete a '
|
||||
+ 'floating ip (120 by default).')
|
||||
help="""Max number of second to create/delete a """
|
||||
"""floating ip (120 by default).""")
|
||||
|
||||
parser.add_argument('--floating_ip', metavar='floating_ip', type=fip_type,
|
||||
default=None,
|
||||
help='Regex of IP(s) to check for existance. '
|
||||
+ 'This value can be "all" for conveniance (match '
|
||||
+ 'all ip). This permit to avoid certain floating '
|
||||
+ 'ip to be kept. Its default value prevents the '
|
||||
+ 'removal of any existing floating ip')
|
||||
help="""Regex of IP(s) to check for existance. """
|
||||
"""This value can be "all" for conveniance """
|
||||
"""(match all ip). This permit to avoid """
|
||||
"""certain floating ip to be kept. Its """
|
||||
"""default value prevents the removal of """
|
||||
"""any existing floating ip""")
|
||||
|
||||
parser.add_argument('--ext_router_name', metavar='ext_router_name',
|
||||
type=str, default='public',
|
||||
|
|
|
@ -88,8 +88,8 @@ class Novautils(object):
|
|||
dt = datetime.datetime.utcnow()
|
||||
td = dt - epoch
|
||||
# return td.total_seconds()
|
||||
return int((td.microseconds + (td.seconds + td.days * 24 * 3600)
|
||||
* 10**6) / 1e6)
|
||||
return int((td.microseconds +
|
||||
(td.seconds + td.days * 24 * 3600) * 10**6) / 1e6)
|
||||
|
||||
def check_connection(self, force=False):
|
||||
if not self.connection_done or force:
|
||||
|
@ -109,11 +109,11 @@ class Novautils(object):
|
|||
endpoint_url = urllib.parse.urlparse(url)
|
||||
except Exception as e:
|
||||
utils.unknown("you must provide an endpoint_url in the form"
|
||||
+ "<scheme>://<url>/ (%s)\n" % e)
|
||||
"<scheme>://<url>/ (%s)\n" % e)
|
||||
scheme = endpoint_url.scheme
|
||||
if scheme is None:
|
||||
utils.unknown("you must provide an endpoint_url in the form"
|
||||
+ "<scheme>://<url>/ (%s)\n" % e)
|
||||
"<scheme>://<url>/ (%s)\n" % e)
|
||||
catalog_url = None
|
||||
try:
|
||||
catalog_url = urllib.parse.urlparse(
|
||||
|
@ -153,9 +153,10 @@ class Novautils(object):
|
|||
% (instance_name, count))
|
||||
else:
|
||||
self.msgs.append(
|
||||
"Found '%s' present %d time(s). " % (instance_name, count)
|
||||
+ "Won't create test instance. "
|
||||
+ "Please check and delete.")
|
||||
"Found '%s' present %d time(s). " %
|
||||
(instance_name, count) +
|
||||
"Won't create test instance. "
|
||||
"Please check and delete.")
|
||||
|
||||
def get_image(self, image_name):
|
||||
if not self.msgs:
|
||||
|
@ -246,10 +247,9 @@ class Novautils(object):
|
|||
time.sleep(1)
|
||||
if timer >= timeout:
|
||||
self.msgs.append(
|
||||
"Could not delete the vm %s within %d seconds "
|
||||
% (instance.name, timer)
|
||||
+ "(created at %s)"
|
||||
% instance.created)
|
||||
"Could not delete the vm %s within %d seconds " %
|
||||
(instance.name, timer) + "(created at %s)" %
|
||||
instance.created)
|
||||
break
|
||||
timer += 1
|
||||
try:
|
||||
|
@ -268,35 +268,39 @@ class Novautils(object):
|
|||
|
||||
def _check_nova_instance():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Check an OpenStack Keystone server.',conflict_handler='resolve')
|
||||
description='Check an OpenStack Keystone server.',
|
||||
conflict_handler='resolve')
|
||||
|
||||
parser.add_argument('--auth_url','--os-auth-url', metavar='URL', type=str,
|
||||
default=os.getenv('OS_AUTH_URL'),
|
||||
parser.add_argument('--auth_url', '--os-auth-url', metavar='URL',
|
||||
type=str, default=os.getenv('OS_AUTH_URL'),
|
||||
help='url to use for authetication (Deprecated)')
|
||||
|
||||
parser.add_argument('--os-auth-url', dest='auth_url', type=str,
|
||||
default=os.getenv('OS_AUTH_URL'),
|
||||
help='url to use for authetication')
|
||||
|
||||
parser.add_argument('--username','--os-username', metavar='username', type=str,
|
||||
default=os.getenv('OS_USERNAME'),
|
||||
help='username to use for authentication (Deprecated)')
|
||||
parser.add_argument('--username', '--os-username', metavar='username',
|
||||
type=str, default=os.getenv('OS_USERNAME'),
|
||||
help="""username to use for authentication"""
|
||||
""" (Deprecated)""")
|
||||
|
||||
parser.add_argument('--os-username',dest='username' ,type=str,
|
||||
parser.add_argument('--os-username', dest='username', type=str,
|
||||
default=os.getenv('OS_USERNAME'),
|
||||
help='username to use for authentication')
|
||||
|
||||
parser.add_argument('--password','--os-password', metavar='password', type=str,
|
||||
default=os.getenv('OS_PASSWORD'),
|
||||
help='password to use for authentication (Deprecated)')
|
||||
parser.add_argument('--password', '--os-password', metavar='password',
|
||||
type=str, default=os.getenv('OS_PASSWORD'),
|
||||
help="""password to use for authentication"""
|
||||
""" (Deprecated)""")
|
||||
|
||||
parser.add_argument('--os-password', dest='password', type=str,
|
||||
default=os.getenv('OS_PASSWORD'),
|
||||
help='password to use for authentication')
|
||||
|
||||
parser.add_argument('--tenant','--os-tenant-name', metavar='tenant', type=str,
|
||||
default=os.getenv('OS_TENANT_NAME'),
|
||||
help='tenant name to use for authentication (Deprecated)')
|
||||
parser.add_argument('--tenant', '--os-tenant-name', metavar='tenant',
|
||||
type=str, default=os.getenv('OS_TENANT_NAME'),
|
||||
help="""tenant name to use for authentication"""
|
||||
""" (Deprecated)""")
|
||||
|
||||
parser.add_argument('--os-tenant-name', dest='tenant', type=str,
|
||||
default=os.getenv('OS_TENANT_NAME'),
|
||||
|
@ -305,15 +309,16 @@ def _check_nova_instance():
|
|||
parser.add_argument('--endpoint_url', metavar='endpoint_url', type=str,
|
||||
help='Override the catalog endpoint.')
|
||||
|
||||
parser.add_argument('--endpoint_type','--os-endpoint-type', metavar='endpoint_type', type=str,
|
||||
parser.add_argument('--endpoint_type', '--os-endpoint-type',
|
||||
metavar='endpoint_type', type=str,
|
||||
default="publicURL",
|
||||
help='Endpoint type in the catalog request. '
|
||||
+ 'Public by default. (Deprecated)')
|
||||
help="""Endpoint type in the catalog request. """
|
||||
"""Public by default. (Deprecated)""")
|
||||
|
||||
parser.add_argument('--os-endpoint-type', dest='endpoint_type', type=str,
|
||||
default="publicURL",
|
||||
help='Endpoint type in the catalog request. '
|
||||
+ 'Public by default.')
|
||||
help="""Endpoint type in the catalog request. """
|
||||
"""Public by default.""")
|
||||
|
||||
parser.add_argument('--image_name', metavar='image_name', type=str,
|
||||
default=default_image_name,
|
||||
|
@ -331,9 +336,9 @@ def _check_nova_instance():
|
|||
% default_instance_name)
|
||||
|
||||
parser.add_argument('--force_delete', action='store_true',
|
||||
help='If matching instances are found delete them and '
|
||||
+ 'add a notification in the message instead of '
|
||||
+ 'getting out in critical state.')
|
||||
help="""If matching instances are found delete """
|
||||
"""them and add a notification in the message"""
|
||||
""" instead of getting out in critical state.""")
|
||||
|
||||
parser.add_argument('--api_version', metavar='api_version', type=str,
|
||||
default='2',
|
||||
|
@ -341,13 +346,13 @@ def _check_nova_instance():
|
|||
|
||||
parser.add_argument('--timeout', metavar='timeout', type=int,
|
||||
default=120,
|
||||
help='Max number of second to create a instance'
|
||||
+ '(120 by default)')
|
||||
help="""Max number of second to create a instance"""
|
||||
""" (120 by default)""")
|
||||
|
||||
parser.add_argument('--timeout_delete', metavar='timeout_delete', type=int,
|
||||
default=45,
|
||||
help='Max number of second to delete an existing '
|
||||
+ 'instance (45 by default).')
|
||||
parser.add_argument('--timeout_delete', metavar='timeout_delete',
|
||||
type=int, default=45,
|
||||
help="""Max number of second to delete an existing """
|
||||
"""instance (45 by default).""")
|
||||
|
||||
parser.add_argument('--insecure', action='store_true',
|
||||
help="The server's cert will not be verified")
|
||||
|
|
|
@ -74,10 +74,10 @@ def check_process_exists_and_amqp_connected(name):
|
|||
except psutil.NoSuchProcess:
|
||||
continue
|
||||
found_amqp = (
|
||||
len(list(itertools.takewhile(lambda c: len(c.remote_address) <= 1
|
||||
or c.remote_address[1]
|
||||
!= AMQP_PORT, connections)))
|
||||
!= len(connections))
|
||||
len(list(itertools.takewhile(lambda c:
|
||||
len(c.remote_address) <= 1 or
|
||||
c.remote_address[1] != AMQP_PORT,
|
||||
connections))) != len(connections))
|
||||
if found_amqp:
|
||||
ok("%s is working." % name)
|
||||
critical("%s is not connected to AMQP" % name)
|
||||
|
@ -256,7 +256,6 @@ class Keystone(object):
|
|||
self.shell.stderr = StringIO()
|
||||
self.help = False
|
||||
|
||||
|
||||
def run(self):
|
||||
command = ['token', 'issue']
|
||||
vformat = ['-f', 'value', '-c', 'id']
|
||||
|
|
|
@ -32,5 +32,6 @@ commands = flake8
|
|||
commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
IGNORE= H105,H405
|
||||
exclude = .tox,doc
|
||||
show-source = true
|
||||
|
|
Loading…
Reference in New Issue