已开启
feat:rackmount适配默认网口组 #1498
huangxiaomao创建于 29 天前
feat:rackmount适配默认网口组 #1498
已开启
huangxiaomao创建于 29 天前
共 19 个文件变更+555-165
@@ -1,5 +1,8 @@
1# Changelog1# Changelog
2All notable changes to this project will be documented in this file.2All notable changes to this project will be documented in this file.
3+## [1.110.129] 2026-08-27
4+rackmount适配默认网口组
5+ 
3## [1.110.128] 2026-08-266## [1.110.128] 2026-08-26
4能效裁剪webrest接口7能效裁剪webrest接口
5 8 
@@ -27,7 +27,7 @@
27 echo(string.format('Net Mode : %s\n', get_net_mode(eth_group.NetMode)))27 echo(string.format('Net Mode : %s\n', get_net_mode(eth_group.NetMode)))
28 echo(string.format('Net Type : %s\n', eth_group.ActivePort.Type))28 echo(string.format('Net Type : %s\n', eth_group.ActivePort.Type))
29 29 
30- local ethName = "eth" .. tostring(eth_group.ActiveEthId)30+ local ethName = eth_group.ActiveEthName
31 if eth_group.ActivePort.Type == 'Dedicated' then31 if eth_group.ActivePort.Type == 'Dedicated' then
32 echo('Active Port : ' .. ethName .. '\n')32 echo('Active Port : ' .. ethName .. '\n')
33 end33 end
@@ -94,30 +94,30 @@
94 "Description": "Get ip information",94 "Description": "Get ip information",
95 "Usage": "ipmcget -d ipinfo",95 "Usage": "ipmcget -d ipinfo",
96 "RspBody": {96 "RspBody": {
97- "NetMode": "${ProcessingFlow[1]/Destination/NetMode}",97+ "NetMode": "${ProcessingFlow[2]/Destination/NetMode}",
98- "EthName": "${ProcessingFlow[1]/Destination/EthName}",98+ "EthName": "${ProcessingFlow[2]/Destination/EthName}",
99- "Mac": "${ProcessingFlow[1]/Destination/Mac}",99+ "Mac": "${ProcessingFlow[2]/Destination/Mac}",
100- "LinkLocalAddress": "${ProcessingFlow[1]/Destination/LinkLocalAddress}",100+ "LinkLocalAddress": "${ProcessingFlow[2]/Destination/LinkLocalAddress}",
101- "SLAACAddressList": "${ProcessingFlow[1]/Destination/SLAACAddressList}",101+ "SLAACAddressList": "${ProcessingFlow[2]/Destination/SLAACAddressList}",
102- "NcsiEnable": "${ProcessingFlow[1]/Destination/NcsiEnable}",102+ "NcsiEnable": "${ProcessingFlow[3]/Destination/NcsiEnable}",
103- "NCSIVLANEnable": "${ProcessingFlow[1]/Destination/NCSIVLANEnable}",103+ "NCSIVLANEnable": "${ProcessingFlow[2]/Destination/NCSIVLANEnable}",
104- "NCSIVLANId": "${ProcessingFlow[1]/Destination/NCSIVLANId}",104+ "NCSIVLANId": "${ProcessingFlow[2]/Destination/NCSIVLANId}",
105- "IpModeIpv4": "${ProcessingFlow[2]/Destination/IpModeIpv4}",105+ "IpModeIpv4": "${ProcessingFlow[4]/Destination/IpModeIpv4}",
106- "IpAddrIpv4": "${ProcessingFlow[2]/Destination/IpAddrIpv4}",106+ "IpAddrIpv4": "${ProcessingFlow[4]/Destination/IpAddrIpv4}",
107- "SubnetMask": "${ProcessingFlow[2]/Destination/SubnetMask}",107+ "SubnetMask": "${ProcessingFlow[4]/Destination/SubnetMask}",
108- "DefaultGatewayIpv4": "${ProcessingFlow[2]/Destination/DefaultGatewayIpv4}",108+ "DefaultGatewayIpv4": "${ProcessingFlow[4]/Destination/DefaultGatewayIpv4}",
109- "BackupIpAddrIpv4": "${ProcessingFlow[2]/Destination/BackupIpAddrIpv4}",109+ "BackupIpAddrIpv4": "${ProcessingFlow[4]/Destination/BackupIpAddrIpv4}",
110- "BackupSubnetMaskIpv4": "${ProcessingFlow[2]/Destination/BackupSubnetMaskIpv4}",110+ "BackupSubnetMaskIpv4": "${ProcessingFlow[4]/Destination/BackupSubnetMaskIpv4}",
111- "IpModeIpv6": "${ProcessingFlow[3]/Destination/IpModeIpv6}",111+ "IpModeIpv6": "${ProcessingFlow[5]/Destination/IpModeIpv6}",
112- "IpAddrIpv6": "${ProcessingFlow[3]/Destination/IpAddrIpv6}",112+ "IpAddrIpv6": "${ProcessingFlow[5]/Destination/IpAddrIpv6}",
113- "PrefixLength": "${ProcessingFlow[3]/Destination/PrefixLength}",113+ "PrefixLength": "${ProcessingFlow[5]/Destination/PrefixLength}",
114- "DefaultGatewayIpv6": "${ProcessingFlow[3]/Destination/DefaultGatewayIpv6}",114+ "DefaultGatewayIpv6": "${ProcessingFlow[5]/Destination/DefaultGatewayIpv6}",
115- "DedicatedVLANEnable": "${ProcessingFlow[4]/Destination/DedicatedVLANEnable}",115+ "DedicatedVLANEnable": "${ProcessingFlow[6]/Destination/DedicatedVLANEnable}",
116- "DedicatedVLANId": "${ProcessingFlow[4]/Destination/DedicatedVLANId}",116+ "DedicatedVLANId": "${ProcessingFlow[6]/Destination/DedicatedVLANId}",
117- "BackupIpActivated": "${ProcessingFlow[1]/Destination/BackupIpActivated}",117+ "BackupIpActivated": "${ProcessingFlow[3]/Destination/BackupIpActivated}",
118 "ActivePort": "${Statements/get_active_port_info()}",118 "ActivePort": "${Statements/get_active_port_info()}",
119- "IpVersion": "${ProcessingFlow[1]/Destination/IpVersion}",119+ "IpVersion": "${ProcessingFlow[2]/Destination/IpVersion}",
120- "Channel": "${ProcessingFlow[1]/Destination/Channel}",120+ "Channel": "${ProcessingFlow[2]/Destination/Channel}",
121 "EthernetInterfaceGroups": "${Statements/GetEthernetInterfaceGroups()}"121 "EthernetInterfaceGroups": "${Statements/GetEthernetInterfaceGroups()}"
122 },122 },
123 "Statements": {123 "Statements": {
@@ -125,7 +125,7 @@
125 "Steps": [125 "Steps": [
126 {126 {
127 "Type": "Plugin",127 "Type": "Plugin",
128- "Formula": "orchestrator.bmc_network.get_active_port_info(ProcessingFlow[1].Destination.PortId)"128+ "Formula": "orchestrator.bmc_network.get_active_port_info(ProcessingFlow[2].Destination.PortId)"
129 }129 }
130 ]130 ]
131 },131 },
@@ -133,35 +133,58 @@
133 "Steps": [133 "Steps": [
134 {134 {
135 "Type": "Plugin",135 "Type": "Plugin",
136- "Formula": "orchestrator.bmc_network.get_ethernet_interface_groups(ProcessingFlow[5].Destination.Port, ProcessingFlow[6].Destination.group_list)"136+ "Formula": "orchestrator.bmc_network.get_ethernet_interface_groups(ProcessingFlow[7].Destination.Port, ProcessingFlow[1].Destination.group_list)"
137+ }
138+ ]
139+ },
140+ "PatchDefaultGroup": {
141+ "Steps": [
142+ {
143+ "Type": "Plugin",
144+ "Formula": "orchestrator.multi_patch.get_default_group_paths(ProcessingFlow[1].Destination.group_list)"
137 }145 }
138 ]146 ]
139 }147 }
140 },148 },
141 "ProcessingFlow": [149 "ProcessingFlow": [
150+ {
151+ "Type": "List",
152+ "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/EthGroup",
153+ "Interface": "bmc.kepler.Managers.EthernetInterfaces.EthGroup",
154+ "Destination": {
155+ "Members": "group_list"
156+ }
157+ },
142 {158 {
143 "Type": "Property",159 "Type": "Property",
144- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces",160+ "Path": "${Statements/PatchDefaultGroup()/EthernetInterfaces/Path}",
145- "Interface": "bmc.kepler.Managers.EthernetInterfaces",161+ "Interface": "${Statements/PatchDefaultGroup()/EthernetInterfaces/Interface}",
146 "Destination": {162 "Destination": {
147 "NetMode": "NetMode",163 "NetMode": "NetMode",
148- "EthName": "EthName",
149 "Mac": "Mac",164 "Mac": "Mac",
150- "PortId": "PortId",165+ "${Statements/PatchDefaultGroup()/EthernetInterfaces/PortId}": "PortId",
151 "LinkLocalAddress": "LinkLocalAddress",166 "LinkLocalAddress": "LinkLocalAddress",
152 "SLAACAddressList": "SLAACAddressList",167 "SLAACAddressList": "SLAACAddressList",
153- "NcsiEnable": "NcsiEnable",168+ "${Statements/PatchDefaultGroup()/EthernetInterfaces/VLANEnable}": "NCSIVLANEnable",
154- "VLANEnable": "NCSIVLANEnable",169+ "${Statements/PatchDefaultGroup()/EthernetInterfaces/EthName}": "EthName",
155 "VLANId": "NCSIVLANId",170 "VLANId": "NCSIVLANId",
156- "BackupIpActivated": "BackupIpActivated",
157 "IpVersion": "IpVersion",171 "IpVersion": "IpVersion",
158 "Channel": "Channel"172 "Channel": "Channel"
159 }173 }
160 },174 },
161 {175 {
162 "Type": "Property",176 "Type": "Property",
163- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",177+ "Path": "/bmc/kepler/Managers/1/EthernetInterfaces",
164- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",178+ "Interface": "bmc.kepler.Managers.EthernetInterfaces",
179+ "Destination": {
180+ "NcsiEnable": "NcsiEnable",
181+ "BackupIpActivated": "BackupIpActivated"
182+ }
183+ },
184+ {
185+ "Type": "Property",
186+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
187+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
165 "Destination": {188 "Destination": {
166 "IpMode": "IpModeIpv4",189 "IpMode": "IpModeIpv4",
167 "IpAddr": "IpAddrIpv4",190 "IpAddr": "IpAddrIpv4",
@@ -173,13 +196,13 @@
173 },196 },
174 {197 {
175 "Type": "Property",198 "Type": "Property",
176- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",199+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
177- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",200+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
178 "Destination": {201 "Destination": {
179- "IpMode": "IpModeIpv6",202+ "${Statements/PatchDefaultGroup()/Ipv6/IpMode}": "IpModeIpv6",
180- "IpAddr": "IpAddrIpv6",203+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "IpAddrIpv6",
181 "PrefixLength": "PrefixLength",204 "PrefixLength": "PrefixLength",
182- "DefaultGateway": "DefaultGatewayIpv6"205+ "${Statements/PatchDefaultGroup()/Ipv6/DefaultGateway}": "DefaultGatewayIpv6"
183 }206 }
184 },207 },
185 {208 {
@@ -200,14 +223,6 @@
200 "Destination": {223 "Destination": {
201 "Port": "Port"224 "Port": "Port"
202 }225 }
203- },
204- {
205- "Type": "List",
206- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/EthGroup",
207- "Interface": "bmc.kepler.Managers.EthernetInterfaces.EthGroup",
208- "Destination": {
209- "Members": "group_list"
210- }
211 }226 }
212 ],227 ],
213 "Echoes": [228 "Echoes": [
@@ -561,11 +561,29 @@
561 "ipaddr": "${ReqBody/ipaddr}",561 "ipaddr": "${ReqBody/ipaddr}",
562 "mask": "${ReqBody/mask}"562 "mask": "${ReqBody/mask}"
563 },563 },
564+ "Statements": {
565+ "PatchDefaultGroup": {
566+ "Steps": [
567+ {
568+ "Type": "Plugin",
569+ "Formula": "orchestrator.multi_patch.get_default_group_paths(ProcessingFlow[2].Destination.group_list)"
570+ }
571+ ]
572+ }
573+ },
564 "ProcessingFlow": [574 "ProcessingFlow": [
575+ {
576+ "Type": "List",
577+ "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/EthGroup",
578+ "Interface": "bmc.kepler.Managers.EthernetInterfaces.EthGroup",
579+ "Destination": {
580+ "Members": "group_list"
581+ }
582+ },
565 {583 {
566 "Type": "Method",584 "Type": "Method",
567- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",585+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
568- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",586+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
569 "Name": "SetDedicatedMaintIpMask",587 "Name": "SetDedicatedMaintIpMask",
570 "Params": [588 "Params": [
571 "${ReqBody/ipaddr}",589 "${ReqBody/ipaddr}",
@@ -14,6 +14,7 @@ local MDB_SERVICE <const> = 'bmc.kepler.bmc_network'
14local ETH_OBJ_PATH <const> = '/bmc/kepler/Managers/1/EthernetInterfaces'14local ETH_OBJ_PATH <const> = '/bmc/kepler/Managers/1/EthernetInterfaces'
15local ETH_PORT_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.MgmtPort'15local ETH_PORT_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.MgmtPort'
16local ETH_GROUP_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.EthGroup'16local ETH_GROUP_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.EthGroup'
17+local ETH_OBJ_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces'
17 18 
18-- 0-专用/1-LOM/2-pcie,目前只支持专用网口、pcie19-- 0-专用/1-LOM/2-pcie,目前只支持专用网口、pcie
19local port_type_table = {20local port_type_table = {
@@ -205,6 +206,7 @@ local function get_ethernet_group(ethGroup_obj, ports)
205 local ethernet_group = {206 local ethernet_group = {
206 GroupId = ethGroup_obj.GroupId,207 GroupId = ethGroup_obj.GroupId,
207 ActiveEthId = ethGroup_obj.ActiveEthId,208 ActiveEthId = ethGroup_obj.ActiveEthId,
209+ ActiveEthName = string.match(ethGroup_obj.ActiveInterfaceName, '^[^.]+') or ethGroup_obj.ActiveInterfaceName,
208 Channel = ethGroup_obj.Channel,210 Channel = ethGroup_obj.Channel,
209 NetMode = ethGroup_obj.NetMode,211 NetMode = ethGroup_obj.NetMode,
210 ActivePort = {212 ActivePort = {
@@ -239,10 +241,12 @@ end
239 241 
240function m.get_ethernet_interface_groups(ports, group_paths)242function m.get_ethernet_interface_groups(ports, group_paths)
241 local eth_groups = {}243 local eth_groups = {}
244+ local eth_obj = mdb.get_object(bus, ETH_OBJ_PATH, ETH_OBJ_INTERFACE)
245+ local default_group_id = eth_obj.DefaultEthGroupId
242 246 
243 for _, group_path in ipairs(group_paths) do247 for _, group_path in ipairs(group_paths) do
244 local ok, ethGroup_obj = pcall(mdb.get_object, bus, group_path, ETH_GROUP_INTERFACE)248 local ok, ethGroup_obj = pcall(mdb.get_object, bus, group_path, ETH_GROUP_INTERFACE)
245- if ok and ethGroup_obj.OutType == 2 and ethGroup_obj.Status then249+ if ok and ethGroup_obj.OutType == 2 and ethGroup_obj.Status and ethGroup_obj.GroupId ~= default_group_id then
246 local ethernet_group = get_ethernet_group(ethGroup_obj, ports)250 local ethernet_group = get_ethernet_group(ethGroup_obj, ports)
247 table.insert(eth_groups, ethernet_group)251 table.insert(eth_groups, ethernet_group)
248 end252 end
@@ -17,6 +17,65 @@ local ETH_GROUP_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.EthG
17 17 
18local m = {}18local m = {}
19 19 
20+local function apply_default_setting(mdb_path, mdb_setting)
21+ mdb_setting.EthernetInterfaces.Path = mdb_path
22+ mdb_setting.EthernetInterfaces.Interface = ETH_OBJ_INTERFACE
23+ mdb_setting.Ipv4.Path = mdb_path .. '/Ipv4'
24+ mdb_setting.Ipv4.Interface = ETH_OBJ_INTERFACE .. '.Ipv4'
25+ mdb_setting.Ipv6.Path = mdb_path .. '/Ipv6'
26+ mdb_setting.Ipv6.Interface = ETH_OBJ_INTERFACE .. '.Ipv6'
27+end
28+ 
29+local function apply_eth_group_setting(sub_path, mdb_setting)
30+ mdb_setting.EthernetInterfaces.Path = sub_path
31+ mdb_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE
32+ mdb_setting.EthernetInterfaces.PortId = 'ActivePortId'
33+ mdb_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
34+ mdb_setting.EthernetInterfaces.EthName = 'ActiveInterfaceName'
35+ mdb_setting.Ipv4.Path = sub_path
36+ mdb_setting.Ipv4.Interface = ETH_GROUP_INTERFACE
37+ mdb_setting.Ipv6.Path = sub_path
38+ mdb_setting.Ipv6.Interface = ETH_GROUP_INTERFACE
39+ mdb_setting.Ipv6.IpMode = 'Ipv6Mode'
40+ mdb_setting.Ipv6.IpAddr = 'Ipv6Addr'
41+ mdb_setting.Ipv6.DefaultGateway = 'Ipv6DefaultGateway'
42+ mdb_setting.Ipv6.SetIpAddr = 'SetIpv6Addr'
43+ mdb_setting.Ipv6.SetDefaultGateway = 'SetIpv6DefaultGateway'
44+end
45+ 
46+--根据DefaultEthGroupId 解析默认网口组的IPV4和IPV6路径配置
47+-- 0:走IPV4和IPV6
48+--非0:走默认网口组ID指定的ethGroup对象
49+local function resolve_default_group_paths(eth_obj, mdb_path, mdb_setting, group_paths)
50+ local default_group_id = eth_obj.DefaultEthGroupId
51+ if default_group_id == nil then
52+ default_group_id = 0
53+ end
54+ mdb_setting.GroupId = default_group_id
55+ if default_group_id == 0 then
56+ apply_default_setting(mdb_path, mdb_setting)
57+ else
58+ for _, group_path in pairs(group_paths) do
59+ local ok, ethGroup_obj = pcall(mdb.get_object, bus, group_path, ETH_GROUP_INTERFACE)
60+ if not ok then
61+ log:notice('[resolve_default_group_paths] mdb.get_object FAILED, group_path=%s, err=%s', group_path, tostring(ethGroup_obj))
62+ else
63+ log:notice('[resolve_default_group_paths] try group_path=%s, OutType=%s, Status=%s, GroupId=%s, ActivePortId=%s', group_path, tostring(ethGroup_obj.OutType), tostring(ethGroup_obj.Status), tostring(ethGroup_obj.GroupId), tostring(ethGroup_obj.ActivePortId))
64+ end
65+ 
66+ if ok and ethGroup_obj.OutType == 2 and ethGroup_obj.Status and ethGroup_obj.GroupId == default_group_id then
67+ log:notice('[resolve_default_group_paths] matched EthGroup, GroupId=%s, group_path=%s, ActivePortId=%s, apply EthGroup IPv4/IPv6 paths', ethGroup_obj.GroupId, group_path, tostring(ethGroup_obj.ActivePortId))
68+ apply_eth_group_setting(group_path, mdb_setting)
69+ break
70+ end
71+ end
72+ 
73+ if mdb_setting.Ipv4.Path == '' then
74+ apply_default_setting(mdb_path, mdb_setting)
75+ end
76+ end
77+end
78+ 
20local function create_base_setting()79local function create_base_setting()
21 local setting = {80 local setting = {
22 IsGroupIdValid = false,81 IsGroupIdValid = false,
@@ -25,6 +84,7 @@ local function create_base_setting()
25 Interface = '',84 Interface = '',
26 PortId = 'PortId',85 PortId = 'PortId',
27 VLANEnable = 'VLANEnable',86 VLANEnable = 'VLANEnable',
87+ EthName = 'EthName',
28 },88 },
29 Ipv4 = {89 Ipv4 = {
30 Path = '',90 Path = '',
@@ -63,8 +123,13 @@ local function patch_group_id_to_ethgroup(group_id, eth_group_setting)
63 123 
64 local ethGroup_objs = {}124 local ethGroup_objs = {}
65 for _, sub_path in pairs(rsp.SubPaths) do125 for _, sub_path in pairs(rsp.SubPaths) do
66- local ok, ethGroup_obj = pcall(mdb.get_object, bus, sub_path, ETH_GROUP_INTERFACE)126+ local ok2, ethGroup_obj = pcall(mdb.get_object, bus, sub_path, ETH_GROUP_INTERFACE)
67- if ok and ethGroup_obj.OutType == 2 and ethGroup_obj.Status then127+ if not ok2 then
128+ log:notice_easy('[patch_group_id_to_ethgroup] mdb.get_object FAILED, sub_path=%s, err=%s', sub_path, tostring(ethGroup_obj))
129+ else
130+ log:notice_easy('[patch_group_id_to_ethgroup] sub_path=%s, OutType=%s, Status=%s, GroupId=%s, ActivePortId=%s', sub_path, tostring(ethGroup_obj.OutType), tostring(ethGroup_obj.Status), tostring(ethGroup_obj.GroupId), tostring(ethGroup_obj.ActivePortId))
131+ end
132+ if ok2 and ethGroup_obj.OutType == 2 and ethGroup_obj.Status then
68 table.insert(ethGroup_objs, ethGroup_obj)133 table.insert(ethGroup_objs, ethGroup_obj)
69 end134 end
70 end135 end
@@ -76,33 +141,63 @@ local function patch_group_id_to_ethgroup(group_id, eth_group_setting)
76 141 
77 local ethGroup_obj = get_group_id_patched_ethgroup_object(group_id, ethGroup_objs)142 local ethGroup_obj = get_group_id_patched_ethgroup_object(group_id, ethGroup_objs)
78 if ethGroup_obj ~= nil then143 if ethGroup_obj ~= nil then
79- eth_group_setting.EthernetInterfaces.Path = ethGroup_obj.path144+ log:notice_easy('[patch_group_id_to_ethgroup] matched ethGroup_obj, path=%s, ActivePortId=%s', tostring(ethGroup_obj.path), tostring(ethGroup_obj.ActivePortId))
80- eth_group_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE145+ apply_eth_group_setting(ethGroup_obj.path, eth_group_setting)
81- eth_group_setting.EthernetInterfaces.PortId = 'ActivePortId'146+ return true
82- eth_group_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'147+ end
83- eth_group_setting.Ipv4.Path = ethGroup_obj.path148+ end
84- eth_group_setting.Ipv4.Interface = ETH_GROUP_INTERFACE149+ log:notice_easy('[patch_group_id_to_ethgroup] no matched EthGroup for group_id=%s', tostring(group_id))
85- eth_group_setting.Ipv6.Path = ethGroup_obj.path150+end
86- eth_group_setting.Ipv6.Interface = ETH_GROUP_INTERFACE151+ 
87- eth_group_setting.Ipv6.IpMode = 'Ipv6Mode'152+local function patch_group_id_to_default_ethgroup(default_group_id, eth_group_setting)
88- eth_group_setting.Ipv6.IpAddr = 'Ipv6Addr'153+ local ok, rsp = pcall(mdb_service.get_sub_paths, bus, ETH_OBJ_PATH .. '/EthGroup', 1, { ETH_GROUP_INTERFACE })
89- eth_group_setting.Ipv6.DefaultGateway = 'Ipv6DefaultGateway'154+ log:notice_easy('[patch_group_id_to_ethgroup] group_id=%s, ok=%s', tostring(group_id), tostring(ok))
90- eth_group_setting.Ipv6.SetIpAddr = 'SetIpv6Addr'155+ 
91- eth_group_setting.Ipv6.SetDefaultGateway = 'SetIpv6DefaultGateway'156+ if not ok then
157+ log:debug('Incorrect parent path or interface')
158+ return false
159+ end
160+ 
161+ for _, sub_path in pairs(rsp.SubPaths) do
162+ local ok2, ethGroup_obj = pcall(mdb.get_object, bus, sub_path, ETH_GROUP_INTERFACE)
163+ if not ok2 then
164+ log:notice_easy('[patch_group_id_to_ethgroup] mdb.get_object FAILED, sub_path=%s, err=%s', sub_path, tostring(ethGroup_obj))
165+ else
166+ log:notice_easy('[patch_group_id_to_ethgroup] sub_path=%s, OutType=%s, Status=%s, GroupId=%s, ActivePortId=%s', sub_path, tostring(ethGroup_obj.OutType), tostring(ethGroup_obj.Status), tostring(ethGroup_obj.GroupId), tostring(ethGroup_obj.ActivePortId))
167+ end
168+ if ok2 and ethGroup_obj.OutType == 2 and ethGroup_obj.Status and ethGroup_obj.GroupId == default_group_id then
169+ apply_eth_group_setting(ethGroup_obj.path, eth_group_setting)
92 return true170 return true
93 end171 end
94 end172 end
95end173end
96 174 
175+function m.get_default_group_paths(group_list)
176+ local mdb_setting = create_base_setting()
177+ local eth_obj = mdb.get_object(bus, ETH_OBJ_PATH, ETH_OBJ_INTERFACE)
178+ log:notice_easy('[get_default_group_paths] eth_obj.DefaultEthGroupId=%s, PortId=%s, group_list count=%s', tostring(eth_obj.DefaultEthGroupId), tostring(eth_obj.PortId), #(group_list or {}))
179+ resolve_default_group_paths(eth_obj, ETH_OBJ_PATH, mdb_setting, group_list)
180+ log:notice_easy('[get_default_group_paths] result: EthernetInterfaces.Path=%s, EthernetInterfaces.PortId=%s, Ipv4.Path=%s, Ipv6.Path=%s, GroupId=%s', mdb_setting.EthernetInterfaces.Path, mdb_setting.EthernetInterfaces.PortId, mdb_setting.Ipv4.Path, mdb_setting.Ipv6.Path, tostring(mdb_setting.GroupId))
181+ mdb_setting.IsGroupIdValid = true
182+ return mdb_setting
183+end
184+ 
97function m.patch_eth_info(group_id)185function m.patch_eth_info(group_id)
186+ log:notice_easy('[patch_eth_info] group_id=%s', tostring(group_id))
98 if not group_id or group_id == 1 then187 if not group_id or group_id == 1 then
188+ local eth_obj = mdb.get_object(bus, ETH_OBJ_PATH, ETH_OBJ_INTERFACE)
189+ local default_group_id = eth_obj.DefaultEthGroupId
190+ log:notice_easy('[patch_eth_info] group_id=%s, resolve by DefaultEthGroupId', tostring(default_group_id))
191+ if default_group_id ~= nil and default_group_id ~= 0 then
192+ local eth_group_setting = create_base_setting()
193+ if patch_group_id_to_default_ethgroup(default_group_id, eth_group_setting) then
194+ eth_group_setting.IsGroupIdValid = true
195+ log:notice_easy('[patch_eth_info] DefaultEthGroupId=%s matched EthGroup, Path=%s, PortId=%s', tostring(default_group_id), eth_group_setting.EthernetInterfaces.Path, eth_group_setting.EthernetInterfaces.PortId)
196+ return eth_group_setting
197+ end
198+ end
99 local mdb_setting = create_base_setting()199 local mdb_setting = create_base_setting()
100- mdb_setting.EthernetInterfaces.Path = ETH_OBJ_PATH200+ apply_default_setting(ETH_OBJ_PATH, mdb_setting)
101- mdb_setting.EthernetInterfaces.Interface = ETH_OBJ_INTERFACE
102- mdb_setting.Ipv4.Path = ETH_OBJ_PATH .. '/Ipv4'
103- mdb_setting.Ipv4.Interface = ETH_OBJ_INTERFACE .. '.Ipv4'
104- mdb_setting.Ipv6.Path = ETH_OBJ_PATH .. '/Ipv6'
105- mdb_setting.Ipv6.Interface = ETH_OBJ_INTERFACE .. '.Ipv6'
106 mdb_setting.IsGroupIdValid = true201 mdb_setting.IsGroupIdValid = true
107 return mdb_setting202 return mdb_setting
108 end203 end
@@ -111,9 +206,11 @@ function m.patch_eth_info(group_id)
111 local eth_group_setting = create_base_setting()206 local eth_group_setting = create_base_setting()
112 if patch_group_id_to_ethgroup(group_id, eth_group_setting) then207 if patch_group_id_to_ethgroup(group_id, eth_group_setting) then
113 eth_group_setting.IsGroupIdValid = true208 eth_group_setting.IsGroupIdValid = true
209+ log:notice_easy('[patch_eth_info] matched EthGroup, EthernetInterfaces.Path=%s, EthernetInterfaces.PortId=%s', eth_group_setting.EthernetInterfaces.Path, eth_group_setting.EthernetInterfaces.PortId)
114 return eth_group_setting210 return eth_group_setting
115 end211 end
116 212 
213+ log:notice_easy('[patch_eth_info] no matched EthGroup, return base setting')
117 return create_base_setting()214 return create_base_setting()
118end215end
119 216 
@@ -531,9 +531,9 @@
531 "IpVersion": "IPVersion",531 "IpVersion": "IPVersion",
532 "SLAACAddressList": "SLAACAddressList",532 "SLAACAddressList": "SLAACAddressList",
533 "LinkLocalAddress": "LinkLocalAddress",533 "LinkLocalAddress": "LinkLocalAddress",
534- "EthName": "EthName",534+ "${Statements/PatchMac()/EthernetInterfaces/EthName}": "EthName",
535 "NetMode": "NetMode",535 "NetMode": "NetMode",
536- "PortId": "PortId",536+ "${Statements/PatchMac()/EthernetInterfaces/PortId}": "PortId",
537 "Mac": "Mac"537 "Mac": "Mac"
538 },538 },
539 "CallIf": "CheckUri"539 "CallIf": "CheckUri"
@@ -1558,10 +1558,10 @@
1558 "Interface": "${Statements/PatchMac()/EthernetInterfaces/Interface}",1558 "Interface": "${Statements/PatchMac()/EthernetInterfaces/Interface}",
1559 "Destination": {1559 "Destination": {
1560 "NetMode": "NetMode",1560 "NetMode": "NetMode",
1561- "PortId": "PortId",1561+ "${Statements/PatchMac()/EthernetInterfaces/PortId}": "PortId",
1562 "VLANId": "VLANId",1562 "VLANId": "VLANId",
1563 "${Statements/PatchMac()/EthernetInterfaces/VLANEnable}": "VLANEnable",1563 "${Statements/PatchMac()/EthernetInterfaces/VLANEnable}": "VLANEnable",
1564- "EthName": "EthName",1564+ "${Statements/PatchMac()/EthernetInterfaces/EthName}": "EthName",
1565 "IpVersion": "IpVersion",1565 "IpVersion": "IpVersion",
1566 "Mac": "Mac"1566 "Mac": "Mac"
1567 },1567 },
@@ -551,6 +551,14 @@
551 "Formula": "orchestrator.managers.get_servers()"551 "Formula": "orchestrator.managers.get_servers()"
552 }552 }
553 ]553 ]
554+ },
555+ "PatchDefaultGroup": {
556+ "Steps": [
557+ {
558+ "Type": "Plugin",
559+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
560+ }
561+ ]
554 }562 }
555 },563 },
556 "ProcessingFlow": [564 "ProcessingFlow": [
@@ -617,18 +625,18 @@
617 },625 },
618 {626 {
619 "Type": "Property",627 "Type": "Property",
620- "Path": "/bmc/kepler/Managers/${Uri/managerid}/EthernetInterfaces/Ipv4",628+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
621- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",629+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
622- "Destination": {630+ "Destination": {
623 "IpAddr": "DeviceIPv4"631 "IpAddr": "DeviceIPv4"
624 }632 }
625 },633 },
626 {634 {
627 "Type": "Property",635 "Type": "Property",
628- "Path": "/bmc/kepler/Managers/${Uri/managerid}/EthernetInterfaces/Ipv6",636+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
629- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",637+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
630- "Destination": {638+ "Destination": {
631- "IpAddr": "DeviceIPv6"639+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "DeviceIPv6"
632 }640 }
633 },641 },
634 {642 {
@@ -487,7 +487,7 @@
487 "IpVersion": "IpVersion",487 "IpVersion": "IpVersion",
488 "SLAACAddressList": "SLAACAddressList",488 "SLAACAddressList": "SLAACAddressList",
489 "LinkLocalAddress": "LinkLocalAddress",489 "LinkLocalAddress": "LinkLocalAddress",
490- "EthName": "EthName",490+ "${Statements/PatchNicId()/EthernetInterfaces/EthName}": "EthName",
491 "Mac": "Mac"491 "Mac": "Mac"
492 },492 },
493 "CallIf": {493 "CallIf": {
@@ -1327,7 +1327,7 @@
1327 "VLANId": "VLANId",1327 "VLANId": "VLANId",
1328 "${Statements/PatchNicId()/EthernetInterfaces/VLANEnable}": "VLANEnable",1328 "${Statements/PatchNicId()/EthernetInterfaces/VLANEnable}": "VLANEnable",
1329 "IpVersion": "IpVersion",1329 "IpVersion": "IpVersion",
1330- "EthName": "EthName"1330+ "${Statements/PatchNicId()/EthernetInterfaces/EthName}": "EthName"
1331 }1331 }
1332 },1332 },
1333 {1333 {
@@ -309,6 +309,14 @@
309 ]309 ]
310 }310 }
311 ]311 ]
312+ },
313+ "PatchDefaultGroup": {
314+ "Steps": [
315+ {
316+ "Type": "Plugin",
317+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
318+ }
319+ ]
312 }320 }
313 },321 },
314 "ProcessingFlow": [322 "ProcessingFlow": [
@@ -441,18 +449,18 @@
441 },449 },
442 {450 {
443 "Type": "Property",451 "Type": "Property",
444- "Path": "/bmc/kepler/Managers/${Uri/managerid}/EthernetInterfaces/Ipv4",452+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
445- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",453+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
446 "Destination": {454 "Destination": {
447 "IpMode": "IpMode"455 "IpMode": "IpMode"
448 }456 }
449 },457 },
450 {458 {
451 "Type": "Property",459 "Type": "Property",
452- "Path": "/bmc/kepler/Managers/${Uri/managerid}/EthernetInterfaces/Ipv6",460+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
453- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",461+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
454 "Destination": {462 "Destination": {
455- "IpMode": "IpMode"463+ "${Statements/PatchDefaultGroup()/Ipv6/IpMode}": "IpMode"
456 }464 }
457 },465 },
458 {466 {
@@ -1045,6 +1053,14 @@
1045 "Formula": "return Input.RwRelatedProperties"1053 "Formula": "return Input.RwRelatedProperties"
1046 }1054 }
1047 ]1055 ]
1056+ },
1057+ "PatchDefaultGroup": {
1058+ "Steps": [
1059+ {
1060+ "Type": "Plugin",
1061+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
1062+ }
1063+ ]
1048 }1064 }
1049 },1065 },
1050 "ProcessingFlow": [1066 "ProcessingFlow": [
@@ -1316,8 +1332,8 @@
1316 },1332 },
1317 {1333 {
1318 "Type": "Property",1334 "Type": "Property",
1319- "Path": "/bmc/kepler/Managers/${Uri/managerid}/EthernetInterfaces/Ipv4",1335+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
1320- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",1336+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
1321 "Source": {1337 "Source": {
1322 "IpMode": "${Statements/DHCPEnabled()}"1338 "IpMode": "${Statements/DHCPEnabled()}"
1323 },1339 },
@@ -1327,10 +1343,10 @@
1327 },1343 },
1328 {1344 {
1329 "Type": "Property",1345 "Type": "Property",
1330- "Path": "/bmc/kepler/Managers/${Uri/managerid}/EthernetInterfaces/Ipv6",1346+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
1331- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",1347+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
1332 "Source": {1348 "Source": {
1333- "IpMode": "${Statements/DHCPv6Enabled()}"1349+ "${Statements/PatchDefaultGroup()/Ipv6/IpMode}": "${Statements/DHCPv6Enabled()}"
1334 },1350 },
1335 "CallIf": {1351 "CallIf": {
1336 "${ReqBody/DHCPv6/ProtocolEnabled}": "#WITH"1352 "${ReqBody/DHCPv6/ProtocolEnabled}": "#WITH"
@@ -441,6 +441,14 @@
441 "Formula": "orchestrator.systemoverview.get_status_health_by_type(Input, 4)"441 "Formula": "orchestrator.systemoverview.get_status_health_by_type(Input, 4)"
442 }442 }
443 ]443 ]
444+ },
445+ "PatchDefaultGroup": {
446+ "Steps": [
447+ {
448+ "Type": "Plugin",
449+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
450+ }
451+ ]
444 }452 }
445 },453 },
446 "ProcessingFlow": [454 "ProcessingFlow": [
@@ -552,18 +560,18 @@
552 },560 },
553 {561 {
554 "Type": "Property",562 "Type": "Property",
555- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",563+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
556- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",564+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
557 "Destination": {565 "Destination": {
558 "IpAddr": "DeviceIPv4"566 "IpAddr": "DeviceIPv4"
559 }567 }
560 },568 },
561 {569 {
562 "Type": "Property",570 "Type": "Property",
563- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",571+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
564- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",572+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
565 "Destination": {573 "Destination": {
566- "IpAddr": "DeviceIPv6"574+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "DeviceIPv6"
567 }575 }
568 },576 },
569 {577 {
@@ -844,6 +852,14 @@
844 "Formula": "if ProcessingFlow[4].Destination.SystemLockDownSupport ~= 'Supported' then return lua_nil end return ProcessingFlow[10].Destination.SystemLockDownStatus == 'Locked'"852 "Formula": "if ProcessingFlow[4].Destination.SystemLockDownSupport ~= 'Supported' then return lua_nil end return ProcessingFlow[10].Destination.SystemLockDownStatus == 'Locked'"
845 }853 }
846 ]854 ]
855+ },
856+ "PatchDefaultGroup": {
857+ "Steps": [
858+ {
859+ "Type": "Plugin",
860+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
861+ }
862+ ]
847 }863 }
848 },864 },
849 "ProcessingFlow": [865 "ProcessingFlow": [
@@ -883,18 +899,18 @@
883 },899 },
884 {900 {
885 "Type": "Property",901 "Type": "Property",
886- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",902+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
887- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",903+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
888 "Destination": {904 "Destination": {
889 "IpAddr": "DeviceIPv4"905 "IpAddr": "DeviceIPv4"
890 }906 }
891 },907 },
892 {908 {
893 "Type": "Property",909 "Type": "Property",
894- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",910+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
895- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",911+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
896 "Destination": {912 "Destination": {
897- "IpAddr": "DeviceIPv6"913+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "DeviceIPv6"
898 }914 }
899 },915 },
900 {916 {
@@ -1143,6 +1159,14 @@
1143 "Formula": "orchestrator.systemoverview.get_status_health_by_type(Input, 4)"1159 "Formula": "orchestrator.systemoverview.get_status_health_by_type(Input, 4)"
1144 }1160 }
1145 ]1161 ]
1162+ },
1163+ "PatchDefaultGroup": {
1164+ "Steps": [
1165+ {
1166+ "Type": "Plugin",
1167+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
1168+ }
1169+ ]
1146 }1170 }
1147 },1171 },
1148 "ProcessingFlow": [1172 "ProcessingFlow": [
@@ -1253,18 +1277,18 @@
1253 },1277 },
1254 {1278 {
1255 "Type": "Property",1279 "Type": "Property",
1256- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",1280+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
1257- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",1281+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
1258 "Destination": {1282 "Destination": {
1259 "IpAddr": "DeviceIPv4"1283 "IpAddr": "DeviceIPv4"
1260 }1284 }
1261 },1285 },
1262 {1286 {
1263 "Type": "Property",1287 "Type": "Property",
1264- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",1288+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
1265- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",1289+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
1266 "Destination": {1290 "Destination": {
1267- "IpAddr": "DeviceIPv6"1291+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "DeviceIPv6"
1268 }1292 }
1269 },1293 },
1270 {1294 {
@@ -21,6 +21,7 @@ local function create_base_setting()
21 Path = '',21 Path = '',
22 Interface = '',22 Interface = '',
23 PortId = 'PortId',23 PortId = 'PortId',
24+ EthName = 'EthName',
24 },25 },
25 Ipv4 = {26 Ipv4 = {
26 Path = '',27 Path = '',
@@ -125,6 +126,7 @@ local function patch_mac_to_ethgroup(mdb, bus, mdb_path, interface_name, mac_id,
125 mdb_setting.EthernetInterfaces.Path = sub_path126 mdb_setting.EthernetInterfaces.Path = sub_path
126 mdb_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE127 mdb_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE
127 mdb_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'128 mdb_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
129+ mdb_setting.EthernetInterfaces.EthName = 'ActiveInterfaceName'
128 if ethgroup_object.ActivePortId ~= 255 then130 if ethgroup_object.ActivePortId ~= 255 then
129 mdb_setting.EthernetInterfacesPortId.Path = mdb_path .. '/' .. ethgroup_object.ActivePortId131 mdb_setting.EthernetInterfacesPortId.Path = mdb_path .. '/' .. ethgroup_object.ActivePortId
130 mdb_setting.EthernetInterfacesPortId.Interface = ETH_PORT_INTERFACE132 mdb_setting.EthernetInterfacesPortId.Interface = ETH_PORT_INTERFACE
@@ -360,6 +362,7 @@ local function get_out_group_data(manager_id, group_id)
360 ncsi_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE362 ncsi_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE
361 ncsi_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'363 ncsi_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
362 ncsi_setting.EthernetInterfaces.PortId = 'ActivePortId'364 ncsi_setting.EthernetInterfaces.PortId = 'ActivePortId'
365+ ncsi_setting.EthernetInterfaces.EthName = 'ActiveInterfaceName'
363 if out_group_object.ActivePortId ~= 255 then366 if out_group_object.ActivePortId ~= 255 then
364 ncsi_setting.EthernetInterfacesPortId.Path = mdb_path .. '/' .. out_group_object.ActivePortId367 ncsi_setting.EthernetInterfacesPortId.Path = mdb_path .. '/' .. out_group_object.ActivePortId
365 ncsi_setting.EthernetInterfacesPortId.Interface = ETH_PORT_INTERFACE368 ncsi_setting.EthernetInterfacesPortId.Interface = ETH_PORT_INTERFACE
@@ -409,6 +412,34 @@ function m.patch_nic_id(manager_id, nic_id)
409 return create_base_setting()412 return create_base_setting()
410end413end
411 414 
415+function m.get_default_group_paths()
416+ local eth_obj = get_netinterface_object(bus, ETH_OBJ_PATH, ETH_OBJ_INTERFACE)
417+ local default_group_id
418+ if eth_obj then
419+ default_group_id = eth_obj.DefaultEthGroupId
420+ end
421+ if default_group_id == nil then
422+ default_group_id = 0
423+ end
424+ if default_group_id == 0 then
425+ local mdb_setting = get_netinterface_data()
426+ mdb_setting.GroupId = 0
427+ mdb_setting.IsGroupIdValid = true
428+ return mdb_setting
429+ end
430+ local ncsi_setting = get_out_group_data('1', default_group_id)
431+ if ncsi_setting.EthernetInterfaces.Path ~= '' then
432+ ncsi_setting.IsValidId = true
433+ ncsi_setting.GroupId = default_group_id
434+ return ncsi_setting
435+ end
436+ -- 没有数据,返回独立子节点
437+ ncsi_setting = get_netinterface_data()
438+ ncsi_setting.GroupId = 0
439+ ncsi_setting.IsValidId = true
440+ return ncsi_setting
441+end
442+ 
412function m.check_single_network_port()443function m.check_single_network_port()
413 local is_single_network_port = true444 local is_single_network_port = true
414 local ok, rsp = pcall(mdb_service.get_sub_paths, bus, ETH_OBJ_PATH .. '/EthGroup', 1, { ETH_GROUP_INTERFACE })445 local ok, rsp = pcall(mdb_service.get_sub_paths, bus, ETH_OBJ_PATH .. '/EthGroup', 1, { ETH_GROUP_INTERFACE })
@@ -8,6 +8,7 @@
8-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.8-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9-- See the Mulan PSL v2 for more details.9-- See the Mulan PSL v2 for more details.
10local mc_utils = require('mc.utils')10local mc_utils = require('mc.utils')
11+local mdb_service = require('mc.mdb.mdb_service')
11 12 
12local m = {}13local m = {}
13local IPV4_PATH <const> = '/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4'14local IPV4_PATH <const> = '/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4'
@@ -19,6 +20,33 @@ local ETH_PORT_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.MgmtP
19local ETH_GROUP_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.EthGroup'20local ETH_GROUP_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.EthGroup'
20local DEDICATED_TYPE <const> = 'Dedicated'21local DEDICATED_TYPE <const> = 'Dedicated'
21 22 
23+-- 根据DefaultEthGroupId获取默认网口端口号
24+-- 0:走IPV4和IPV6
25+-- 非0:走默认网口组ID指定的ethGroup对象
26+ 
27+local function get_default_group_obj()
28+ local eth_obj = mdb.get_object(bus, ETHERNET_PATH, ETHERNET_INTERFACE)
29+ local default_group_id = eth_obj.DefaultEthGroupId
30+ 
31+ if default_group_id == nil then
32+ default_group_id = 0
33+ end
34+ if default_group_id == 0 then
35+ return nil
36+ end
37+ local ok, rsp = mdb.get_object(bus, ETHERNET_PATH .. '/EthGroup', 1, {ETH_GROUP_INTERFACE})
38+ if ok then
39+ for _, sub_path in pairs(rsp.SubPaths) do
40+ local ok2, group_obj = pcall(mdb.get_object, bus, sub_path, ETH_GROUP_INTERFACE)
41+ if ok2 and group_obj.OutType == 2 and group_obj.Status and group_obj.GroupId == default_group_id then
42+ return group_obj.PortId
43+ end
44+ end
45+ end
46+ return nil
47+end
48+ 
49+ 
22-- 获取NCSI网口端口号50-- 获取NCSI网口端口号
23local function get_eth_host_port()51local function get_eth_host_port()
24 local eth_obj = mdb.get_object(bus, ETHERNET_PATH, ETHERNET_INTERFACE)52 local eth_obj = mdb.get_object(bus, ETHERNET_PATH, ETHERNET_INTERFACE)
@@ -114,6 +142,14 @@ local function insert_eth_group_info(info, group_paths)
114end142end
115 143 
116function m.get_network_rsp(group_paths)144function m.get_network_rsp(group_paths)
145+ local default_group_obj = get_default_group_obj()
146+ if default_group_obj then
147+ local info = get_ethernet_group_info(0, default_group_obj)
148+ if info then
149+ return insert_eth_group_info(info, group_paths)
150+ end
151+ end
152+
117 local ipv4_obj = mdb.get_object(bus, IPV4_PATH, IPV4_INTERFACE)153 local ipv4_obj = mdb.get_object(bus, IPV4_PATH, IPV4_INTERFACE)
118 local ipv4_addr = (ipv4_obj.IpAddr ~= '') and ipv4_obj.IpAddr or '0.0.0.0'154 local ipv4_addr = (ipv4_obj.IpAddr ~= '') and ipv4_obj.IpAddr or '0.0.0.0'
119 local submask = (ipv4_obj.SubnetMask ~= '') and ipv4_obj.SubnetMask or '0.0.0.0'155 local submask = (ipv4_obj.SubnetMask ~= '') and ipv4_obj.SubnetMask or '0.0.0.0'
@@ -20,6 +20,60 @@ local MGMT_PORT_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.Mgmt
20 20 
21local m = {}21local m = {}
22 22 
23+local function apply_default_setting(mdb_path, mdb_setting)
24+ mdb_setting.EthernetInterfaces.Path = mdb_path
25+ mdb_setting.EthernetInterfaces.Interface = ETH_OBJ_INTERFACE
26+ mdb_setting.Ipv4.Path = mdb_path .. '/Ipv4'
27+ mdb_setting.Ipv4.Interface = ETH_OBJ_INTERFACE .. '.Ipv4'
28+ mdb_setting.Ipv6.Path = mdb_path .. '/Ipv6'
29+ mdb_setting.Ipv6.Interface = ETH_OBJ_INTERFACE .. '.Ipv6'
30+end
31+ 
32+local function apply_eth_group_setting(sub_path, mdb_setting)
33+ mdb_setting.EthernetInterfaces.Path = sub_path
34+ mdb_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE
35+ mdb_setting.EthernetInterfaces.PortId = 'ActivePortId'
36+ mdb_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
37+ mdb_setting.EthernetInterfaces.EthName = 'ActiveInterfaceName'
38+ mdb_setting.Ipv4.Path = sub_path
39+ mdb_setting.Ipv4.Interface = ETH_GROUP_INTERFACE
40+ mdb_setting.Ipv6.Path = sub_path
41+ mdb_setting.Ipv6.Interface = ETH_GROUP_INTERFACE
42+ mdb_setting.Ipv6.IpMode = 'Ipv6Mode'
43+ mdb_setting.Ipv6.IpAddr = 'Ipv6Addr'
44+ mdb_setting.Ipv6.DefaultGateway = 'Ipv6DefaultGateway'
45+ mdb_setting.Ipv6.SetIpAddr = 'SetIpv6Addr'
46+ mdb_setting.Ipv6.SetDefaultGateway = 'SetIpv6DefaultGateway'
47+end
48+ 
49+--根据DefaultEthGroupId 解析默认网口组的IPV4和IPV6路径配置
50+-- 0:走IPV4和IPV6
51+--非0:走默认网口组ID指定的ethGroup对象
52+local function resolve_default_group_paths(eth_obj, mdb_path, mdb_setting)
53+ local default_group_id = eth_obj.DefaultEthGroupId
54+ if default_group_id == nil then
55+ default_group_id = 0
56+ end
57+ mdb_setting.GroupId = default_group_id
58+ if default_group_id == 0 then
59+ apply_default_setting(mdb_path, mdb_setting)
60+ else
61+ local ok, rsp = pcall(mdb_service.get_sub_paths, bus, mdb_path .. '/EthGroup', 1, { ETH_OBJ_INTERFACE })
62+ if ok then
63+ for _, sub_path in pairs(rsp.SubPaths) do
64+ local ok2, group_obj = pcall(mdb.get_object, bus, sub_path, ETH_GROUP_INTERFACE)
65+ if ok2 and group_obj.OutType == 2 and group_obj.Status and group_obj.GroupId == default_group_id then
66+ apply_eth_group_setting(sub_path, mdb_setting)
67+ break
68+ end
69+ end
70+ end
71+ if mdb_setting.Ipv4.Path == '' then
72+ apply_default_setting(mdb_path, mdb_setting)
73+ end
74+ end
75+end
76+ 
23local function create_base_setting()77local function create_base_setting()
24 local setting = {78 local setting = {
25 EthernetInterfaces = {79 EthernetInterfaces = {
@@ -27,6 +81,7 @@ local function create_base_setting()
27 Interface = '',81 Interface = '',
28 PortId = 'PortId',82 PortId = 'PortId',
29 VLANEnable = 'VLANEnable',83 VLANEnable = 'VLANEnable',
84+ EthName = 'EthName',
30 SetFlag = false,85 SetFlag = false,
31 EthModeNetMode = 'NetMode',86 EthModeNetMode = 'NetMode',
32 EthModePortId = 0,87 EthModePortId = 0,
@@ -161,6 +216,7 @@ local function get_eth_group_setting(ethGroup_obj, ipv4_enable, host_port, eth_m
161 end216 end
162 eth_group_setting.EthernetInterfaces.PortId = 'ActivePortId'217 eth_group_setting.EthernetInterfaces.PortId = 'ActivePortId'
163 eth_group_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'218 eth_group_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
219+ eth_group_setting.EthernetInterfaces.EthName = 'ActiveInterfaceName'
164 eth_group_setting.Ipv4.Path = ethGroup_obj.path220 eth_group_setting.Ipv4.Path = ethGroup_obj.path
165 eth_group_setting.Ipv4.Interface = ETH_GROUP_INTERFACE221 eth_group_setting.Ipv4.Interface = ETH_GROUP_INTERFACE
166 eth_group_setting.Ipv6.Path = ethGroup_obj.path222 eth_group_setting.Ipv6.Path = ethGroup_obj.path
@@ -243,4 +299,11 @@ function m.patch_eth_info(eth_num, ipv4_enable, host_port, eth_mode)
243 return create_base_setting()299 return create_base_setting()
244end300end
245 301 
302+function m.get_default_group_paths()
303+ local mdb_setting = create_base_setting()
304+ local eth_obj = mdb.get_object(bus, ETH_OBJ_PATH, ETH_OBJ_INTERFACE)
305+ resolve_default_group_paths(mdb_setting, eth_obj)
306+ return mdb_setting
307+end
308+ 
246return m309return m
@@ -46,6 +46,14 @@
46 "Formula": "return not (ProcessingFlow[6].Destination.IpVersion == 'IPv4' or ProcessingFlow[5].Destination.IpMode == 'Static')"46 "Formula": "return not (ProcessingFlow[6].Destination.IpVersion == 'IPv4' or ProcessingFlow[5].Destination.IpMode == 'Static')"
47 }47 }
48 ]48 ]
49+ },
50+ "PatchDefaultGroup": {
51+ "Steps": [
52+ {
53+ "Type": "Plugin",
54+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
atomgit-bot
atomgit-botatomgit-bot29 天前

🟠 High Priority

变更行:NTP.json:54(以及 NetworkSettings.json:54、Overview.json:43/302)新增的 Plugin 步骤 Formula 均为 orchestrator.multi_patch.get_default_group_paths()(复数),但本 PR 新增的插件 interface_config/web_backend/plugins/orchestrator/multi_patch.lua:226 只定义了 function m.get_default_group_path()(单数),全仓库 grep 均不存在 get_default_group_paths 的 Lua 定义。

受影响行为/契约:这些 GET 流的 ProcessingFlow 步骤(NTP.json:95-106、NetworkSettings.json:143-160、Overview.json:167-178/592-603)都改为 ${Statements/PatchDefaultGroup()/Ipv4/Path}、${.../Ipv4/Interface}、${.../Ipv6/IpMode} 等模板引用,引擎必须成功执行 PatchDefaultGroup 语句才能解析出 Path/Interface。

失败模式:orchestrator 加载 multi_patch 模块后调用 get_default_group_paths,得到 nil 函数 → Plugin 语句执行报错(attempt to call a nil value)或输出为空 → 后续 Property 步骤的 Path/Interface 解析为 nil/空串 → /UI/Rest/Overview、/UI/Rest/BMCSettings/NetworkSettings、/UI/Rest/BMCSettings/NTP 三个 GET 接口直接故障,PR 核心功能(默认网口组适配)整体不可用。

建议:把 multi_patch.lua:226 的函数名改为 get_default_group_paths 与 4 处 JSON 调用对齐;同时按另一条 finding 在函数末尾补 return mdb_setting。这是跨文件修复,需要同步改名后做回归验证。

likedislike
不准确?
55+ }
56+ ]
49 }57 }
50 },58 },
51 "ProcessingFlow": [59 "ProcessingFlow": [
@@ -84,28 +92,28 @@
84 },92 },
85 {93 {
86 "Type": "Property",94 "Type": "Property",
87- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",95+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
88- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",96+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
89 "Destination": {97 "Destination": {
90 "IpMode": "IpMode"98 "IpMode": "IpMode"
91 }99 }
92 },100 },
93 {101 {
94 "Type": "Property",102 "Type": "Property",
95- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",103+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
96- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",104+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
97 "Destination": {105 "Destination": {
98- "IpMode": "IpMode"106+ "${Statements/PatchDefaultGroup()/Ipv6/IpMode}": "IpMode"
99 }107 }
100 },108 },
101 {109 {
102 "Type": "Property",110 "Type": "Property",
103- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces",111+ "Path": "${Statements/PatchDefaultGroup()/EthernetInterfaces/Path}",
104- "Interface": "bmc.kepler.Managers.EthernetInterfaces",112+ "Interface": "${Statements/PatchDefaultGroup()/EthernetInterfaces/Interface}",
105 "Destination": {113 "Destination": {
106 "IpVersion": "IpVersion"114 "IpVersion": "IpVersion"
107 }115 }
108- },116+ },
109 {117 {
110 "Type": "List",118 "Type": "List",
111 "Path": "/bmc/kepler/Managers",119 "Path": "/bmc/kepler/Managers",
@@ -47,6 +47,14 @@
47 "NetworkPort": "${Statements/GetNetworkPort()}"47 "NetworkPort": "${Statements/GetNetworkPort()}"
48 },48 },
49 "Statements": {49 "Statements": {
50+ "PatchDefaultGroup": {
51+ "Steps": [
52+ {
53+ "Type": "Plugin",
54+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
55+ }
56+ ]
57+ },
50 "GetAddressMode": {58 "GetAddressMode": {
51 "Steps": [59 "Steps": [
52 {60 {
@@ -116,15 +124,15 @@
116 "ProcessingFlow": [124 "ProcessingFlow": [
117 {125 {
118 "Type": "Property",126 "Type": "Property",
119- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces",127+ "Path": "${Statements/PatchDefaultGroup()/EthernetInterfaces/Path}",
120- "Interface": "bmc.kepler.Managers.EthernetInterfaces",128+ "Interface": "${Statements/PatchDefaultGroup()/EthernetInterfaces/Interface}",
121 "Destination": {129 "Destination": {
122 "IpVersion": "IpVersion",130 "IpVersion": "IpVersion",
123 "Mac": "Mac",131 "Mac": "Mac",
124 "VLANId": "VLANId",132 "VLANId": "VLANId",
125- "VLANEnable": "VLANEnable",133+ "${Statements/PatchDefaultGroup()/EthernetInterfaces/VLANEnable}": "VLANEnable",
126 "NetMode": "NetMode",134 "NetMode": "NetMode",
127- "PortId": "PortId",135+ "${Statements/PatchDefaultGroup()/EthernetInterfaces/PortId}": "PortId",
128 "LinkLocalAddress": "LinkLocalAddress",136 "LinkLocalAddress": "LinkLocalAddress",
129 "SLAACAddressList": "SLAACAddressList",137 "SLAACAddressList": "SLAACAddressList",
130 "Status": "Status"138 "Status": "Status"
@@ -132,8 +140,8 @@
132 },140 },
133 {141 {
134 "Type": "Property",142 "Type": "Property",
135- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",143+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
136- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",144+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
137 "Destination": {145 "Destination": {
138 "IpMode": "IpMode",146 "IpMode": "IpMode",
139 "IpAddr": "IpAddr",147 "IpAddr": "IpAddr",
@@ -143,13 +151,13 @@
143 },151 },
144 {152 {
145 "Type": "Property",153 "Type": "Property",
146- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",154+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
147- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",155+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
148 "Destination": {156 "Destination": {
149- "DefaultGateway": "DefaultGateway",157+ "${Statements/PatchDefaultGroup()/Ipv6/DefaultGateway}": "DefaultGateway",
150 "PrefixLength": "PrefixLength",158 "PrefixLength": "PrefixLength",
151- "IpAddr": "IpAddr",159+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "IpAddr",
152- "IpMode": "IpMode"160+ "${Statements/PatchDefaultGroup()/Ipv6/IpMode}": "IpMode"
153 }161 }
154 },162 },
155 {163 {
@@ -36,6 +36,14 @@
36 "ProductImage": "${ProcessingFlow[11]/Destination/ProductImage}"36 "ProductImage": "${ProcessingFlow[11]/Destination/ProductImage}"
37 },37 },
38 "Statements": {38 "Statements": {
39+ "PatchDefaultGroup": {
40+ "Steps": [
41+ {
42+ "Type": "Plugin",
43+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
44+ }
45+ ]
46+ },
39 "ProductName": {47 "ProductName": {
40 "Input": "${ProcessingFlow[13]/Destination/ProductName}",48 "Input": "${ProcessingFlow[13]/Destination/ProductName}",
41 "Steps": [49 "Steps": [
@@ -156,18 +164,18 @@
156 },164 },
157 {165 {
158 "Type": "Property",166 "Type": "Property",
159- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",167+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
160- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",168+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
161 "Destination": {169 "Destination": {
162 "IpAddr": "IpAddr"170 "IpAddr": "IpAddr"
163 }171 }
164 },172 },
165 {173 {
166 "Type": "Property",174 "Type": "Property",
167- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",175+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
168- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",176+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
169 "Destination": {177 "Destination": {
170- "IpAddr": "IpAddr"178+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "IpAddr"
171 }179 }
172 },180 },
173 {181 {
@@ -284,6 +292,14 @@
284 }292 }
285 },293 },
286 "Statements": {294 "Statements": {
295+ "PatchDefaultGroup": {
296+ "Steps": [
297+ {
298+ "Type": "Plugin",
299+ "Formula": "orchestrator.multi_patch.get_default_group_paths()"
300+ }
301+ ]
302+ },
287 "CpuCount": {303 "CpuCount": {
288 "Steps": [304 "Steps": [
289 {305 {
@@ -543,18 +559,18 @@
543 },559 },
544 {560 {
545 "Type": "Property",561 "Type": "Property",
546- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv4",562+ "Path": "${Statements/PatchDefaultGroup()/Ipv4/Path}",
547- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv4",563+ "Interface": "${Statements/PatchDefaultGroup()/Ipv4/Interface}",
548 "Destination": {564 "Destination": {
549 "IpAddr": "IpAddr"565 "IpAddr": "IpAddr"
550 }566 }
551 },567 },
552 {568 {
553 "Type": "Property",569 "Type": "Property",
554- "Path": "/bmc/kepler/Managers/1/EthernetInterfaces/Ipv6",570+ "Path": "${Statements/PatchDefaultGroup()/Ipv6/Path}",
555- "Interface": "bmc.kepler.Managers.EthernetInterfaces.Ipv6",571+ "Interface": "${Statements/PatchDefaultGroup()/Ipv6/Interface}",
556 "Destination": {572 "Destination": {
557- "IpAddr": "IpAddr"573+ "${Statements/PatchDefaultGroup()/Ipv6/IpAddr}": "IpAddr"
558 }574 }
559 },575 },
560 {576 {
@@ -18,6 +18,63 @@ local ETH_GROUP_INTERFACE <const> = 'bmc.kepler.Managers.EthernetInterfaces.EthG
18 18 
19local m = {}19local m = {}
20 20 
21+local function apply_default_setting(mdb_path, mdb_setting)
22+ mdb_setting.EthernetInterfaces.Path = mdb_path
23+ mdb_setting.EthernetInterfaces.Interface = ETH_OBJ_INTERFACE
24+ mdb_setting.Ipv4.Path = mdb_path .. '/Ipv4'
25+ mdb_setting.Ipv4.Interface = ETH_OBJ_INTERFACE .. '.Ipv4'
26+ mdb_setting.Ipv6.Path = mdb_path .. '/Ipv6'
27+ mdb_setting.Ipv6.Interface = ETH_OBJ_INTERFACE .. '.Ipv6'
28+end
29+ 
30+local function apply_eth_group_setting(sub_path, mdb_setting)
31+ mdb_setting.EthernetInterfaces.Path = sub_path
32+ mdb_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE
33+ mdb_setting.EthernetInterfaces.PortId = 'ActivePortId'
34+ mdb_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
35+ mdb_setting.EthernetInterfaces.EthName = 'ActiveInterfaceName'
36+ mdb_setting.Ipv4.Path = sub_path
37+ mdb_setting.Ipv4.Interface = ETH_GROUP_INTERFACE
38+ mdb_setting.Ipv6.Path = sub_path
39+ mdb_setting.Ipv6.Interface = ETH_GROUP_INTERFACE
40+ mdb_setting.Ipv6.IpMode = 'Ipv6Mode'
41+ mdb_setting.Ipv6.IpAddr = 'Ipv6Addr'
42+ mdb_setting.Ipv6.DefaultGateway = 'Ipv6DefaultGateway'
43+ mdb_setting.Ipv6.SetIpAddr = 'SetIpv6Addr'
44+ mdb_setting.Ipv6.SetDefaultGateway = 'SetIpv6DefaultGateway'
45+end
46+ 
47+--根据DefaultEthGroupId 解析默认网口组的IPV4和IPV6路径配置
48+-- 0:走IPV4和IPV6
49+--非0:走默认网口组ID指定的ethGroup对象
50+local function resolve_default_group_paths(eth_obj, mdb_path, mdb_setting)
51+ local default_group_id
52+ if eth_obj then
53+ default_group_id = eth_obj.DefaultEthGroupId
54+ end
55+ if default_group_id == nil then
56+ default_group_id = 0
57+ end
58+ mdb_setting.GroupId = default_group_id
59+ if default_group_id == 0 then
60+ apply_default_setting(mdb_path, mdb_setting)
61+ else
62+ local ok, rsp = pcall(mdb_service.get_sub_paths, bus, mdb_path .. '/EthGroup', 1, { ETH_GROUP_INTERFACE })
63+ if ok then
64+ for _, sub_path in pairs(rsp.SubPaths) do
65+ local ok2, group_obj = pcall(mdb.get_object, bus, sub_path, ETH_GROUP_INTERFACE)
66+ if ok2 and group_obj.OutType == 2 and group_obj.Status and group_obj.GroupId == default_group_id then
67+ apply_eth_group_setting(sub_path, mdb_setting)
68+ break
69+ end
70+ end
71+ end
72+ if mdb_setting.Ipv4.Path == '' then
73+ apply_default_setting(mdb_path, mdb_setting)
74+ end
75+ end
76+end
77+ 
21local function create_base_setting()78local function create_base_setting()
22 local setting = {79 local setting = {
23 GroupId = 0,80 GroupId = 0,
@@ -26,6 +83,7 @@ local function create_base_setting()
26 Interface = '',83 Interface = '',
27 PortId = 'PortId',84 PortId = 'PortId',
28 VLANEnable = 'VLANEnable',85 VLANEnable = 'VLANEnable',
86+ EthName = 'EthName',
29 },87 },
30 Ipv4 = {88 Ipv4 = {
31 Path = '',89 Path = '',
@@ -122,19 +180,7 @@ local function patch_mac_to_ethgroup(mac_id, eth_group_setting)
122 if ethgroup_object ~= nil then180 if ethgroup_object ~= nil then
123 if ethgroup_object.OutType == 2 then181 if ethgroup_object.OutType == 2 then
124 eth_group_setting.GroupId = ethgroup_object.GroupId182 eth_group_setting.GroupId = ethgroup_object.GroupId
125- eth_group_setting.EthernetInterfaces.Path = sub_path183+ apply_eth_group_setting(sub_path, eth_group_setting)
126- eth_group_setting.EthernetInterfaces.Interface = ETH_GROUP_INTERFACE
127- eth_group_setting.EthernetInterfaces.PortId = 'ActivePortId'
128- eth_group_setting.EthernetInterfaces.VLANEnable = 'VLANEnabled'
129- eth_group_setting.Ipv4.Path = sub_path
130- eth_group_setting.Ipv4.Interface = ETH_GROUP_INTERFACE
131- eth_group_setting.Ipv6.Path = sub_path
132- eth_group_setting.Ipv6.Interface = ETH_GROUP_INTERFACE
133- eth_group_setting.Ipv6.IpMode = 'Ipv6Mode'
134- eth_group_setting.Ipv6.IpAddr = 'Ipv6Addr'
135- eth_group_setting.Ipv6.DefaultGateway = 'Ipv6DefaultGateway'
136- eth_group_setting.Ipv6.SetIpAddr = 'SetIpv6Addr'
137- eth_group_setting.Ipv6.SetDefaultGateway = 'SetIpv6DefaultGateway'
138 return true184 return true
139 end185 end
140 end186 end
@@ -147,12 +193,7 @@ local function patch_mac_to_eth(mac_id, eth_interface_setting)
147 local netinterface_object = get_mac_patched_eth_object(mac_id)193 local netinterface_object = get_mac_patched_eth_object(mac_id)
148 if netinterface_object ~= nil and netinterface_object.Status then194 if netinterface_object ~= nil and netinterface_object.Status then
149 eth_interface_setting.GroupId = 0195 eth_interface_setting.GroupId = 0
150- eth_interface_setting.EthernetInterfaces.Path = ETH_OBJ_PATH196+ apply_default_setting(ETH_OBJ_PATH, eth_interface_setting)
151- eth_interface_setting.EthernetInterfaces.Interface = ETH_OBJ_INTERFACE
152- eth_interface_setting.Ipv4.Path = ETH_OBJ_PATH .. '/Ipv4'
153- eth_interface_setting.Ipv4.Interface = ETH_OBJ_INTERFACE .. '.Ipv4'
154- eth_interface_setting.Ipv6.Path = ETH_OBJ_PATH .. '/Ipv6'
155- eth_interface_setting.Ipv6.Interface = ETH_OBJ_INTERFACE .. '.Ipv6'
156 return true197 return true
157 end198 end
158 return false199 return false
@@ -172,17 +213,19 @@ local function get_ports_path(ports, mdb_setting)
172 mdb_setting.PortPaths = port_paths213 mdb_setting.PortPaths = port_paths
173end214end
174 215 
216+function m.get_default_group_paths()
217+ local mdb_setting = create_base_setting()
218+ local eth_obj = get_netinterface_object(ETH_OBJ_PATH, ETH_OBJ_INTERFACE)
219+ resolve_default_group_paths(eth_obj, ETH_OBJ_PATH, mdb_setting)
220+ return mdb_setting
221+end
222+ 
175function m.patch_eth_info(mac_id, network_port)223function m.patch_eth_info(mac_id, network_port)
176 -- 之前的单网口环境不需要传mac地址224 -- 之前的单网口环境不需要传mac地址
177 if mac_id == nil then225 if mac_id == nil then
178 local mdb_setting = create_base_setting()226 local mdb_setting = create_base_setting()
179 mdb_setting.GroupId = 0227 mdb_setting.GroupId = 0
180- mdb_setting.EthernetInterfaces.Path = ETH_OBJ_PATH228+ apply_default_setting(ETH_OBJ_PATH, mdb_setting)
181- mdb_setting.EthernetInterfaces.Interface = ETH_OBJ_INTERFACE
182- mdb_setting.Ipv4.Path = ETH_OBJ_PATH .. '/Ipv4'
183- mdb_setting.Ipv4.Interface = ETH_OBJ_INTERFACE .. '.Ipv4'
184- mdb_setting.Ipv6.Path = ETH_OBJ_PATH .. '/Ipv6'
185- mdb_setting.Ipv6.Interface = ETH_OBJ_INTERFACE .. '.Ipv6'
186 return mdb_setting229 return mdb_setting
187 end230 end
188 231 
@@ -1,7 +1,7 @@
1{1{
2 "name": "rackmount",2 "name": "rackmount",
3 "type": "configuration",3 "type": "configuration",
4- "version": "1.110.128",4+ "version": "1.110.129",
5 "author": "Huawei",5 "author": "Huawei",
6 "license": "Mulan PSL v2",6 "license": "Mulan PSL v2",
7 "options": {7 "options": {