Clean up PEP8 errors
This commit is contained in:
parent
647580aa1f
commit
7a11e58653
|
@ -368,7 +368,7 @@ def admin_api(request):
|
|||
' and url "%s"' %
|
||||
(request.user.token, url_for(request, 'compute', True)))
|
||||
return openstackx.admin.Admin(auth_token=request.user.token,
|
||||
management_url=url_for(request, 'compute', True))
|
||||
management_url=url_for(request, 'compute', True))
|
||||
|
||||
|
||||
def extras_api(request):
|
||||
|
@ -401,14 +401,14 @@ def _get_base_client_from_token(tenant_id, token):
|
|||
|
||||
|
||||
def novaclient(request):
|
||||
LOG.debug('novaclient connection created using token "%s"'
|
||||
' and url "%s"' % (request.user.token, url_for(request, 'compute')))
|
||||
LOG.debug('novaclient connection created using token "%s" and url "%s"' %
|
||||
(request.user.token, url_for(request, 'compute')))
|
||||
c = nova_client.Client(username=request.user.username,
|
||||
api_key=request.user.token,
|
||||
project_id=request.user.tenant_id,
|
||||
auth_url=url_for(request, 'compute'))
|
||||
c.client.auth_token = request.user.token
|
||||
c.client.management_url=url_for(request, 'compute')
|
||||
c.client.management_url = url_for(request, 'compute')
|
||||
return c
|
||||
|
||||
|
||||
|
@ -642,15 +642,15 @@ def tenant_list(request):
|
|||
|
||||
def tenant_list_for_token(request, token):
|
||||
# FIXME: use novaclient for this
|
||||
keystone = openstackx.auth.Auth(
|
||||
management_url=settings.OPENSTACK_KEYSTONE_URL)
|
||||
keystone = openstackx.auth.Auth(
|
||||
management_url=settings.OPENSTACK_KEYSTONE_URL)
|
||||
return [Tenant(t) for t in keystone.tenants.for_token(token)]
|
||||
|
||||
|
||||
def users_list_for_token_and_tenant(request, token, tenant):
|
||||
admin_account = openstackx.extras.Account(
|
||||
auth_token=token,
|
||||
management_url=settings.OPENSTACK_KEYSTONE_ADMIN_URL)
|
||||
admin_account = openstackx.extras.Account(
|
||||
auth_token=token,
|
||||
management_url=settings.OPENSTACK_KEYSTONE_ADMIN_URL)
|
||||
return [User(u) for u in admin_account.users.get_for_tenant(tenant)]
|
||||
|
||||
|
||||
|
@ -721,10 +721,12 @@ def security_group_list(request):
|
|||
return [SecurityGroup(g) for g in novaclient(request).\
|
||||
security_groups.list()]
|
||||
|
||||
|
||||
def security_group_get(request, security_group_id):
|
||||
return SecurityGroup(novaclient(request).\
|
||||
security_groups.get(security_group_id))
|
||||
|
||||
|
||||
def security_group_create(request, name, description):
|
||||
return SecurityGroup(novaclient(request).\
|
||||
security_groups.create(name, description))
|
||||
|
@ -775,7 +777,7 @@ def _get_role(request, name):
|
|||
roles = account_api(request).roles.list()
|
||||
for role in roles:
|
||||
if role.name.lower() == name.lower():
|
||||
return role
|
||||
return role
|
||||
|
||||
raise Exception('Role does not exist: %s' % name)
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class Login(forms.SelfHandlingForm):
|
|||
if not tenant:
|
||||
messages.error(request,
|
||||
'No tenants present for user: %(user)s' %
|
||||
{"user" : data['username']})
|
||||
{"user": data['username']})
|
||||
return
|
||||
|
||||
# Create a token
|
||||
|
|
|
@ -46,7 +46,7 @@ class DeleteContainer(forms.SelfHandlingForm):
|
|||
api.swift_delete_container(request, data['container_name'])
|
||||
except ContainerNotEmpty, e:
|
||||
messages.error(request,
|
||||
_('Unable to delete non-empty container: %s') %
|
||||
_('Unable to delete non-empty container: %s') %
|
||||
data['container_name'])
|
||||
LOG.exception('Unable to delete container "%s". Exception: "%s"' %
|
||||
(data['container_name'], str(e)))
|
||||
|
|
|
@ -143,8 +143,8 @@ def index(request, tenant_id):
|
|||
|
||||
return shortcuts.render_to_response(
|
||||
'django_openstack/dash/floating_ips/index.html', {
|
||||
'allocate_form': FloatingIpAllocate(initial={
|
||||
'tenant_id': request.user.tenant_id}),
|
||||
'allocate_form': FloatingIpAllocate(
|
||||
initial={'tenant_id': request.user.tenant_id}),
|
||||
'disassociate_form': FloatingIpDisassociate(),
|
||||
'floating_ips': floating_ips,
|
||||
'release_form': ReleaseFloatingIp(),
|
||||
|
|
|
@ -50,7 +50,8 @@ class DeleteKeypair(forms.SelfHandlingForm):
|
|||
% data['keypair_id'])
|
||||
except novaclient_exceptions.ClientException, e:
|
||||
LOG.exception("ClientException in DeleteKeypair")
|
||||
messages.error(request, _('Error deleting keypair: %s') % e.message)
|
||||
messages.error(request,
|
||||
_('Error deleting keypair: %s') % e.message)
|
||||
return redirect(request.build_absolute_uri())
|
||||
|
||||
|
||||
|
@ -70,7 +71,8 @@ class CreateKeypair(forms.SelfHandlingForm):
|
|||
return response
|
||||
except novaclient_exceptions.ClientException, e:
|
||||
LOG.exception("ClientException in CreateKeyPair")
|
||||
messages.error(request, _('Error Creating Keypair: %s') % e.message)
|
||||
messages.error(request,
|
||||
_('Error Creating Keypair: %s') % e.message)
|
||||
return redirect(request.build_absolute_uri())
|
||||
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ class RenameNetwork(forms.SelfHandlingForm):
|
|||
_('Unable to rename network %(network)s: %(msg)s') %
|
||||
{"network": data['network'], "msg": e.message})
|
||||
else:
|
||||
msg = _('Network %(network)s has been renamed to %(new_name)s.') %{
|
||||
"network": data['network'], "new_name": data['new_name']}
|
||||
msg = _('Network %(net)s has been renamed to %(new_name)s.') % {
|
||||
"net": data['network'], "new_name": data['new_name']}
|
||||
LOG.info(msg)
|
||||
messages.success(request, msg)
|
||||
|
||||
|
@ -134,7 +134,8 @@ def index(request, tenant_id):
|
|||
})
|
||||
|
||||
except Exception, e:
|
||||
messages.error(request, _('Unable to get network list: %s') % e.message)
|
||||
messages.error(request,
|
||||
_('Unable to get network list: %s') % e.message)
|
||||
|
||||
return shortcuts.render_to_response(
|
||||
'django_openstack/dash/networks/index.html', {
|
||||
|
|
|
@ -51,8 +51,8 @@ class FilterObjects(forms.SelfHandlingForm):
|
|||
|
||||
if not objects:
|
||||
messages.info(request,
|
||||
_('There are no objects matching that prefix in %s') %
|
||||
data['container_name'])
|
||||
_('There are no objects matching that prefix in %s') %
|
||||
data['container_name'])
|
||||
|
||||
return objects
|
||||
|
||||
|
|
|
@ -105,7 +105,8 @@ def index(request):
|
|||
messages.info(request, _("There are currently no images."))
|
||||
except glance_exception.ClientConnectionError, e:
|
||||
LOG.exception("Error connecting to glance")
|
||||
messages.error(request, _("Error connecting to glance: %s") % e.message)
|
||||
messages.error(request,
|
||||
_("Error connecting to glance: %s") % e.message)
|
||||
except glance_exception.Error, e:
|
||||
LOG.exception("Error retrieving image list")
|
||||
messages.error(request,
|
||||
|
@ -125,7 +126,8 @@ def update(request, image_id):
|
|||
image = api.image_get(request, image_id)
|
||||
except glance_exception.ClientConnectionError, e:
|
||||
LOG.exception("Error connecting to glance")
|
||||
messages.error(request, _("Error connecting to glance: %s") % e.message)
|
||||
messages.error(request,
|
||||
_("Error connecting to glance: %s") % e.message)
|
||||
except glance_exception.Error, e:
|
||||
LOG.exception('Error retrieving image with id "%s"' % image_id)
|
||||
messages.error(request,
|
||||
|
@ -209,7 +211,8 @@ def upload(request):
|
|||
'container_format': 'ami',
|
||||
'name': image['name']}
|
||||
try:
|
||||
messages.success(request, _("Image was successfully uploaded."))
|
||||
messages.success(request,
|
||||
_("Image was successfully uploaded."))
|
||||
except:
|
||||
# TODO add better error management
|
||||
messages.error(request,
|
||||
|
@ -218,8 +221,8 @@ def upload(request):
|
|||
try:
|
||||
api.image_create(request, metadata, image['image_file'])
|
||||
except glance_exception.ClientConnectionError, e:
|
||||
LOG.exception('Error connecting to glance while trying to upload'
|
||||
' image')
|
||||
LOG.exception('Error connecting to glance while trying to'
|
||||
'upload image')
|
||||
messages.error(request,
|
||||
_("Error connecting to glance: %s") % e.message)
|
||||
except glance_exception.Error, e:
|
||||
|
|
|
@ -84,7 +84,8 @@ def index(request):
|
|||
services = api.service_list(request)
|
||||
except api_exceptions.ApiException, e:
|
||||
LOG.exception('ApiException fetching service list')
|
||||
messages.error(request, _('Unable to get service info: %s') % e.message)
|
||||
messages.error(request,
|
||||
_('Unable to get service info: %s') % e.message)
|
||||
|
||||
other_services = []
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ class RemoveUser(forms.SelfHandlingForm):
|
|||
data['user'],
|
||||
settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE)
|
||||
messages.success(request,
|
||||
'%(user)s was successfully removed from %(tenant)s.'
|
||||
% {"user": data['user'], "tenant": data['tenant']})
|
||||
'%(user)s was successfully removed from %(tenant)s.'
|
||||
% {"user": data['user'], "tenant": data['tenant']})
|
||||
except api_exceptions.ApiException, e:
|
||||
messages.error(request, _('Unable to create tenant: %s') %
|
||||
(e.message))
|
||||
|
|
Loading…
Reference in New Issue