diff --git a/openstack_dashboard/api/glance.py b/openstack_dashboard/api/glance.py
index 3924a24e2b..356b12e640 100644
--- a/openstack_dashboard/api/glance.py
+++ b/openstack_dashboard/api/glance.py
@@ -20,14 +20,12 @@ from __future__ import absolute_import
import itertools
import logging
-import thread
from django.conf import settings
-
import glanceclient as glance_client
+from six.moves import _thread as thread
from horizon.utils import functions as utils
-
from openstack_dashboard.api import base
diff --git a/openstack_dashboard/api/heat.py b/openstack_dashboard/api/heat.py
index 36f4e38712..63ff991ed4 100644
--- a/openstack_dashboard/api/heat.py
+++ b/openstack_dashboard/api/heat.py
@@ -14,6 +14,7 @@ import logging
from django.conf import settings
from heatclient import client as heat_client
+
from horizon.utils import functions as utils
from openstack_dashboard.api import base
@@ -41,10 +42,10 @@ def heatclient(request, password=None):
'ca_file': cacert,
'username': request.user.username,
'password': password
- #'timeout': args.timeout,
- #'ca_file': args.ca_file,
- #'cert_file': args.cert_file,
- #'key_file': args.key_file,
+ # 'timeout': args.timeout,
+ # 'ca_file': args.ca_file,
+ # 'cert_file': args.cert_file,
+ # 'key_file': args.key_file,
}
client = heat_client.Client(api_version, endpoint, **kwargs)
client.format_parameters = format_parameters
diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py
index ca74622a93..387fbb8045 100644
--- a/openstack_dashboard/api/keystone.py
+++ b/openstack_dashboard/api/keystone.py
@@ -217,6 +217,7 @@ def tenant_create(request, name, description=None, enabled=None,
def get_default_domain(request):
"""Gets the default domain object to use when creating Identity object.
+
Returns the domain context if is set, otherwise return the domain
of the logon user.
"""
@@ -575,9 +576,7 @@ def remove_group_role(request, role, group, domain=None, project=None):
def remove_group_roles(request, group, domain=None, project=None):
- """Removes all roles from a group on a domain or project,
- removing them from it.
- """
+ """Removes all roles from a group on a domain or project."""
client = keystoneclient(request, admin=True)
roles = client.roles.list(group=group, domain=domain, project=project)
for role in roles:
@@ -586,8 +585,9 @@ def remove_group_roles(request, group, domain=None, project=None):
def get_default_role(request):
- """Gets the default role object from Keystone and saves it as a global
- since this is configured in settings and should not change from request
+ """Gets the default role object from Keystone and saves it as a global.
+
+ Since this is configured in settings and should not change from request
to request. Supports lookup by name or id.
"""
global DEFAULT_ROLE
diff --git a/openstack_dashboard/api/network_base.py b/openstack_dashboard/api/network_base.py
index 9c19b8d963..10fda2fae3 100644
--- a/openstack_dashboard/api/network_base.py
+++ b/openstack_dashboard/api/network_base.py
@@ -112,15 +112,17 @@ class FloatingIpManager(object):
@abc.abstractmethod
def get_target_id_by_instance(self, instance_id):
- """Returns a target ID of floating IP association based on
- a backend implementation.
+ """Returns a target ID of floating IP association.
+
+ Based on a backend implementation.
"""
pass
@abc.abstractmethod
def list_target_id_by_instance(self, instance_id):
- """Returns a list of instance's target IDs of floating IP association
- based on the backend implementation
+ """Returns a list of instance's target IDs of floating IP association.
+
+ Based on the backend implementation
"""
pass
diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py
index 06524e7ea5..abbb6303be 100644
--- a/openstack_dashboard/api/neutron.py
+++ b/openstack_dashboard/api/neutron.py
@@ -21,20 +21,20 @@ from __future__ import absolute_import
import collections
import logging
+
import netaddr
from django.conf import settings
from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _
+from neutronclient.v2_0 import client as neutron_client
from horizon import messages
from horizon.utils.memoized import memoized # noqa
-
from openstack_dashboard.api import base
from openstack_dashboard.api import network_base
from openstack_dashboard.api import nova
-from neutronclient.v2_0 import client as neutron_client
LOG = logging.getLogger(__name__)
@@ -120,7 +120,7 @@ class Router(NeutronAPIDictWrapper):
"""Wrapper for neutron routers."""
def __init__(self, apiresource):
- #apiresource['admin_state'] = \
+ # apiresource['admin_state'] = \
# 'UP' if apiresource['admin_state_up'] else 'DOWN'
super(Router, self).__init__(apiresource)
@@ -463,6 +463,7 @@ def network_list(request, **params):
def network_list_for_tenant(request, tenant_id, **params):
"""Return a network list available for the tenant.
+
The list contains networks owned by the tenant and public networks.
If requested_networks specified, it searches requested_networks only.
"""
@@ -497,6 +498,7 @@ def network_get(request, network_id, expand_subnet=True, **params):
def network_create(request, **kwargs):
"""Create a subnet on a specified network.
+
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
@@ -539,6 +541,7 @@ def subnet_get(request, subnet_id, **params):
def subnet_create(request, network_id, cidr, ip_version, **kwargs):
"""Create a subnet on a specified network.
+
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: subnet IP address range
@@ -586,6 +589,7 @@ def port_get(request, port_id, **params):
def port_create(request, network_id, **kwargs):
"""Create a port on a specified network.
+
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py
index 773bdd6c52..0338d010ee 100644
--- a/openstack_dashboard/api/nova.py
+++ b/openstack_dashboard/api/nova.py
@@ -51,31 +51,33 @@ DEFAULT_QUOTA_NAME = 'default'
class VNCConsole(base.APIDictWrapper):
- """Wrapper for the "console" dictionary returned by the
- novaclient.servers.get_vnc_console method.
+ """Wrapper for the "console" dictionary.
+
+ Returned by the novaclient.servers.get_vnc_console method.
"""
_attrs = ['url', 'type']
class SPICEConsole(base.APIDictWrapper):
- """Wrapper for the "console" dictionary returned by the
- novaclient.servers.get_spice_console method.
+ """Wrapper for the "console" dictionary.
+
+ Returned by the novaclient.servers.get_spice_console method.
"""
_attrs = ['url', 'type']
class RDPConsole(base.APIDictWrapper):
- """Wrapper for the "console" dictionary returned by the
- novaclient.servers.get_rdp_console method.
+ """Wrapper for the "console" dictionary.
+
+ Returned by the novaclient.servers.get_rdp_console method.
"""
_attrs = ['url', 'type']
class Server(base.APIResourceWrapper):
- """Simple wrapper around novaclient.server.Server
-
- Preserves the request info so image name can later be retrieved
+ """Simple wrapper around novaclient.server.Server.
+ Preserves the request info so image name can later be retrieved.
"""
_attrs = ['addresses', 'attrs', 'id', 'image', 'links',
'metadata', 'name', 'private_ip', 'public_ip', 'status', 'uuid',
@@ -92,8 +94,9 @@ class Server(base.APIResourceWrapper):
# TODO(gabriel): deprecate making a call to Glance as a fallback.
@property
def image_name(self):
- import glanceclient.exc as glance_exceptions
- from openstack_dashboard.api import glance
+ import glanceclient.exc as glance_exceptions # noqa
+ from openstack_dashboard.api import glance # noqa
+
if not self.image:
return "-"
if hasattr(self.image, 'name'):
@@ -118,6 +121,7 @@ class Server(base.APIResourceWrapper):
class NovaUsage(base.APIResourceWrapper):
"""Simple wrapper around contrib/simple_usage.py."""
+
_attrs = ['start', 'server_usages', 'stop', 'tenant_id',
'total_local_gb_usage', 'total_memory_mb_usage',
'total_vcpus_usage', 'total_hours']
@@ -159,9 +163,11 @@ class NovaUsage(base.APIResourceWrapper):
class SecurityGroup(base.APIResourceWrapper):
- """Wrapper around novaclient.security_groups.SecurityGroup which wraps its
- rules in SecurityGroupRule objects and allows access to them.
+ """Wrapper around novaclient.security_groups.SecurityGroup.
+
+ Wraps its rules in SecurityGroupRule objects and allows access to them.
"""
+
_attrs = ['id', 'name', 'description', 'tenant_id']
@cached_property
@@ -175,6 +181,7 @@ class SecurityGroup(base.APIResourceWrapper):
class SecurityGroupRule(base.APIResourceWrapper):
"""Wrapper for individual rules in a SecurityGroup."""
+
_attrs = ['id', 'ip_protocol', 'from_port', 'to_port', 'ip_range', 'group']
def __unicode__(self):
@@ -759,8 +766,9 @@ def list_extensions(request):
@memoized
def extension_supported(extension_name, request):
- """this method will determine if nova supports a given extension name.
- example values for the extension_name include AdminActions, ConsoleOutput,
+ """Determine if nova supports a given extension name.
+
+ Example values for the extension_name include AdminActions, ConsoleOutput,
etc.
"""
extensions = list_extensions(request)
diff --git a/openstack_dashboard/api/trove.py b/openstack_dashboard/api/trove.py
index ee9604f6fd..4a12204dc6 100644
--- a/openstack_dashboard/api/trove.py
+++ b/openstack_dashboard/api/trove.py
@@ -108,7 +108,8 @@ def backup_delete(request, backup_id):
return troveclient(request).backups.delete(backup_id)
-def backup_create(request, name, instance_id, description=None, parent_id=None):
+def backup_create(request, name, instance_id, description=None,
+ parent_id=None):
return troveclient(request).backups.create(name, instance_id,
description, parent_id)
diff --git a/openstack_dashboard/dashboards/admin/aggregates/tests.py b/openstack_dashboard/dashboards/admin/aggregates/tests.py
index d410d346bf..4c8f5846c8 100644
--- a/openstack_dashboard/dashboards/admin/aggregates/tests.py
+++ b/openstack_dashboard/dashboards/admin/aggregates/tests.py
@@ -83,11 +83,11 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
api.nova.aggregate_details_list(IsA(http.HttpRequest)).AndReturn([])
workflow_data = self._get_create_workflow_data(aggregate)
- api.nova.aggregate_create(IsA(http.HttpRequest),
- name=workflow_data['name'],
- availability_zone=
- workflow_data['availability_zone'])\
- .AndReturn(aggregate)
+ api.nova.aggregate_create(
+ IsA(http.HttpRequest),
+ name=workflow_data['name'],
+ availability_zone=workflow_data['availability_zone'],
+ ).AndReturn(aggregate)
self.mox.ReplayAll()
@@ -110,11 +110,11 @@ class CreateAggregateWorkflowTests(BaseAggregateWorkflowTests):
api.nova.aggregate_details_list(IsA(http.HttpRequest)).AndReturn([])
workflow_data = self._get_create_workflow_data(aggregate, hosts)
- api.nova.aggregate_create(IsA(http.HttpRequest),
- name=workflow_data['name'],
- availability_zone=
- workflow_data['availability_zone'])\
- .AndReturn(aggregate)
+ api.nova.aggregate_create(
+ IsA(http.HttpRequest),
+ name=workflow_data['name'],
+ availability_zone=workflow_data['availability_zone'],
+ ).AndReturn(aggregate)
compute_hosts = []
for host in hosts:
diff --git a/openstack_dashboard/dashboards/admin/flavors/tables.py b/openstack_dashboard/dashboards/admin/flavors/tables.py
index 1c3666ebe0..8135bf4e62 100644
--- a/openstack_dashboard/dashboards/admin/flavors/tables.py
+++ b/openstack_dashboard/dashboards/admin/flavors/tables.py
@@ -56,6 +56,7 @@ class ViewFlavorExtras(tables.LinkAction):
url = "horizon:admin:flavors:extras:index"
icon = "pencil"
+
class ModifyAccess(tables.LinkAction):
name = "projects"
verbose_name = _("Modify Access")
@@ -63,7 +64,6 @@ class ModifyAccess(tables.LinkAction):
classes = ("ajax-modal",)
icon = "pencil"
-
def get_link_url(self, flavor):
step = 'update_flavor_access'
base_url = reverse(self.url, args=[flavor.id])
diff --git a/openstack_dashboard/dashboards/admin/flavors/tests.py b/openstack_dashboard/dashboards/admin/flavors/tests.py
index f2803b20b4..8d19e8216d 100644
--- a/openstack_dashboard/dashboards/admin/flavors/tests.py
+++ b/openstack_dashboard/dashboards/admin/flavors/tests.py
@@ -437,13 +437,13 @@ class UpdateFlavorWorkflowTests(BaseFlavorWorkflowTests):
self.mox.ReplayAll()
- #run get test
+ # run get test
url = reverse('horizon:admin:flavors:update', args=[flavor.id])
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertTemplateUsed(resp, "admin/flavors/update.html")
- #run post test
+ # run post test
workflow_data = {'flavor_id': flavor.id,
'name': new_flavor.name,
'vcpus': new_flavor.vcpus,
diff --git a/openstack_dashboard/dashboards/admin/info/tabs.py b/openstack_dashboard/dashboards/admin/info/tabs.py
index a8e54deeb0..3cf84d6140 100644
--- a/openstack_dashboard/dashboards/admin/info/tabs.py
+++ b/openstack_dashboard/dashboards/admin/info/tabs.py
@@ -12,21 +12,18 @@
# License for the specific language governing permissions and limitations
# under the License.
-from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
-
from openstack_dashboard.api import base
from openstack_dashboard.api import cinder
from openstack_dashboard.api import keystone
from openstack_dashboard.api import neutron
from openstack_dashboard.api import nova
-from openstack_dashboard.usage import quotas
-
from openstack_dashboard.dashboards.admin.info import constants
from openstack_dashboard.dashboards.admin.info import tables
+from openstack_dashboard.usage import quotas
class ServicesTab(tabs.TableTab):
diff --git a/openstack_dashboard/dashboards/admin/instances/tables.py b/openstack_dashboard/dashboards/admin/instances/tables.py
index d6b394acb2..c46376ce22 100644
--- a/openstack_dashboard/dashboards/admin/instances/tables.py
+++ b/openstack_dashboard/dashboards/admin/instances/tables.py
@@ -124,7 +124,7 @@ class AdminInstancesTable(tables.DataTable):
# is an ID, and correlating that at production scale using our current
# techniques isn't practical. It can be added back in when we have names
# returned in a practical manner by the API.
- #user = tables.Column("user_id", verbose_name=_("User"))
+ # user = tables.Column("user_id", verbose_name=_("User"))
host = tables.Column("OS-EXT-SRV-ATTR:host",
verbose_name=_("Host"),
classes=('nowrap-col',))
diff --git a/openstack_dashboard/dashboards/admin/metering/views.py b/openstack_dashboard/dashboards/admin/metering/views.py
index d2ed7bce96..8890d0e5bd 100644
--- a/openstack_dashboard/dashboards/admin/metering/views.py
+++ b/openstack_dashboard/dashboards/admin/metering/views.py
@@ -18,7 +18,7 @@ import json
from django.http import HttpResponse # noqa
from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _
-from django.views import generic
+import django.views
from horizon import exceptions
from horizon import tables
@@ -39,7 +39,7 @@ class IndexView(tabs.TabbedTableView):
template_name = 'admin/metering/index.html'
-class SamplesView(generic.TemplateView):
+class SamplesView(django.views.generic.TemplateView):
template_name = "admin/metering/samples.csv"
@staticmethod
@@ -130,7 +130,7 @@ class ReportView(tables.MultiTableView):
return context
-class CsvReportView(generic.View):
+class CsvReportView(django.views.generic.View):
def get(self, request, **response_kwargs):
render_class = ReportCsvRenderer
response_kwargs.setdefault("filename", "usage.csv")
diff --git a/openstack_dashboard/dashboards/admin/networks/ports/forms.py b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
index 69c32444cc..cc2755e784 100644
--- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
@@ -83,7 +83,7 @@ class CreatePort(forms.SelfHandlingForm):
class UpdatePort(project_forms.UpdatePort):
- #tenant_id = forms.CharField(widget=forms.HiddenInput())
+ # tenant_id = forms.CharField(widget=forms.HiddenInput())
device_id = forms.CharField(max_length=100, label=_("Device ID"),
help_text=_("Device ID attached to the port"),
required=False)
diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py
index 39fd3a61c4..0be151d780 100644
--- a/openstack_dashboard/dashboards/admin/networks/tables.py
+++ b/openstack_dashboard/dashboards/admin/networks/tables.py
@@ -74,7 +74,7 @@ class EditNetwork(tables.LinkAction):
return {"project_id": project_id}
-#def _get_subnets(network):
+# def _get_subnets(network):
# cidrs = [subnet.get('cidr') for subnet in network.subnets]
# return ','.join(cidrs)
diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py
index 15cecb0c04..80a247710d 100644
--- a/openstack_dashboard/dashboards/admin/networks/tests.py
+++ b/openstack_dashboard/dashboards/admin/networks/tests.py
@@ -308,8 +308,8 @@ class NetworkTests(test.BaseAdminViewTests):
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_network_create_post_network_exception_with_profile(self):
- self.test_network_create_post_network_exception(test_with_profile=
- True)
+ self.test_network_create_post_network_exception(
+ test_with_profile=True)
@test.create_stubs({api.neutron: ('network_get',)})
def test_network_update_get(self):
diff --git a/openstack_dashboard/dashboards/admin/projects/tests.py b/openstack_dashboard/dashboards/admin/projects/tests.py
index 4562301511..f44ebb24ab 100644
--- a/openstack_dashboard/dashboards/admin/projects/tests.py
+++ b/openstack_dashboard/dashboards/admin/projects/tests.py
@@ -837,7 +837,6 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
api.cinder: ('tenant_quota_update',),
quotas: ('get_tenant_quota_data',
'get_disabled_quotas')})
-
def test_update_project_save(self, neutron=False):
keystone_api_version = api.keystone.VERSIONS.active
diff --git a/openstack_dashboard/dashboards/admin/routers/views.py b/openstack_dashboard/dashboards/admin/routers/views.py
index 73156c5c95..2ae4bc0e91 100644
--- a/openstack_dashboard/dashboards/admin/routers/views.py
+++ b/openstack_dashboard/dashboards/admin/routers/views.py
@@ -43,7 +43,7 @@ class IndexView(r_views.IndexView, n_views.IndexView):
tenant_dict = self._get_tenant_list()
ext_net_dict = self._list_external_networks()
for r in routers:
- # Set tenant name
+ # Set tenant name
tenant = tenant_dict.get(r.tenant_id, None)
r.tenant_name = getattr(tenant, 'name', None)
# If name is empty use UUID as name
diff --git a/openstack_dashboard/dashboards/admin/users/tables.py b/openstack_dashboard/dashboards/admin/users/tables.py
index 4d3d5c8282..0ac4cbc918 100644
--- a/openstack_dashboard/dashboards/admin/users/tables.py
+++ b/openstack_dashboard/dashboards/admin/users/tables.py
@@ -137,7 +137,7 @@ class UsersTable(tables.DataTable):
defaultfilters.urlize)
)
# Default tenant is not returned from Keystone currently.
- #default_tenant = tables.Column('default_tenant',
+ # default_tenant = tables.Column('default_tenant',
# verbose_name=_('Default Project'))
id = tables.Column('id', verbose_name=_('User ID'))
enabled = tables.Column('enabled', verbose_name=_('Enabled'),
diff --git a/openstack_dashboard/dashboards/project/access_and_security/tests.py b/openstack_dashboard/dashboards/project/access_and_security/tests.py
index c19d30a5e7..db398b4d6f 100644
--- a/openstack_dashboard/dashboards/project/access_and_security/tests.py
+++ b/openstack_dashboard/dashboards/project/access_and_security/tests.py
@@ -20,17 +20,14 @@ from copy import deepcopy # noqa
from django.core.urlresolvers import reverse
from django import http
-
from mox import IsA # noqa
from horizon.workflows import views
-
from openstack_dashboard import api
+from openstack_dashboard.dashboards.project.access_and_security import (
+ api_access)
from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas
-from openstack_dashboard.dashboards.project.access_and_security import (
- api_access
-)
class AccessAndSecurityTests(test.TestCase):
@@ -59,7 +56,6 @@ class AccessAndSecurityTests(test.TestCase):
quotas.tenant_quota_usages(IsA(http.HttpRequest)).MultipleTimes()\
.AndReturn(quota_data)
-
api.base.is_service_enabled(IsA(http.HttpRequest),
'network').MultipleTimes().AndReturn(True)
api.base.is_service_enabled(IsA(http.HttpRequest),
@@ -103,7 +99,6 @@ class AccessAndSecurityTests(test.TestCase):
quotas.tenant_quota_usages(IsA(http.HttpRequest)).MultipleTimes()\
.AndReturn(quota_data)
-
api.base.is_service_enabled(IsA(http.HttpRequest),
'network').MultipleTimes().AndReturn(True)
api.base.is_service_enabled(IsA(http.HttpRequest),
diff --git a/openstack_dashboard/dashboards/project/containers/views.py b/openstack_dashboard/dashboards/project/containers/views.py
index bbb58f9d18..20d73a7d70 100644
--- a/openstack_dashboard/dashboards/project/containers/views.py
+++ b/openstack_dashboard/dashboards/project/containers/views.py
@@ -20,18 +20,19 @@
Views for managing Swift containers.
"""
+import os
+
from django.core.urlresolvers import reverse
from django import http
from django.utils.functional import cached_property # noqa
from django.utils import http as utils_http
from django.utils.translation import ugettext_lazy as _
-from django.views import generic
+import django.views.generic
from horizon import browsers
from horizon import exceptions
from horizon import forms
from horizon.utils import memoized
-
from openstack_dashboard import api
from openstack_dashboard.api import swift
from openstack_dashboard.dashboards.project.containers \
@@ -40,8 +41,6 @@ from openstack_dashboard.dashboards.project.containers \
import forms as project_forms
from openstack_dashboard.dashboards.project.containers import tables
-import os
-
def for_url(container_name):
"""Build a URL friendly container name.
@@ -261,7 +260,8 @@ class CopyView(forms.ModalFormView):
return context
-class ContainerDetailView(forms.ModalFormMixin, generic.TemplateView):
+class ContainerDetailView(forms.ModalFormMixin,
+ django.views.generic.TemplateView):
template_name = 'project/containers/container_detail.html'
@memoized.memoized_method
@@ -283,7 +283,8 @@ class ContainerDetailView(forms.ModalFormMixin, generic.TemplateView):
return context
-class ObjectDetailView(forms.ModalFormMixin, generic.TemplateView):
+class ObjectDetailView(forms.ModalFormMixin,
+ django.views.generic.TemplateView):
template_name = 'project/containers/object_detail.html'
@memoized.memoized_method
diff --git a/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/copy.py b/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/copy.py
index 4b81e364f5..50db431363 100644
--- a/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/copy.py
+++ b/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/copy.py
@@ -43,36 +43,36 @@ class CopyClusterTemplate(create_flow.ConfigureClusterTemplate):
super(CopyClusterTemplate, self).__init__(request, context_seed,
entry_point, *args,
**kwargs)
- #init Node Groups
+ # Initialize node groups.
+ # TODO(rdopieralski) The same (or very similar) code appears
+ # multiple times in this dashboard. It should be refactored to
+ # a function.
for step in self.steps:
if isinstance(step, create_flow.ConfigureNodegroups):
ng_action = step.action
template_ngs = template.node_groups
- if 'forms_ids' not in request.POST:
- ng_action.groups = []
- for id in range(0, len(template_ngs), 1):
- group_name = "group_name_" + str(id)
- template_id = "template_id_" + str(id)
- count = "count_" + str(id)
- templ_ng = template_ngs[id]
- ng_action.groups.append(
- {"name": templ_ng["name"],
- "template_id":
- templ_ng["node_group_template_id"],
- "count": templ_ng["count"],
- "id": id,
- "deletable": "true"})
-
- wf_helpers.build_node_group_fields(ng_action,
- group_name,
- template_id,
- count)
+ if 'forms_ids' in request.POST:
+ continue
+ ng_action.groups = []
+ for i, templ_ng in enumerate(template_ngs):
+ group_name = "group_name_%d" % i
+ template_id = "template_id_%d" % i
+ count = "count_%d" % i
+ ng_action.groups.append({
+ "name": templ_ng["name"],
+ "template_id": templ_ng["node_group_template_id"],
+ "count": templ_ng["count"],
+ "id": i,
+ "deletable": "true",
+ })
+ wf_helpers.build_node_group_fields(
+ ng_action, group_name, template_id, count)
elif isinstance(step, create_flow.GeneralConfig):
fields = step.action.fields
- fields["cluster_template_name"].initial = \
- template.name + "-copy"
+ fields["cluster_template_name"].initial = (
+ template.name + "-copy")
fields["description"].initial = template.description
except Exception:
diff --git a/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/create.py b/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/create.py
index 29a34a5e9b..3bc4d5b170 100644
--- a/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/create.py
+++ b/openstack_dashboard/dashboards/project/data_processing/cluster_templates/workflows/create.py
@@ -11,15 +11,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import json
import logging
from django.utils.translation import ugettext_lazy as _
-import json
+from saharaclient.api import base as api_base
from horizon import exceptions
from horizon import forms
from horizon import workflows
-
from openstack_dashboard.api import sahara as saharaclient
from openstack_dashboard.dashboards.project.data_processing. \
utils import helpers as helpers
@@ -28,8 +28,6 @@ from openstack_dashboard.dashboards.project.data_processing. \
import openstack_dashboard.dashboards.project.data_processing. \
utils.workflow_helpers as whelpers
-from saharaclient.api import base as api_base
-
LOG = logging.getLogger(__name__)
@@ -283,7 +281,7 @@ class ConfigureClusterTemplate(whelpers.ServiceParametersWorkflow,
plugin, hadoop_version = whelpers.\
get_plugin_and_hadoop_version(request)
- #TODO(nkonovalov): Fix client to support default_image_id
+ # TODO(nkonovalov): Fix client to support default_image_id
saharaclient.cluster_template_create(
request,
context["general_cluster_template_name"],
@@ -292,7 +290,8 @@ class ConfigureClusterTemplate(whelpers.ServiceParametersWorkflow,
context["general_description"],
configs_dict,
node_groups,
- context["anti_affinity_info"])
+ context["anti_affinity_info"],
+ )
return True
except api_base.APIException as e:
self.error_description = str(e)
diff --git a/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py b/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py
index d18b6cdf02..e66ef966e9 100644
--- a/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py
+++ b/openstack_dashboard/dashboards/project/data_processing/clusters/tabs.py
@@ -130,7 +130,7 @@ class InstancesTable(tables.DataTable):
class Meta:
name = "cluster_instances"
- #just ignoring the name
+ # Just ignoring the name.
verbose_name = _(" ")
diff --git a/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/create.py b/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/create.py
index be82337d62..7c8089fd27 100644
--- a/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/create.py
+++ b/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/create.py
@@ -200,7 +200,7 @@ class ConfigureCluster(whelpers.StatusFormatMixin, workflows.Workflow):
def handle(self, request, context):
try:
- #TODO(nkonovalov) Implement AJAX Node Groups
+ # TODO(nkonovalov) Implement AJAX Node Groups.
node_groups = None
plugin, hadoop_version = whelpers.\
diff --git a/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/scale.py b/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/scale.py
index 3029df74e6..7f72678a38 100644
--- a/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/scale.py
+++ b/openstack_dashboard/dashboards/project/data_processing/clusters/workflows/scale.py
@@ -23,8 +23,8 @@ import openstack_dashboard.dashboards.project.data_processing. \
cluster_templates.workflows.create as clt_create_flow
import openstack_dashboard.dashboards.project.data_processing. \
clusters.workflows.create as cl_create_flow
-import openstack_dashboard.dashboards.project.data_processing. \
- utils.workflow_helpers as whelpers
+from openstack_dashboard.dashboards.project.data_processing.utils import (
+ workflow_helpers)
from saharaclient.api import base as api_base
@@ -36,7 +36,7 @@ class NodeGroupsStep(clt_create_flow.ConfigureNodegroups):
class ScaleCluster(cl_create_flow.ConfigureCluster,
- whelpers.StatusFormatMixin):
+ workflow_helpers.StatusFormatMixin):
slug = "scale_cluster"
name = _("Scale Cluster")
finalize_button_name = _("Scale")
@@ -54,7 +54,7 @@ class ScaleCluster(cl_create_flow.ConfigureCluster,
plugin = cluster.plugin_name
hadoop_version = cluster.hadoop_version
- #init deletable nodegroups
+ # Initialize deletable node groups.
deletable = dict()
for group in cluster.node_groups:
deletable[group["name"]] = "false"
@@ -69,32 +69,29 @@ class ScaleCluster(cl_create_flow.ConfigureCluster,
super(ScaleCluster, self).__init__(request, context_seed,
entry_point, *args,
**kwargs)
-
- #init Node Groups
-
+ # Initialize node groups.
for step in self.steps:
- if isinstance(step, clt_create_flow.ConfigureNodegroups):
- ng_action = step.action
- template_ngs = cluster.node_groups
+ if not isinstance(step, clt_create_flow.ConfigureNodegroups):
+ continue
+ ng_action = step.action
+ template_ngs = cluster.node_groups
- if 'forms_ids' not in request.POST:
- ng_action.groups = []
- for id in range(0, len(template_ngs), 1):
- group_name = "group_name_" + str(id)
- template_id = "template_id_" + str(id)
- count = "count_" + str(id)
- templ_ng = template_ngs[id]
- ng_action.groups.append(
- {"name": templ_ng["name"],
- "template_id": templ_ng["node_group_template_id"],
- "count": templ_ng["count"],
- "id": id,
- "deletable": "false"})
-
- whelpers.build_node_group_fields(ng_action,
- group_name,
- template_id,
- count)
+ if 'forms_ids' in request.POST:
+ continue
+ ng_action.groups = []
+ for i, templ_ng in enumerate(template_ngs):
+ group_name = "group_name_%d" % i
+ template_id = "template_id_%d" % i
+ count = "count_%d" % i
+ ng_action.groups.append({
+ "name": templ_ng["name"],
+ "template_id": templ_ng["node_group_template_id"],
+ "count": templ_ng["count"],
+ "id": i,
+ "deletable": "false",
+ })
+ workflow_helpers.build_node_group_fields(
+ ng_action, group_name, template_id, count)
except Exception:
exceptions.handle(request,
_("Unable to fetch cluster to scale"))
diff --git a/openstack_dashboard/dashboards/project/data_processing/data_image_registry/forms.py b/openstack_dashboard/dashboards/project/data_processing/data_image_registry/forms.py
index 81e318ce5d..ff4a18ece0 100644
--- a/openstack_dashboard/dashboards/project/data_processing/data_image_registry/forms.py
+++ b/openstack_dashboard/dashboards/project/data_processing/data_image_registry/forms.py
@@ -14,10 +14,10 @@
import json
from django.utils.translation import ugettext_lazy as _
+
from horizon import exceptions
from horizon import forms
from horizon import messages
-
from openstack_dashboard.api import glance
from openstack_dashboard.api import sahara as saharaclient
diff --git a/openstack_dashboard/dashboards/project/data_processing/job_binaries/views.py b/openstack_dashboard/dashboards/project/data_processing/job_binaries/views.py
index da865dca21..92eca462ff 100644
--- a/openstack_dashboard/dashboards/project/data_processing/job_binaries/views.py
+++ b/openstack_dashboard/dashboards/project/data_processing/job_binaries/views.py
@@ -18,7 +18,7 @@ from django.core.urlresolvers import reverse_lazy
from django import http
from django.template import defaultfilters
from django.utils.translation import ugettext_lazy as _
-from django.views import generic
+import django.views
from horizon import exceptions
from horizon import forms
@@ -73,7 +73,7 @@ class JobBinaryDetailsView(tabs.TabView):
pass
-class DownloadJobBinaryView(generic.View):
+class DownloadJobBinaryView(django.views.generic.View):
def get(self, request, job_binary_id=None):
try:
jb = saharaclient.job_binary_get(request, job_binary_id)
diff --git a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py
index b670f5676c..ccb8f442fd 100644
--- a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py
+++ b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tabs.py
@@ -34,7 +34,8 @@ class GeneralTab(tabs.Tab):
def get_context_data(self, request):
template_id = self.tab_group.kwargs['template_id']
try:
- template = saharaclient.nodegroup_template_get(request, template_id)
+ template = saharaclient.nodegroup_template_get(
+ request, template_id)
except Exception:
template = {}
exceptions.handle(request,
@@ -57,7 +58,8 @@ class ConfigsTab(tabs.Tab):
def get_context_data(self, request):
template_id = self.tab_group.kwargs['template_id']
try:
- template = saharaclient.nodegroup_template_get(request, template_id)
+ template = saharaclient.nodegroup_template_get(
+ request, template_id)
except Exception:
template = {}
exceptions.handle(request,
diff --git a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/copy.py b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/copy.py
index f09a20959c..01c32a8857 100644
--- a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/copy.py
+++ b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/copy.py
@@ -76,7 +76,7 @@ class CopyNodegroupTemplate(create_flow.ConfigureNodegroupTemplate):
exceptions.handle(request,
_("Unable to fetch plugin details."))
for process in template.node_processes:
- #need to know the service
+ # need to know the service
_service = None
for service, processes in plugin_node_processes.items():
if process in processes:
diff --git a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/create.py b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/create.py
index da7a0074e6..e77626b351 100644
--- a/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/create.py
+++ b/openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/workflows/create.py
@@ -11,24 +11,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from horizon import forms
import logging
from django.utils.translation import ugettext_lazy as _
+from saharaclient.api import base as api_base
from horizon import exceptions
+from horizon import forms
from horizon import workflows
-
from openstack_dashboard.api import network
from openstack_dashboard.api import nova
from openstack_dashboard.api import sahara as saharaclient
-
-import openstack_dashboard.dashboards.project.data_processing. \
- utils.helpers as helpers
-import openstack_dashboard.dashboards.project.data_processing. \
- utils.workflow_helpers as whelpers
-
-from saharaclient.api import base as api_base
+from openstack_dashboard.dashboards.project.data_processing.utils import (
+ helpers)
+from openstack_dashboard.dashboards.project.data_processing.utils import (
+ workflow_helpers)
LOG = logging.getLogger(__name__)
@@ -74,8 +71,8 @@ class GeneralConfigAction(workflows.Action):
sahara = saharaclient.client(request)
hlps = helpers.Helpers(sahara)
- plugin, hadoop_version = whelpers.\
- get_plugin_and_hadoop_version(request)
+ plugin, hadoop_version = (
+ workflow_helpers.get_plugin_and_hadoop_version(request))
process_choices = []
try:
version_details = saharaclient.plugin_get_version_details(request,
@@ -117,7 +114,7 @@ class GeneralConfigAction(workflows.Action):
node_parameters = hlps.get_general_node_group_configs(plugin,
hadoop_version)
for param in node_parameters:
- self.fields[param.name] = whelpers.build_control(param)
+ self.fields[param.name] = workflow_helpers.build_control(param)
def populate_flavor_choices(self, request, context):
try:
@@ -132,8 +129,8 @@ class GeneralConfigAction(workflows.Action):
def get_help_text(self):
extra = dict()
- plugin, hadoop_version = whelpers.\
- get_plugin_and_hadoop_version(self.request)
+ plugin, hadoop_version = (
+ workflow_helpers.get_plugin_and_hadoop_version(self.request))
extra["plugin_name"] = plugin
extra["hadoop_version"] = hadoop_version
return super(GeneralConfigAction, self).get_help_text(extra)
@@ -160,8 +157,8 @@ class GeneralConfig(workflows.Step):
return context
-class ConfigureNodegroupTemplate(whelpers.ServiceParametersWorkflow,
- whelpers.StatusFormatMixin):
+class ConfigureNodegroupTemplate(workflow_helpers.ServiceParametersWorkflow,
+ workflow_helpers.StatusFormatMixin):
slug = "configure_nodegroup_template"
name = _("Create Node Group Template")
finalize_button_name = _("Create")
@@ -174,8 +171,8 @@ class ConfigureNodegroupTemplate(whelpers.ServiceParametersWorkflow,
sahara = saharaclient.client(request)
hlps = helpers.Helpers(sahara)
- plugin, hadoop_version = whelpers.\
- get_plugin_and_hadoop_version(request)
+ plugin, hadoop_version = (
+ workflow_helpers.get_plugin_and_hadoop_version(request))
general_parameters = hlps.get_general_node_group_configs(
plugin,
@@ -224,11 +221,12 @@ class ConfigureNodegroupTemplate(whelpers.ServiceParametersWorkflow,
for service_process in context["general_processes"]:
processes.append(str(service_process).split(":")[1])
- configs_dict = whelpers.parse_configs_from_context(context,
- self.defaults)
+ configs_dict = (
+ workflow_helpers.parse_configs_from_context(
+ context, self.defaults))
- plugin, hadoop_version = whelpers.\
- get_plugin_and_hadoop_version(request)
+ plugin, hadoop_version = (
+ workflow_helpers.get_plugin_and_hadoop_version(request))
volumes_per_node = None
volumes_size = None
@@ -258,7 +256,7 @@ class ConfigureNodegroupTemplate(whelpers.ServiceParametersWorkflow,
class SelectPluginAction(workflows.Action,
- whelpers.PluginAndVersionMixin):
+ workflow_helpers.PluginAndVersionMixin):
hidden_create_field = forms.CharField(
required=False,
widget=forms.HiddenInput(attrs={"class": "hidden_create_field"}))
diff --git a/openstack_dashboard/dashboards/project/data_processing/utils/neutron_support.py b/openstack_dashboard/dashboards/project/data_processing/utils/neutron_support.py
index 4128ee7fdd..684e45c3f5 100644
--- a/openstack_dashboard/dashboards/project/data_processing/utils/neutron_support.py
+++ b/openstack_dashboard/dashboards/project/data_processing/utils/neutron_support.py
@@ -14,8 +14,8 @@
# limitations under the License.
from django.utils.translation import ugettext_lazy as _
-from horizon import exceptions
+from horizon import exceptions
from openstack_dashboard.api import neutron
diff --git a/openstack_dashboard/dashboards/project/databases/forms.py b/openstack_dashboard/dashboards/project/databases/forms.py
index 53e7c11575..32b21d41bd 100644
--- a/openstack_dashboard/dashboards/project/databases/forms.py
+++ b/openstack_dashboard/dashboards/project/databases/forms.py
@@ -19,16 +19,16 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import messages
-
from openstack_dashboard import api
class ResizeVolumeForm(forms.SelfHandlingForm):
instance_id = forms.CharField(widget=forms.HiddenInput())
- orig_size = forms.IntegerField(label=_("Current Size (GB)"),
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ), required=False)
+ orig_size = forms.IntegerField(
+ label=_("Current Size (GB)"),
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ required=False,
+ )
new_size = forms.IntegerField(label=_("New Size (GB)"))
def clean(self):
diff --git a/openstack_dashboard/dashboards/project/databases/tabs.py b/openstack_dashboard/dashboards/project/databases/tabs.py
index 724dedb0ba..2de1aa3b7b 100644
--- a/openstack_dashboard/dashboards/project/databases/tabs.py
+++ b/openstack_dashboard/dashboards/project/databases/tabs.py
@@ -12,13 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from django import template
from django.conf import settings
+from django import template
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
-
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.databases import tables
diff --git a/openstack_dashboard/dashboards/project/databases/tests.py b/openstack_dashboard/dashboards/project/databases/tests.py
index e3c017740a..ccc026c29a 100644
--- a/openstack_dashboard/dashboards/project/databases/tests.py
+++ b/openstack_dashboard/dashboards/project/databases/tests.py
@@ -98,13 +98,16 @@ class DatabaseTests(test.TestCase):
@test.create_stubs(
{api.trove: ('instance_list', 'flavor_list')})
def test_index_flavor_list_exception(self):
- #Mocking instances
+ # Mocking instances.
databases = common.Paginated(self.databases.list())
- api.trove.instance_list(IsA(http.HttpRequest), marker=None)\
- .AndReturn(databases)
- #Mocking flavor list with raising an exception
- api.trove.flavor_list(IsA(http.HttpRequest))\
- .AndRaise(self.exceptions.trove)
+ api.trove.instance_list(
+ IsA(http.HttpRequest),
+ marker=None,
+ ).AndReturn(databases)
+ # Mocking flavor list with raising an exception.
+ api.trove.flavor_list(
+ IsA(http.HttpRequest),
+ ).AndRaise(self.exceptions.trove)
self.mox.ReplayAll()
@@ -306,8 +309,9 @@ class DatabaseTests(test.TestCase):
res = self.client.post(url, form_data)
self.assertRedirectsNoFollow(res, url)
- @test.create_stubs(
- {api.trove: ('instance_get', 'instance_resize_volume' )})
+ @test.create_stubs({
+ api.trove: ('instance_get', 'instance_resize_volume'),
+ })
def test_resize_volume(self):
database = self.databases.first()
database_id = database.id
@@ -333,8 +337,9 @@ class DatabaseTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(
- {api.trove: ('instance_get', 'instance_resize_volume' )})
+ @test.create_stubs({
+ api.trove: ('instance_get', 'instance_resize_volume'),
+ })
def test_resize_volume_bad_value(self):
database = self.databases.first()
database_id = database.id
@@ -355,4 +360,3 @@ class DatabaseTests(test.TestCase):
res = self.client.post(url, post)
self.assertContains(res,
"New size for volume must be greater than current size.")
-
diff --git a/openstack_dashboard/dashboards/project/databases/workflows/create_instance.py b/openstack_dashboard/dashboards/project/databases/workflows/create_instance.py
index 6c888e6b42..511d7fb29a 100644
--- a/openstack_dashboard/dashboards/project/databases/workflows/create_instance.py
+++ b/openstack_dashboard/dashboards/project/databases/workflows/create_instance.py
@@ -16,13 +16,14 @@ import logging
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
+
from horizon import exceptions
from horizon import forms
from horizon.utils import memoized
from horizon import workflows
-
from openstack_dashboard import api
+
LOG = logging.getLogger(__name__)
@@ -35,7 +36,8 @@ class SetInstanceDetailsAction(workflows.Action):
initial=1,
help_text=_("Size of the volume in GB."))
datastore = forms.ChoiceField(label=_("Datastore"),
- help_text=_("Type and version of datastore."))
+ help_text=_(
+ "Type and version of datastore."))
class Meta:
name = _("Details")
@@ -87,7 +89,7 @@ class SetInstanceDetailsAction(workflows.Action):
if len(versions) >= 2:
set_initial = True
elif len(versions) == 1:
- num_datastores_with_one_version = num_datastores_with_one_version + 1
+ num_datastores_with_one_version += 1
if num_datastores_with_one_version > 1:
set_initial = True
if len(versions) > 0:
@@ -227,7 +229,7 @@ class RestoreAction(workflows.Action):
try:
backups = api.trove.backup_list(request)
choices = [(b.id, b.name) for b in backups
- if b.status == 'COMPLETED' ]
+ if b.status == 'COMPLETED']
except Exception:
choices = []
diff --git a/openstack_dashboard/dashboards/project/images/images/forms.py b/openstack_dashboard/dashboards/project/images/images/forms.py
index 6e1732fb3e..1b0f7238c3 100644
--- a/openstack_dashboard/dashboards/project/images/images/forms.py
+++ b/openstack_dashboard/dashboards/project/images/images/forms.py
@@ -183,27 +183,32 @@ class CreateImageForm(forms.SelfHandlingForm):
class UpdateImageForm(forms.SelfHandlingForm):
image_id = forms.CharField(widget=forms.HiddenInput())
name = forms.CharField(max_length="255", label=_("Name"))
- description = forms.CharField(widget=forms.widgets.Textarea(),
- label=_("Description"),
- required=False)
- kernel = forms.CharField(max_length="36", label=_("Kernel ID"),
- required=False,
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
- ramdisk = forms.CharField(max_length="36", label=_("Ramdisk ID"),
- required=False,
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
- architecture = forms.CharField(label=_("Architecture"), required=False,
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
- disk_format = forms.CharField(label=_("Format"),
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
+ description = forms.CharField(
+ widget=forms.widgets.Textarea(),
+ label=_("Description"),
+ required=False,
+ )
+ kernel = forms.CharField(
+ max_length="36",
+ label=_("Kernel ID"),
+ required=False,
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ )
+ ramdisk = forms.CharField(
+ max_length="36",
+ label=_("Ramdisk ID"),
+ required=False,
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ )
+ architecture = forms.CharField(
+ label=_("Architecture"),
+ required=False,
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ )
+ disk_format = forms.CharField(
+ label=_("Format"),
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ )
public = forms.BooleanField(label=_("Public"), required=False)
protected = forms.BooleanField(label=_("Protected"), required=False)
diff --git a/openstack_dashboard/dashboards/project/instances/console.py b/openstack_dashboard/dashboards/project/instances/console.py
index a37b09d24d..42d694cfc4 100644
--- a/openstack_dashboard/dashboards/project/instances/console.py
+++ b/openstack_dashboard/dashboards/project/instances/console.py
@@ -42,15 +42,15 @@ def get_console(request, console_type, instance):
raise exceptions.NotAvailable(msg)
for api_call in check_consoles.values():
- # ugly workaround due novaclient API change from 2.17 to 2.18
+ # Ugly workaround due novaclient API change from 2.17 to 2.18.
try:
httpnotimplemented = nova_exception.HttpNotImplemented
except AttributeError:
httpnotimplemented = nova_exception.HTTPNotImplemented
try:
console = api_call(request, instance.id)
- #if not supported don't log it to avoid lot of errors
- #in case of AUTO
+ # If not supported, don't log it to avoid lot of errors in case
+ # of AUTO.
except httpnotimplemented:
continue
except Exception:
diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py
index 4f07e8cc53..862620eb38 100644
--- a/openstack_dashboard/dashboards/project/instances/tests.py
+++ b/openstack_dashboard/dashboards/project/instances/tests.py
@@ -22,24 +22,22 @@ import uuid
from django.conf import settings
from django.core.urlresolvers import reverse
from django import http
-from django.test import utils as test_utils
+import django.test
from django.utils.datastructures import SortedDict
from django.utils import encoding
from django.utils.http import urlencode
-
from mox import IgnoreArg # noqa
from mox import IsA # noqa
from horizon import exceptions
from horizon.workflows import views
-
from openstack_dashboard import api
from openstack_dashboard.api import cinder
from openstack_dashboard.dashboards.project.instances import console
from openstack_dashboard.dashboards.project.instances import tables
from openstack_dashboard.dashboards.project.instances import tabs
from openstack_dashboard.dashboards.project.instances import workflows
-from openstack_dashboard.test import helpers as test
+from openstack_dashboard.test import helpers
from openstack_dashboard.usage import quotas
@@ -48,16 +46,20 @@ SEC_GROUP_ROLE_PREFIX = \
workflows.update_instance.INSTANCE_SEC_GROUP_SLUG + "_role_"
-class InstanceTests(test.TestCase):
- @test.create_stubs({api.nova: ('flavor_list',
- 'server_list',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+class InstanceTests(helpers.TestCase):
+ @helpers.create_stubs({
+ api.nova: (
+ 'flavor_list',
+ 'server_list',
+ 'tenant_absolute_limits',
+ 'extension_supported',
+ ),
+ api.glance: ('image_list_detailed',),
+ api.network: (
+ 'floating_ip_simple_associate_supported',
+ 'servers_update_addresses',
+ ),
+ })
def test_index(self):
servers = self.servers.list()
api.nova.extension_supported('AdminActions',
@@ -86,7 +88,7 @@ class InstanceTests(test.TestCase):
self.assertItemsEqual(instances, self.servers.list())
- @test.create_stubs({api.nova: ('server_list',
+ @helpers.create_stubs({api.nova: ('server_list',
'tenant_absolute_limits',)})
def test_index_server_list_exception(self):
search_opts = {'marker': None, 'paginate': True}
@@ -103,16 +105,13 @@ class InstanceTests(test.TestCase):
self.assertEqual(len(res.context['instances_table'].data), 0)
self.assertMessageCount(res, error=1)
- @test.create_stubs({api.nova: ('flavor_list',
- 'server_list',
- 'flavor_get',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'flavor_get',
+ 'tenant_absolute_limits', 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def test_index_flavor_list_exception(self):
servers = self.servers.list()
flavors = self.flavors.list()
@@ -145,16 +144,13 @@ class InstanceTests(test.TestCase):
self.assertItemsEqual(instances, self.servers.list())
- @test.create_stubs({api.nova: ('flavor_list',
- 'server_list',
- 'flavor_get',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'flavor_get',
+ 'tenant_absolute_limits', 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def test_index_flavor_get_exception(self):
servers = self.servers.list()
flavors = self.flavors.list()
@@ -191,15 +187,13 @@ class InstanceTests(test.TestCase):
self.assertMessageCount(res, error=len(servers))
self.assertItemsEqual(instances, self.servers.list())
- @test.create_stubs({api.nova: ('flavor_list',
- 'server_list',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
+ 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def test_index_with_instance_booted_from_volume(self):
volume_server = self.servers.first()
volume_server.image = ""
@@ -232,7 +226,7 @@ class InstanceTests(test.TestCase):
self.assertEqual(len(instances), len(servers))
self.assertContains(res, "(not found)")
- @test.create_stubs({api.nova: ('server_list',
+ @helpers.create_stubs({api.nova: ('server_list',
'flavor_list',
'server_delete',),
api.glance: ('image_list_detailed',),
@@ -256,7 +250,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_list',
+ @helpers.create_stubs({api.nova: ('server_list',
'flavor_list',
'server_delete',),
api.glance: ('image_list_detailed',),
@@ -282,7 +276,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_pause',
+ @helpers.create_stubs({api.nova: ('server_pause',
'server_list',
'flavor_list',
'extension_supported',),
@@ -312,7 +306,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_pause',
+ @helpers.create_stubs({api.nova: ('server_pause',
'server_list',
'flavor_list',
'extension_supported',),
@@ -343,7 +337,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_unpause',
+ @helpers.create_stubs({api.nova: ('server_unpause',
'server_list',
'flavor_list',
'extension_supported',),
@@ -373,7 +367,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_unpause',
+ @helpers.create_stubs({api.nova: ('server_unpause',
'server_list',
'flavor_list',
'extension_supported',),
@@ -405,7 +399,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_reboot',
+ @helpers.create_stubs({api.nova: ('server_reboot',
'server_list',
'flavor_list',),
api.glance: ('image_list_detailed',),
@@ -431,7 +425,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_reboot',
+ @helpers.create_stubs({api.nova: ('server_reboot',
'server_list',
'flavor_list',),
api.glance: ('image_list_detailed',),
@@ -459,7 +453,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_reboot',
+ @helpers.create_stubs({api.nova: ('server_reboot',
'server_list',
'flavor_list',),
api.glance: ('image_list_detailed',),
@@ -486,7 +480,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_suspend',
+ @helpers.create_stubs({api.nova: ('server_suspend',
'server_list',
'flavor_list',
'extension_supported',),
@@ -516,7 +510,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_suspend',
+ @helpers.create_stubs({api.nova: ('server_suspend',
'server_list',
'flavor_list',
'extension_supported',),
@@ -547,7 +541,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_resume',
+ @helpers.create_stubs({api.nova: ('server_resume',
'server_list',
'flavor_list',
'extension_supported',),
@@ -578,7 +572,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_resume',
+ @helpers.create_stubs({api.nova: ('server_resume',
'server_list',
'flavor_list',
'extension_supported',),
@@ -611,7 +605,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ("server_get",
+ @helpers.create_stubs({api.nova: ("server_get",
"instance_volumes_list",
"flavor_get"),
api.network: ("server_security_groups",
@@ -638,7 +632,7 @@ class InstanceTests(test.TestCase):
self.assertItemsEqual(res.context['instance'].volumes, volumes)
- @test.create_stubs({api.nova: ("server_get",
+ @helpers.create_stubs({api.nova: ("server_get",
"instance_volumes_list",
"flavor_get"),
api.network: ("server_security_groups",
@@ -669,7 +663,7 @@ class InstanceTests(test.TestCase):
self.assertEqual(res.context['instance'].volumes[1].device,
"/dev/hdk")
- @test.create_stubs({api.nova: ("server_get",
+ @helpers.create_stubs({api.nova: ("server_get",
"instance_volumes_list",
"flavor_get"),
api.network: ("server_security_groups",
@@ -702,10 +696,10 @@ class InstanceTests(test.TestCase):
1)
self.assertContains(res, "
<!--", 1)
self.assertContains(res, "empty", 1)
- #TODO(david-lyle): uncomment when fixed with Django 1.6
- #self.assertContains(res, "N/A", 1)
+ # TODO(david-lyle): uncomment when fixed with Django 1.6
+ # self.assertContains(res, "N/A", 1)
- @test.create_stubs({api.nova: ("server_get",
+ @helpers.create_stubs({api.nova: ("server_get",
"instance_volumes_list",
"flavor_get"),
api.network: ("server_security_groups",
@@ -741,7 +735,7 @@ class InstanceTests(test.TestCase):
res = self.client.get(url)
self.assertItemsEqual(res.context['instance'].fault, server.fault)
- @test.create_stubs({api.nova: ('server_get',)})
+ @helpers.create_stubs({api.nova: ('server_get',)})
def test_instance_details_exception(self):
server = self.servers.first()
@@ -756,7 +750,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ("server_get",)})
+ @helpers.create_stubs({api.nova: ("server_get",)})
def test_instance_details_unauthorized(self):
server = self.servers.first()
@@ -770,7 +764,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_console_output',)})
+ @helpers.create_stubs({api.nova: ('server_console_output',)})
def test_instance_log(self):
server = self.servers.first()
CONSOLE_OUTPUT = 'output'
@@ -791,7 +785,7 @@ class InstanceTests(test.TestCase):
self.assertIsInstance(res, http.HttpResponse)
self.assertContains(res, CONSOLE_OUTPUT)
- @test.create_stubs({api.nova: ('server_console_output',)})
+ @helpers.create_stubs({api.nova: ('server_console_output',)})
def test_instance_log_exception(self):
server = self.servers.first()
@@ -933,7 +927,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_get',
+ @helpers.create_stubs({api.nova: ('server_get',
'snapshot_create',
'server_list',
'flavor_list',
@@ -962,23 +956,23 @@ class InstanceTests(test.TestCase):
res = self.client.post(url, formData)
self.assertRedirects(res, redir_url)
- @test_utils.override_settings(OPENSTACK_ENABLE_PASSWORD_RETRIEVE=False)
+ @django.test.utils.override_settings(
+ OPENSTACK_ENABLE_PASSWORD_RETRIEVE=False)
def test_instances_index_retrieve_password_action_disabled(self):
self. _test_instances_index_retrieve_password_action()
- @test_utils.override_settings(OPENSTACK_ENABLE_PASSWORD_RETRIEVE=True)
+ @django.test.utils.override_settings(
+ OPENSTACK_ENABLE_PASSWORD_RETRIEVE=True)
def test_instances_index_retrieve_password_action_enabled(self):
self._test_instances_index_retrieve_password_action()
- @test.create_stubs({api.nova: ('flavor_list',
- 'server_list',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
+ 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def _test_instances_index_retrieve_password_action(self):
servers = self.servers.list()
api.nova.extension_supported('AdminActions',
@@ -1011,7 +1005,7 @@ class InstanceTests(test.TestCase):
else:
self.assertNotContains(res, _action_id)
- @test.create_stubs({api.nova: ('get_password',)})
+ @helpers.create_stubs({api.nova: ('get_password',)})
def test_decrypt_instance_password(self):
server = self.servers.first()
enc_password = "azerty"
@@ -1024,7 +1018,7 @@ class InstanceTests(test.TestCase):
res = self.client.get(url)
self.assertTemplateUsed(res, 'project/instances/decryptpassword.html')
- @test.create_stubs({api.nova: ('get_password',)})
+ @helpers.create_stubs({api.nova: ('get_password',)})
def test_decrypt_instance_get_exception(self):
server = self.servers.first()
keypair = self.keypairs.first()
@@ -1042,7 +1036,7 @@ class InstanceTests(test.TestCase):
api.network: ('security_group_list',
'server_security_groups',)}
- @test.create_stubs(instance_update_get_stubs)
+ @helpers.create_stubs(instance_update_get_stubs)
def test_instance_update_get(self):
server = self.servers.first()
@@ -1059,7 +1053,7 @@ class InstanceTests(test.TestCase):
self.assertTemplateUsed(res, views.WorkflowView.template_name)
- @test.create_stubs(instance_update_get_stubs)
+ @helpers.create_stubs(instance_update_get_stubs)
def test_instance_update_get_server_get_exception(self):
server = self.servers.first()
@@ -1090,7 +1084,7 @@ class InstanceTests(test.TestCase):
'server_security_groups',
'server_update_security_groups')}
- @test.create_stubs(instance_update_post_stubs)
+ @helpers.create_stubs(instance_update_post_stubs)
def test_instance_update_post(self):
server = self.servers.first()
secgroups = self.security_groups.list()[:3]
@@ -1117,7 +1111,7 @@ class InstanceTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(instance_update_post_stubs)
+ @helpers.create_stubs(instance_update_post_stubs)
def test_instance_update_post_api_exception(self):
server = self.servers.first()
@@ -1137,7 +1131,7 @@ class InstanceTests(test.TestCase):
res = self._instance_update_post(server.id, server.name, [])
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(instance_update_post_stubs)
+ @helpers.create_stubs(instance_update_post_stubs)
def test_instance_update_post_secgroup_api_exception(self):
server = self.servers.first()
@@ -1159,7 +1153,7 @@ class InstanceTests(test.TestCase):
res = self._instance_update_post(server.id, server.name, [])
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('extension_supported',
+ @helpers.create_stubs({api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
'tenant_absolute_limits',
@@ -1258,7 +1252,7 @@ class InstanceTests(test.TestCase):
('dddddddd-dddd-dddd-dddd-dddddddddddd', 'm1.secret'),
('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'm1.tiny'),
)
- elif custom_flavor_sort == test.my_custom_sort:
+ elif custom_flavor_sort == helpers.my_custom_sort:
sorted_flavors = (
('dddddddd-dddd-dddd-dddd-dddddddddddd', 'm1.secret'),
('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'm1.tiny'),
@@ -1302,7 +1296,7 @@ class InstanceTests(test.TestCase):
else:
self.assertNotContains(res, disk_config_field_label)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_HYPERVISOR_FEATURES={'can_set_password': False})
def test_launch_instance_get_without_password(self):
self.test_launch_instance_get(expect_password_fields=False)
@@ -1313,7 +1307,7 @@ class InstanceTests(test.TestCase):
def test_launch_instance_get_no_disk_config_supported(self):
self.test_launch_instance_get(disk_config=False)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
CREATE_INSTANCE_FLAVOR_SORT={
'key': 'id',
'reverse': True,
@@ -1321,7 +1315,7 @@ class InstanceTests(test.TestCase):
def test_launch_instance_get_custom_flavor_sort_by_id(self):
self.test_launch_instance_get(custom_flavor_sort='id')
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
CREATE_INSTANCE_FLAVOR_SORT={
'key': 'name',
'reverse': False,
@@ -1329,15 +1323,16 @@ class InstanceTests(test.TestCase):
def test_launch_instance_get_custom_flavor_sort_by_name(self):
self.test_launch_instance_get(custom_flavor_sort='name')
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
CREATE_INSTANCE_FLAVOR_SORT={
- 'key': test.my_custom_sort,
+ 'key': helpers.my_custom_sort,
'reverse': False,
})
def test_launch_instance_get_custom_flavor_sort_by_callable(self):
- self.test_launch_instance_get(custom_flavor_sort=test.my_custom_sort)
+ self.test_launch_instance_get(
+ custom_flavor_sort=helpers.my_custom_sort)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
CREATE_INSTANCE_FLAVOR_SORT={
'key': 'no_such_column',
'reverse': False,
@@ -1348,12 +1343,12 @@ class InstanceTests(test.TestCase):
def test_launch_instance_get_with_only_one_network(self):
self.test_launch_instance_get(only_one_network=True)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_get_with_profile(self):
self.test_launch_instance_get(test_with_profile=True)
- @test.create_stubs({api.nova: ('extension_supported',
+ @helpers.create_stubs({api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
'tenant_absolute_limits',
@@ -1437,12 +1432,12 @@ class InstanceTests(test.TestCase):
for volume in bootable_volumes:
self.assertTrue(volume in volume_sources_ids)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_get_bootable_volumes_with_profile(self):
self.test_launch_instance_get_bootable_volumes(test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
'port_create',),
@@ -1563,12 +1558,12 @@ class InstanceTests(test.TestCase):
def test_launch_instance_post_no_disk_config_supported(self):
self.test_launch_instance_post(disk_config=False)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_post_with_profile(self):
self.test_launch_instance_post(test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
'port_create',),
@@ -1683,12 +1678,12 @@ class InstanceTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_post_boot_from_volume_with_profile(self):
self.test_launch_instance_post_boot_from_volume(test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
'port_create'),
@@ -1704,7 +1699,8 @@ class InstanceTests(test.TestCase):
quotas: ('tenant_quota_usages',)})
def test_launch_instance_post_no_images_available_boot_from_volume(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
flavor = self.flavors.first()
keypair = self.keypairs.first()
server = self.servers.first()
@@ -1785,7 +1781,7 @@ class InstanceTests(test.TestCase):
form_data = {'flavor': flavor.id,
'source_type': 'volume_id',
- #'image_id': '',
+ # 'image_id': '',
'keypair': keypair.name,
'name': server.name,
'customization_script': customization_script,
@@ -1807,13 +1803,13 @@ class InstanceTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_lnch_inst_post_no_images_avail_boot_from_vol_with_profile(self):
self.test_launch_instance_post_no_images_available_boot_from_volume(
test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
api.nova: ('extension_supported',
@@ -1898,13 +1894,13 @@ class InstanceTests(test.TestCase):
self.assertFormErrors(res, 1, "You must select an image.")
self.assertTemplateUsed(res, views.WorkflowView.template_name)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_instance_post_no_images_available_with_profile(self):
self.test_launch_instance_post_no_images_available(
test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
cinder: ('volume_list',
@@ -1966,12 +1962,12 @@ class InstanceTests(test.TestCase):
self.assertTemplateUsed(res, views.WorkflowView.template_name)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_flavorlist_error_with_profile(self):
self.test_launch_flavorlist_error(test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',
'port_create',),
@@ -2085,12 +2081,12 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_form_keystone_exception_with_profile(self):
self.test_launch_form_keystone_exception(test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
api.nova: ('extension_supported',
@@ -2183,12 +2179,12 @@ class InstanceTests(test.TestCase):
self.assertContains(res, "greater than or equal to 1")
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_form_instance_count_error_with_profile(self):
self.test_launch_form_instance_count_error(test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
api.nova: ('extension_supported',
@@ -2282,7 +2278,8 @@ class InstanceTests(test.TestCase):
def test_launch_form_instance_requirement_error_disk(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
flavor = self.flavors.first()
image = self.images.first()
image.min_ram = flavor.ram
@@ -2292,7 +2289,8 @@ class InstanceTests(test.TestCase):
def test_launch_form_instance_requirement_error_ram(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
flavor = self.flavors.first()
image = self.images.first()
image.min_ram = flavor.ram + 1
@@ -2300,19 +2298,19 @@ class InstanceTests(test.TestCase):
self._test_launch_form_instance_requirement_error(image, flavor,
test_with_profile)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_form_instance_requirement_error_disk_with_profile(self):
self.test_launch_form_instance_requirement_error_disk(
test_with_profile=True)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_form_instance_requirement_error_ram_with_profile(self):
self.test_launch_form_instance_requirement_error_ram(
test_with_profile=True)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'profile_list',),
api.nova: ('extension_supported',
@@ -2419,26 +2417,25 @@ class InstanceTests(test.TestCase):
self._test_launch_form_instance_volume_size(image, 1.5, msg,
test_with_profile)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_form_instance_volume_size_error_with_profile(self):
self.test_launch_form_instance_volume_size_error(
test_with_profile=True)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_launch_form_instance_non_int_volume_size_with_profile(self):
self.test_launch_form_instance_non_int_volume_size(
test_with_profile=True)
- @test.create_stubs({api.nova: ('flavor_list', 'server_list',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
+ 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def test_launch_button_disabled_when_quota_exceeded(self):
servers = self.servers.list()
limits = self.limits['absolute']
@@ -2480,14 +2477,13 @@ class InstanceTests(test.TestCase):
self.assertContains(res, expected_string, html=True,
msg_prefix="The launch button is not disabled")
- @test.create_stubs({api.nova: ('flavor_list', 'server_list',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
+ 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def test_index_options_after_migrate(self):
servers = self.servers.list()
server = self.servers.first()
@@ -2514,7 +2510,7 @@ class InstanceTests(test.TestCase):
self.assertContains(res, "instances__confirm")
self.assertContains(res, "instances__revert")
- @test.create_stubs({api.nova: ('extension_supported',
+ @helpers.create_stubs({api.nova: ('extension_supported',
'flavor_list',
'keypair_list',
'availability_zone_list',
@@ -2581,12 +2577,12 @@ class InstanceTests(test.TestCase):
html=True,
msg_prefix="The default key pair was not selected.")
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_select_default_keypair_if_only_one_with_profile(self):
self.test_select_default_keypair_if_only_one(test_with_profile=True)
- @test.create_stubs({api.network: ('floating_ip_target_get_by_instance',
+ @helpers.create_stubs({api.network: ('floating_ip_target_get_by_instance',
'tenant_floating_ip_allocate',
'floating_ip_associate',
'servers_update_addresses',),
@@ -2620,7 +2616,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.network: ('floating_ip_target_list_by_instance',
+ @helpers.create_stubs({api.network: ('floating_ip_target_list_by_instance',
'tenant_floating_ip_list',
'floating_ip_disassociate',
'servers_update_addresses',),
@@ -2655,7 +2651,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_get',
+ @helpers.create_stubs({api.nova: ('server_get',
'flavor_list',
'tenant_absolute_limits',
'extension_supported')})
@@ -2680,7 +2676,7 @@ class InstanceTests(test.TestCase):
self.assertTemplateUsed(res, views.WorkflowView.template_name)
- @test.create_stubs({api.nova: ('server_get',
+ @helpers.create_stubs({api.nova: ('server_get',
'flavor_list',)})
def test_instance_resize_get_server_get_exception(self):
server = self.servers.first()
@@ -2696,7 +2692,7 @@ class InstanceTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.nova: ('server_get',
+ @helpers.create_stubs({api.nova: ('server_get',
'flavor_list',)})
def test_instance_resize_get_flavor_list_exception(self):
server = self.servers.first()
@@ -2727,7 +2723,7 @@ class InstanceTests(test.TestCase):
'flavor_list', 'flavor_get',
'extension_supported')}
- @test.create_stubs(instance_resize_post_stubs)
+ @helpers.create_stubs(instance_resize_post_stubs)
def test_instance_resize_post(self):
server = self.servers.first()
flavor = self.flavors.first()
@@ -2748,7 +2744,7 @@ class InstanceTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(instance_resize_post_stubs)
+ @helpers.create_stubs(instance_resize_post_stubs)
def test_instance_resize_post_api_exception(self):
server = self.servers.first()
flavor = self.flavors.first()
@@ -2769,7 +2765,7 @@ class InstanceTests(test.TestCase):
res = self._instance_resize_post(server.id, flavor.id, 'AUTO')
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs({api.glance: ('image_list_detailed',),
+ @helpers.create_stubs({api.glance: ('image_list_detailed',),
api.nova: ('extension_supported',)})
def test_rebuild_instance_get(self, expect_password_fields=True):
server = self.servers.first()
@@ -2798,7 +2794,7 @@ class InstanceTests(test.TestCase):
else:
self.assertNotContains(res, password_field_label)
- @test_utils.override_settings(
+ @django.test.utils.override_settings(
OPENSTACK_HYPERVISOR_FEATURES={'can_set_password': False})
def test_rebuild_instance_get_without_set_password(self):
self.test_rebuild_instance_get(expect_password_fields=False)
@@ -2822,7 +2818,7 @@ class InstanceTests(test.TestCase):
'extension_supported'),
api.glance: ('image_list_detailed',)}
- @test.create_stubs(instance_rebuild_post_stubs)
+ @helpers.create_stubs(instance_rebuild_post_stubs)
def test_rebuild_instance_post_with_password(self):
server = self.servers.first()
image = self.images.first()
@@ -2854,7 +2850,7 @@ class InstanceTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(instance_rebuild_post_stubs)
+ @helpers.create_stubs(instance_rebuild_post_stubs)
def test_rebuild_instance_post_with_password_equals_none(self):
server = self.servers.first()
image = self.images.first()
@@ -2885,7 +2881,7 @@ class InstanceTests(test.TestCase):
disk_config='AUTO')
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(instance_rebuild_post_stubs)
+ @helpers.create_stubs(instance_rebuild_post_stubs)
def test_rebuild_instance_post_password_do_not_match(self):
server = self.servers.first()
image = self.images.first()
@@ -2912,7 +2908,7 @@ class InstanceTests(test.TestCase):
self.assertContains(res, "Passwords do not match.")
- @test.create_stubs(instance_rebuild_post_stubs)
+ @helpers.create_stubs(instance_rebuild_post_stubs)
def test_rebuild_instance_post_with_empty_string(self):
server = self.servers.first()
image = self.images.first()
@@ -2943,7 +2939,7 @@ class InstanceTests(test.TestCase):
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test.create_stubs(instance_rebuild_post_stubs)
+ @helpers.create_stubs(instance_rebuild_post_stubs)
def test_rebuild_instance_post_api_exception(self):
server = self.servers.first()
image = self.images.first()
@@ -2975,16 +2971,14 @@ class InstanceTests(test.TestCase):
disk_config='AUTO')
self.assertRedirectsNoFollow(res, INDEX_URL)
- @test_utils.override_settings(API_RESULT_PAGE_SIZE=2)
- @test.create_stubs({api.nova: ('flavor_list',
- 'server_list',
- 'tenant_absolute_limits',
- 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network:
- ('floating_ip_simple_associate_supported',
- 'servers_update_addresses',),
- })
+ @django.test.utils.override_settings(API_RESULT_PAGE_SIZE=2)
+ @helpers.create_stubs({
+ api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
+ 'extension_supported',),
+ api.glance: ('image_list_detailed',),
+ api.network: ('floating_ip_simple_associate_supported',
+ 'servers_update_addresses',),
+ })
def test_index_form_action_with_pagination(self):
"""The form action on the next page should have marker
object from the previous page last element.
@@ -3035,8 +3029,8 @@ class InstanceTests(test.TestCase):
# ensure that marker object exists in form action
self.assertContains(res, form_action, count=1)
- @test_utils.override_settings(API_RESULT_PAGE_SIZE=2)
- @test.create_stubs({api.nova: ('server_list',
+ @django.test.utils.override_settings(API_RESULT_PAGE_SIZE=2)
+ @helpers.create_stubs({api.nova: ('server_list',
'flavor_list',
'server_delete',),
api.glance: ('image_list_detailed',),
@@ -3071,8 +3065,8 @@ class InstanceTests(test.TestCase):
self.assertMessageCount(success=1)
-class InstanceAjaxTests(test.TestCase):
- @test.create_stubs({api.nova: ("server_get",
+class InstanceAjaxTests(helpers.TestCase):
+ @helpers.create_stubs({api.nova: ("server_get",
"flavor_get",
"extension_supported"),
api.neutron: ("is_extension_supported",)})
@@ -3103,7 +3097,7 @@ class InstanceAjaxTests(test.TestCase):
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertContains(res, server.name)
- @test.create_stubs({api.nova: ("server_get",
+ @helpers.create_stubs({api.nova: ("server_get",
"flavor_get",
"extension_supported"),
api.neutron: ("is_extension_supported",)})
@@ -3156,11 +3150,11 @@ class InstanceAjaxTests(test.TestCase):
self.assertTrue(messages[0][1].startswith('Failed'))
-class ConsoleManagerTests(test.TestCase):
+class ConsoleManagerTests(helpers.TestCase):
def setup_consoles(self):
- #need to refresh with mocks or will fail since mox do not detect
- #the api_call() as mocked
+ # Need to refresh with mocks or will fail since mox do not detect
+ # the api_call() as mocked.
console.CONSOLES = SortedDict([
('VNC', api.nova.server_vnc_console),
('SPICE', api.nova.server_spice_console),
diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
index 6628050981..c528356698 100644
--- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
+++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
@@ -731,16 +731,15 @@ class LaunchInstance(workflows.Workflow):
# for the use with the plugin supporting port profiles.
# neutron port-create --n1kv:profile
# for net_id in context['network_id']:
- ## HACK for now use first network
+ # HACK for now use first network.
if api.neutron.is_port_profiles_supported():
net_id = context['network_id'][0]
LOG.debug("Horizon->Create Port with %(netid)s %(profile_id)s",
{'netid': net_id, 'profile_id': context['profile_id']})
port = None
try:
- port = api.neutron.port_create(request, net_id,
- policy_profile_id=
- context['profile_id'])
+ port = api.neutron.port_create(
+ request, net_id, policy_profile_id=context['profile_id'])
except Exception:
msg = (_('Port not created for profile-id (%s).') %
context['profile_id'])
diff --git a/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py
index 7e1c637729..fbd49ef996 100644
--- a/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py
+++ b/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py
@@ -21,9 +21,7 @@ from django.views.decorators.debug import sensitive_variables # noqa
from horizon import exceptions
from horizon import forms
from horizon import workflows
-
from openstack_dashboard import api
-
from openstack_dashboard.dashboards.project.instances \
import utils as instance_utils
from openstack_dashboard.dashboards.project.instances.workflows \
@@ -32,11 +30,11 @@ from openstack_dashboard.dashboards.project.instances.workflows \
class SetFlavorChoiceAction(workflows.Action):
old_flavor_id = forms.CharField(required=False, widget=forms.HiddenInput())
- old_flavor_name = forms.CharField(label=_("Old Flavor"),
- required=False,
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
+ old_flavor_name = forms.CharField(
+ label=_("Old Flavor"),
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ required=False,
+ )
flavor = forms.ChoiceField(label=_("New Flavor"),
help_text=_("Choose the flavor to launch."))
diff --git a/openstack_dashboard/dashboards/project/network_topology/instances/tables.py b/openstack_dashboard/dashboards/project/network_topology/instances/tables.py
index 24cb2ad30e..a643d67d66 100644
--- a/openstack_dashboard/dashboards/project/network_topology/instances/tables.py
+++ b/openstack_dashboard/dashboards/project/network_topology/instances/tables.py
@@ -13,11 +13,14 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
-from openstack_dashboard.dashboards.project.instances import tables as i_tables
+
+from openstack_dashboard.dashboards.project.instances import tables
-class InstancesTable(i_tables.InstancesTable):
+class InstancesTable(tables.InstancesTable):
class Meta:
name = "instances"
verbose_name = _("Instances")
- row_actions = (i_tables.TerminateInstance,)
+ row_actions = (
+ tables.TerminateInstance,
+ )
diff --git a/openstack_dashboard/dashboards/project/network_topology/ports/tables.py b/openstack_dashboard/dashboards/project/network_topology/ports/tables.py
index 3cdfa260f5..75741c458d 100644
--- a/openstack_dashboard/dashboards/project/network_topology/ports/tables.py
+++ b/openstack_dashboard/dashboards/project/network_topology/ports/tables.py
@@ -14,15 +14,15 @@
from django.utils.translation import ugettext_lazy as _
-from openstack_dashboard.dashboards.project.routers.ports import\
- tables as p_tables
+
+from openstack_dashboard.dashboards.project.routers.ports import tables
-class RemoveInterface(p_tables.RemoveInterface):
+class RemoveInterface(tables.RemoveInterface):
failure_url = 'horizon:project:network_topology:router'
-class PortsTable(p_tables.PortsTable):
+class PortsTable(tables.PortsTable):
class Meta:
name = "interfaces"
verbose_name = _("Interfaces")
diff --git a/openstack_dashboard/dashboards/project/network_topology/routers/tables.py b/openstack_dashboard/dashboards/project/network_topology/routers/tables.py
index e9c0526897..0e8646e9ba 100644
--- a/openstack_dashboard/dashboards/project/network_topology/routers/tables.py
+++ b/openstack_dashboard/dashboards/project/network_topology/routers/tables.py
@@ -13,15 +13,15 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
-from openstack_dashboard.dashboards.project.routers import\
- tables as r_tables
+
+from openstack_dashboard.dashboards.project.routers import tables
-class DeleteRouter(r_tables.DeleteRouter):
+class DeleteRouter(tables.DeleteRouter):
redirect_url = "horizon:project:network_topology:router"
-class RoutersTable(r_tables.RoutersTable):
+class RoutersTable(tables.RoutersTable):
class Meta:
name = "Routers"
verbose_name = _("Routers")
diff --git a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py
index 830ecba4c5..8a6a31268c 100644
--- a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py
@@ -95,8 +95,6 @@ class UpdateSubnetInfoAction(CreateSubnetInfoAction):
# Thus now I use HiddenInput for the ip_version ChoiceField as a work
# around.
ip_version = forms.ChoiceField(choices=[(4, 'IPv4'), (6, 'IPv6')],
- #widget=forms.Select(
- # attrs={'disabled': 'disabled'}),
widget=forms.HiddenInput(),
label=_("IP Version"))
@@ -174,10 +172,9 @@ class UpdateSubnet(network_workflows.CreateNetwork):
elif data['gateway_ip']:
params['gateway_ip'] = data['gateway_ip']
- #We should send gateway_ip only when it is changed,
- #because updating gateway_ip is prohibited
- #when the ip is used.
- #see bug 1227268
+ # We should send gateway_ip only when it is changed, because
+ # updating gateway_ip is prohibited when the ip is used.
+ # See bug 1227268.
subnet = api.neutron.subnet_get(request, subnet_id)
if params['gateway_ip'] == subnet.gateway_ip:
del params['gateway_ip']
diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py
index 390214f971..b23e754dbc 100644
--- a/openstack_dashboard/dashboards/project/networks/tests.py
+++ b/openstack_dashboard/dashboards/project/networks/tests.py
@@ -411,7 +411,8 @@ class NetworkTests(test.TestCase):
'profile_list')})
def test_network_create_post_with_subnet_network_exception(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
@@ -449,7 +450,8 @@ class NetworkTests(test.TestCase):
'profile_list')})
def test_network_create_post_with_subnet_subnet_exception(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
network = self.networks.first()
subnet = self.subnets.first()
params = {'name': network.name,
@@ -518,12 +520,14 @@ class NetworkTests(test.TestCase):
@override_settings(OPENSTACK_NEUTRON_NETWORK={'profile_support': 'cisco'})
def test_nw_create_post_w_subnet_no_cidr_w_profile(self):
- self.test_network_create_post_with_subnet_nocidr(test_with_profile=True)
+ self.test_network_create_post_with_subnet_nocidr(
+ test_with_profile=True)
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_cidr_without_mask(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
@@ -554,7 +558,8 @@ class NetworkTests(test.TestCase):
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_cidr_inconsistent(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
@@ -587,7 +592,8 @@ class NetworkTests(test.TestCase):
@test.create_stubs({api.neutron: ('profile_list',)})
def test_network_create_post_with_subnet_gw_inconsistent(
self,
- test_with_profile=False):
+ test_with_profile=False,
+ ):
network = self.networks.first()
subnet = self.subnets.first()
if test_with_profile:
diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py
index 039a1c6fd3..fd896f2585 100644
--- a/openstack_dashboard/dashboards/project/networks/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/workflows.py
@@ -14,16 +14,15 @@
import logging
-import netaddr
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
+import netaddr
from horizon import exceptions
from horizon import forms
from horizon import messages
from horizon import workflows
-
from openstack_dashboard import api
@@ -377,7 +376,6 @@ class CreateNetwork(workflows.Workflow):
redirect = self.get_failure_url()
messages.info(request, msg)
raise exceptions.Http302(redirect)
- #return exceptions.RecoverableError
except Exception:
msg = _('Failed to delete network "%s"') % network.name
LOG.info(msg)
diff --git a/openstack_dashboard/dashboards/project/routers/tables.py b/openstack_dashboard/dashboards/project/routers/tables.py
index 01fdbb8857..65fafc8c4b 100644
--- a/openstack_dashboard/dashboards/project/routers/tables.py
+++ b/openstack_dashboard/dashboards/project/routers/tables.py
@@ -17,13 +17,14 @@ import logging
from django.core.urlresolvers import reverse
from django.template.defaultfilters import title # noqa
from django.utils.translation import ugettext_lazy as _
+from neutronclient.common import exceptions as q_ext
from horizon import exceptions
from horizon import messages
from horizon import tables
-from neutronclient.common import exceptions as q_ext
from openstack_dashboard import api
+
LOG = logging.getLogger(__name__)
diff --git a/openstack_dashboard/dashboards/project/stacks/forms.py b/openstack_dashboard/dashboards/project/stacks/forms.py
index 3cbca28ce5..b14b937391 100644
--- a/openstack_dashboard/dashboards/project/stacks/forms.py
+++ b/openstack_dashboard/dashboards/project/stacks/forms.py
@@ -229,9 +229,7 @@ class ChangeTemplateForm(TemplateForm):
stack_id = forms.CharField(label=_('Stack ID'),
widget=forms.widgets.HiddenInput)
stack_name = forms.CharField(label=_('Stack Name'),
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}))
class CreateStackForm(forms.SelfHandlingForm):
@@ -358,9 +356,7 @@ class EditStackForm(CreateStackForm):
stack_id = forms.CharField(label=_('Stack ID'),
widget=forms.widgets.HiddenInput)
stack_name = forms.CharField(label=_('Stack Name'),
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ))
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}))
@sensitive_variables('password')
def handle(self, request, data):
diff --git a/openstack_dashboard/dashboards/project/stacks/views.py b/openstack_dashboard/dashboards/project/stacks/views.py
index f1c946182d..b247215a94 100644
--- a/openstack_dashboard/dashboards/project/stacks/views.py
+++ b/openstack_dashboard/dashboards/project/stacks/views.py
@@ -13,20 +13,18 @@
import json
import logging
+from django.core.urlresolvers import reverse
+from django.core.urlresolvers import reverse_lazy
+from django.http import HttpResponse # noqa
+from django.utils.translation import ugettext_lazy as _
+import django.views.generic
+
from horizon import exceptions
from horizon import forms
from horizon import tables
from horizon import tabs
from horizon.utils import memoized
-
-from django.core.urlresolvers import reverse
-from django.core.urlresolvers import reverse_lazy
-from django.http import HttpResponse # noqa
-from django.utils.translation import ugettext_lazy as _
-from django.views import generic
-
from openstack_dashboard import api
-
from openstack_dashboard.dashboards.project.stacks \
import api as project_api
from openstack_dashboard.dashboards.project.stacks \
@@ -246,7 +244,7 @@ class ResourceView(tabs.TabView):
request, resource=resource, metadata=metadata, **kwargs)
-class JSONView(generic.View):
+class JSONView(django.views.generic.View):
def get(self, request, stack_id=''):
return HttpResponse(project_api.d3_data(request, stack_id=stack_id),
content_type="application/json")
diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/volumes/forms.py
index 9a3ffd44ad..15cc9ba645 100644
--- a/openstack_dashboard/dashboards/project/volumes/volumes/forms.py
+++ b/openstack_dashboard/dashboards/project/volumes/volumes/forms.py
@@ -490,14 +490,16 @@ class UpdateForm(forms.SelfHandlingForm):
class ExtendForm(forms.SelfHandlingForm):
- name = forms.CharField(label=_("Volume Name"),
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ), required=False)
- orig_size = forms.IntegerField(label=_("Current Size (GB)"),
- widget=forms.TextInput(
- attrs={'readonly': 'readonly'}
- ), required=False)
+ name = forms.CharField(
+ label=_("Volume Name"),
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ required=False,
+ )
+ orig_size = forms.IntegerField(
+ label=_("Current Size (GB)"),
+ widget=forms.TextInput(attrs={'readonly': 'readonly'}),
+ required=False,
+ )
new_size = forms.IntegerField(label=_("New Size (GB)"))
def clean(self):
diff --git a/openstack_dashboard/dashboards/router/nexus1000v/forms.py b/openstack_dashboard/dashboards/router/nexus1000v/forms.py
index 8e06a6ba06..a84511d001 100644
--- a/openstack_dashboard/dashboards/router/nexus1000v/forms.py
+++ b/openstack_dashboard/dashboards/router/nexus1000v/forms.py
@@ -195,15 +195,14 @@ class UpdateNetworkProfile(forms.SelfHandlingForm):
try:
LOG.debug('request = %(req)s, params = %(params)s',
{'req': request, 'params': data})
- profile = api.neutron.profile_update(request,
- data['profile_id'],
- name=data['name'],
- segment_type=
- data['segment_type'],
- segment_range=
- data['segment_range'],
- physical_network=
- data['physical_network'])
+ profile = api.neutron.profile_update(
+ request,
+ data['profile_id'],
+ name=data['name'],
+ segment_type=data['segment_type'],
+ segment_range=data['segment_range'],
+ physical_network=data['physical_network'],
+ )
msg = _('Network Profile %s '
'was successfully updated.') % data['profile_id']
LOG.debug(msg)
diff --git a/openstack_dashboard/dashboards/router/nexus1000v/urls.py b/openstack_dashboard/dashboards/router/nexus1000v/urls.py
index 45b7c39705..7a370d6a8f 100644
--- a/openstack_dashboard/dashboards/router/nexus1000v/urls.py
+++ b/openstack_dashboard/dashboards/router/nexus1000v/urls.py
@@ -18,13 +18,13 @@ from django.conf.urls import url # noqa
from openstack_dashboard.dashboards.router.nexus1000v import views
+
urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
- #Network Profile
+ # Network Profile
url(r'^network_profile/create$', views.CreateNetworkProfileView.as_view(),
name='create_network_profile'),
url(r'^network_profile/(?P[^/]+)/update$',
views.UpdateNetworkProfileView.as_view(),
name='update_network_profile'),
-
)
diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py
index e953d88725..505a564434 100644
--- a/openstack_dashboard/dashboards/settings/user/forms.py
+++ b/openstack_dashboard/dashboards/settings/user/forms.py
@@ -13,7 +13,6 @@
# under the License.
from datetime import datetime # noqa
-import pytz
import string
from django.conf import settings
@@ -21,6 +20,7 @@ from django import shortcuts
from django.utils import encoding
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
+import pytz
from horizon import forms
from horizon import messages
diff --git a/openstack_dashboard/dashboards/settings/user/views.py b/openstack_dashboard/dashboards/settings/user/views.py
index bd551f74bc..37d4742d08 100644
--- a/openstack_dashboard/dashboards/settings/user/views.py
+++ b/openstack_dashboard/dashboards/settings/user/views.py
@@ -13,9 +13,9 @@
# under the License.
from django.conf import settings
+
from horizon import forms
from horizon.utils import functions as utils
-
from openstack_dashboard.dashboards.settings.user import forms as user_forms
diff --git a/openstack_dashboard/policy.py b/openstack_dashboard/policy.py
index 93ea1e3f33..f51cde99fe 100644
--- a/openstack_dashboard/policy.py
+++ b/openstack_dashboard/policy.py
@@ -19,13 +19,12 @@ import logging
import os.path
from django.conf import settings
-
+from openstack_auth import utils as auth_utils
from oslo.config import cfg
-from openstack_auth import utils as auth_utils
-
from openstack_dashboard.openstack.common import policy
+
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
diff --git a/openstack_dashboard/test/api_tests/ceilometer_tests.py b/openstack_dashboard/test/api_tests/ceilometer_tests.py
index 1d72441731..ffcbbf64dc 100644
--- a/openstack_dashboard/test/api_tests/ceilometer_tests.py
+++ b/openstack_dashboard/test/api_tests/ceilometer_tests.py
@@ -158,8 +158,7 @@ class CeilometerApiTests(test.APITestCase):
self.assertIn(ret.name, names)
names.remove(ret.name)
- #TODO(lsmola)
- #test resource aggregates
+ # TODO(lsmola) Test resource aggregates.
@test.create_stubs({api.ceilometer.CeilometerUsage: ("get_user",
"get_tenant")})
diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py
index 8954a17ecf..6d65ef0d37 100644
--- a/openstack_dashboard/test/helpers.py
+++ b/openstack_dashboard/test/helpers.py
@@ -19,6 +19,8 @@
from functools import wraps # noqa
import os
+from ceilometerclient.v2 import client as ceilometer_client
+from cinderclient import client as cinder_client
from django.conf import settings
from django.contrib.auth.middleware import AuthenticationMiddleware # noqa
from django.contrib.messages.storage import default_storage # noqa
@@ -28,30 +30,23 @@ from django import http
from django.test.client import RequestFactory # noqa
from django.utils.importlib import import_module # noqa
from django.utils import unittest
-
-from ceilometerclient.v2 import client as ceilometer_client
-from cinderclient import client as cinder_client
import glanceclient
from heatclient import client as heat_client
+import httplib2
from keystoneclient.v2_0 import client as keystone_client
+import mox
from neutronclient.v2_0 import client as neutron_client
from novaclient.v1_1 import client as nova_client
+from openstack_auth import user
+from openstack_auth import utils
from saharaclient import client as sahara_client
from swiftclient import client as swift_client
from troveclient import client as trove_client
-
-import httplib2
-import mox
-
-from openstack_auth import user
-from openstack_auth import utils
-
from horizon import base
from horizon import conf
from horizon import middleware
from horizon.test import helpers as horizon_helpers
-
from openstack_dashboard import api
from openstack_dashboard import context_processors
from openstack_dashboard.test.test_data import utils as test_utils
@@ -103,8 +98,9 @@ class RequestFactoryWithMessages(RequestFactory):
@unittest.skipIf(os.environ.get('SKIP_UNITTESTS', False),
"The SKIP_UNITTESTS env variable is set.")
class TestCase(horizon_helpers.TestCase):
- """Specialized base test case class for Horizon which gives access to
- numerous additional features:
+ """Specialized base test case class for Horizon.
+
+ It gives access to numerous additional features:
* A full suite of test data through various attached objects and
managers (e.g. ``self.servers``, ``self.user``, etc.). See the
@@ -175,7 +171,9 @@ class TestCase(horizon_helpers.TestCase):
utils.get_user = get_user
def assertRedirectsNoFollow(self, response, expected_url):
- """Asserts that the given response issued a 302 redirect without
+ """Check for redirect.
+
+ Asserts that the given response issued a 302 redirect without
processing the view which is redirected to.
"""
assert (response.status_code / 100 == 3), \
@@ -185,7 +183,9 @@ class TestCase(horizon_helpers.TestCase):
self.assertEqual(response.status_code, 302)
def assertNoFormErrors(self, response, context_name="form"):
- """Asserts that the response either does not contain a form in its
+ """Checks for no form errors.
+
+ Asserts that the response either does not contain a form in its
context, or that if it does, that form has no errors.
"""
context = getattr(response, "context", {})
@@ -197,7 +197,9 @@ class TestCase(horizon_helpers.TestCase):
def assertFormErrors(self, response, count=0, message=None,
context_name="form"):
- """Asserts that the response does contain a form in its
+ """Check for form errors.
+
+ Asserts that the response does contain a form in its
context, and that form has errors, if count were given,
it must match the exact numbers of errors
"""
@@ -218,8 +220,9 @@ class TestCase(horizon_helpers.TestCase):
class BaseAdminViewTests(TestCase):
- """A ``TestCase`` subclass which sets an active user with the "admin" role
- for testing admin-only views and functionality.
+ """Sets an active user with the "admin" role.
+
+ For testing admin-only views and functionality.
"""
def setActiveUser(self, *args, **kwargs):
if "roles" not in kwargs:
@@ -239,17 +242,19 @@ class BaseAdminViewTests(TestCase):
class APITestCase(TestCase):
- """The ``APITestCase`` class is for use with tests which deal with the
- underlying clients rather than stubbing out the
- openstack_dashboard.api.* methods.
+ """Testing APIs.
+
+ For use with tests which deal with the underlying clients rather than
+ stubbing out the openstack_dashboard.api.* methods.
"""
def setUp(self):
super(APITestCase, self).setUp()
utils.patch_middleware_get_user()
def fake_keystoneclient(request, admin=False):
- """Wrapper function which returns the stub keystoneclient. Only
- necessary because the function takes too many arguments to
+ """Returns the stub keystoneclient.
+
+ Only necessary because the function takes too many arguments to
conveniently be a lambda.
"""
return self.stub_keystoneclient()
@@ -410,8 +415,10 @@ class SeleniumTestCase(horizon_helpers.SeleniumTestCase):
class SeleniumAdminTestCase(SeleniumTestCase):
- """A ``TestCase`` subclass which sets an active user with the "admin" role
- for testing admin-only views and functionality.
+ """Version of AdminTestCase for Selenium.
+
+ Sets an active user with the "admin" role for testing admin-only views and
+ functionality.
"""
def setActiveUser(self, *args, **kwargs):
if "roles" not in kwargs:
@@ -429,9 +436,11 @@ def my_custom_sort(flavor):
class PluginTestCase(TestCase):
- """The ``PluginTestCase`` class is for use with tests which deal with the
- pluggable dashboard and panel configuration, it takes care of backing up
- and restoring the Horizon configuration.
+ """Test case for testing plugin system of Horizon.
+
+ For use with tests which deal with the pluggable dashboard and panel
+ configuration, it takes care of backing up and restoring the Horizon
+ configuration.
"""
def setUp(self):
super(PluginTestCase, self).setUp()
@@ -469,7 +478,9 @@ class PluginTestCase(TestCase):
self._reload_urls()
def _reload_urls(self):
- """Clears out the URL caches, reloads the root urls module, and
+ """CLeans up URLs.
+
+ Clears out the URL caches, reloads the root urls module, and
re-triggers the autodiscovery mechanism for Horizon. Allows URLs
to be re-calculated after registering new dashboards. Useful
only for testing and should never be used on a live site.
diff --git a/openstack_dashboard/test/integration_tests/pages/pageobject.py b/openstack_dashboard/test/integration_tests/pages/pageobject.py
index 878dd7ca0e..f59ce41715 100644
--- a/openstack_dashboard/test/integration_tests/pages/pageobject.py
+++ b/openstack_dashboard/test/integration_tests/pages/pageobject.py
@@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-#TODO(dkorn): add handle_popup method
+# TODO(dkorn): add handle_popup method
import selenium.common.exceptions as Exceptions
import selenium.webdriver.support.ui as Support
@@ -19,7 +19,7 @@ import selenium.webdriver.support.ui as Support
class PageObject(object):
"""Base class for page objects."""
def __init__(self, driver, conf):
- """Constructor"""
+ """Constructor."""
self.driver = driver
self.conf = conf
self.login_url = self.conf.dashboard.login_url
diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py
index 8a699efaa1..a827414dd6 100644
--- a/openstack_dashboard/test/settings.py
+++ b/openstack_dashboard/test/settings.py
@@ -14,7 +14,6 @@ import os
from horizon.test.settings import * # noqa
from horizon.utils import secret_key
-
from openstack_dashboard import exceptions
@@ -109,7 +108,7 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_quotas': False, # Enabled in specific tests only
'enable_vpn': True,
'profile_support': None,
- #'profile_support': 'cisco'
+ # 'profile_support': 'cisco'
}
OPENSTACK_HYPERVISOR_FEATURES = {
diff --git a/openstack_dashboard/test/test_data/ceilometer_data.py b/openstack_dashboard/test/test_data/ceilometer_data.py
index c278e7f41d..49b5d873a7 100644
--- a/openstack_dashboard/test/test_data/ceilometer_data.py
+++ b/openstack_dashboard/test/test_data/ceilometer_data.py
@@ -58,7 +58,7 @@ def data(TEST):
TEST.ceilometer_users.add(users.User(None,
ceilometer_user_dict2))
- #tenants
+ # Tenants.
tenant_dict = {'id': "1",
'name': 'test_tenant',
'description': "a test tenant.",
diff --git a/openstack_dashboard/test/test_data/cinder_data.py b/openstack_dashboard/test/test_data/cinder_data.py
index 3b0ce847aa..7dcd5a5797 100644
--- a/openstack_dashboard/test/test_data/cinder_data.py
+++ b/openstack_dashboard/test/test_data/cinder_data.py
@@ -39,31 +39,27 @@ def data(TEST):
TEST.cinder_availability_zones = utils.TestDataContainer()
# Services
- service_1 = services.Service(services.ServiceManager(None),
- {
- "service": "cinder-scheduler",
- "status": "enabled",
- "binary": "cinder-scheduler",
- "zone": "internal",
- "state": "up",
- "updated_at": "2013-07-08T05:21:00.000000",
- "host": "devstack001",
- "disabled_reason": None
- }
- )
+ service_1 = services.Service(services.ServiceManager(None), {
+ "service": "cinder-scheduler",
+ "status": "enabled",
+ "binary": "cinder-scheduler",
+ "zone": "internal",
+ "state": "up",
+ "updated_at": "2013-07-08T05:21:00.000000",
+ "host": "devstack001",
+ "disabled_reason": None
+ })
- service_2 = services.Service(services.ServiceManager(None),
- {
- "service": "cinder-volume",
- "status": "enabled",
- "binary": "cinder-volume",
- "zone": "nova",
- "state": "up",
- "updated_at": "2013-07-08T05:20:51.000000",
- "host": "devstack001",
- "disabled_reason": None
- }
- )
+ service_2 = services.Service(services.ServiceManager(None), {
+ "service": "cinder-volume",
+ "status": "enabled",
+ "binary": "cinder-volume",
+ "zone": "nova",
+ "state": "up",
+ "updated_at": "2013-07-08T05:20:51.000000",
+ "host": "devstack001",
+ "disabled_reason": None
+ })
TEST.cinder_services.add(service_1)
TEST.cinder_services.add(service_2)
diff --git a/openstack_dashboard/test/test_data/heat_data.py b/openstack_dashboard/test/test_data/heat_data.py
index 34f71ae832..a949b21239 100644
--- a/openstack_dashboard/test/test_data/heat_data.py
+++ b/openstack_dashboard/test/test_data/heat_data.py
@@ -340,8 +340,8 @@ def data(TEST):
"parameters": {
'DBUsername': '******',
'InstanceType': 'm1.small',
- 'AWS::StackId':
- 'arn:openstack:heat::2ce287:stacks/teststack/88553ec',
+ 'AWS::StackId': (
+ 'arn:openstack:heat::2ce287:stacks/teststack/88553ec'),
'DBRootPassword': '******',
'AWS::StackName': "teststack{0}".format(i),
'DBPassword': '******',
diff --git a/openstack_dashboard/test/test_data/neutron_data.py b/openstack_dashboard/test/test_data/neutron_data.py
index 2b1eafff8b..f7221998b5 100644
--- a/openstack_dashboard/test/test_data/neutron_data.py
+++ b/openstack_dashboard/test/test_data/neutron_data.py
@@ -20,12 +20,11 @@ from openstack_dashboard.api import fwaas
from openstack_dashboard.api import lbaas
from openstack_dashboard.api import neutron
from openstack_dashboard.api import vpn
-
from openstack_dashboard.test.test_data import utils
def data(TEST):
- # data returned by openstack_dashboard.api.neutron wrapper
+ # Data returned by openstack_dashboard.api.neutron wrapper.
TEST.agents = utils.TestDataContainer()
TEST.networks = utils.TestDataContainer()
TEST.subnets = utils.TestDataContainer()
@@ -53,7 +52,7 @@ def data(TEST):
TEST.fw_policies = utils.TestDataContainer()
TEST.fw_rules = utils.TestDataContainer()
- # data return by neutronclient
+ # Data return by neutronclient.
TEST.api_agents = utils.TestDataContainer()
TEST.api_networks = utils.TestDataContainer()
TEST.api_subnets = utils.TestDataContainer()
@@ -79,8 +78,7 @@ def data(TEST):
TEST.api_fw_policies = utils.TestDataContainer()
TEST.api_fw_rules = utils.TestDataContainer()
- #------------------------------------------------------------
- # 1st network
+ # 1st network.
network_dict = {'admin_state_up': True,
'id': '82288d84-e0a5-42ac-95be-e6af08727e42',
'name': 'net1',
@@ -111,7 +109,7 @@ def data(TEST):
TEST.networks.add(neutron.Network(network))
TEST.subnets.add(subnet)
- # network profile for network when using the cisco n1k plugin
+ # Network profile for network when using the cisco n1k plugin.
net_profile_dict = {'name': 'net_profile_test1',
'segment_type': 'vlan',
'physical_network': 'phys1',
@@ -123,7 +121,7 @@ def data(TEST):
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
- # policy profile for port when using the cisco n1k plugin
+ # Policy profile for port when using the cisco n1k plugin.
policy_profile_dict = {'name': 'policy_profile_test1',
'id':
'00000000-9999-9999-9999-000000000000'}
@@ -131,7 +129,7 @@ def data(TEST):
TEST.api_policy_profiles.add(policy_profile_dict)
TEST.policy_profiles.add(neutron.Profile(policy_profile_dict))
- # network profile binding
+ # Network profile binding.
network_profile_binding_dict = {'profile_id':
'00000000-1111-1111-1111-000000000000',
'tenant_id': network_dict['tenant_id']}
@@ -140,7 +138,7 @@ def data(TEST):
TEST.network_profile_binding.add(neutron.Profile(
network_profile_binding_dict))
- # policy profile binding
+ # Policy profile binding.
policy_profile_binding_dict = {'profile_id':
'00000000-9999-9999-9999-000000000000',
'tenant_id': network_dict['tenant_id']}
@@ -149,7 +147,7 @@ def data(TEST):
TEST.policy_profile_binding.add(neutron.Profile(
policy_profile_binding_dict))
- # ports on 1st network
+ # Ports on 1st network.
port_dict = {'admin_state_up': True,
'device_id': 'af75c8e5-a1cc-4567-8d04-44fcd6922890',
'device_owner': 'network:dhcp',
@@ -179,8 +177,7 @@ def data(TEST):
TEST.ports.add(neutron.Port(port_dict))
assoc_port = port_dict
- #------------------------------------------------------------
- # 2nd network
+ # 2nd network.
network_dict = {'admin_state_up': True,
'id': '72c3ab6c-c80f-4341-9dc5-210fa31ac6c2',
'name': 'net2',
@@ -229,8 +226,7 @@ def data(TEST):
TEST.api_ports.add(port_dict)
TEST.ports.add(neutron.Port(port_dict))
- #------------------------------------------------------------
- # external network
+ # External network.
network_dict = {'admin_state_up': True,
'id': '9b466b94-213a-4cda-badf-72c102a874da',
'name': 'ext_net',
@@ -262,8 +258,7 @@ def data(TEST):
TEST.networks.add(neutron.Network(network))
TEST.subnets.add(subnet)
- #------------------------------------------------------------
- # Set up router data
+ # Set up router data.
port_dict = {'admin_state_up': True,
'device_id': '7180cede-bcd8-4334-b19f-f7ef2f331f53',
'device_owner': 'network:router_gateway',
@@ -310,9 +305,8 @@ def data(TEST):
TEST.api_routers.add(router_dict)
TEST.routers_with_rules.add(neutron.Router(router_dict))
- #------------------------------------------------------------
- # floating IP
- # unassociated
+ # Floating IP.
+ # Unassociated.
fip_dict = {'tenant_id': '1',
'floating_ip_address': '172.16.88.227',
'floating_network_id': ext_net['id'],
@@ -323,7 +317,7 @@ def data(TEST):
TEST.api_q_floating_ips.add(fip_dict)
TEST.q_floating_ips.add(neutron.FloatingIp(fip_dict))
- # associated (with compute port on 1st network)
+ # Associated (with compute port on 1st network).
fip_dict = {'tenant_id': '1',
'floating_ip_address': '172.16.88.228',
'floating_network_id': ext_net['id'],
@@ -334,8 +328,7 @@ def data(TEST):
TEST.api_q_floating_ips.add(fip_dict)
TEST.q_floating_ips.add(neutron.FloatingIp(fip_dict))
- #------------------------------------------------------------
- # security group
+ # Security group.
sec_group_1 = {'tenant_id': '1',
'description': 'default',
@@ -414,21 +407,20 @@ def data(TEST):
groups = [sec_group_1, sec_group_2, sec_group_3]
sg_name_dict = dict([(sg['id'], sg['name']) for sg in groups])
for sg in groups:
- # Neutron API
+ # Neutron API.
TEST.api_q_secgroups.add(sg)
for rule in sg['security_group_rules']:
TEST.api_q_secgroup_rules.add(copy.copy(rule))
- # OpenStack Dashboard internaly API
+ # OpenStack Dashboard internaly API.
TEST.q_secgroups.add(
neutron.SecurityGroup(copy.deepcopy(sg), sg_name_dict))
for rule in sg['security_group_rules']:
TEST.q_secgroup_rules.add(
neutron.SecurityGroupRule(copy.copy(rule), sg_name_dict))
- #------------------------------------------------------------
- # LBaaS
+ # LBaaS.
- # 1st pool
+ # 1st pool.
pool_dict = {'id': '8913dde8-4915-4b90-8d3e-b95eeedb0d49',
'tenant_id': '1',
'vip_id': 'abcdef-c3eb-4fee-9763-12de3338041e',
@@ -445,7 +437,7 @@ def data(TEST):
TEST.api_pools.add(pool_dict)
TEST.pools.add(lbaas.Pool(pool_dict))
- # 2nd pool
+ # 2nd pool.
pool_dict = {'id': '8913dde8-4915-4b90-8d3e-b95eeedb0d50',
'tenant_id': '1',
'vip_id': 'f0881d38-c3eb-4fee-9763-12de3338041d',
@@ -461,7 +453,7 @@ def data(TEST):
TEST.api_pools.add(pool_dict)
TEST.pools.add(lbaas.Pool(pool_dict))
- # 1st vip
+ # 1st vip.
vip_dict = {'id': 'abcdef-c3eb-4fee-9763-12de3338041e',
'name': 'vip1',
'address': '10.0.0.100',
@@ -481,7 +473,7 @@ def data(TEST):
TEST.api_vips.add(vip_dict)
TEST.vips.add(lbaas.Vip(vip_dict))
- # 2nd vip
+ # 2nd vip.
vip_dict = {'id': 'f0881d38-c3eb-4fee-9763-12de3338041d',
'name': 'vip2',
'address': '10.0.0.110',
@@ -501,7 +493,7 @@ def data(TEST):
TEST.api_vips.add(vip_dict)
TEST.vips.add(lbaas.Vip(vip_dict))
- # 1st member
+ # 1st member.
member_dict = {'id': '78a46e5e-eb1a-418a-88c7-0e3f5968b08',
'tenant_id': '1',
'pool_id': pool_dict['id'],
@@ -513,7 +505,7 @@ def data(TEST):
TEST.api_members.add(member_dict)
TEST.members.add(lbaas.Member(member_dict))
- # 2nd member
+ # 2nd member.
member_dict = {'id': '41ac1f8d-6d9c-49a4-a1bf-41955e651f91',
'tenant_id': '1',
'pool_id': pool_dict['id'],
@@ -525,7 +517,7 @@ def data(TEST):
TEST.api_members.add(member_dict)
TEST.members.add(lbaas.Member(member_dict))
- # 1st monitor
+ # 1st monitor.
monitor_dict = {'id': 'd4a0500f-db2b-4cc4-afcf-ec026febff96',
'type': 'http',
'delay': 10,
@@ -541,7 +533,7 @@ def data(TEST):
TEST.api_monitors.add(monitor_dict)
TEST.monitors.add(lbaas.PoolMonitor(monitor_dict))
- # 2nd monitor
+ # 2nd monitor.
monitor_dict = {'id': 'd4a0500f-db2b-4cc4-afcf-ec026febff97',
'type': 'ping',
'delay': 10,
@@ -553,8 +545,7 @@ def data(TEST):
TEST.api_monitors.add(monitor_dict)
TEST.monitors.add(lbaas.PoolMonitor(monitor_dict))
- #------------------------------------------------------------
- # Quotas
+ # Quotas.
quota_data = {'network': '10',
'subnet': '10',
'port': '50',
@@ -565,8 +556,7 @@ def data(TEST):
}
TEST.neutron_quotas.add(base.QuotaSet(quota_data))
- #------------------------------------------------------------
- # Extensions
+ # Extensions.
extension_1 = {"name": "security-group",
"alias": "security-group",
"description": "The security groups extension."}
@@ -576,8 +566,7 @@ def data(TEST):
TEST.api_extensions.add(extension_1)
TEST.api_extensions.add(extension_2)
- #------------------------------------------------------------
- # 1st agent
+ # 1st agent.
agent_dict = {"binary": "neutron-openvswitch-agent",
"description": None,
"admin_state_up": True,
@@ -593,7 +582,7 @@ def data(TEST):
TEST.api_agents.add(agent_dict)
TEST.agents.add(neutron.Agent(agent_dict))
- # 2nd agent
+ # 2nd agent.
agent_dict = {"binary": "neutron-dhcp-agent",
"description": None,
"admin_state_up": True,
@@ -615,17 +604,15 @@ def data(TEST):
TEST.api_agents.add(agent_dict)
TEST.agents.add(neutron.Agent(agent_dict))
- #------------------------------------------------------------
- # Service providers
+ # Service providers.
provider_1 = {"service_type": "LOADBALANCER",
"name": "haproxy",
"default": True}
TEST.providers.add(provider_1)
- #------------------------------------------------------------
- # VPNaaS
+ # VPNaaS.
- # 1st VPNService
+ # 1st VPNService.
vpnservice_dict = {'id': '09a26949-6231-4f72-942a-0c8c0ddd4d61',
'tenant_id': '1',
'name': 'cloud_vpn1',
@@ -640,7 +627,7 @@ def data(TEST):
TEST.api_vpnservices.add(vpnservice_dict)
TEST.vpnservices.add(vpn.VPNService(vpnservice_dict))
- # 2nd VPNService
+ # 2nd VPNService.
vpnservice_dict = {'id': '09a26949-6231-4f72-942a-0c8c0ddd4d62',
'tenant_id': '1',
'name': 'cloud_vpn2',
@@ -892,11 +879,10 @@ def data(TEST):
fw2._apidict['policy'] = policy1
TEST.firewalls.add(fw1)
- #------------------------------------------------------------
- # Additional Cisco N1K profiles
+ # Additional Cisco N1K profiles.
- # 2nd network profile for network when using the cisco n1k plugin
- # Profile applied on 1st network
+ # 2nd network profile for network when using the cisco n1k plugin.
+ # Profile applied on 1st network.
net_profile_dict = {'name': 'net_profile_test2',
'segment_type': 'overlay',
'sub_type': 'native_vxlan',
@@ -909,7 +895,7 @@ def data(TEST):
TEST.api_net_profiles.add(net_profile_dict)
TEST.net_profiles.add(neutron.Profile(net_profile_dict))
- # 2nd network profile binding
+ # 2nd network profile binding.
network_profile_binding_dict = {'profile_id':
'00000000-2222-2222-2222-000000000000',
'tenant_id': '1'}
diff --git a/openstack_dashboard/test/test_data/nova_data.py b/openstack_dashboard/test/test_data/nova_data.py
index ff1f6ba19a..2c14da6f8d 100644
--- a/openstack_dashboard/test/test_data/nova_data.py
+++ b/openstack_dashboard/test/test_data/nova_data.py
@@ -545,26 +545,25 @@ def data(TEST):
TEST.certs.add(certificate)
# Availability Zones
- TEST.availability_zones.add(
- availability_zones.AvailabilityZone(
- availability_zones.AvailabilityZoneManager(None),
- {
- 'zoneName': 'nova',
- 'zoneState': {'available': True},
- 'hosts': {
- "host001": {
- "nova-network": {
- "active": True,
- "available": True
- }
- }
- }
- }
- )
- )
+ TEST.availability_zones.add(availability_zones.AvailabilityZone(
+ availability_zones.AvailabilityZoneManager(None),
+ {
+ 'zoneName': 'nova',
+ 'zoneState': {'available': True},
+ 'hosts': {
+ "host001": {
+ "nova-network": {
+ "active": True,
+ "available": True,
+ },
+ },
+ },
+ },
+ ))
# hypervisors
- hypervisor_1 = hypervisors.Hypervisor(hypervisors.HypervisorManager(None),
+ hypervisor_1 = hypervisors.Hypervisor(
+ hypervisors.HypervisorManager(None),
{
"service": {"host": "devstack001", "id": 3},
"vcpus_used": 1,
@@ -585,11 +584,12 @@ def data(TEST):
"disk_available_least": 6,
"local_gb": 29,
"free_ram_mb": 500,
- "id": 1
- }
+ "id": 1,
+ },
)
- hypervisor_2 = hypervisors.Hypervisor(hypervisors.HypervisorManager(None),
+ hypervisor_2 = hypervisors.Hypervisor(
+ hypervisors.HypervisorManager(None),
{
"service": {"host": "devstack002", "id": 4},
"vcpus_used": 1,
@@ -610,10 +610,11 @@ def data(TEST):
"disk_available_least": 6,
"local_gb": 29,
"free_ram_mb": 500,
- "id": 2
- }
+ "id": 2,
+ },
)
- hypervisor_3 = hypervisors.Hypervisor(hypervisors.HypervisorManager(None),
+ hypervisor_3 = hypervisors.Hypervisor(
+ hypervisors.HypervisorManager(None),
{
"service": {"host": "instance-host", "id": 5},
"vcpus_used": 1,
@@ -634,8 +635,8 @@ def data(TEST):
"disk_available_least": 6,
"local_gb": 29,
"free_ram_mb": 500,
- "id": 3
- }
+ "id": 3,
+ },
)
TEST.hypervisors.add(hypervisor_1)
TEST.hypervisors.add(hypervisor_2)
@@ -654,98 +655,78 @@ def data(TEST):
"disk_available_least": 12556,
"local_gb": 12563,
"free_ram_mb": 428014,
- "memory_mb_used": 55296
+ "memory_mb_used": 55296,
}
}
# Services
- service_1 = services.Service(services.ServiceManager(None),
- {
- "status": "enabled",
- "binary": "nova-conductor",
- "zone": "internal",
- "state": "up",
- "updated_at": "2013-07-08T05:21:00.000000",
- "host": "devstack001",
- "disabled_reason": None
- }
- )
+ service_1 = services.Service(services.ServiceManager(None), {
+ "status": "enabled",
+ "binary": "nova-conductor",
+ "zone": "internal",
+ "state": "up",
+ "updated_at": "2013-07-08T05:21:00.000000",
+ "host": "devstack001",
+ "disabled_reason": None,
+ })
- service_2 = services.Service(services.ServiceManager(None),
- {
- "status": "enabled",
- "binary": "nova-compute",
- "zone": "nova",
- "state": "up",
- "updated_at": "2013-07-08T05:20:51.000000",
- "host": "devstack001",
- "disabled_reason": None
- }
- )
+ service_2 = services.Service(services.ServiceManager(None), {
+ "status": "enabled",
+ "binary": "nova-compute",
+ "zone": "nova",
+ "state": "up",
+ "updated_at": "2013-07-08T05:20:51.000000",
+ "host": "devstack001",
+ "disabled_reason": None,
+ })
TEST.services.add(service_1)
TEST.services.add(service_2)
# Aggregates
- aggregate_1 = aggregates.Aggregate(aggregates.AggregateManager(None),
- {
- "name": "foo",
- "availability_zone": "testing",
- "deleted": 0,
- "created_at": "2013-07-04T13:34:38.000000",
- "updated_at": None,
- "hosts": ["foo", "bar"],
- "deleted_at": None,
- "id": 1,
- "metadata": {
- "foo": "testing",
- "bar": "testing"
- }
- }
- )
+ aggregate_1 = aggregates.Aggregate(aggregates.AggregateManager(None), {
+ "name": "foo",
+ "availability_zone": "testing",
+ "deleted": 0,
+ "created_at": "2013-07-04T13:34:38.000000",
+ "updated_at": None,
+ "hosts": ["foo", "bar"],
+ "deleted_at": None,
+ "id": 1,
+ "metadata": {"foo": "testing", "bar": "testing"},
+ })
- aggregate_2 = aggregates.Aggregate(aggregates.AggregateManager(None),
- {
- "name": "bar",
- "availability_zone": "testing",
- "deleted": 0,
- "created_at": "2013-07-04T13:34:38.000000",
- "updated_at": None,
- "hosts": ["foo", "bar"],
- "deleted_at": None,
- "id": 2,
- "metadata": {
- "foo": "testing",
- "bar": "testing"
- }
- }
- )
+ aggregate_2 = aggregates.Aggregate(aggregates.AggregateManager(None), {
+ "name": "bar",
+ "availability_zone": "testing",
+ "deleted": 0,
+ "created_at": "2013-07-04T13:34:38.000000",
+ "updated_at": None,
+ "hosts": ["foo", "bar"],
+ "deleted_at": None,
+ "id": 2,
+ "metadata": {"foo": "testing", "bar": "testing"},
+ })
TEST.aggregates.add(aggregate_1)
TEST.aggregates.add(aggregate_2)
- host1 = hosts.Host(hosts.HostManager(None),
- {
- "host_name": "devstack001",
- "service": "compute",
- "zone": "testing"
- }
- )
+ host1 = hosts.Host(hosts.HostManager(None), {
+ "host_name": "devstack001",
+ "service": "compute",
+ "zone": "testing",
+ })
- host2 = hosts.Host(hosts.HostManager(None),
- {
- "host_name": "devstack002",
- "service": "nova-conductor",
- "zone": "testing"
- }
- )
+ host2 = hosts.Host(hosts.HostManager(None), {
+ "host_name": "devstack002",
+ "service": "nova-conductor",
+ "zone": "testing",
+ })
- host3 = hosts.Host(hosts.HostManager(None),
- {
- "host_name": "devstack003",
- "service": "compute",
- "zone": "testing"
- }
- )
+ host3 = hosts.Host(hosts.HostManager(None), {
+ "host_name": "devstack003",
+ "service": "compute",
+ "zone": "testing",
+ })
TEST.hosts.add(host1)
TEST.hosts.add(host2)
TEST.hosts.add(host3)
diff --git a/openstack_dashboard/test/test_data/sahara_data.py b/openstack_dashboard/test/test_data/sahara_data.py
index b83631db6f..420412f0f2 100644
--- a/openstack_dashboard/test/test_data/sahara_data.py
+++ b/openstack_dashboard/test/test_data/sahara_data.py
@@ -43,7 +43,7 @@ def data(TEST):
TEST.plugins.add(plugin1)
- #Nodegroup_Templates
+ # Nodegroup_Templates.
ngt1_dict = {
"created_at": "2014-06-04 14:01:03.701243",
"description": None,
@@ -74,7 +74,7 @@ def data(TEST):
TEST.nodegroup_templates.add(ngt1)
- #Cluster_templates
+ # Cluster_templates.
ct1_dict = {
"anti_affinity": [],
"cluster_configs": {},
@@ -135,7 +135,7 @@ def data(TEST):
cluster_templates.ClusterTemplateManager(None), ct1_dict)
TEST.cluster_templates.add(ct1)
- #Clusters
+ # Clusters.
cluster1_dict = {
"anti_affinity": [],
"cluster_configs": {},
@@ -238,7 +238,7 @@ def data(TEST):
clusters.ClusterManager(None), cluster1_dict)
TEST.clusters.add(cluster1)
- #Data Sources
+ # Data Sources.
data_source1_dict = {
"created_at": "2014-06-04 14:01:10.371562",
"description": "sample output",
@@ -268,7 +268,7 @@ def data(TEST):
TEST.data_sources.add(data_source1)
TEST.data_sources.add(data_source2)
- #Job Binaries
+ # Job Binaries.
job_binary1_dict = {
"created_at": "2014-06-05 18:15:15.581285",
"description": "",
@@ -283,7 +283,7 @@ def data(TEST):
job_binaries.JobBinariesManager(None), job_binary1_dict)
TEST.job_binaries.add(job_binary1)
- #Jobs
+ # Jobs.
job1_dict = {
"created_at": "2014-06-05 19:23:59.637165",
"description": "",
@@ -319,7 +319,7 @@ def data(TEST):
job1 = jobs.Job(jobs.JobsManager(None), job1_dict)
TEST.jobs.add(job1)
- #Job Executions
+ # Job Executions.
jobex1_dict = {
"cluster_id": "ec9a0d28-5cfb-4028-a0b5-40afe23f1533",
"created_at": "2014-06-05 20:03:06.195937",
diff --git a/openstack_dashboard/test/tests/templates.py b/openstack_dashboard/test/tests/templates.py
index 8b56960315..b8baf5ad1f 100644
--- a/openstack_dashboard/test/tests/templates.py
+++ b/openstack_dashboard/test/tests/templates.py
@@ -15,6 +15,7 @@
from django import template
from django.template import loader
+
from openstack_dashboard.test import helpers as test
diff --git a/openstack_dashboard/usage/base.py b/openstack_dashboard/usage/base.py
index f884d0c3f3..12593a3c12 100644
--- a/openstack_dashboard/usage/base.py
+++ b/openstack_dashboard/usage/base.py
@@ -140,10 +140,11 @@ class BaseUsage(object):
if not api.base.is_service_enabled(self.request, 'network'):
return
try:
- neutron_quotas_supported = \
- api.neutron.is_quotas_extension_supported(self.request)
- neutron_sg_used = \
- api.neutron.is_extension_supported(self.request, 'security-group')
+ neutron_quotas_supported = (
+ api.neutron.is_quotas_extension_supported(self.request))
+ neutron_sg_used = (
+ api.neutron.is_extension_supported(self.request,
+ 'security-group'))
self._get_neutron_usage(self.limits, 'floatingip')
if neutron_sg_used:
self._get_neutron_usage(self.limits, 'security_group')
diff --git a/openstack_dashboard/usage/quotas.py b/openstack_dashboard/usage/quotas.py
index 79f09a91d6..263654c1c0 100644
--- a/openstack_dashboard/usage/quotas.py
+++ b/openstack_dashboard/usage/quotas.py
@@ -238,8 +238,8 @@ def tenant_quota_usages(request):
def tenant_limit_usages(request):
- #TODO(licostan): This method shall be removed from Quota module.
- #ProjectUsage/BaseUsage maybe used instead on volume/image dashboards.
+ # TODO(licostan): This method shall be removed from Quota module.
+ # ProjectUsage/BaseUsage maybe used instead on volume/image dashboards.
limits = {}
try:
diff --git a/openstack_dashboard/usage/views.py b/openstack_dashboard/usage/views.py
index fe6ff8ff73..5224b818e0 100644
--- a/openstack_dashboard/usage/views.py
+++ b/openstack_dashboard/usage/views.py
@@ -11,6 +11,7 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
+
from horizon import exceptions
from horizon import tables
from openstack_dashboard import api
diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py
index c792f5ed7c..cd0c5b937e 100644
--- a/openstack_dashboard/utils/settings.py
+++ b/openstack_dashboard/utils/settings.py
@@ -15,7 +15,6 @@ import logging
import pkgutil
from django.utils import importlib
-
import six
diff --git a/openstack_dashboard/views.py b/openstack_dashboard/views.py
index 06eb2d79a3..a5e85c528a 100644
--- a/openstack_dashboard/views.py
+++ b/openstack_dashboard/views.py
@@ -13,7 +13,7 @@
# under the License.
from django import shortcuts
-from django.views.decorators import vary
+import django.views.decorators.vary
import horizon
from horizon import base
@@ -35,7 +35,7 @@ def get_user_home(user):
return dashboard.get_absolute_url()
-@vary.vary_on_cookie
+@django.views.decorators.vary.vary_on_cookie
def splash(request):
if request.user.is_authenticated():
return shortcuts.redirect(horizon.get_user_home(request.user))