Replace SortedDict with OrderedDict
From django V1.9 django.utils.datastructures.SortedDict will be removed and it is deprecated in V1.7. The similar functionality is added in collections.OrderedDict from python 2.7. Horizon code also should avoid the SortedDict class and start using the OrderedDict class. This patch replacing the SortedDict with OrderedDict. Change-Id: I8dfcf7c29fc49b6215451f160cf7a951bf11b5ad Closes-Bug: #1492270
This commit is contained in:
parent
3915c85565
commit
4e8549ee9a
@ -32,7 +32,6 @@ from django.conf.urls import patterns
|
||||
from django.conf.urls import url
|
||||
from django.core.exceptions import ImproperlyConfigured # noqa
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.functional import SimpleLazyObject # noqa
|
||||
from django.utils.importlib import import_module # noqa
|
||||
@ -491,7 +490,7 @@ class Dashboard(Registry, HorizonComponent):
|
||||
name=_("Other"),
|
||||
panels=slugs)
|
||||
panel_groups.append((new_group.slug, new_group))
|
||||
return SortedDict(panel_groups)
|
||||
return collections.OrderedDict(panel_groups)
|
||||
|
||||
def get_absolute_url(self):
|
||||
"""Returns the default URL for this dashboard.
|
||||
@ -568,7 +567,7 @@ class Dashboard(Registry, HorizonComponent):
|
||||
panels_to_discover.extend(panel_group.panels)
|
||||
panel_groups.append((panel_group.slug, panel_group))
|
||||
|
||||
self._panel_groups = SortedDict(panel_groups)
|
||||
self._panel_groups = collections.OrderedDict(panel_groups)
|
||||
|
||||
# Do the actual discovery
|
||||
package = '.'.join(self.__module__.split('.')[:-1])
|
||||
|
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
from collections import defaultdict
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
import types
|
||||
import warnings
|
||||
@ -21,7 +22,6 @@ from django.conf import settings
|
||||
from django.core import urlresolvers
|
||||
from django import shortcuts
|
||||
from django.template.loader import render_to_string # noqa
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.functional import Promise # noqa
|
||||
from django.utils.http import urlencode # noqa
|
||||
from django.utils.translation import pgettext_lazy
|
||||
@ -363,7 +363,7 @@ class LinkAction(BaseAction):
|
||||
def get_ajax_update_url(self):
|
||||
table_url = self.table.get_absolute_url()
|
||||
params = urlencode(
|
||||
SortedDict([("action", self.name), ("table", self.table.name)])
|
||||
OrderedDict([("action", self.name), ("table", self.table.name)])
|
||||
)
|
||||
return "%s?%s" % (table_url, params)
|
||||
|
||||
|
@ -27,7 +27,6 @@ from django import template
|
||||
from django.template.defaultfilters import slugify # noqa
|
||||
from django.template.defaultfilters import truncatechars # noqa
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.html import escape
|
||||
from django.utils import http
|
||||
from django.utils.http import urlencode
|
||||
@ -487,7 +486,7 @@ class Row(html.HTMLElement):
|
||||
|
||||
.. attribute:: cells
|
||||
|
||||
The cells belonging to this row stored in a ``SortedDict`` object.
|
||||
The cells belonging to this row stored in a ``OrderedDict`` object.
|
||||
This attribute is populated during instantiation.
|
||||
|
||||
.. attribute:: status
|
||||
@ -555,7 +554,7 @@ class Row(html.HTMLElement):
|
||||
for column in table.columns.values():
|
||||
cell = table._meta.cell_class(datum, column, self)
|
||||
cells.append((column.name or column.auto, cell))
|
||||
self.cells = SortedDict(cells)
|
||||
self.cells = collections.OrderedDict(cells)
|
||||
|
||||
if self.ajax:
|
||||
interval = conf.HORIZON_CONFIG['ajax_poll_interval']
|
||||
@ -610,7 +609,7 @@ class Row(html.HTMLElement):
|
||||
|
||||
def get_ajax_update_url(self):
|
||||
table_url = self.table.get_absolute_url()
|
||||
params = urlencode(SortedDict([
|
||||
params = urlencode(collections.OrderedDict([
|
||||
("action", self.ajax_action_name),
|
||||
("table", self.table.name),
|
||||
("obj_id", self.table.get_object_id(self.datum))
|
||||
@ -805,7 +804,7 @@ class Cell(html.HTMLElement):
|
||||
def get_ajax_update_url(self):
|
||||
column = self.column
|
||||
table_url = column.table.get_absolute_url()
|
||||
params = urlencode(SortedDict([
|
||||
params = urlencode(collections.OrderedDict([
|
||||
("action", self.row.ajax_cell_action_name),
|
||||
("table", column.table.name),
|
||||
("cell_name", column.name),
|
||||
@ -1076,8 +1075,8 @@ class DataTableMetaclass(type):
|
||||
# Iterate in reverse to preserve final order
|
||||
for base in reversed(bases):
|
||||
if hasattr(base, 'base_columns'):
|
||||
columns[0:0] = base.base_columns.items()
|
||||
dt_attrs['base_columns'] = SortedDict(columns)
|
||||
columns = base.base_columns.items() + columns
|
||||
dt_attrs['base_columns'] = collections.OrderedDict(columns)
|
||||
|
||||
# If the table is in a ResourceBrowser, the column number must meet
|
||||
# these limits because of the width of the browser.
|
||||
@ -1110,7 +1109,7 @@ class DataTableMetaclass(type):
|
||||
actions_column.classes.append('actions_column')
|
||||
columns.append(("actions", actions_column))
|
||||
# Store this set of columns internally so we can copy them per-instance
|
||||
dt_attrs['_columns'] = SortedDict(columns)
|
||||
dt_attrs['_columns'] = collections.OrderedDict(columns)
|
||||
|
||||
# Gather and register actions for later access since we only want
|
||||
# to instantiate them once.
|
||||
@ -1118,8 +1117,8 @@ class DataTableMetaclass(type):
|
||||
actions = list(set(opts.row_actions) | set(opts.table_actions) |
|
||||
set(opts.table_actions_menu))
|
||||
actions.sort(key=attrgetter('name'))
|
||||
actions_dict = SortedDict([(action.name, action())
|
||||
for action in actions])
|
||||
actions_dict = collections.OrderedDict([(action.name, action())
|
||||
for action in actions])
|
||||
dt_attrs['base_actions'] = actions_dict
|
||||
if opts._filter_action:
|
||||
# Replace our filter action with the instantiated version
|
||||
@ -1172,7 +1171,7 @@ class DataTable(object):
|
||||
column = copy.copy(_column)
|
||||
column.table = self
|
||||
columns.append((key, column))
|
||||
self.columns = SortedDict(columns)
|
||||
self.columns = collections.OrderedDict(columns)
|
||||
self._populate_data_cache()
|
||||
|
||||
# Associate these actions with this table
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
import itertools
|
||||
import logging
|
||||
import sys
|
||||
@ -18,7 +19,6 @@ import six
|
||||
|
||||
from django import template
|
||||
from django.template import loader
|
||||
from django.utils import datastructures
|
||||
|
||||
from horizon.tables import base as horizon_tables
|
||||
|
||||
@ -55,12 +55,12 @@ class FormsetRow(horizon_tables.Row):
|
||||
# We need to be able to handle empty rows, because there may
|
||||
# be extra empty forms in a formset. The original DataTable breaks
|
||||
# on this, because it sets self.cells to [], but later expects a
|
||||
# SortedDict. We just fill self.cells with empty Cells.
|
||||
# OrderedDict. We just fill self.cells with empty Cells.
|
||||
cells = []
|
||||
for column in self.table.columns.values():
|
||||
cell = self.table._meta.cell_class(None, column, self)
|
||||
cells.append((column.name or column.auto, cell))
|
||||
self.cells = datastructures.SortedDict(cells)
|
||||
self.cells = collections.OrderedDict(cells)
|
||||
|
||||
def render(self):
|
||||
return loader.render_to_string(self.template_path,
|
||||
|
@ -12,13 +12,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from django.template import TemplateSyntaxError # noqa
|
||||
from django.utils.datastructures import SortedDict
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon.utils import html
|
||||
@ -108,7 +108,7 @@ class TabGroup(html.HTMLElement):
|
||||
tab_instances = []
|
||||
for tab in self.tabs:
|
||||
tab_instances.append((tab.slug, tab(self, request)))
|
||||
self._tabs = SortedDict(tab_instances)
|
||||
self._tabs = OrderedDict(tab_instances)
|
||||
if self.sticky:
|
||||
self.attrs['data-sticky-tabs'] = 'sticky'
|
||||
if not self._set_active_tab():
|
||||
@ -428,7 +428,7 @@ class TableTab(Tab):
|
||||
table_instances = [(table._meta.name,
|
||||
table(request, **tab_group.kwargs))
|
||||
for table in self.table_classes]
|
||||
self._tables = SortedDict(table_instances)
|
||||
self._tables = OrderedDict(table_instances)
|
||||
self._table_data_loaded = False
|
||||
|
||||
def load_table_data(self):
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from collections import OrderedDict
|
||||
from horizon.contrib import bootstrap_datepicker
|
||||
|
||||
from django.conf import settings
|
||||
from django import template
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils import translation
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@ -70,10 +70,10 @@ def horizon_nav(context):
|
||||
non_empty_groups.append((group, allowed_panels))
|
||||
if (callable(dash.nav) and dash.nav(context) and
|
||||
dash.can_access(context)):
|
||||
dashboards.append((dash, SortedDict(non_empty_groups)))
|
||||
dashboards.append((dash, OrderedDict(non_empty_groups)))
|
||||
elif (not callable(dash.nav) and dash.nav and
|
||||
dash.can_access(context)):
|
||||
dashboards.append((dash, SortedDict(non_empty_groups)))
|
||||
dashboards.append((dash, OrderedDict(non_empty_groups)))
|
||||
return {'components': dashboards,
|
||||
'user': context['request'].user,
|
||||
'current': current_dashboard,
|
||||
@ -125,7 +125,7 @@ def horizon_dashboard_nav(context):
|
||||
else:
|
||||
non_empty_groups.append((group.name, allowed_panels))
|
||||
|
||||
return {'components': SortedDict(non_empty_groups),
|
||||
return {'components': OrderedDict(non_empty_groups),
|
||||
'user': context['request'].user,
|
||||
'current': context['request'].horizon['panel'].slug,
|
||||
'request': context['request']}
|
||||
|
@ -10,12 +10,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from ceilometerclient import client as ceilometer_client
|
||||
from django.conf import settings
|
||||
from django.utils import datastructures
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -925,7 +925,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
meters_info = datastructures.SortedDict([
|
||||
meters_info = OrderedDict([
|
||||
("instance", {
|
||||
'label': '',
|
||||
'description': _("Existence of instance"),
|
||||
@ -1061,7 +1061,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
return datastructures.SortedDict([
|
||||
return OrderedDict([
|
||||
('network', {
|
||||
'label': '',
|
||||
'description': _("Existence of network"),
|
||||
@ -1134,7 +1134,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
return datastructures.SortedDict([
|
||||
return OrderedDict([
|
||||
('image', {
|
||||
'label': '',
|
||||
'description': _("Image existence check"),
|
||||
@ -1175,7 +1175,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
return datastructures.SortedDict([
|
||||
return OrderedDict([
|
||||
('volume', {
|
||||
'label': '',
|
||||
'description': _("Existence of volume"),
|
||||
@ -1196,7 +1196,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
return datastructures.SortedDict([
|
||||
return OrderedDict([
|
||||
('storage.objects', {
|
||||
'label': '',
|
||||
'description': _("Number of objects"),
|
||||
@ -1233,7 +1233,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
return datastructures.SortedDict([
|
||||
return OrderedDict([
|
||||
('energy', {
|
||||
'label': '',
|
||||
'description': _("Amount of energy"),
|
||||
@ -1254,7 +1254,7 @@ class Meters(object):
|
||||
# below, I need to define it as a static here. I will be joining this
|
||||
# to info that I am able to obtain from Ceilometer meters, hopefully
|
||||
# some day it will be supported all.
|
||||
return datastructures.SortedDict([
|
||||
return OrderedDict([
|
||||
('hardware.ipmi.node.power', {
|
||||
'label': '',
|
||||
'description': _("System Current Power"),
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
from horizon.utils import memoized
|
||||
|
||||
@ -98,7 +98,7 @@ def _rule_list(request, expand_policy, **kwargs):
|
||||
**kwargs).get('firewall_rules')
|
||||
if expand_policy and rules:
|
||||
policies = _policy_list(request, expand_rule=False)
|
||||
policy_dict = SortedDict((p.id, p) for p in policies)
|
||||
policy_dict = OrderedDict((p.id, p) for p in policies)
|
||||
for rule in rules:
|
||||
rule['policy'] = policy_dict.get(rule['firewall_policy_id'])
|
||||
return [Rule(r) for r in rules]
|
||||
@ -170,7 +170,7 @@ def _policy_list(request, expand_rule, **kwargs):
|
||||
**kwargs).get('firewall_policies')
|
||||
if expand_rule and policies:
|
||||
rules = _rule_list(request, expand_policy=False)
|
||||
rule_dict = SortedDict((rule.id, rule) for rule in rules)
|
||||
rule_dict = OrderedDict((rule.id, rule) for rule in rules)
|
||||
for p in policies:
|
||||
p['rules'] = [rule_dict.get(rule) for rule in p['firewall_rules']]
|
||||
return [Policy(p) for p in policies]
|
||||
@ -188,7 +188,7 @@ def _policy_get(request, policy_id, expand_rule):
|
||||
if policy_rules:
|
||||
rules = _rule_list(request, expand_policy=False,
|
||||
firewall_policy_id=policy_id)
|
||||
rule_dict = SortedDict((rule.id, rule) for rule in rules)
|
||||
rule_dict = OrderedDict((rule.id, rule) for rule in rules)
|
||||
policy['rules'] = [rule_dict.get(rule) for rule in policy_rules]
|
||||
else:
|
||||
policy['rules'] = []
|
||||
@ -258,7 +258,7 @@ def _firewall_list(request, expand_policy, **kwargs):
|
||||
**kwargs).get('firewalls')
|
||||
if expand_policy and firewalls:
|
||||
policies = _policy_list(request, expand_rule=False)
|
||||
policy_dict = SortedDict((p.id, p) for p in policies)
|
||||
policy_dict = OrderedDict((p.id, p) for p in policies)
|
||||
for fw in firewalls:
|
||||
fw['policy'] = policy_dict.get(fw['firewall_policy_id'])
|
||||
return [Firewall(f) for f in firewalls]
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
from collections import OrderedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import messages
|
||||
@ -171,13 +171,13 @@ def _pool_list(request, expand_subnet=False, expand_vip=False, **kwargs):
|
||||
pools = neutronclient(request).list_pools(**kwargs).get('pools')
|
||||
if expand_subnet:
|
||||
subnets = neutron.subnet_list(request)
|
||||
subnet_dict = SortedDict((s.id, s) for s in subnets)
|
||||
subnet_dict = OrderedDict((s.id, s) for s in subnets)
|
||||
for p in pools:
|
||||
subnet = subnet_dict.get(p['subnet_id'])
|
||||
p['subnet_name'] = subnet.cidr if subnet else None
|
||||
if expand_vip:
|
||||
vips = vip_list(request)
|
||||
vip_dict = SortedDict((v.id, v) for v in vips)
|
||||
vip_dict = OrderedDict((v.id, v) for v in vips)
|
||||
for p in pools:
|
||||
p['vip'] = _get_vip(request, p, vip_dict)
|
||||
return [Pool(p) for p in pools]
|
||||
@ -342,7 +342,7 @@ def _member_list(request, expand_pool, **kwargs):
|
||||
members = neutronclient(request).list_members(**kwargs).get('members')
|
||||
if expand_pool:
|
||||
pools = _pool_list(request)
|
||||
pool_dict = SortedDict((p.id, p) for p in pools)
|
||||
pool_dict = OrderedDict((p.id, p) for p in pools)
|
||||
for m in members:
|
||||
m['pool_name'] = pool_dict.get(m['pool_id']).name_or_id
|
||||
return [Member(m) for m in members]
|
||||
|
@ -25,7 +25,6 @@ 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.common import exceptions as neutron_exc
|
||||
from neutronclient.v2_0 import client as neutron_client
|
||||
@ -409,7 +408,7 @@ class FloatingIpManager(network_base.FloatingIpManager):
|
||||
# Get port list to add instance_id to floating IP list
|
||||
# instance_id is stored in device_id attribute
|
||||
ports = port_list(self.request, **port_search_opts)
|
||||
port_dict = SortedDict([(p['id'], p) for p in ports])
|
||||
port_dict = collections.OrderedDict([(p['id'], p) for p in ports])
|
||||
for fip in fips:
|
||||
self._set_instance_info(fip, port_dict.get(fip['port_id']))
|
||||
return [FloatingIp(fip) for fip in fips]
|
||||
@ -469,7 +468,8 @@ class FloatingIpManager(network_base.FloatingIpManager):
|
||||
tenant_id = self.request.user.tenant_id
|
||||
ports = port_list(self.request, tenant_id=tenant_id)
|
||||
servers, has_more = nova.server_list(self.request)
|
||||
server_dict = SortedDict([(s.id, s.name) for s in servers])
|
||||
server_dict = collections.OrderedDict(
|
||||
[(s.id, s.name) for s in servers])
|
||||
reachable_subnets = self._get_reachable_subnets(ports)
|
||||
if is_service_enabled(self.request,
|
||||
config_name='enable_lb',
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
from horizon.utils.memoized import memoized # noqa
|
||||
|
||||
@ -88,12 +88,12 @@ def _vpnservice_list(request, expand_subnet=False, expand_router=False,
|
||||
**kwargs).get('vpnservices')
|
||||
if expand_subnet:
|
||||
subnets = neutron.subnet_list(request)
|
||||
subnet_dict = SortedDict((s.id, s) for s in subnets)
|
||||
subnet_dict = OrderedDict((s.id, s) for s in subnets)
|
||||
for s in vpnservices:
|
||||
s['subnet_name'] = subnet_dict.get(s['subnet_id']).cidr
|
||||
if expand_router:
|
||||
routers = neutron.router_list(request)
|
||||
router_dict = SortedDict((r.id, r) for r in routers)
|
||||
router_dict = OrderedDict((r.id, r) for r in routers)
|
||||
for s in vpnservices:
|
||||
s['router_name'] = router_dict.get(s['router_id']).name_or_id
|
||||
if expand_conns:
|
||||
@ -324,18 +324,18 @@ def _ipsecsiteconnection_list(request, expand_ikepolicies=False,
|
||||
**kwargs).get('ipsec_site_connections')
|
||||
if expand_ikepolicies:
|
||||
ikepolicies = _ikepolicy_list(request, **kwargs)
|
||||
policy_dict = SortedDict((p.id, p) for p in ikepolicies)
|
||||
policy_dict = OrderedDict((p.id, p) for p in ikepolicies)
|
||||
for c in ipsecsiteconnections:
|
||||
c['ikepolicy_name'] = policy_dict.get(c['ikepolicy_id']).name_or_id
|
||||
if expand_ipsecpolicies:
|
||||
ipsecpolicies = _ipsecpolicy_list(request, **kwargs)
|
||||
policy_dict = SortedDict((p.id, p) for p in ipsecpolicies)
|
||||
policy_dict = OrderedDict((p.id, p) for p in ipsecpolicies)
|
||||
for c in ipsecsiteconnections:
|
||||
c['ipsecpolicy_name'] = policy_dict.get(c['ipsecpolicy_id']
|
||||
).name_or_id
|
||||
if expand_vpnservices:
|
||||
vpnservices = _vpnservice_list(request, **kwargs)
|
||||
service_dict = SortedDict((s.id, s) for s in vpnservices)
|
||||
service_dict = OrderedDict((s.id, s) for s in vpnservices)
|
||||
for c in ipsecsiteconnections:
|
||||
c['vpnservice_name'] = service_dict.get(c['vpnservice_id']
|
||||
).name_or_id
|
||||
|
@ -15,11 +15,11 @@
|
||||
"""
|
||||
Views for managing database instances.
|
||||
"""
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import six
|
||||
@ -60,8 +60,8 @@ class IndexView(horizon_tables.DataTableView):
|
||||
flavors = []
|
||||
msg = _('Unable to retrieve database size information.')
|
||||
exceptions.handle(self.request, msg)
|
||||
return SortedDict((six.text_type(flavor.id), flavor)
|
||||
for flavor in flavors)
|
||||
return OrderedDict((six.text_type(flavor.id), flavor)
|
||||
for flavor in flavors)
|
||||
|
||||
def _extra_data(self, instance):
|
||||
flavor = self.get_flavors().get(instance.flavor["id"])
|
||||
|
@ -12,11 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
import uuid
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django import http
|
||||
from django.utils.datastructures import SortedDict
|
||||
|
||||
from mox3.mox import IgnoreArg # noqa
|
||||
from mox3.mox import IsA # noqa
|
||||
@ -63,7 +63,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
|
||||
servers = self.servers.list()
|
||||
tenants = self.tenants.list()
|
||||
flavors = self.flavors.list()
|
||||
full_flavors = SortedDict([(f.id, f) for f in flavors])
|
||||
full_flavors = OrderedDict([(f.id, f) for f in flavors])
|
||||
|
||||
search_opts = {'marker': None, 'paginate': True}
|
||||
api.nova.server_list(IsA(http.HttpRequest),
|
||||
|
@ -17,9 +17,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -119,8 +119,8 @@ class AdminIndexView(tables.DataTableView):
|
||||
# If fails to retrieve flavor list, creates an empty list.
|
||||
flavors = []
|
||||
|
||||
full_flavors = SortedDict([(f.id, f) for f in flavors])
|
||||
tenant_dict = SortedDict([(t.id, t) for t in tenants])
|
||||
full_flavors = OrderedDict([(f.id, f) for f in flavors])
|
||||
tenant_dict = OrderedDict([(t.id, t) for t in tenants])
|
||||
# Loop through instances to get flavor and tenant info.
|
||||
for inst in instances:
|
||||
flavor_id = inst.flavor["id"]
|
||||
|
@ -12,8 +12,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -51,7 +52,7 @@ class IndexView(tables.DataTableView):
|
||||
"networks' projects.")
|
||||
exceptions.handle(self.request, msg)
|
||||
|
||||
tenant_dict = SortedDict([(t.id, t) for t in tenants])
|
||||
tenant_dict = OrderedDict([(t.id, t) for t in tenants])
|
||||
return tenant_dict
|
||||
|
||||
def _get_agents_data(self, network):
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
from collections import OrderedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -53,7 +53,7 @@ class VolumeTab(tabs.TableTab, volumes_tabs.VolumeTableMixIn):
|
||||
msg = _('Unable to retrieve volume project information.')
|
||||
exceptions.handle(self.request, msg)
|
||||
|
||||
tenant_dict = SortedDict([(t.id, t) for t in tenants])
|
||||
tenant_dict = OrderedDict([(t.id, t) for t in tenants])
|
||||
for volume in volumes:
|
||||
tenant_id = getattr(volume, "os-vol-tenant-attr:tenant_id", None)
|
||||
tenant = tenant_dict.get(tenant_id, None)
|
||||
@ -88,7 +88,7 @@ class VolumeTypesTab(tabs.TableTab, volumes_tabs.VolumeTableMixIn):
|
||||
msg = _('Unable to retrieve volume type encryption information.')
|
||||
exceptions.handle(self.request, msg)
|
||||
|
||||
vol_type_enc_dict = SortedDict([(e.volume_type_id, e) for e in
|
||||
vol_type_enc_dict = OrderedDict([(e.volume_type_id, e) for e in
|
||||
vol_type_enc_list])
|
||||
for volume_type in volume_types:
|
||||
vol_type_enc = vol_type_enc_dict.get(volume_type.id, None)
|
||||
|
@ -11,9 +11,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import six
|
||||
@ -26,7 +26,7 @@ from openstack_dashboard import api
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
CONSOLES = SortedDict([('VNC', api.nova.server_vnc_console),
|
||||
CONSOLES = OrderedDict([('VNC', api.nova.server_vnc_console),
|
||||
('SPICE', api.nova.server_spice_console),
|
||||
('RDP', api.nova.server_rdp_console),
|
||||
('SERIAL', api.nova.server_serial_console)])
|
||||
|
@ -16,6 +16,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
import json
|
||||
import sys
|
||||
|
||||
@ -25,7 +26,6 @@ from django.core.urlresolvers import reverse
|
||||
from django.forms import widgets
|
||||
from django import http
|
||||
import django.test
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils import encoding
|
||||
from django.utils.http import urlencode
|
||||
from mox3.mox import IgnoreArg # noqa
|
||||
@ -131,7 +131,7 @@ class InstanceTests(helpers.TestCase):
|
||||
def test_index_flavor_list_exception(self):
|
||||
servers = self.servers.list()
|
||||
flavors = self.flavors.list()
|
||||
full_flavors = SortedDict([(f.id, f) for f in flavors])
|
||||
full_flavors = OrderedDict([(f.id, f) for f in flavors])
|
||||
search_opts = {'marker': None, 'paginate': True}
|
||||
api.nova.extension_supported('AdminActions',
|
||||
IsA(http.HttpRequest)) \
|
||||
@ -4136,7 +4136,7 @@ class InstanceAjaxTests(helpers.TestCase):
|
||||
instance_id = server.id
|
||||
flavor_id = server.flavor["id"]
|
||||
flavors = self.flavors.list()
|
||||
full_flavors = SortedDict([(f.id, f) for f in flavors])
|
||||
full_flavors = OrderedDict([(f.id, f) for f in flavors])
|
||||
|
||||
api.nova.extension_supported('AdminActions', IsA(http.HttpRequest))\
|
||||
.MultipleTimes().AndReturn(True)
|
||||
@ -4167,7 +4167,7 @@ class InstanceAjaxTests(helpers.TestCase):
|
||||
instance_id = server.id
|
||||
flavor_id = server.flavor["id"]
|
||||
flavors = self.flavors.list()
|
||||
full_flavors = SortedDict([(f.id, f) for f in flavors])
|
||||
full_flavors = OrderedDict([(f.id, f) for f in flavors])
|
||||
|
||||
server.status = 'ERROR'
|
||||
server.fault = {"message": "NoValidHost",
|
||||
@ -4245,7 +4245,7 @@ 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.
|
||||
console.CONSOLES = SortedDict([
|
||||
console.CONSOLES = OrderedDict([
|
||||
('VNC', api.nova.server_vnc_console),
|
||||
('SPICE', api.nova.server_spice_console),
|
||||
('RDP', api.nova.server_rdp_console),
|
||||
|
@ -19,13 +19,13 @@
|
||||
"""
|
||||
Views for managing instances.
|
||||
"""
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django import http
|
||||
from django import shortcuts
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views import generic
|
||||
|
||||
@ -100,9 +100,9 @@ class IndexView(tables.DataTableView):
|
||||
images = []
|
||||
exceptions.handle(self.request, ignore=True)
|
||||
|
||||
full_flavors = SortedDict([(str(flavor.id), flavor)
|
||||
full_flavors = OrderedDict([(str(flavor.id), flavor)
|
||||
for flavor in flavors])
|
||||
image_map = SortedDict([(str(image.id), image)
|
||||
image_map = OrderedDict([(str(image.id), image)
|
||||
for image in images])
|
||||
|
||||
# Loop through instances to get flavor info.
|
||||
@ -416,7 +416,7 @@ class ResizeView(workflows.WorkflowView):
|
||||
def get_flavors(self, *args, **kwargs):
|
||||
try:
|
||||
flavors = api.nova.flavor_list(self.request)
|
||||
return SortedDict((str(flavor.id), flavor) for flavor in flavors)
|
||||
return OrderedDict((str(flavor.id), flavor) for flavor in flavors)
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:instances:index")
|
||||
exceptions.handle(self.request,
|
||||
|
@ -17,9 +17,10 @@
|
||||
Views for managing Neutron Routers.
|
||||
"""
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import pgettext_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@ -68,8 +69,8 @@ class IndexView(tables.DataTableView):
|
||||
search_opts = {'router:external': True}
|
||||
ext_nets = api.neutron.network_list(self.request,
|
||||
**search_opts)
|
||||
ext_net_dict = SortedDict((n['id'], n.name_or_id)
|
||||
for n in ext_nets)
|
||||
ext_net_dict = OrderedDict((n['id'], n.name_or_id)
|
||||
for n in ext_nets)
|
||||
except Exception as e:
|
||||
msg = _('Unable to retrieve a list of external networks "%s".') % e
|
||||
exceptions.handle(self.request, msg)
|
||||
|
@ -12,7 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.datastructures import SortedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
@ -68,7 +69,7 @@ class VolumeTableMixIn(object):
|
||||
volumes,
|
||||
instances,
|
||||
volume_ids_with_snapshots):
|
||||
instances = SortedDict([(inst.id, inst) for inst in instances])
|
||||
instances = OrderedDict([(inst.id, inst) for inst in instances])
|
||||
for volume in volumes:
|
||||
if volume_ids_with_snapshots:
|
||||
if volume.id in volume_ids_with_snapshots:
|
||||
|
2
tox.ini
2
tox.ini
@ -66,6 +66,7 @@ max-complexity = 20
|
||||
|
||||
[hacking]
|
||||
import_exceptions = collections.defaultdict,
|
||||
collections.OrderedDict,
|
||||
django.conf.settings,
|
||||
django.conf.urls.include,
|
||||
django.conf.urls.patterns,
|
||||
@ -74,7 +75,6 @@ import_exceptions = collections.defaultdict,
|
||||
django.core.urlresolvers.reverse_lazy,
|
||||
django.template.loader.render_to_string,
|
||||
django.test.utils.override_settings,
|
||||
django.utils.datastructures.SortedDict,
|
||||
django.utils.encoding.force_text,
|
||||
django.utils.html.conditional_escape,
|
||||
django.utils.html.escape,
|
||||
|
Loading…
Reference in New Issue
Block a user