diff --git a/openstack_dashboard/api/ceilometer.py b/openstack_dashboard/api/ceilometer.py index 12dd7a12dc..bb161aaf4d 100644 --- a/openstack_dashboard/api/ceilometer.py +++ b/openstack_dashboard/api/ceilometer.py @@ -36,18 +36,18 @@ def get_flavor_names(request): return [f.name for f in flavors] except Exception: return ['m1.tiny', 'm1.small', 'm1.medium', - 'm1.large', 'm1.xlarge'] + 'm1.large', 'm1.xlarge'] def is_iterable(var): """Return True if the given is list or tuple.""" return (isinstance(var, (list, tuple)) or - issubclass(var.__class__, (list, tuple))) + issubclass(var.__class__, (list, tuple))) def make_query(user_id=None, tenant_id=None, resource_id=None, - user_ids=None, tenant_ids=None, resource_ids=None): + user_ids=None, tenant_ids=None, resource_ids=None): """Returns query built form given parameters. This query can be then used for querying resources, meters and @@ -233,8 +233,10 @@ class ResourceAggregate(Resource): self.resource_id = resource_id self._query = make_query(tenant_id=tenant_id, user_id=user_id, - resource_id=resource_id, tenant_ids=tenant_ids, - user_ids=user_ids, resource_ids=resource_ids) + resource_id=resource_id, + tenant_ids=tenant_ids, + user_ids=user_ids, + resource_ids=resource_ids) @property def id(self): @@ -356,21 +358,22 @@ class ThreadedUpdateResourceWithStatistics(threading.Thread): def run(self): # Run the job - self.resource_usage.update_with_statistics(self.resource, + self.resource_usage.update_with_statistics( + self.resource, meter_names=self.meter_names, period=self.period, stats_attr=self.stats_attr, additional_query=self.additional_query) @classmethod def process_list(cls, resource_usage, resources, meter_names=None, - period=None, filter_func=None, stats_attr=None, - additional_query=None): + period=None, filter_func=None, stats_attr=None, + additional_query=None): threads = [] for resource in resources: # add statistics data into resource thread = cls(resource_usage, resource, meter_names=meter_names, - period=period, stats_attr=stats_attr, - additional_query=additional_query) + period=period, stats_attr=stats_attr, + additional_query=additional_query) thread.start() threads.append(thread) @@ -512,7 +515,8 @@ class CeilometerUsage(object): with_users_and_tenants=with_users_and_tenants) else: # Will load only resources without statistical data. - resources = self.resources(query, filter_func=filter_func, + resources = self.resources( + query, filter_func=filter_func, with_users_and_tenants=with_users_and_tenants) return [used_cls(resource) for resource in resources] @@ -610,7 +614,8 @@ class CeilometerUsage(object): ceilometer_usage_object = self else: ceilometer_usage_object = None - resources = resource_list(self._request, + resources = resource_list( + self._request, query=query, ceilometer_usage_object=ceilometer_usage_object) if filter_func: resources = [resource for resource in resources if @@ -645,10 +650,12 @@ class CeilometerUsage(object): be added to each resource object. """ - resources = self.resources(query, filter_func=filter_func, + resources = self.resources( + query, filter_func=filter_func, with_users_and_tenants=with_users_and_tenants) - ThreadedUpdateResourceWithStatistics.process_list(self, resources, + ThreadedUpdateResourceWithStatistics.process_list( + self, resources, meter_names=meter_names, period=period, stats_attr=stats_attr, additional_query=additional_query) @@ -672,8 +679,9 @@ class CeilometerUsage(object): return resource_aggregates def resource_aggregates_with_statistics(self, queries=None, - meter_names=None, period=None, filter_func=None, stats_attr=None, - additional_query=None): + meter_names=None, period=None, + filter_func=None, stats_attr=None, + additional_query=None): """Obtaining resource aggregates with statistics data inside. :Parameters: @@ -695,7 +703,8 @@ class CeilometerUsage(object): """ resource_aggregates = self.resource_aggregates(queries) - ThreadedUpdateResourceWithStatistics.process_list(self, + ThreadedUpdateResourceWithStatistics.process_list( + self, resource_aggregates, meter_names=meter_names, period=period, stats_attr=stats_attr, additional_query=additional_query) @@ -748,14 +757,16 @@ class Meters(object): # Storing the meters info of all services together. all_services_meters = (self._nova_meters_info, - self._neutron_meters_info, self._glance_meters_info, - self._cinder_meters_info, self._swift_meters_info, - self._kwapi_meters_info) + self._neutron_meters_info, + self._glance_meters_info, + self._cinder_meters_info, + self._swift_meters_info, + self._kwapi_meters_info) self._all_meters_info = {} for service_meters in all_services_meters: self._all_meters_info.update(dict([(meter_name, meter_info) - for meter_name, - meter_info in service_meters.items()])) + for meter_name, meter_info + in service_meters.items()])) # Here will be the cached Meter objects, that will be reused for # repeated listing. @@ -770,17 +781,17 @@ class Meters(object): """ return self._list(only_meters=only_meters, - except_meters=except_meters) + except_meters=except_meters) def list_nova(self, except_meters=None): """Returns a list of meters tied to nova :Parameters: - - `except_meters`: The list of meter names we don't want to show + - `except_meters`: The list of meter names we don't want to show """ return self._list(only_meters=self._nova_meters_info.keys(), - except_meters=except_meters) + except_meters=except_meters) def list_neutron(self, except_meters=None): """Returns a list of meters tied to neutron @@ -790,7 +801,7 @@ class Meters(object): """ return self._list(only_meters=self._neutron_meters_info.keys(), - except_meters=except_meters) + except_meters=except_meters) def list_glance(self, except_meters=None): """Returns a list of meters tied to glance @@ -800,7 +811,7 @@ class Meters(object): """ return self._list(only_meters=self._glance_meters_info.keys(), - except_meters=except_meters) + except_meters=except_meters) def list_cinder(self, except_meters=None): """Returns a list of meters tied to cinder @@ -810,7 +821,7 @@ class Meters(object): """ return self._list(only_meters=self._cinder_meters_info.keys(), - except_meters=except_meters) + except_meters=except_meters) def list_swift(self, except_meters=None): """Returns a list of meters tied to swift @@ -820,7 +831,7 @@ class Meters(object): """ return self._list(only_meters=self._swift_meters_info.keys(), - except_meters=except_meters) + except_meters=except_meters) def list_kwapi(self, except_meters=None): """Returns a list of meters tied to kwapi @@ -830,7 +841,7 @@ class Meters(object): """ return self._list(only_meters=self._kwapi_meters_info.keys(), - except_meters=except_meters) + except_meters=except_meters) def _list(self, only_meters=None, except_meters=None): """Returns a list of meters based on the meters names diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py index 39ca3283a8..43d72a58e7 100644 --- a/openstack_dashboard/api/keystone.py +++ b/openstack_dashboard/api/keystone.py @@ -157,8 +157,9 @@ def keystoneclient(request, admin=False): # Admin vs. non-admin clients are cached separately for token matching. cache_attr = "_keystoneclient_admin" if admin \ else backend.KEYSTONE_CLIENT_ATTR - if hasattr(request, cache_attr) and (not user.token.id - or getattr(request, cache_attr).auth_token == user.token.id): + if (hasattr(request, cache_attr) and + (not user.token.id or + getattr(request, cache_attr).auth_token == user.token.id)): LOG.debug("Using cached client for token: %s" % user.token.id) conn = getattr(request, cache_attr) else: @@ -321,8 +322,8 @@ def user_update(request, user, **data): error = None if not keystone_can_edit_user(): - raise keystone_exceptions.ClientException(405, _("Identity service " - "does not allow editing user data.")) + raise keystone_exceptions.ClientException( + 405, _("Identity service does not allow editing user data.")) # The v2 API updates user model, password and default project separately if VERSIONS.active < 3: diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py index 52752dfaf9..8ee92f9961 100644 --- a/openstack_dashboard/api/nova.py +++ b/openstack_dashboard/api/nova.py @@ -81,12 +81,12 @@ class Server(base.APIResourceWrapper): 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', - 'image_name', 'VirtualInterfaces', 'flavor', 'key_name', 'fault', - 'tenant_id', 'user_id', 'created', 'OS-EXT-STS:power_state', - 'OS-EXT-STS:task_state', 'OS-EXT-SRV-ATTR:instance_name', - 'OS-EXT-SRV-ATTR:host', 'OS-EXT-AZ:availability_zone', - 'OS-DCF:diskConfig'] + 'metadata', 'name', 'private_ip', 'public_ip', 'status', 'uuid', + 'image_name', 'VirtualInterfaces', 'flavor', 'key_name', 'fault', + 'tenant_id', 'user_id', 'created', 'OS-EXT-STS:power_state', + 'OS-EXT-STS:task_state', 'OS-EXT-SRV-ATTR:instance_name', + 'OS-EXT-SRV-ATTR:host', 'OS-EXT-AZ:availability_zone', + 'OS-DCF:diskConfig'] def __init__(self, apiresource, request): super(Server, self).__init__(apiresource) @@ -142,8 +142,8 @@ 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'] + 'total_local_gb_usage', 'total_memory_mb_usage', + 'total_vcpus_usage', 'total_hours'] def get_summary(self): return {'instances': self.total_active_instances, @@ -434,8 +434,8 @@ def novaclient(request): def server_vnc_console(request, instance_id, console_type='novnc'): - return VNCConsole(novaclient(request).servers.get_vnc_console(instance_id, - console_type)['console']) + return VNCConsole(novaclient(request).servers.get_vnc_console( + instance_id, console_type)['console']) def server_spice_console(request, instance_id, console_type='spice-html5'): diff --git a/openstack_dashboard/api/sahara.py b/openstack_dashboard/api/sahara.py index faa80be6f7..62917732da 100644 --- a/openstack_dashboard/api/sahara.py +++ b/openstack_dashboard/api/sahara.py @@ -27,10 +27,12 @@ LOG = logging.getLogger(__name__) # "type" of Sahara service registered in keystone SAHARA_SERVICE = 'data_processing' -SAHARA_AUTO_IP_ALLOCATION_ENABLED = getattr(settings, +SAHARA_AUTO_IP_ALLOCATION_ENABLED = getattr( + settings, 'SAHARA_AUTO_IP_ALLOCATION_ENABLED', False) -VERSIONS = base.APIVersionManager(SAHARA_SERVICE, +VERSIONS = base.APIVersionManager( + SAHARA_SERVICE, preferred_version=getattr(settings, 'OPENSTACK_API_VERSIONS', {}).get(SAHARA_SERVICE, 1.1)) @@ -83,9 +85,9 @@ def plugin_get_version_details(request, plugin_name, hadoop_version): def plugin_convert_to_template(request, plugin_name, hadoop_version, template_name, file_content): return client(request).plugins.convert_to_cluster_template(plugin_name, - hadoop_version, - template_name, - file_content) + hadoop_version, + template_name, + file_content) def nodegroup_template_create(request, name, plugin_name, hadoop_version, diff --git a/openstack_dashboard/api/vpn.py b/openstack_dashboard/api/vpn.py index e0902c9b6b..a2788741d7 100644 --- a/openstack_dashboard/api/vpn.py +++ b/openstack_dashboard/api/vpn.py @@ -256,7 +256,8 @@ def _ipsecpolicy_get(request, ipsecpolicy_id, expand_conns=False): if expand_conns: ipsecsiteconns = _ipsecsiteconnection_list(request) ipsecpolicy['ipsecsiteconns'] = [c for c in ipsecsiteconns - if c.ipsecpolicy_id == ipsecpolicy['id']] + if (c.ipsecpolicy_id == + ipsecpolicy['id'])] return IPSecPolicy(ipsecpolicy) diff --git a/openstack_dashboard/dashboards/identity/domains/tables.py b/openstack_dashboard/dashboards/identity/domains/tables.py index a70693994c..c480309d83 100644 --- a/openstack_dashboard/dashboards/identity/domains/tables.py +++ b/openstack_dashboard/dashboards/identity/domains/tables.py @@ -168,8 +168,8 @@ class SetDomainContext(tables.Action): request.session['domain_context'] = obj_id request.session['domain_context_name'] = domain.name messages.success(request, - _('Domain Context updated to Domain %s.') % - domain.name) + _('Domain Context updated to Domain %s.') % + domain.name) except Exception: messages.error(request, _('Unable to set Domain Context.')) diff --git a/openstack_dashboard/dashboards/identity/domains/tests.py b/openstack_dashboard/dashboards/identity/domains/tests.py index 7942251cb3..7cd6da3f2f 100644 --- a/openstack_dashboard/dashboards/identity/domains/tests.py +++ b/openstack_dashboard/dashboards/identity/domains/tests.py @@ -250,10 +250,11 @@ class UpdateDomainWorkflowTests(test.BaseAdminViewTests): self.assertEqual(step.action.initial['name'], domain.name) self.assertEqual(step.action.initial['description'], domain.description) - self.assertQuerysetEqual(workflow.steps, - ['', - '', - '']) + self.assertQuerysetEqual( + workflow.steps, + ['', + '', + '']) @test.create_stubs({api.keystone: ('domain_get', 'domain_update', diff --git a/openstack_dashboard/dashboards/identity/domains/urls.py b/openstack_dashboard/dashboards/identity/domains/urls.py index 995c7a6bbc..65e2d0c89f 100644 --- a/openstack_dashboard/dashboards/identity/domains/urls.py +++ b/openstack_dashboard/dashboards/identity/domains/urls.py @@ -18,7 +18,8 @@ from django.conf.urls import url from openstack_dashboard.dashboards.identity.domains import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^create$', views.CreateDomainView.as_view(), name='create'), url(r'^(?P[^/]+)/update/$', diff --git a/openstack_dashboard/dashboards/identity/groups/urls.py b/openstack_dashboard/dashboards/identity/groups/urls.py index 84090064fc..7a3d1a9407 100644 --- a/openstack_dashboard/dashboards/identity/groups/urls.py +++ b/openstack_dashboard/dashboards/identity/groups/urls.py @@ -18,7 +18,8 @@ from django.conf.urls import url from openstack_dashboard.dashboards.identity.groups import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^create$', views.CreateView.as_view(), name='create'), url(r'^(?P[^/]+)/update/$', diff --git a/openstack_dashboard/dashboards/identity/groups/views.py b/openstack_dashboard/dashboards/identity/groups/views.py index 74bf0336ae..7c0fbff35a 100644 --- a/openstack_dashboard/dashboards/identity/groups/views.py +++ b/openstack_dashboard/dashboards/identity/groups/views.py @@ -68,7 +68,7 @@ class UpdateView(forms.ModalFormView): def get_object(self): try: return api.keystone.group_get(self.request, - self.kwargs['group_id']) + self.kwargs['group_id']) except Exception: redirect = reverse(constants.GROUPS_INDEX_URL) exceptions.handle(self.request, diff --git a/openstack_dashboard/dashboards/identity/projects/tests.py b/openstack_dashboard/dashboards/identity/projects/tests.py index 2f2327ef6d..106da2cc6a 100644 --- a/openstack_dashboard/dashboards/identity/projects/tests.py +++ b/openstack_dashboard/dashboards/identity/projects/tests.py @@ -212,11 +212,12 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests): self.assertEqual(step.action.initial['ram'], quota.get('ram').limit) self.assertEqual(step.action.initial['injected_files'], quota.get('injected_files').limit) - self.assertQuerysetEqual(workflow.steps, - ['', - '', - '', - '']) + self.assertQuerysetEqual( + workflow.steps, + ['', + '', + '', + '']) def test_add_project_get_domain(self): domain = self.domains.get(id="1") @@ -356,7 +357,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests): project.id, **nova_updated_quota) cinder_updated_quota = dict([(key, quota_data[key]) for key in - quotas.CINDER_QUOTA_FIELDS]) + quotas.CINDER_QUOTA_FIELDS]) api.cinder.tenant_quota_update(IsA(http.HttpRequest), project.id, **cinder_updated_quota) @@ -905,11 +906,12 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests): self.assertEqual(step.action.initial['name'], project.name) self.assertEqual(step.action.initial['description'], project.description) - self.assertQuerysetEqual(workflow.steps, - ['', - '', - '', - '']) + self.assertQuerysetEqual( + workflow.steps, + ['', + '', + '', + '']) @test.create_stubs({api.keystone: ('tenant_get', 'domain_get', @@ -1109,7 +1111,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests): **nova_updated_quota) cinder_updated_quota = dict([(key, updated_quota[key]) for key in - quotas.CINDER_QUOTA_FIELDS]) + quotas.CINDER_QUOTA_FIELDS]) api.cinder.tenant_quota_update(IsA(http.HttpRequest), project.id, **cinder_updated_quota) @@ -1874,8 +1876,9 @@ class SeleniumTests(test.SeleniumAdminTestCase): self.mox.ReplayAll() - self.selenium.get("%s%s" % (self.live_server_url, - reverse('horizon:identity:projects:create'))) + self.selenium.get("%s%s" % + (self.live_server_url, + reverse('horizon:identity:projects:create'))) members = self.selenium.find_element_by_css_selector(member_css_class) diff --git a/openstack_dashboard/dashboards/identity/projects/urls.py b/openstack_dashboard/dashboards/identity/projects/urls.py index 0ac708f8c1..20937f5fdf 100644 --- a/openstack_dashboard/dashboards/identity/projects/urls.py +++ b/openstack_dashboard/dashboards/identity/projects/urls.py @@ -22,7 +22,8 @@ from django.conf.urls import url from openstack_dashboard.dashboards.identity.projects import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^create$', views.CreateProjectView.as_view(), name='create'), url(r'^(?P[^/]+)/update/$', diff --git a/openstack_dashboard/dashboards/identity/projects/views.py b/openstack_dashboard/dashboards/identity/projects/views.py index 49fce4ecdb..3d9f004c3d 100644 --- a/openstack_dashboard/dashboards/identity/projects/views.py +++ b/openstack_dashboard/dashboards/identity/projects/views.py @@ -186,16 +186,16 @@ class UpdateProjectView(workflows.WorkflowView): initial["domain_name"] = domain.name except Exception: exceptions.handle(self.request, - _('Unable to retrieve project domain.'), - redirect=reverse(INDEX_URL)) + _('Unable to retrieve project domain.'), + redirect=reverse(INDEX_URL)) # get initial project quota quota_data = quotas.get_tenant_quota_data(self.request, tenant_id=project_id) if api.base.is_service_enabled(self.request, 'network') and \ api.neutron.is_quotas_extension_supported(self.request): - quota_data += api.neutron.tenant_quota_get(self.request, - tenant_id=project_id) + quota_data += api.neutron.tenant_quota_get( + self.request, tenant_id=project_id) for field in quotas.QUOTA_FIELDS: initial[field] = quota_data.get(field).limit except Exception: diff --git a/openstack_dashboard/dashboards/identity/roles/urls.py b/openstack_dashboard/dashboards/identity/roles/urls.py index 711dd01428..a60b26eb97 100644 --- a/openstack_dashboard/dashboards/identity/roles/urls.py +++ b/openstack_dashboard/dashboards/identity/roles/urls.py @@ -17,7 +17,8 @@ from django.conf.urls import url from openstack_dashboard.dashboards.identity.roles import views -urlpatterns = patterns('openstack_dashboard.dashboards.identity.roles.views', +urlpatterns = patterns( + 'openstack_dashboard.dashboards.identity.roles.views', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^(?P[^/]+)/update/$', views.UpdateView.as_view(), name='update'), diff --git a/openstack_dashboard/dashboards/identity/users/forms.py b/openstack_dashboard/dashboards/identity/users/forms.py index 447e6dd956..02ce769b19 100644 --- a/openstack_dashboard/dashboards/identity/users/forms.py +++ b/openstack_dashboard/dashboards/identity/users/forms.py @@ -130,19 +130,19 @@ class CreateUserForm(BaseUserForm): % data['name']) if data['project'] and data['role_id']: roles = api.keystone.roles_for_user(request, - new_user.id, - data['project']) or [] + new_user.id, + data['project']) or [] assigned = [role for role in roles if role.id == str( data['role_id'])] if not assigned: try: api.keystone.add_tenant_user_role(request, - data['project'], - new_user.id, - data['role_id']) + data['project'], + new_user.id, + data['role_id']) except Exception: exceptions.handle(request, - _('Unable to add user ' + _('Unable to add user ' 'to primary project.')) return new_user except Exception: diff --git a/openstack_dashboard/dashboards/identity/users/tests.py b/openstack_dashboard/dashboards/identity/users/tests.py index 930d9c24af..c5c853f8a3 100644 --- a/openstack_dashboard/dashboards/identity/users/tests.py +++ b/openstack_dashboard/dashboards/identity/users/tests.py @@ -369,8 +369,8 @@ class UsersViewTests(test.BaseAdminViewTests): domain = self.domains.get(id=domain_id) api.keystone.user_get(IsA(http.HttpRequest), - '1', - admin=True).AndReturn(user) + '1', + admin=True).AndReturn(user) api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \ .AndReturn(domain) api.keystone.tenant_list(IgnoreArg(), domain=domain_id, user=user.id) \ diff --git a/openstack_dashboard/dashboards/identity/users/urls.py b/openstack_dashboard/dashboards/identity/users/urls.py index acb74bc5d9..5aab13f144 100644 --- a/openstack_dashboard/dashboards/identity/users/urls.py +++ b/openstack_dashboard/dashboards/identity/users/urls.py @@ -21,7 +21,8 @@ from django.conf.urls import url from openstack_dashboard.dashboards.identity.users import views -urlpatterns = patterns('openstack_dashboard.dashboards.identity.users.views', +urlpatterns = patterns( + 'openstack_dashboard.dashboards.identity.users.views', url(r'^$', views.IndexView.as_view(), name='index'), url(r'^(?P[^/]+)/update/$', views.UpdateView.as_view(), name='update'), diff --git a/openstack_dashboard/dashboards/identity/users/views.py b/openstack_dashboard/dashboards/identity/users/views.py index 88b854a810..ebcbdafbee 100644 --- a/openstack_dashboard/dashboards/identity/users/views.py +++ b/openstack_dashboard/dashboards/identity/users/views.py @@ -83,7 +83,7 @@ class UpdateView(forms.ModalFormView): def get_object(self): try: return api.keystone.user_get(self.request, self.kwargs['user_id'], - admin=True) + admin=True) except Exception: redirect = reverse("horizon:identity:users:index") exceptions.handle(self.request, @@ -107,7 +107,7 @@ class UpdateView(forms.ModalFormView): domain_name = domain.name except Exception: exceptions.handle(self.request, - _('Unable to retrieve project domain.')) + _('Unable to retrieve project domain.')) return {'domain_id': domain_id, 'domain_name': domain_name, 'id': user.id, diff --git a/openstack_dashboard/dashboards/router/nexus1000v/forms.py b/openstack_dashboard/dashboards/router/nexus1000v/forms.py index 9e8cffc96b..2f8a3ddb7d 100644 --- a/openstack_dashboard/dashboards/router/nexus1000v/forms.py +++ b/openstack_dashboard/dashboards/router/nexus1000v/forms.py @@ -66,12 +66,13 @@ class CreateNetworkProfile(forms.SelfHandlingForm): _("Sub Type")})) # Sub type options available for Trunk segment type sub_type_trunk = forms.ChoiceField(label=_('Sub Type'), - choices=[('vlan', _('VLAN'))], - required=False, - widget=forms.Select - (attrs={'class': 'switched', - 'data-switch-on': 'segtype', - 'data-segtype-trunk': _("Sub Type")})) + choices=[('vlan', _('VLAN'))], + required=False, + widget=forms.Select + (attrs={'class': 'switched', + 'data-switch-on': 'segtype', + 'data-segtype-trunk': + _("Sub Type")})) segment_range = forms.CharField(max_length=255, label=_("Segment Range"), required=False, @@ -106,7 +107,7 @@ class CreateNetworkProfile(forms.SelfHandlingForm): 'data-subtype-other': _("Sub Type Value " "(Manual Input)")}), - help_text=_("Enter parameter (e.g. GRE)")) + help_text=_("Enter parameter (e.g. GRE)")) physical_network = forms.CharField(max_length=255, label=_("Physical Network"), required=False, diff --git a/openstack_dashboard/dashboards/router/nexus1000v/urls.py b/openstack_dashboard/dashboards/router/nexus1000v/urls.py index 9d98775244..5a631938c9 100644 --- a/openstack_dashboard/dashboards/router/nexus1000v/urls.py +++ b/openstack_dashboard/dashboards/router/nexus1000v/urls.py @@ -16,7 +16,8 @@ from django.conf.urls import url from openstack_dashboard.dashboards.router.nexus1000v import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.IndexView.as_view(), name='index'), # Network Profile url(r'^network_profile/create$', views.CreateNetworkProfileView.as_view(), diff --git a/openstack_dashboard/dashboards/settings/password/forms.py b/openstack_dashboard/dashboards/settings/password/forms.py index 631329ec8f..5b1557c1a8 100644 --- a/openstack_dashboard/dashboards/settings/password/forms.py +++ b/openstack_dashboard/dashboards/settings/password/forms.py @@ -28,15 +28,18 @@ from openstack_dashboard import api class PasswordForm(forms.SelfHandlingForm): - current_password = forms.CharField(label=_("Current password"), - widget=forms.PasswordInput(render_value=False)) - new_password = forms.RegexField(label=_("New password"), - widget=forms.PasswordInput(render_value=False), - regex=validators.password_validator(), - error_messages={'invalid': - validators.password_validator_msg()}) - confirm_password = forms.CharField(label=_("Confirm new password"), - widget=forms.PasswordInput(render_value=False)) + current_password = forms.CharField( + label=_("Current password"), + widget=forms.PasswordInput(render_value=False)) + new_password = forms.RegexField( + label=_("New password"), + widget=forms.PasswordInput(render_value=False), + regex=validators.password_validator(), + error_messages={'invalid': + validators.password_validator_msg()}) + confirm_password = forms.CharField( + label=_("Confirm new password"), + widget=forms.PasswordInput(render_value=False)) no_autocomplete = True def clean(self): @@ -56,8 +59,8 @@ class PasswordForm(forms.SelfHandlingForm): if user_is_editable: try: api.keystone.user_update_own_password(request, - data['current_password'], - data['new_password']) + data['current_password'], + data['new_password']) response = http.HttpResponseRedirect(settings.LOGOUT_URL) msg = _("Password changed. Please log in again to continue.") utils.add_logout_reason(request, response, msg) diff --git a/openstack_dashboard/dashboards/settings/password/urls.py b/openstack_dashboard/dashboards/settings/password/urls.py index f5b75a9748..9987814787 100644 --- a/openstack_dashboard/dashboards/settings/password/urls.py +++ b/openstack_dashboard/dashboards/settings/password/urls.py @@ -18,5 +18,6 @@ from django.conf.urls import url from openstack_dashboard.dashboards.settings.password import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.PasswordView.as_view(), name='index')) diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py index 944d583996..77613361e3 100644 --- a/openstack_dashboard/dashboards/settings/user/forms.py +++ b/openstack_dashboard/dashboards/settings/user/forms.py @@ -49,7 +49,7 @@ class UserSettingsForm(forms.SelfHandlingForm): def _sorted_zones(): d = datetime(datetime.today().year, 1, 1) zones = [(tz, pytz.timezone(tz).localize(d).strftime('%z')) - for tz in pytz.common_timezones] + for tz in pytz.common_timezones] zones.sort(key=lambda zone: int(zone[1])) return zones @@ -87,11 +87,11 @@ class UserSettingsForm(forms.SelfHandlingForm): elif tz == "GMT": tz_name = _("GMT") else: - tz_label = babel.dates.get_timezone_location(tz, - locale=babel_locale) + tz_label = babel.dates.get_timezone_location( + tz, locale=babel_locale) # Translators: UTC offset and timezone label tz_name = _("%(offset)s: %(label)s") % {"offset": utc_offset, - "label": tz_label} + "label": tz_label} timezones.append((tz, tz_name)) self.fields['timezone'].choices = timezones diff --git a/openstack_dashboard/dashboards/settings/user/urls.py b/openstack_dashboard/dashboards/settings/user/urls.py index b0c51c2f98..33c0115f8f 100644 --- a/openstack_dashboard/dashboards/settings/user/urls.py +++ b/openstack_dashboard/dashboards/settings/user/urls.py @@ -18,5 +18,6 @@ from django.conf.urls import url from openstack_dashboard.dashboards.settings.user import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.UserSettingsView.as_view(), name='index')) diff --git a/openstack_dashboard/management/commands/make_web_conf.py b/openstack_dashboard/management/commands/make_web_conf.py index 1d8f2577eb..38d1de887c 100644 --- a/openstack_dashboard/management/commands/make_web_conf.py +++ b/openstack_dashboard/management/commands/make_web_conf.py @@ -150,7 +150,7 @@ location you desire, e.g.:: make_option("-H", "--hostname", dest="hostname", help=("Use with the --apache option to define the server's" - " hostname (default : %s)") % context['VHOSTNAME'], + " hostname (default : %s)") % context['VHOSTNAME'], metavar="HOSTNAME"), make_option("--logdir", dest="logdir", @@ -172,7 +172,7 @@ location you desire, e.g.:: make_option("-p", "--project", dest="project", help=("Use with the --apache option to define the project " - "name (default : %s)") % context['PROJECT_NAME'], + "name (default : %s)") % context['PROJECT_NAME'], metavar="PROJECT"), make_option("-s", "--ssl", default=False, action="store_true", dest="ssl", diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index f4e619408c..3cac3f0c94 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -190,12 +190,14 @@ STATICFILES_DIRS = [ if xstatic.main.XStatic(xstatic.pkg.jquery_ui).version.startswith('1.10.'): # The 1.10.x versions already contain the 'ui' directory. - STATICFILES_DIRS.append(('horizon/lib/jquery-ui', - xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir)) + STATICFILES_DIRS.append( + ('horizon/lib/jquery-ui', + xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir)) else: # Newer versions dropped the directory, add it to keep the path the same. - STATICFILES_DIRS.append(('horizon/lib/jquery-ui/ui', - xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir)) + STATICFILES_DIRS.append( + ('horizon/lib/jquery-ui/ui', + xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir)) COMPRESS_PRECOMPILERS = ( ('text/scss', 'django_pyscss.compressor.DjangoScssFilter'), diff --git a/openstack_dashboard/templatetags/context_selection.py b/openstack_dashboard/templatetags/context_selection.py index 2a96da99ea..2014617a27 100644 --- a/openstack_dashboard/templatetags/context_selection.py +++ b/openstack_dashboard/templatetags/context_selection.py @@ -67,7 +67,7 @@ def show_project_list(context): return {} request = context['request'] context = {'projects': sorted(context['authorized_tenants'], - key=lambda project: project.name), + key=lambda project: project.name), 'project_id': request.user.project_id, 'request': request} return context diff --git a/openstack_dashboard/test/api_tests/base_tests.py b/openstack_dashboard/test/api_tests/base_tests.py index 341bf3618a..315036e2f8 100644 --- a/openstack_dashboard/test/api_tests/base_tests.py +++ b/openstack_dashboard/test/api_tests/base_tests.py @@ -61,8 +61,9 @@ class APIResourceWrapperTests(test.TestCase): def test_get_invalid_attribute(self): resource = APIResource.get_instance() - self.assertNotIn('missing', resource._attrs, - msg="Test assumption broken. Find new missing attribute") + self.assertNotIn( + 'missing', resource._attrs, + msg="Test assumption broken. Find new missing attribute") with self.assertRaises(AttributeError): resource.missing @@ -89,8 +90,9 @@ class APIDictWrapperTests(test.TestCase): def test_get_invalid_item(self): resource = APIDict.get_instance() - self.assertNotIn('missing', resource._attrs, - msg="Test assumption broken. Find new missing attribute") + self.assertNotIn( + 'missing', resource._attrs, + msg="Test assumption broken. Find new missing attribute") with self.assertRaises(AttributeError): resource.missing with self.assertRaises(KeyError): diff --git a/openstack_dashboard/test/api_tests/heat_tests.py b/openstack_dashboard/test/api_tests/heat_tests.py index a3dfa7033f..0fe5c7ad0a 100644 --- a/openstack_dashboard/test/api_tests/heat_tests.py +++ b/openstack_dashboard/test/api_tests/heat_tests.py @@ -45,8 +45,8 @@ class HeatApiTests(test.APITestCase): heatclient = self.stub_heatclient() heatclient.stacks = self.mox.CreateMockAnything() heatclient.stacks.list(limit=limit, - sort_dir=sort_dir, - sort_key=sort_key,) \ + sort_dir=sort_dir, + sort_key=sort_key,) \ .AndReturn(iter(api_stacks)) self.mox.ReplayAll() @@ -67,8 +67,8 @@ class HeatApiTests(test.APITestCase): heatclient = self.stub_heatclient() heatclient.stacks = self.mox.CreateMockAnything() heatclient.stacks.list(limit=page_size + 1, - sort_dir=sort_dir, - sort_key=sort_key,) \ + sort_dir=sort_dir, + sort_key=sort_key,) \ .AndReturn(iter(api_stacks)) self.mox.ReplayAll() @@ -91,8 +91,8 @@ class HeatApiTests(test.APITestCase): heatclient = self.stub_heatclient() heatclient.stacks = self.mox.CreateMockAnything() heatclient.stacks.list(limit=page_size + 1, - sort_dir=sort_dir, - sort_key=sort_key,) \ + sort_dir=sort_dir, + sort_key=sort_key,) \ .AndReturn(iter(api_stacks)) self.mox.ReplayAll() @@ -188,7 +188,7 @@ class HeatApiTests(test.APITestCase): self.mox.ReplayAll() returned_stack = api.heat.stack_update(self.request, - stack_id, - **form_data) + stack_id, + **form_data) from heatclient.v1 import stacks self.assertIsInstance(returned_stack, stacks.Stack) diff --git a/openstack_dashboard/test/api_tests/keystone_tests.py b/openstack_dashboard/test/api_tests/keystone_tests.py index e1183d33f9..c724765ff3 100644 --- a/openstack_dashboard/test/api_tests/keystone_tests.py +++ b/openstack_dashboard/test/api_tests/keystone_tests.py @@ -33,8 +33,8 @@ class ClientConnectionTests(test.TestCase): super(ClientConnectionTests, self).setUp() self.mox.StubOutWithMock(keystone_client, "Client") self.internal_url = api.base.url_for(self.request, - 'identity', - endpoint_type='internalURL') + 'identity', + endpoint_type='internalURL') self.admin_url = api.base.url_for(self.request, 'identity', endpoint_type='adminURL') diff --git a/openstack_dashboard/test/api_tests/vpnaas_tests.py b/openstack_dashboard/test/api_tests/vpnaas_tests.py index 6e4ebb2443..ad6f070c49 100644 --- a/openstack_dashboard/test/api_tests/vpnaas_tests.py +++ b/openstack_dashboard/test/api_tests/vpnaas_tests.py @@ -289,5 +289,5 @@ class VPNaasApiTests(test.APITestCase): self.mox.ReplayAll() ret_val = api.vpn.ipsecsiteconnection_get(self.request, - ipsecsiteconnection.id) + ipsecsiteconnection.id) self.assertIsInstance(ret_val, api.vpn.IPSecSiteConnection) diff --git a/openstack_dashboard/test/error_pages_urls.py b/openstack_dashboard/test/error_pages_urls.py index 0ee1182bbd..906c2b9f3e 100644 --- a/openstack_dashboard/test/error_pages_urls.py +++ b/openstack_dashboard/test/error_pages_urls.py @@ -2,6 +2,7 @@ from django.conf.urls import patterns from openstack_dashboard.urls import urlpatterns # noqa -urlpatterns += patterns('', +urlpatterns += patterns( + '', (r'^500/$', 'django.views.defaults.server_error') ) diff --git a/openstack_dashboard/test/test_data/ceilometer_data.py b/openstack_dashboard/test/test_data/ceilometer_data.py index 49b5d873a7..5e8716c1ce 100644 --- a/openstack_dashboard/test/test_data/ceilometer_data.py +++ b/openstack_dashboard/test/test_data/ceilometer_data.py @@ -38,21 +38,21 @@ def data(TEST): # users ceilometer_user_dict1 = {'id': "1", - 'name': 'user', - 'email': 'test@example.com', - 'password': 'password', - 'token': 'test_token', - 'project_id': '1', - 'enabled': True, - 'domain_id': "1"} + 'name': 'user', + 'email': 'test@example.com', + 'password': 'password', + 'token': 'test_token', + 'project_id': '1', + 'enabled': True, + 'domain_id': "1"} ceilometer_user_dict2 = {'id': "2", - 'name': 'user2', - 'email': 'test2@example.com', - 'password': 'password', - 'token': 'test_token', - 'project_id': '2', - 'enabled': True, - 'domain_id': "2"} + 'name': 'user2', + 'email': 'test2@example.com', + 'password': 'password', + 'token': 'test_token', + 'project_id': '2', + 'enabled': True, + 'domain_id': "2"} TEST.ceilometer_users.add(users.User(None, ceilometer_user_dict1)) TEST.ceilometer_users.add(users.User(None, @@ -122,25 +122,25 @@ def data(TEST): # samples sample_dict_1 = {'resource_id': 'fake_resource_id', - 'project_id': 'fake_project_id', - 'user_id': 'fake_user_id', - 'counter_name': 'image', - 'counter_type': 'gauge', - 'counter_unit': 'image', - 'counter_volume': 1, - 'timestamp': '2012-12-21T11:00:55.000000', - 'metadata': {'name1': 'value1', 'name2': 'value2'}, - 'message_id': 'fake_message_id'} + 'project_id': 'fake_project_id', + 'user_id': 'fake_user_id', + 'counter_name': 'image', + 'counter_type': 'gauge', + 'counter_unit': 'image', + 'counter_volume': 1, + 'timestamp': '2012-12-21T11:00:55.000000', + 'metadata': {'name1': 'value1', 'name2': 'value2'}, + 'message_id': 'fake_message_id'} sample_dict_2 = {'resource_id': 'fake_resource_id2', - 'project_id': 'fake_project_id', - 'user_id': 'fake_user_id', - 'counter_name': 'image', - 'counter_type': 'gauge', - 'counter_unit': 'image', - 'counter_volume': 1, - 'timestamp': '2012-12-21T11:00:55.000000', - 'metadata': {'name1': 'value1', 'name2': 'value2'}, - 'message_id': 'fake_message_id'} + 'project_id': 'fake_project_id', + 'user_id': 'fake_user_id', + 'counter_name': 'image', + 'counter_type': 'gauge', + 'counter_unit': 'image', + 'counter_volume': 1, + 'timestamp': '2012-12-21T11:00:55.000000', + 'metadata': {'name1': 'value1', 'name2': 'value2'}, + 'message_id': 'fake_message_id'} sample_1 = samples.Sample(samples.SampleManager(None), sample_dict_1) sample_2 = samples.Sample(samples.SampleManager(None), sample_dict_2) TEST.samples.add(sample_1) @@ -148,29 +148,29 @@ def data(TEST): # meters meter_dict_1 = {'name': 'instance', - 'type': 'gauge', - 'unit': 'instance', - 'resource_id': 'fake_resource_id', - 'project_id': 'fake_project_id', - 'user_id': 'fake_user_id'} + 'type': 'gauge', + 'unit': 'instance', + 'resource_id': 'fake_resource_id', + 'project_id': 'fake_project_id', + 'user_id': 'fake_user_id'} meter_dict_2 = {'name': 'instance', - 'type': 'gauge', - 'unit': 'instance', - 'resource_id': 'fake_resource_id', - 'project_id': 'fake_project_id', - 'user_id': 'fake_user_id'} + 'type': 'gauge', + 'unit': 'instance', + 'resource_id': 'fake_resource_id', + 'project_id': 'fake_project_id', + 'user_id': 'fake_user_id'} meter_dict_3 = {'name': 'disk.read.bytes', - 'type': 'gauge', - 'unit': 'instance', - 'resource_id': 'fake_resource_id', - 'project_id': 'fake_project_id', - 'user_id': 'fake_user_id'} + 'type': 'gauge', + 'unit': 'instance', + 'resource_id': 'fake_resource_id', + 'project_id': 'fake_project_id', + 'user_id': 'fake_user_id'} meter_dict_4 = {'name': 'disk.write.bytes', - 'type': 'gauge', - 'unit': 'instance', - 'resource_id': 'fake_resource_id', - 'project_id': 'fake_project_id', - 'user_id': 'fake_user_id'} + 'type': 'gauge', + 'unit': 'instance', + 'resource_id': 'fake_resource_id', + 'project_id': 'fake_project_id', + 'user_id': 'fake_user_id'} meter_1 = meters.Meter(meters.MeterManager(None), meter_dict_1) meter_2 = meters.Meter(meters.MeterManager(None), meter_dict_2) meter_3 = meters.Meter(meters.MeterManager(None), meter_dict_3) @@ -182,15 +182,15 @@ def data(TEST): # statistic statistic_dict_1 = {'min': 1, - 'max': 9, - 'avg': 4.55, - 'sum': 45, - 'count': 10, - 'duration_start': '2012-12-21T11:00:55.000000', - 'duration_end': '2012-12-21T11:00:55.000000', - 'period': 7200, - 'period_start': '2012-12-21T11:00:55.000000', - 'period_end': '2012-12-21T11:00:55.000000'} + 'max': 9, + 'avg': 4.55, + 'sum': 45, + 'count': 10, + 'duration_start': '2012-12-21T11:00:55.000000', + 'duration_end': '2012-12-21T11:00:55.000000', + 'period': 7200, + 'period_start': '2012-12-21T11:00:55.000000', + 'period_end': '2012-12-21T11:00:55.000000'} statistic_1 = statistics.Statistics(statistics.StatisticsManager(None), statistic_dict_1) TEST.statistics.add(statistic_1) diff --git a/openstack_dashboard/test/test_data/cinder_data.py b/openstack_dashboard/test/test_data/cinder_data.py index 3a04e130eb..56cee1a546 100644 --- a/openstack_dashboard/test/test_data/cinder_data.py +++ b/openstack_dashboard/test/test_data/cinder_data.py @@ -67,46 +67,50 @@ def data(TEST): TEST.cinder_services.add(service_2) # Volumes - Cinder v1 - volume = volumes.Volume(volumes.VolumeManager(None), - {'id': "11023e92-8008-4c8b-8059-7f2293ff3887", - 'status': 'available', - 'size': 40, - 'display_name': 'Volume name', - 'display_description': 'Volume description', - 'created_at': '2014-01-27 10:30:00', - 'volume_type': None, - 'attachments': []}) - nameless_volume = volumes.Volume(volumes.VolumeManager(None), - dict(id="4b069dd0-6eaa-4272-8abc-5448a68f1cce", - status='available', - size=10, - display_name='', - display_description='', - device="/dev/hda", - created_at='2010-11-21 18:34:25', - volume_type='vol_type_1', - attachments=[])) - other_volume = volumes.Volume(volumes.VolumeManager(None), - {'id': "21023e92-8008-1234-8059-7f2293ff3889", - 'status': 'in-use', - 'size': 10, - 'display_name': u'my_volume', - 'display_description': '', - 'created_at': '2013-04-01 10:30:00', - 'volume_type': None, - 'attachments': [{"id": "1", "server_id": '1', - "device": "/dev/hda"}]}) - volume_with_type = volumes.Volume(volumes.VolumeManager(None), - {'id': "7dcb47fd-07d9-42c2-9647-be5eab799ebe", - 'name': 'my_volume2', - 'status': 'in-use', - 'size': 10, - 'display_name': u'my_volume2', - 'display_description': '', - 'created_at': '2013-04-01 10:30:00', - 'volume_type': 'vol_type_2', - 'attachments': [{"id": "2", "server_id": '2', - "device": "/dev/hdb"}]}) + volume = volumes.Volume( + volumes.VolumeManager(None), + {'id': "11023e92-8008-4c8b-8059-7f2293ff3887", + 'status': 'available', + 'size': 40, + 'display_name': 'Volume name', + 'display_description': 'Volume description', + 'created_at': '2014-01-27 10:30:00', + 'volume_type': None, + 'attachments': []}) + nameless_volume = volumes.Volume( + volumes.VolumeManager(None), + {"id": "4b069dd0-6eaa-4272-8abc-5448a68f1cce", + "status": 'available', + "size": 10, + "display_name": '', + "display_description": '', + "device": "/dev/hda", + "created_at": '2010-11-21 18:34:25', + "volume_type": 'vol_type_1', + "attachments": []}) + other_volume = volumes.Volume( + volumes.VolumeManager(None), + {'id': "21023e92-8008-1234-8059-7f2293ff3889", + 'status': 'in-use', + 'size': 10, + 'display_name': u'my_volume', + 'display_description': '', + 'created_at': '2013-04-01 10:30:00', + 'volume_type': None, + 'attachments': [{"id": "1", "server_id": '1', + "device": "/dev/hda"}]}) + volume_with_type = volumes.Volume( + volumes.VolumeManager(None), + {'id': "7dcb47fd-07d9-42c2-9647-be5eab799ebe", + 'name': 'my_volume2', + 'status': 'in-use', + 'size': 10, + 'display_name': u'my_volume2', + 'display_description': '', + 'created_at': '2013-04-01 10:30:00', + 'volume_type': 'vol_type_2', + 'attachments': [{"id": "2", "server_id": '2', + "device": "/dev/hdb"}]}) volume.bootable = 'true' nameless_volume.bootable = 'true' @@ -127,34 +131,37 @@ def data(TEST): TEST.cinder_volume_types.add(vol_type1, vol_type2) # Volumes - Cinder v2 - volume_v2 = volumes_v2.Volume(volumes_v2.VolumeManager(None), - {'id': "31023e92-8008-4c8b-8059-7f2293ff1234", - 'name': 'v2_volume', - 'description': "v2 Volume Description", - 'status': 'available', - 'size': 20, - 'created_at': '2014-01-27 10:30:00', - 'volume_type': None, - 'bootable': 'true', - 'attachments': []}) + volume_v2 = volumes_v2.Volume( + volumes_v2.VolumeManager(None), + {'id': "31023e92-8008-4c8b-8059-7f2293ff1234", + 'name': 'v2_volume', + 'description': "v2 Volume Description", + 'status': 'available', + 'size': 20, + 'created_at': '2014-01-27 10:30:00', + 'volume_type': None, + 'bootable': 'true', + 'attachments': []}) volume_v2.bootable = 'true' TEST.cinder_volumes.add(api.cinder.Volume(volume_v2)) - snapshot = vol_snaps.Snapshot(vol_snaps.SnapshotManager(None), - {'id': '5f3d1c33-7d00-4511-99df-a2def31f3b5d', - 'display_name': 'test snapshot', - 'display_description': 'volume snapshot', - 'size': 40, - 'status': 'available', - 'volume_id': '11023e92-8008-4c8b-8059-7f2293ff3887'}) - snapshot2 = vol_snaps_v2.Snapshot(vol_snaps_v2.SnapshotManager(None), - {'id': 'c9d0881a-4c0b-4158-a212-ad27e11c2b0f', - 'name': '', - 'description': 'v2 volume snapshot description', - 'size': 80, - 'status': 'available', - 'volume_id': '31023e92-8008-4c8b-8059-7f2293ff1234'}) + snapshot = vol_snaps.Snapshot( + vol_snaps.SnapshotManager(None), + {'id': '5f3d1c33-7d00-4511-99df-a2def31f3b5d', + 'display_name': 'test snapshot', + 'display_description': 'volume snapshot', + 'size': 40, + 'status': 'available', + 'volume_id': '11023e92-8008-4c8b-8059-7f2293ff3887'}) + snapshot2 = vol_snaps_v2.Snapshot( + vol_snaps_v2.SnapshotManager(None), + {'id': 'c9d0881a-4c0b-4158-a212-ad27e11c2b0f', + 'name': '', + 'description': 'v2 volume snapshot description', + 'size': 80, + 'status': 'available', + 'volume_id': '31023e92-8008-4c8b-8059-7f2293ff1234'}) snapshot.bootable = 'true' snapshot2.bootable = 'true' @@ -163,25 +170,25 @@ def data(TEST): TEST.cinder_volume_snapshots.add(api.cinder.VolumeSnapshot(snapshot2)) TEST.cinder_volume_snapshots.first()._volume = volume - volume_backup1 = vol_backups.VolumeBackup(vol_backups. - VolumeBackupManager(None), - {'id': 'a374cbb8-3f99-4c3f-a2ef-3edbec842e31', - 'name': 'backup1', - 'description': 'volume backup 1', - 'size': 10, - 'status': 'available', - 'container_name': 'volumebackups', - 'volume_id': '11023e92-8008-4c8b-8059-7f2293ff3887'}) + volume_backup1 = vol_backups.VolumeBackup( + vol_backups.VolumeBackupManager(None), + {'id': 'a374cbb8-3f99-4c3f-a2ef-3edbec842e31', + 'name': 'backup1', + 'description': 'volume backup 1', + 'size': 10, + 'status': 'available', + 'container_name': 'volumebackups', + 'volume_id': '11023e92-8008-4c8b-8059-7f2293ff3887'}) - volume_backup2 = vol_backups.VolumeBackup(vol_backups. - VolumeBackupManager(None), - {'id': 'c321cbb8-3f99-4c3f-a2ef-3edbec842e52', - 'name': 'backup2', - 'description': 'volume backup 2', - 'size': 20, - 'status': 'available', - 'container_name': 'volumebackups', - 'volume_id': '31023e92-8008-4c8b-8059-7f2293ff1234'}) + volume_backup2 = vol_backups.VolumeBackup( + vol_backups.VolumeBackupManager(None), + {'id': 'c321cbb8-3f99-4c3f-a2ef-3edbec842e52', + 'name': 'backup2', + 'description': 'volume backup 2', + 'size': 20, + 'status': 'available', + 'container_name': 'volumebackups', + 'volume_id': '31023e92-8008-4c8b-8059-7f2293ff1234'}) TEST.cinder_volume_backups.add(volume_backup1) TEST.cinder_volume_backups.add(volume_backup2) @@ -229,12 +236,14 @@ def data(TEST): TEST.cinder_limits = limits # QOS Specs - qos_spec1 = qos_specs.QoSSpecs(qos_specs.QoSSpecsManager(None), + qos_spec1 = qos_specs.QoSSpecs( + qos_specs.QoSSpecsManager(None), {"id": "418db45d-6992-4674-b226-80aacad2073c", "name": "high_iops", "consumer": "back-end", "specs": {"minIOPS": "1000", "maxIOPS": '100000'}}) - qos_spec2 = qos_specs.QoSSpecs(qos_specs.QoSSpecsManager(None), + qos_spec2 = qos_specs.QoSSpecs( + qos_specs.QoSSpecsManager(None), {"id": "6ed7035f-992e-4075-8ed6-6eff19b3192d", "name": "high_bws", "consumer": "back-end", diff --git a/openstack_dashboard/test/test_data/keystone_data.py b/openstack_dashboard/test/test_data/keystone_data.py index 280d8093d4..dcc31314db 100644 --- a/openstack_dashboard/test/test_data/keystone_data.py +++ b/openstack_dashboard/test/test_data/keystone_data.py @@ -221,28 +221,28 @@ def data(TEST): TEST.user.service_catalog = copy.deepcopy(SERVICE_CATALOG) group_dict = {'id': "1", - 'name': 'group_one', - 'description': 'group one description', - 'project_id': '1', - 'domain_id': '1'} + 'name': 'group_one', + 'description': 'group one description', + 'project_id': '1', + 'domain_id': '1'} group = groups.Group(groups.GroupManager(None), group_dict) group_dict = {'id': "2", - 'name': 'group_two', - 'description': 'group two description', - 'project_id': '1', - 'domain_id': '1'} + 'name': 'group_two', + 'description': 'group two description', + 'project_id': '1', + 'domain_id': '1'} group2 = groups.Group(groups.GroupManager(None), group_dict) group_dict = {'id': "3", - 'name': 'group_three', - 'description': 'group three description', - 'project_id': '1', - 'domain_id': '1'} + 'name': 'group_three', + 'description': 'group three description', + 'project_id': '1', + 'domain_id': '1'} group3 = groups.Group(groups.GroupManager(None), group_dict) group_dict = {'id': "4", - 'name': 'group_four', - 'description': 'group four description', - 'project_id': '2', - 'domain_id': '2'} + 'name': 'group_four', + 'description': 'group four description', + 'project_id': '2', + 'domain_id': '2'} group4 = groups.Group(groups.GroupManager(None), group_dict) TEST.groups.add(group, group2, group3, group4) diff --git a/openstack_dashboard/test/test_data/neutron_data.py b/openstack_dashboard/test/test_data/neutron_data.py index 087a6c5211..c0308633e5 100644 --- a/openstack_dashboard/test/test_data/neutron_data.py +++ b/openstack_dashboard/test/test_data/neutron_data.py @@ -116,7 +116,6 @@ def data(TEST): 'segment_range': '3000-3100', 'id': '00000000-1111-1111-1111-000000000000', -# 'project': network_dict['tenant_id'], 'project': TEST.networks.get(name="net1")['tenant_id'], # vlan profiles have no sub_type or multicast_ip_range 'multicast_ip_range': None, @@ -597,13 +596,13 @@ def data(TEST): # 2nd member. member_dict = {'id': '41ac1f8d-6d9c-49a4-a1bf-41955e651f91', - 'tenant_id': '1', - 'pool_id': pool_dict['id'], - 'address': '10.0.0.12', - 'protocol_port': 80, - 'weight': 10, - 'status': 'ACTIVE', - 'admin_state_up': True} + 'tenant_id': '1', + 'pool_id': pool_dict['id'], + 'address': '10.0.0.12', + 'protocol_port': 80, + 'weight': 10, + 'status': 'ACTIVE', + 'admin_state_up': True} TEST.api_members.add(member_dict) TEST.members.add(lbaas.Member(member_dict)) @@ -777,77 +776,78 @@ def data(TEST): # 1st IPSecPolicy ipsecpolicy_dict = {'id': '8376e1dd-2b1c-4346-b23c-6989e75ecdb8', - 'tenant_id': '1', - 'name': 'ipsecpolicy_1', - 'description': 'ipsecpolicy description', - 'auth_algorithm': 'sha1', - 'encapsulation_mode': 'tunnel', - 'encryption_algorithm': '3des', - 'lifetime': {'units': 'seconds', 'value': 3600}, - 'pfs': 'group5', - 'transform_protocol': 'esp', - 'ipsecsiteconns': TEST.ipsecsiteconnections.list()} + 'tenant_id': '1', + 'name': 'ipsecpolicy_1', + 'description': 'ipsecpolicy description', + 'auth_algorithm': 'sha1', + 'encapsulation_mode': 'tunnel', + 'encryption_algorithm': '3des', + 'lifetime': {'units': 'seconds', 'value': 3600}, + 'pfs': 'group5', + 'transform_protocol': 'esp', + 'ipsecsiteconns': TEST.ipsecsiteconnections.list()} TEST.api_ipsecpolicies.add(ipsecpolicy_dict) TEST.ipsecpolicies.add(vpn.IPSecPolicy(ipsecpolicy_dict)) # 2nd IPSecPolicy ipsecpolicy_dict = {'id': '8376e1dd-2b1c-4346-b23c-6989e75ecdb9', - 'tenant_id': '1', - 'name': 'ipsecpolicy_2', - 'description': 'ipsecpolicy description', - 'auth_algorithm': 'sha1', - 'encapsulation_mode': 'tunnel', - 'encryption_algorithm': '3des', - 'lifetime': {'units': 'seconds', 'value': 3600}, - 'pfs': 'group5', - 'transform_protocol': 'esp', - 'ipsecsiteconns': []} + 'tenant_id': '1', + 'name': 'ipsecpolicy_2', + 'description': 'ipsecpolicy description', + 'auth_algorithm': 'sha1', + 'encapsulation_mode': 'tunnel', + 'encryption_algorithm': '3des', + 'lifetime': {'units': 'seconds', 'value': 3600}, + 'pfs': 'group5', + 'transform_protocol': 'esp', + 'ipsecsiteconns': []} TEST.api_ipsecpolicies.add(ipsecpolicy_dict) TEST.ipsecpolicies.add(vpn.IPSecPolicy(ipsecpolicy_dict)) # 1st IPSecSiteConnection ipsecsiteconnection_dict = {'id': 'dd1dd3a0-f349-49be-b013-245e147763d6', - 'tenant_id': '1', - 'name': 'ipsec_connection_1', - 'description': 'vpn connection description', - 'dpd': {'action': 'hold', - 'interval': 30, - 'timeout': 120}, - 'ikepolicy_id': ikepolicy_dict['id'], - 'initiator': 'bi-directional', - 'ipsecpolicy_id': ipsecpolicy_dict['id'], - 'mtu': 1500, - 'peer_address': - '2607:f0d0:4545:3:200:f8ff:fe21:67cf', - 'peer_cidrs': ['20.1.0.0/24', '21.1.0.0/24'], - 'peer_id': '2607:f0d0:4545:3:200:f8ff:fe21:67cf', - 'psk': 'secret', - 'vpnservice_id': vpnservice_dict['id'], - 'admin_state_up': True, - 'status': 'Active'} + 'tenant_id': '1', + 'name': 'ipsec_connection_1', + 'description': 'vpn connection description', + 'dpd': {'action': 'hold', + 'interval': 30, + 'timeout': 120}, + 'ikepolicy_id': ikepolicy_dict['id'], + 'initiator': 'bi-directional', + 'ipsecpolicy_id': ipsecpolicy_dict['id'], + 'mtu': 1500, + 'peer_address': + '2607:f0d0:4545:3:200:f8ff:fe21:67cf', + 'peer_cidrs': ['20.1.0.0/24', '21.1.0.0/24'], + 'peer_id': + '2607:f0d0:4545:3:200:f8ff:fe21:67cf', + 'psk': 'secret', + 'vpnservice_id': vpnservice_dict['id'], + 'admin_state_up': True, + 'status': 'Active'} TEST.api_ipsecsiteconnections.add(ipsecsiteconnection_dict) TEST.ipsecsiteconnections.add( vpn.IPSecSiteConnection(ipsecsiteconnection_dict)) # 2nd IPSecSiteConnection ipsecsiteconnection_dict = {'id': 'dd1dd3a0-f349-49be-b013-245e147763d7', - 'tenant_id': '1', - 'name': 'ipsec_connection_2', - 'description': 'vpn connection description', - 'dpd': {'action': 'hold', - 'interval': 30, - 'timeout': 120}, - 'ikepolicy_id': ikepolicy_dict['id'], - 'initiator': 'bi-directional', - 'ipsecpolicy_id': ipsecpolicy_dict['id'], - 'mtu': 1500, - 'peer_address': '172.0.0.2', - 'peer_cidrs': ['20.1.0.0/24'], - 'peer_id': '172.0.0.2', - 'psk': 'secret', - 'vpnservice_id': vpnservice_dict['id'], - 'admin_state_up': True, - 'status': 'Active'} + 'tenant_id': '1', + 'name': 'ipsec_connection_2', + 'description': 'vpn connection description', + 'dpd': {'action': 'hold', + 'interval': 30, + 'timeout': 120}, + 'ikepolicy_id': ikepolicy_dict['id'], + 'initiator': 'bi-directional', + 'ipsecpolicy_id': ipsecpolicy_dict['id'], + 'mtu': 1500, + 'peer_address': '172.0.0.2', + 'peer_cidrs': ['20.1.0.0/24'], + 'peer_id': '172.0.0.2', + 'psk': 'secret', + 'vpnservice_id': vpnservice_dict['id'], + 'admin_state_up': True, + 'status': 'Active'} TEST.api_ipsecsiteconnections.add(ipsecsiteconnection_dict) TEST.ipsecsiteconnections.add( vpn.IPSecSiteConnection(ipsecsiteconnection_dict)) diff --git a/openstack_dashboard/test/test_data/nova_data.py b/openstack_dashboard/test/test_data/nova_data.py index e89010cab2..1894c60828 100644 --- a/openstack_dashboard/test/test_data/nova_data.py +++ b/openstack_dashboard/test/test_data/nova_data.py @@ -190,48 +190,52 @@ def data(TEST): TEST.api_floating_ips_uuid = utils.TestDataContainer() # Volumes - volume = volumes.Volume(volumes.VolumeManager(None), - dict(id="41023e92-8008-4c8b-8059-7f2293ff3775", - name='test_volume', - status='available', - size=40, - display_name='Volume name', - created_at='2012-04-01 10:30:00', - volume_type=None, - attachments=[])) - nameless_volume = volumes.Volume(volumes.VolumeManager(None), - dict(id="3b189ac8-9166-ac7f-90c9-16c8bf9e01ac", - name='', - status='in-use', - size=10, - display_name='', - display_description='', - device="/dev/hda", - created_at='2010-11-21 18:34:25', - volume_type='vol_type_1', - attachments=[{"id": "1", "server_id": '1', - "device": "/dev/hda"}])) - attached_volume = volumes.Volume(volumes.VolumeManager(None), - dict(id="8cba67c1-2741-6c79-5ab6-9c2bf8c96ab0", - name='my_volume', - status='in-use', - size=30, - display_name='My Volume', - display_description='', - device="/dev/hdk", - created_at='2011-05-01 11:54:33', - volume_type='vol_type_2', - attachments=[{"id": "2", "server_id": '1', - "device": "/dev/hdk"}])) - non_bootable_volume = volumes.Volume(volumes.VolumeManager(None), - dict(id="41023e92-8008-4c8b-8059-7f2293ff3771", - name='non_bootable_volume', - status='available', - size=40, - display_name='Non Bootable Volume', - created_at='2012-04-01 10:30:00', - volume_type=None, - attachments=[])) + volume = volumes.Volume( + volumes.VolumeManager(None), + {"id": "41023e92-8008-4c8b-8059-7f2293ff3775", + "name": 'test_volume', + "status": 'available', + "size": 40, + "display_name": 'Volume name', + "created_at": '2012-04-01 10:30:00', + "volume_type": None, + "attachments": []}) + nameless_volume = volumes.Volume( + volumes.VolumeManager(None), + {"id": "3b189ac8-9166-ac7f-90c9-16c8bf9e01ac", + "name": '', + "status": 'in-use', + "size": 10, + "display_name": '', + "display_description": '', + "device": "/dev/hda", + "created_at": '2010-11-21 18:34:25', + "volume_type": 'vol_type_1', + "attachments": [{"id": "1", "server_id": '1', + "device": "/dev/hda"}]}) + attached_volume = volumes.Volume( + volumes.VolumeManager(None), + {"id": "8cba67c1-2741-6c79-5ab6-9c2bf8c96ab0", + "name": 'my_volume', + "status": 'in-use', + "size": 30, + "display_name": 'My Volume', + "display_description": '', + "device": "/dev/hdk", + "created_at": '2011-05-01 11:54:33', + "volume_type": 'vol_type_2', + "attachments": [{"id": "2", "server_id": '1', + "device": "/dev/hdk"}]}) + non_bootable_volume = volumes.Volume( + volumes.VolumeManager(None), + {"id": "41023e92-8008-4c8b-8059-7f2293ff3771", + "name": 'non_bootable_volume', + "status": 'available', + "size": 40, + "display_name": 'Non Bootable Volume', + "created_at": '2012-04-01 10:30:00', + "volume_type": None, + "attachments": []}) volume.bootable = 'true' nameless_volume.bootable = 'true' @@ -297,12 +301,14 @@ def data(TEST): TEST.flavors.add(flavor_1, flavor_2, flavor_3, flavor_4) flavor_access_manager = flavor_access.FlavorAccessManager(None) - flavor_access_1 = flavor_access.FlavorAccess(flavor_access_manager, - {"tenant_id": "1", - "flavor_id": "dddddddd-dddd-dddd-dddd-dddddddddddd"}) - flavor_access_2 = flavor_access.FlavorAccess(flavor_access_manager, - {"tenant_id": "2", - "flavor_id": "dddddddd-dddd-dddd-dddd-dddddddddddd"}) + flavor_access_1 = flavor_access.FlavorAccess( + flavor_access_manager, + {"tenant_id": "1", + "flavor_id": "dddddddd-dddd-dddd-dddd-dddddddddddd"}) + flavor_access_2 = flavor_access.FlavorAccess( + flavor_access_manager, + {"tenant_id": "2", + "flavor_id": "dddddddd-dddd-dddd-dddd-dddddddddddd"}) TEST.flavor_access.add(flavor_access_1, flavor_access_2) # Key pairs @@ -547,20 +553,22 @@ def data(TEST): json.loads(USAGE_DATA % usage_2_vals)) TEST.usages.add(usage_obj_2) - volume_snapshot = vol_snaps.Snapshot(vol_snaps.SnapshotManager(None), - {'id': '40f3fabf-3613-4f5e-90e5-6c9a08333fc3', - 'display_name': 'test snapshot', - 'display_description': 'vol snap!', - 'size': 40, - 'status': 'available', - 'volume_id': '41023e92-8008-4c8b-8059-7f2293ff3775'}) - volume_snapshot2 = vol_snaps.Snapshot(vol_snaps.SnapshotManager(None), - {'id': 'a374cbb8-3f99-4c3f-a2ef-3edbec842e31', - 'display_name': '', - 'display_description': 'vol snap 2!', - 'size': 80, - 'status': 'available', - 'volume_id': '3b189ac8-9166-ac7f-90c9-16c8bf9e01ac'}) + volume_snapshot = vol_snaps.Snapshot( + vol_snaps.SnapshotManager(None), + {'id': '40f3fabf-3613-4f5e-90e5-6c9a08333fc3', + 'display_name': 'test snapshot', + 'display_description': 'vol snap!', + 'size': 40, + 'status': 'available', + 'volume_id': '41023e92-8008-4c8b-8059-7f2293ff3775'}) + volume_snapshot2 = vol_snaps.Snapshot( + vol_snaps.SnapshotManager(None), + {'id': 'a374cbb8-3f99-4c3f-a2ef-3edbec842e31', + 'display_name': '', + 'display_description': 'vol snap 2!', + 'size': 80, + 'status': 'available', + 'volume_id': '3b189ac8-9166-ac7f-90c9-16c8bf9e01ac'}) TEST.volume_snapshots.add(volume_snapshot) TEST.volume_snapshots.add(volume_snapshot2) diff --git a/openstack_dashboard/test/test_panels/plugin_panel/urls.py b/openstack_dashboard/test/test_panels/plugin_panel/urls.py index 4886314a04..136af6413d 100644 --- a/openstack_dashboard/test/test_panels/plugin_panel/urls.py +++ b/openstack_dashboard/test/test_panels/plugin_panel/urls.py @@ -15,6 +15,7 @@ from django.conf.urls import url from openstack_dashboard.test.test_panels.plugin_panel import views -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', views.IndexView.as_view(), name='index'), ) diff --git a/openstack_dashboard/test/tests/quotas.py b/openstack_dashboard/test/tests/quotas.py index 102b51f0d0..4836fa5ff2 100644 --- a/openstack_dashboard/test/tests/quotas.py +++ b/openstack_dashboard/test/tests/quotas.py @@ -62,9 +62,9 @@ class QuotaTests(test.APITestCase): if s.tenant_id == self.request.user.tenant_id] api.base.is_service_enabled(IsA(http.HttpRequest), - 'volume').AndReturn(True) + 'volume').AndReturn(True) api.base.is_service_enabled(IsA(http.HttpRequest), - 'network').AndReturn(False) + 'network').AndReturn(False) api.nova.flavor_list(IsA(http.HttpRequest)) \ .AndReturn(self.flavors.list()) api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \ @@ -101,9 +101,9 @@ class QuotaTests(test.APITestCase): if s.tenant_id == self.request.user.tenant_id] api.base.is_service_enabled(IsA(http.HttpRequest), - 'volume').AndReturn(False) + 'volume').AndReturn(False) api.base.is_service_enabled(IsA(http.HttpRequest), - 'network').AndReturn(False) + 'network').AndReturn(False) api.nova.flavor_list(IsA(http.HttpRequest)) \ .AndReturn(self.flavors.list()) api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \ @@ -136,9 +136,9 @@ class QuotaTests(test.APITestCase): api.base: ('is_service_enabled',)}) def test_tenant_quota_usages_no_instances_running(self): api.base.is_service_enabled(IsA(http.HttpRequest), - 'volume').AndReturn(False) + 'volume').AndReturn(False) api.base.is_service_enabled(IsA(http.HttpRequest), - 'network').AndReturn(False) + 'network').AndReturn(False) api.nova.flavor_list(IsA(http.HttpRequest)) \ .AndReturn(self.flavors.list()) api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \ @@ -178,9 +178,9 @@ class QuotaTests(test.APITestCase): if s.tenant_id == self.request.user.tenant_id] api.base.is_service_enabled(IsA(http.HttpRequest), - 'volume').AndReturn(True) + 'volume').AndReturn(True) api.base.is_service_enabled(IsA(http.HttpRequest), - 'network').AndReturn(False) + 'network').AndReturn(False) api.nova.flavor_list(IsA(http.HttpRequest)) \ .AndReturn(self.flavors.list()) api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \ @@ -222,9 +222,9 @@ class QuotaTests(test.APITestCase): if s.tenant_id == self.request.user.tenant_id] api.base.is_service_enabled(IsA(http.HttpRequest), - 'volume').AndReturn(True) + 'volume').AndReturn(True) api.base.is_service_enabled(IsA(http.HttpRequest), - 'network').AndReturn(False) + 'network').AndReturn(False) api.nova.flavor_list(IsA(http.HttpRequest)) \ .AndReturn(self.flavors.list()) api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \ diff --git a/openstack_dashboard/urls.py b/openstack_dashboard/urls.py index 5b2df03604..f40007b308 100644 --- a/openstack_dashboard/urls.py +++ b/openstack_dashboard/urls.py @@ -30,7 +30,8 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns # noqa import horizon -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', 'openstack_dashboard.views.splash', name='splash'), url(r'^auth/', include('openstack_auth.urls')), url(r'', include(horizon.urls)) @@ -45,6 +46,7 @@ urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: - urlpatterns += patterns('', + urlpatterns += patterns( + '', url(r'^500/$', 'django.views.defaults.server_error') ) diff --git a/tox.ini b/tox.ini index 39b0dc22a7..fbbdaa0ae9 100644 --- a/tox.ini +++ b/tox.ini @@ -62,12 +62,11 @@ downloadcache = ~/cache/pip [flake8] exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject -# E128 continuation line under-indented for visual indent # H307 like imports should be grouped together # H405 multi line docstring summary not separated with an empty line # H803 git commit title should not end with period (disabled on purpose, see bug #1236621) # H904 Wrap long lines in parentheses instead of a backslash -ignore = E128,H307,H405,H803,H904 +ignore = H307,H405,H803,H904 [hacking] import_exceptions = collections.defaultdict,