fix pylint E302, E502, E713, E1305

This commit is contained in:
Florian Ermisch 2015-07-01 15:41:00 +02:00
parent 3baacc72b4
commit bbda079fa5

View file

@ -63,6 +63,7 @@ try:
except ImportError:
pass
def __virtual__():
'''
Only load this module if glance
@ -127,31 +128,32 @@ def _auth(profile=None, api_version=2, **connection_args):
kwargs['insecure'] = True
if token:
log.debug('Calling glanceclient.client.Client(' + \
'{0}, **{1})'.format(api_version, endpoint, kwargs))
log.debug('Calling glanceclient.client.Client(' +
'{0}, {1}, **{2})'.format(api_version, endpoint, kwargs))
try:
return client.Client(api_version, endpoint, **kwargs)
except exc.HTTPUnauthorized:
kwargs.pop('token')
kwargs['password'] = password
log.warn('Supplied token is invalid, trying to ' + \
log.warn('Supplied token is invalid, trying to ' +
'get a new one using username and password.')
if HAS_KEYSTONE:
# TODO: redact kwargs['password']
log.debug('Calling keystoneclient.v2_0.client.Client(' + \
log.debug('Calling keystoneclient.v2_0.client.Client(' +
'{0}, **{1})'.format(endpoint, kwargs))
keystone = kstone.Client(**kwargs)
log.debug(help(keystone.get_token))
kwargs['token'] = keystone.get_token(keystone.session)
kwargs.pop('password')
log.debug('Calling glanceclient.client.Client(' + \
'{0}, **{1})'.format(api_version, endpoint, kwargs))
log.debug('Calling glanceclient.client.Client(' +
'{0}, {1}, **{2})'.format(api_version, endpoint, kwargs))
return client.Client(api_version, endpoint, **kwargs)
else:
raise NotImplementedError(
"Can't retrieve a auth_token without keystone")
def image_create(name, location, profile=None, visibility='public',
container_format='bare', disk_format='raw'):
'''
@ -175,14 +177,14 @@ def image_create(name, location, profile=None, visibility='public',
# valid options for "disk_format":
df_list = ['ami', 'ari', 'aki', 'vhd', 'vmdk',
'raw', 'qcow2', 'vdi', 'iso']
if not visibility in v_list:
raise SaltInvocationError('"visibility" needs to be one ' +\
if visibility not in v_list:
raise SaltInvocationError('"visibility" needs to be one ' +
'of the following: {0}'.format(', '.join(v_list)))
if not container_format in cf_list:
raise SaltInvocationError('"container_format" needs to be ' +\
if container_format not in cf_list:
raise SaltInvocationError('"container_format" needs to be ' +
'one of the following: {0}'.format(', '.join(cf_list)))
if not disk_format in df_list:
raise SaltInvocationError('"disk_format" needs to be one ' +\
if disk_format not in df_list:
raise SaltInvocationError('"disk_format" needs to be one ' +
'of the following: {0}'.format(', '.join(df_list)))
# Icehouse's glanceclient doesn't have add_location() and
# glanceclient.v2 doesn't implement Client.images.create()
@ -191,6 +193,7 @@ def image_create(name, location, profile=None, visibility='public',
image = g_client.images.create(name=name, copy_from=location)
return image_show(image.id)
def image_delete(id=None, name=None, profile=None): # pylint: disable=C0103
'''
Delete an image (glance image-delete)
@ -288,6 +291,7 @@ def image_list(id=None, profile=None): # pylint: disable=C0103
return ret[image.name]
return ret
def image_schema(profile=None):
'''
Returns names and descriptions of the schema "image"'s
@ -295,6 +299,7 @@ def image_schema(profile=None):
'''
return schema_get('image', profile)
def schema_get(name, profile=None):
'''
Known valid names of schemas are:
@ -312,6 +317,7 @@ def schema_get(name, profile=None):
name, pformat(schema_props)))
return {name: schema_props}
def _item_list(profile=None):
'''
Template for writing list functions
@ -332,6 +338,7 @@ def _item_list(profile=None):
# }
return ret
#The following is a list of functions that need to be incorporated in the
#glance module. This list should be updated as functions are added.