Fix OrderedDict usage for Python 2.6
"import collections" also works on Python 2.6 but collections.OrderedDict() is not available so the current check is wrong. Using a function to get an OrderedDict() instance works fine for that. Closes-Bug: #1375568 Change-Id: Iaf739dc2deb7d4b09bf477be60de4df8c4fcf5c0
This commit is contained in:
parent
fb34fcbdaf
commit
7212f7dc92
@ -33,10 +33,17 @@ from ceilometer.ipmi.platform import ipmitool
|
||||
from ceilometer.openstack.common.gettextutils import _
|
||||
from oslo.config import cfg
|
||||
|
||||
try:
|
||||
import collections as ordereddict
|
||||
except ImportError:
|
||||
import ordereddict
|
||||
|
||||
def get_ordereddict():
|
||||
"""A fix for py26 not having ordereddict."""
|
||||
try:
|
||||
import collections
|
||||
return collections.OrderedDict
|
||||
except AttributeError:
|
||||
import ordereddict
|
||||
return ordereddict.OrderedDict
|
||||
|
||||
OrderedDict = get_ordereddict()
|
||||
|
||||
node_manager_init_retry = cfg.IntOpt('node_manager_init_retry',
|
||||
default=3,
|
||||
@ -66,7 +73,7 @@ INTEL_PREFIX = '5701000d01'
|
||||
|
||||
ONE_RETURN_TEMPLATE = {"ret": 1}
|
||||
|
||||
BMC_INFO_TEMPLATE = ordereddict.OrderedDict()
|
||||
BMC_INFO_TEMPLATE = OrderedDict()
|
||||
BMC_INFO_TEMPLATE['Device_ID'] = 1
|
||||
BMC_INFO_TEMPLATE['Device_Revision'] = 1
|
||||
BMC_INFO_TEMPLATE['Firmware_Revision_1'] = 1
|
||||
@ -77,7 +84,7 @@ BMC_INFO_TEMPLATE['Manufacturer_ID'] = 3
|
||||
BMC_INFO_TEMPLATE['Product_ID'] = 2
|
||||
BMC_INFO_TEMPLATE['Auxiliary_Firmware_Revision'] = 4
|
||||
|
||||
NM_STATISTICS_TEMPLATE = ordereddict.OrderedDict()
|
||||
NM_STATISTICS_TEMPLATE = OrderedDict()
|
||||
NM_STATISTICS_TEMPLATE['Manufacturer_ID'] = 3
|
||||
NM_STATISTICS_TEMPLATE['Current_value'] = 2
|
||||
NM_STATISTICS_TEMPLATE['Minimum_value'] = 2
|
||||
@ -87,7 +94,7 @@ NM_STATISTICS_TEMPLATE['Time_stamp'] = 4
|
||||
NM_STATISTICS_TEMPLATE['Report_period'] = 4
|
||||
NM_STATISTICS_TEMPLATE["DomainID_PolicyState"] = 1
|
||||
|
||||
NM_GET_DEVICE_ID_TEMPLATE = ordereddict.OrderedDict()
|
||||
NM_GET_DEVICE_ID_TEMPLATE = OrderedDict()
|
||||
NM_GET_DEVICE_ID_TEMPLATE['Device_ID'] = 1
|
||||
NM_GET_DEVICE_ID_TEMPLATE['Device_revision'] = 1
|
||||
NM_GET_DEVICE_ID_TEMPLATE['Firmware_revision_1'] = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user