MCPcopy Create free account
hub / github.com/FDio/vpp / demo_ring_buffer_schema

Function demo_ring_buffer_schema

src/vpp-api/python/vpp_papi/vpp_stats.py:1580–1633  ·  view source on GitHub ↗

Demo function showing how to use ring buffer schema functionality

()

Source from the content-addressed store, hash-verified

1578
1579
1580def demo_ring_buffer_schema():
1581 """Demo function showing how to use ring buffer schema functionality"""
1582 print("Ring Buffer Schema Demo")
1583 print("=" * 30)
1584
1585 try:
1586 # Connect to VPP stats
1587 stats = VPPStats()
1588 stats.connect()
1589
1590 # Look for test ring buffer
1591 try:
1592 ring_buffer = stats.get_ring_buffer("/test/ring-buffer")
1593 print("✓ Found test ring buffer")
1594
1595 # Get configuration
1596 config = ring_buffer.get_config()
1597 print(f"Ring buffer config: {config}")
1598
1599 # Get schema information
1600 schema_data, schema_size, schema_version = ring_buffer.get_schema()
1601 print(f"Schema info: size={schema_size}, version={schema_version}")
1602
1603 # Get schema as string
1604 schema_string, _, _ = ring_buffer.get_schema_string()
1605 if schema_string:
1606 print(f"Schema content:\n{schema_string}")
1607 else:
1608 print("No schema found")
1609
1610 # Use convenience methods
1611 print("\nUsing convenience methods:")
1612 conv_schema_string, conv_size, conv_version = (
1613 stats.get_ring_buffer_schema_string("/test/ring-buffer")
1614 )
1615 print(
1616 f"Convenience method result: size={conv_size}, version={conv_version}"
1617 )
1618 if conv_schema_string:
1619 print(f"Schema: {conv_schema_string[:100]}...")
1620
1621 except (KeyError, ValueError) as e:
1622 print(f"Test ring buffer not found: {e}")
1623 print(
1624 "Run 'test stats ring-buffer-gen /test/ring-buffer 100 1000 16' in VPP first"
1625 )
1626
1627 stats.disconnect()
1628
1629 except Exception as e:
1630 print(f"Error: {e}")
1631 print("Make sure VPP is running and stats socket is available")
1632
1633 print("=" * 30)
1634
1635
1636if __name__ == "__main__":

Callers 1

vpp_stats.pyFile · 0.85

Calls 9

connectMethod · 0.95
get_ring_bufferMethod · 0.95
disconnectMethod · 0.95
printFunction · 0.85
VPPStatsClass · 0.85
get_configMethod · 0.80
get_schemaMethod · 0.80
get_schema_stringMethod · 0.80

Tested by

no test coverage detected