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