!20 Fix latest version of python construct
From: @zhangy1317 Reviewed-by: @xiyuanwang, @huangtianhua Signed-off-by: @huangtianhua
This commit is contained in:
commit
0c2a0d796a
182
0001-Use-latest-version-of-python-construct.patch
Normal file
182
0001-Use-latest-version-of-python-construct.patch
Normal file
@ -0,0 +1,182 @@
|
||||
From cf440426ffe756dde69092cf38e0103f64ecf58f Mon Sep 17 00:00:00 2001
|
||||
From: zhangy1317 <zhangy1317@chinaunicom.cn>
|
||||
Date: Tue, 22 Mar 2022 16:24:22 +0800
|
||||
Subject: [PATCH] Use latest version of python construct
|
||||
|
||||
---
|
||||
ironic_inspector/common/lldp_parsers.py | 13 +++++++++----
|
||||
ironic_inspector/common/lldp_tlvs.py | 16 +++++++---------
|
||||
.../plugins/local_link_connection.py | 4 ++--
|
||||
.../test/unit/test_plugins_lldp_basic.py | 2 +-
|
||||
lower-constraints.txt | 2 +-
|
||||
.../construct-fly-free-fab62c0a5cb71fa5.yaml | 6 ++++++
|
||||
requirements.txt | 2 +-
|
||||
7 files changed, 27 insertions(+), 18 deletions(-)
|
||||
create mode 100644 ironic-inspector-9.2.4/releasenotes/notes/construct-fly-free-fab62c0a5cb71fa5.yaml
|
||||
|
||||
diff --git a/ironic_inspector/common/lldp_parsers.py b/ironic_inspector/common/lldp_parsers.py
|
||||
index 1f7c21a..336629b 100644
|
||||
--- a/ironic_inspector/common/lldp_parsers.py
|
||||
+++ b/ironic_inspector/common/lldp_parsers.py
|
||||
@@ -101,6 +101,10 @@ class LLDPParser(object):
|
||||
def add_single_value(self, struct, name, data):
|
||||
"""Add a single name/value pair to the nv dict"""
|
||||
self.set_value(name, struct.value)
|
||||
+
|
||||
+ def add_nested_value(self, struct, name, data):
|
||||
+ """Add a single nested name/value pair to the dict"""
|
||||
+ self.set_value(name, struct.value.value)
|
||||
|
||||
def parse_tlv(self, tlv_type, data):
|
||||
"""Parse TLVs from mapping table
|
||||
@@ -193,10 +197,10 @@ class LLDPBasicMgmtParser(LLDPParser):
|
||||
|
||||
self.parser_map = {
|
||||
tlv.LLDP_TLV_CHASSIS_ID:
|
||||
- (self.add_single_value, tlv.ChassisId,
|
||||
- LLDP_CHASSIS_ID_NM, False),
|
||||
+ (self.add_nested_value, tlv.ChassisId, LLDP_CHASSIS_ID_NM,
|
||||
+ False),
|
||||
tlv.LLDP_TLV_PORT_ID:
|
||||
- (self.add_single_value, tlv.PortId, LLDP_PORT_ID_NM, False),
|
||||
+ (self.add_nested_value, tlv.PortId, LLDP_PORT_ID_NM, False),
|
||||
tlv.LLDP_TLV_TTL: (None, None, None, False),
|
||||
tlv.LLDP_TLV_PORT_DESCRIPTION:
|
||||
(self.add_single_value, tlv.PortDesc, LLDP_PORT_DESC_NM,
|
||||
@@ -221,7 +225,8 @@ class LLDPBasicMgmtParser(LLDPParser):
|
||||
|
||||
There can be multiple Mgmt Address TLVs, store in list.
|
||||
"""
|
||||
- self.append_value(name, struct.address)
|
||||
+ if struct.address:
|
||||
+ self.append_value(name, struct.address)
|
||||
|
||||
def _get_capabilities_list(self, caps):
|
||||
"""Get capabilities from bit map"""
|
||||
diff --git a/ironic_inspector/common/lldp_tlvs.py b/ironic_inspector/common/lldp_tlvs.py
|
||||
index 4c2d441..c8d66cb 100644
|
||||
--- a/ironic_inspector/common/lldp_tlvs.py
|
||||
+++ b/ironic_inspector/common/lldp_tlvs.py
|
||||
@@ -107,11 +107,11 @@ IANA_ADDRESS_FAMILY_ID_MAPPING = {
|
||||
('mac', 6): MACAddress,
|
||||
}
|
||||
|
||||
-IANAAddress = core.Embedded(core.Struct(
|
||||
+IANAAddress = core.Struct(
|
||||
'family' / core.Enum(core.Int8ub, **mapping_for_enum(
|
||||
IANA_ADDRESS_FAMILY_ID_MAPPING)),
|
||||
'value' / core.Switch(construct.this.family, mapping_for_switch(
|
||||
- IANA_ADDRESS_FAMILY_ID_MAPPING))))
|
||||
+ IANA_ADDRESS_FAMILY_ID_MAPPING)))
|
||||
|
||||
# Note that 'GreedyString()' is used in cases where string len is not defined
|
||||
CHASSIS_ID_MAPPING = {
|
||||
@@ -132,9 +132,8 @@ CHASSIS_ID_MAPPING = {
|
||||
ChassisId = core.Struct(
|
||||
'subtype' / core.Enum(core.Byte, **mapping_for_enum(
|
||||
CHASSIS_ID_MAPPING)),
|
||||
- 'value' /
|
||||
- core.Embedded(core.Switch(construct.this.subtype,
|
||||
- mapping_for_switch(CHASSIS_ID_MAPPING)))
|
||||
+ 'value' / core.Switch(construct.this.subtype,
|
||||
+ mapping_for_switch(CHASSIS_ID_MAPPING))
|
||||
)
|
||||
|
||||
PORT_ID_MAPPING = {
|
||||
@@ -150,9 +149,8 @@ PORT_ID_MAPPING = {
|
||||
PortId = core.Struct(
|
||||
'subtype' / core.Enum(core.Byte, **mapping_for_enum(
|
||||
PORT_ID_MAPPING)),
|
||||
- 'value' /
|
||||
- core.Embedded(core.Switch(construct.this.subtype,
|
||||
- mapping_for_switch(PORT_ID_MAPPING)))
|
||||
+ 'value' / core.Switch(construct.this.subtype,
|
||||
+ mapping_for_switch(PORT_ID_MAPPING))
|
||||
)
|
||||
|
||||
PortDesc = core.Struct('value' / core.GreedyString("utf8"))
|
||||
@@ -215,7 +213,7 @@ Dot1_VlanName = core.Struct(
|
||||
'vlanid' / core.Int16ub,
|
||||
'name_len' / core.Rebuild(core.Int8ub,
|
||||
construct.len_(construct.this.value)),
|
||||
- 'vlan_name' / core.String(construct.this.name_len, "utf8")
|
||||
+ 'vlan_name' / core.PaddedString(construct.this.name_len, "utf8")
|
||||
)
|
||||
|
||||
Dot1_ProtocolIdentity = core.Struct(
|
||||
diff --git a/ironic_inspector/plugins/local_link_connection.py b/ironic_inspector/plugins/local_link_connection.py
|
||||
index aea9faa..047d5b8 100644
|
||||
--- a/ironic_inspector/plugins/local_link_connection.py
|
||||
+++ b/ironic_inspector/plugins/local_link_connection.py
|
||||
@@ -67,7 +67,7 @@ class GenericLocalLinkConnectionHook(base.ProcessingHook):
|
||||
return
|
||||
|
||||
item = PORT_ID_ITEM_NAME
|
||||
- value = port_id.value
|
||||
+ value = port_id.value.value if port_id.value else None
|
||||
elif tlv_type == tlv.LLDP_TLV_CHASSIS_ID:
|
||||
try:
|
||||
chassis_id = tlv.ChassisId.parse(data)
|
||||
@@ -79,7 +79,7 @@ class GenericLocalLinkConnectionHook(base.ProcessingHook):
|
||||
# Only accept mac address for chassis ID
|
||||
if 'mac_address' in chassis_id.subtype:
|
||||
item = SWITCH_ID_ITEM_NAME
|
||||
- value = chassis_id.value
|
||||
+ value = chassis_id.value.value
|
||||
|
||||
if item and value:
|
||||
if (not CONF.processing.overwrite_existing and
|
||||
diff --git a/ironic_inspector/test/unit/test_plugins_lldp_basic.py b/ironic_inspector/test/unit/test_plugins_lldp_basic.py
|
||||
index ce58932..e9978b6 100644
|
||||
--- a/ironic_inspector/test/unit/test_plugins_lldp_basic.py
|
||||
+++ b/ironic_inspector/test/unit/test_plugins_lldp_basic.py
|
||||
@@ -287,7 +287,7 @@ class TestLLDPBasicProcessingHook(test_base.NodeTest):
|
||||
}]
|
||||
self.hook.before_update(self.data, self.node_info)
|
||||
self.assertEqual(self.expected, self.data['all_interfaces'])
|
||||
- self.assertEqual(2, mock_log.warning.call_count)
|
||||
+ self.assertEqual(1, mock_log.warning.call_count)
|
||||
|
||||
@mock.patch('ironic_inspector.common.lldp_parsers.LOG')
|
||||
def test_truncated_mac(self, mock_log):
|
||||
diff --git a/lower-constraints.txt b/lower-constraints.txt
|
||||
index 38863c1..47c1287 100644
|
||||
--- a/lower-constraints.txt
|
||||
+++ b/lower-constraints.txt
|
||||
@@ -9,7 +9,7 @@ chardet==3.0.4
|
||||
click==6.7
|
||||
cliff==2.11.0
|
||||
cmd2==0.8.1
|
||||
-construct==2.8.10
|
||||
+construct==2.10.56
|
||||
contextlib2==0.5.5
|
||||
coverage==4.0
|
||||
debtcollector==1.19.0
|
||||
diff --git a/releasenotes/notes/construct-fly-free-fab62c0a5cb71fa5.yaml b/releasenotes/notes/construct-fly-free-fab62c0a5cb71fa5.yaml
|
||||
new file mode 100644
|
||||
index 0000000..6cba700
|
||||
--- /dev/null
|
||||
+++ b/releasenotes/notes/construct-fly-free-fab62c0a5cb71fa5.yaml
|
||||
@@ -0,0 +1,6 @@
|
||||
+---
|
||||
+upgrade:
|
||||
+ - |
|
||||
+ Remove upper constraint for python construct library and use the latest
|
||||
+ version available.
|
||||
+ The minimum compatible version for python construct is now 2.10.56
|
||||
diff --git a/requirements.txt b/requirements.txt
|
||||
index 7aed082..1de2911 100644
|
||||
--- a/requirements.txt
|
||||
+++ b/requirements.txt
|
||||
@@ -4,7 +4,7 @@
|
||||
automaton>=1.9.0 # Apache-2.0
|
||||
alembic>=0.8.10 # MIT
|
||||
Babel!=2.4.0,>=2.3.4 # BSD
|
||||
-construct<2.9,>=2.8.10 # MIT
|
||||
+construct>=2.10.56 # MIT
|
||||
eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
|
||||
Flask!=0.11,>=0.10 # BSD
|
||||
futurist>=1.2.0 # Apache-2.0
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
Name: openstack-ironic-inspector
|
||||
Summary: Hardware introspection service for OpenStack Ironic
|
||||
Version: 9.2.4
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: ASL 2.0
|
||||
URL: https://launchpad.net/ironic-inspector
|
||||
|
||||
@ -19,7 +19,8 @@ Source4: ironic-inspector-rootwrap-sudoers
|
||||
Source5: ironic-inspector.logrotate
|
||||
Source6: ironic-inspector-dist.conf
|
||||
Source7: openstack-ironic-inspector-conductor.service
|
||||
|
||||
Patch0: 0001-Use-latest-version-of-python-construct.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: git-core
|
||||
@ -325,6 +326,9 @@ exit 0
|
||||
%systemd_postun_with_restart openstack-ironic-inspector-conductor.service
|
||||
|
||||
%changelog
|
||||
* Tue Mar 22 2022 zhangy1317 <zhangy1317@chinaunicom.cn> -9.2.4-3
|
||||
- Fix latest version of python construct
|
||||
|
||||
* Fri Nov 12 2021 wangxiyuan <wangxiyuan1007@gmail.com> - 9.2.4-2
|
||||
- Fix build issue
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user