5656 set_network_ports as _set_network_ports ,
5757 set_networks as _set_networks ,
5858 set_subnets as _set_subnets ,
59+ get_floating_ip_pools as _get_floating_ip_pools ,
60+ set_floating_ip_port_forwarding as _set_floating_ip_port_forwarding ,
5961 set_network_qos_policies as _set_network_qos_policies ,
6062 set_network_agents as _set_network_agents ,
6163 # Load Balancer (Octavia) functions
@@ -1741,39 +1743,59 @@ async def get_floating_ips() -> str:
17411743
17421744
17431745@conditional_tool
1744- async def set_floating_ip (action : str , floating_network_id : str = "" , port_id : str = "" , floating_ip_id : str = "" ) -> str :
1746+ async def set_floating_ip (action : str , floating_network_id : str = "" , port_id : str = "" , floating_ip_id : str = "" ,
1747+ floating_ip_address : str = "" , description : str = "" ) -> str :
17451748 """
1746- Manage floating IPs (create, delete, associate, disassociate).
1749+ Manage floating IPs (create, delete, associate, disassociate, set, show, unset, list ).
17471750
17481751 Functions:
1749- - Create new floating IPs from external networks
1750- - Delete existing floating IPs
1752+ - Create new floating IPs from external networks (allocate)
1753+ - Delete existing floating IPs (release)
17511754 - Associate floating IPs with instance ports
17521755 - Disassociate floating IPs from instances
1756+ - Set floating IP properties (description, fixed IP)
1757+ - Show detailed floating IP information
1758+ - Unset floating IP properties (clear description)
1759+ - List all floating IPs
17531760
17541761 Use when user requests floating IP management, external connectivity setup, or IP allocation tasks.
17551762
17561763 Args:
1757- action: Action to perform (create, delete, associate, disassociate)
1758- floating_network_id: ID of external network for create action (optional)
1759- port_id: Port ID for association operations (optional)
1760- floating_ip_id: Floating IP ID for delete/associate/disassociate actions (optional)
1764+ action: Action to perform (create/allocate, delete/release, associate, disassociate, set, show, unset, list)
1765+ floating_network_id: ID of external network for create action
1766+ port_id: Port ID for association operations
1767+ floating_ip_id: Floating IP ID for operations
1768+ floating_ip_address: Floating IP address (alternative to floating_ip_id)
1769+ description: Description for the floating IP (for set action)
17611770
17621771 Returns:
17631772 Result of floating IP management operation in JSON format.
17641773 """
17651774 try :
17661775 logger .info (f"Managing floating IP with action '{ action } '" )
17671776
1777+ # Map CLI-style actions to internal actions
1778+ action_map = {
1779+ 'create' : 'allocate' ,
1780+ 'delete' : 'release' ,
1781+ 'allocate' : 'allocate' ,
1782+ 'release' : 'release'
1783+ }
1784+ internal_action = action_map .get (action .lower (), action .lower ())
1785+
17681786 kwargs = {}
17691787 if floating_network_id .strip ():
17701788 kwargs ['floating_network_id' ] = floating_network_id .strip ()
17711789 if port_id .strip ():
17721790 kwargs ['port_id' ] = port_id .strip ()
17731791 if floating_ip_id .strip ():
17741792 kwargs ['floating_ip_id' ] = floating_ip_id .strip ()
1793+ if floating_ip_address .strip ():
1794+ kwargs ['floating_ip_address' ] = floating_ip_address .strip ()
1795+ if description .strip ():
1796+ kwargs ['description' ] = description .strip ()
17751797
1776- result_data = _set_floating_ip (action , ** kwargs )
1798+ result_data = _set_floating_ip (internal_action , ** kwargs )
17771799
17781800 result = {
17791801 "timestamp" : datetime .now ().isoformat (),
@@ -1790,6 +1812,125 @@ async def set_floating_ip(action: str, floating_network_id: str = "", port_id: s
17901812 return error_msg
17911813
17921814
1815+ @mcp .tool ()
1816+ async def get_floating_ip_pools () -> str :
1817+ """
1818+ Get list of floating IP pools (external networks).
1819+
1820+ Functions:
1821+ - List all external networks that can provide floating IPs
1822+ - Show available and used IP counts for each pool
1823+ - Display network configuration for floating IP allocation
1824+ - Provide pool capacity and utilization information
1825+
1826+ Use when user requests:
1827+ - "Show floating IP pools"
1828+ - "List available floating IP networks"
1829+ - "Check floating IP capacity"
1830+ - "What external networks are available?"
1831+
1832+ Returns:
1833+ List of floating IP pools with capacity information in JSON format.
1834+ """
1835+ try :
1836+ result_data = _get_floating_ip_pools ()
1837+
1838+ result = {
1839+ "timestamp" : datetime .now ().isoformat (),
1840+ "pools" : result_data ,
1841+ "total_pools" : len (result_data )
1842+ }
1843+
1844+ return json .dumps (result , indent = 2 )
1845+
1846+ except Exception as e :
1847+ error_msg = f"Error: Failed to get floating IP pools - { str (e )} "
1848+ logger .error (error_msg )
1849+ return error_msg
1850+
1851+
1852+ @conditional_tool
1853+ async def set_floating_ip_port_forwarding (
1854+ action : str ,
1855+ floating_ip_id : str = "" ,
1856+ floating_ip_address : str = "" ,
1857+ port_forwarding_id : str = "" ,
1858+ protocol : str = "tcp" ,
1859+ external_port : int = 0 ,
1860+ internal_port : int = 0 ,
1861+ internal_ip_address : str = "" ,
1862+ internal_port_id : str = "" ,
1863+ description : str = ""
1864+ ) -> str :
1865+ """
1866+ Manage floating IP port forwarding rules for NAT translation.
1867+
1868+ Functions:
1869+ - Create port forwarding rules to redirect external traffic to internal IPs
1870+ - Delete existing port forwarding rules
1871+ - List all port forwarding rules for a floating IP
1872+ - Show detailed configuration of specific port forwarding rule
1873+ - Update port forwarding settings (description, internal target)
1874+
1875+ Use when user requests:
1876+ - "Create port forwarding rule for floating IP [ip] from port [ext] to [int:internal]"
1877+ - "Delete port forwarding rule [id] from floating IP [ip]"
1878+ - "List port forwarding rules for floating IP [ip]"
1879+ - "Show port forwarding rule [id] details"
1880+ - "Update port forwarding rule [id] description to [text]"
1881+
1882+ Args:
1883+ action: Action to perform (create, delete, list, show, set)
1884+ floating_ip_id: Floating IP ID (alternative to floating_ip_address)
1885+ floating_ip_address: Floating IP address (alternative to floating_ip_id)
1886+ port_forwarding_id: Port forwarding rule ID (for delete/show/set actions)
1887+ protocol: Protocol for port forwarding (tcp, udp, icmp) - default: tcp
1888+ external_port: External port number (for create action)
1889+ internal_port: Internal port number (for create action)
1890+ internal_ip_address: Internal IP address target (for create/set actions)
1891+ internal_port_id: Internal port ID target (optional)
1892+ description: Description for the port forwarding rule
1893+
1894+ Returns:
1895+ Result of port forwarding management operation in JSON format.
1896+ """
1897+ try :
1898+ logger .info (f"Managing floating IP port forwarding with action '{ action } '" )
1899+
1900+ kwargs = {
1901+ 'floating_ip_id' : floating_ip_id .strip () if floating_ip_id .strip () else None ,
1902+ 'floating_ip_address' : floating_ip_address .strip () if floating_ip_address .strip () else None ,
1903+ 'port_forwarding_id' : port_forwarding_id .strip () if port_forwarding_id .strip () else None ,
1904+ 'protocol' : protocol .lower () if protocol .strip () else 'tcp' ,
1905+ 'description' : description .strip () if description .strip () else None
1906+ }
1907+
1908+ if external_port > 0 :
1909+ kwargs ['external_port' ] = external_port
1910+ if internal_port > 0 :
1911+ kwargs ['internal_port' ] = internal_port
1912+ if internal_ip_address .strip ():
1913+ kwargs ['internal_ip_address' ] = internal_ip_address .strip ()
1914+ if internal_port_id .strip ():
1915+ kwargs ['internal_port_id' ] = internal_port_id .strip ()
1916+
1917+ result_data = _set_floating_ip_port_forwarding (action , ** kwargs )
1918+
1919+ result = {
1920+ "timestamp" : datetime .now ().isoformat (),
1921+ "action" : action ,
1922+ "parameters" : kwargs ,
1923+ "result" : result_data
1924+ }
1925+
1926+ return json .dumps (result , indent = 2 )
1927+
1928+ except Exception as e :
1929+ error_msg = f"Error: Failed to manage floating IP port forwarding - { str (e )} "
1930+ logger .error (error_msg )
1931+ return error_msg
1932+
1933+
17931934@mcp .tool ()
17941935async def get_routers () -> str :
17951936 """
0 commit comments