@@ -173,6 +173,64 @@ def services(args: List[str]) -> None:
173173
174174 cli_pretty (data , f"show-services" )
175175
176+ def container (args : List [str ]) -> None :
177+ """Handle show container [name]
178+
179+ Arguments:
180+ (none) - Show all containers in table format
181+ name - Show detailed view of specific container
182+ """
183+ data = run_sysrepocfg ("/infix-containers:containers" )
184+ if not data :
185+ print ("No container data retrieved." )
186+ return
187+
188+ # Fetch interface data for bridge resolution (both table and detailed views)
189+ # Fetch operational interface data
190+ iface_oper = run_sysrepocfg ("/ietf-interfaces:interfaces" )
191+
192+ # Also fetch config data for veth peer information (not in operational)
193+ try :
194+ result = subprocess .run ([
195+ "sysrepocfg" , "-f" , "json" , "-X" , "-d" , "running" , "-x" , "/ietf-interfaces:interfaces"
196+ ], capture_output = True , text = True , check = True )
197+ iface_config = json .loads (result .stdout )
198+
199+ # Merge config veth peer info into operational data
200+ if iface_oper and iface_config :
201+ oper_ifaces = iface_oper .get ('ietf-interfaces:interfaces' , {}).get ('interface' , [])
202+ config_ifaces = iface_config .get ('ietf-interfaces:interfaces' , {}).get ('interface' , [])
203+
204+ # Create a map of config interfaces
205+ config_map = {iface ['name' ]: iface for iface in config_ifaces }
206+
207+ # Merge veth peer info from config into operational
208+ for oper_iface in oper_ifaces :
209+ name = oper_iface .get ('name' )
210+ if name in config_map :
211+ config_iface = config_map [name ]
212+ # Add veth peer if it exists in config but not in operational
213+ if 'infix-interfaces:veth' in config_iface and 'infix-interfaces:veth' not in oper_iface :
214+ oper_iface ['infix-interfaces:veth' ] = config_iface ['infix-interfaces:veth' ]
215+
216+ data .update (iface_oper )
217+ except (subprocess .CalledProcessError , json .JSONDecodeError ):
218+ # If config fetch fails, just use operational data
219+ if iface_oper :
220+ data .update (iface_oper )
221+
222+ if RAW_OUTPUT :
223+ print (json .dumps (data , indent = 2 ))
224+ return
225+
226+ if len (args ) == 0 or not args [0 ]:
227+ cli_pretty (data , "show-container" )
228+ elif len (args ) == 1 :
229+ name = args [0 ]
230+ cli_pretty (data , "show-container-detail" , name )
231+ else :
232+ print ("Too many arguments provided. Expected: show container [name]" )
233+
176234def bfd (args : List [str ]) -> None :
177235 """Handle show bfd [subcommand] [peer] [brief]
178236
@@ -486,6 +544,7 @@ def execute_command(command: str, args: List[str]):
486544 command_mapping = {
487545 'bfd' : bfd ,
488546 'boot-order' : boot_order ,
547+ 'container' : container ,
489548 'dhcp' : dhcp ,
490549 'hardware' : hardware ,
491550 'interface' : interface ,
0 commit comments