@@ -37,17 +37,12 @@ def register_tools(self, mcp: FastMCP):
3737 mcp .tool ()(self .get_port_detail )
3838 mcp .tool ()(self .update_port )
3939 mcp .tool ()(self .delete_port )
40-
4140 mcp .tool ()(self .get_port_allowed_address_pairs )
4241 mcp .tool ()(self .set_port_binding )
43-
4442 mcp .tool ()(self .get_floating_ips )
4543 mcp .tool ()(self .create_floating_ip )
46- mcp .tool ()(self .attach_floating_ip_to_port )
47- mcp .tool ()(self .detach_floating_ip_from_port )
4844 mcp .tool ()(self .delete_floating_ip )
49- mcp .tool ()(self .update_floating_ip_description )
50- mcp .tool ()(self .reassign_floating_ip_to_port )
45+ mcp .tool ()(self .update_floating_ip )
5146 mcp .tool ()(self .create_floating_ips_bulk )
5247 mcp .tool ()(self .assign_first_available_floating_ip )
5348
@@ -701,15 +696,46 @@ def attach_floating_ip_to_port(
701696 ip = conn .network .update_ip (floating_ip_id , ** update_args )
702697 return self ._convert_to_floating_ip_model (ip )
703698
704- def detach_floating_ip_from_port (self , floating_ip_id : str ) -> FloatingIP :
699+ def update_floating_ip (
700+ self ,
701+ floating_ip_id : str ,
702+ description : str | None | object = _UNSET ,
703+ port_id : str | None | object = _UNSET ,
704+ fixed_ip_address : str | None | object = _UNSET ,
705+ ) -> FloatingIP :
705706 """
706- Detach a Floating IP from its Port.
707+ Update Floating IP attributes. Only provided parameters are changed; omitted
708+ parameters remain untouched.
707709
708- :param floating_ip_id: Floating IP ID
710+ Typical use-cases:
711+ - Attach to a port: port_id="port-1" (optionally fixed_ip_address="10.0.0.10").
712+ - Detach from its port: port_id=None.
713+ - Update description: description="new desc" or clear with description=None.
714+ - Reassign to another port: port_id="new-port" (optionally with fixed_ip_address).
715+
716+ Notes:
717+ - Passing None for description clears it.
718+ - Passing None for port_id detaches the address from any port.
719+ - fixed_ip_address is optional and can be provided alongside port_id.
720+
721+ :param floating_ip_id: Floating IP ID to update
722+ :param description: New description or None to clear
723+ :param port_id: Port ID to attach; None to detach; omit to keep unchanged
724+ :param fixed_ip_address: Specific fixed IP to map; omit to keep unchanged
709725 :return: Updated FloatingIP object
710726 """
711727 conn = get_openstack_conn ()
712- ip = conn .network .update_ip (floating_ip_id , port_id = None )
728+ update_args : dict = {}
729+ if description is not _UNSET :
730+ update_args ["description" ] = description
731+ if port_id is not _UNSET :
732+ update_args ["port_id" ] = port_id
733+ if fixed_ip_address is not _UNSET :
734+ update_args ["fixed_ip_address" ] = fixed_ip_address
735+ if not update_args :
736+ current = conn .network .get_ip (floating_ip_id )
737+ return self ._convert_to_floating_ip_model (current )
738+ ip = conn .network .update_ip (floating_ip_id , ** update_args )
713739 return self ._convert_to_floating_ip_model (ip )
714740
715741 def delete_floating_ip (self , floating_ip_id : str ) -> None :
@@ -723,43 +749,6 @@ def delete_floating_ip(self, floating_ip_id: str) -> None:
723749 conn .network .delete_ip (floating_ip_id , ignore_missing = False )
724750 return None
725751
726- def update_floating_ip_description (
727- self ,
728- floating_ip_id : str ,
729- description : str | None ,
730- ) -> FloatingIP :
731- """
732- Update a Floating IP's description.
733-
734- :param floating_ip_id: Floating IP ID
735- :param description: New description (`None` to clear)
736- :return: Updated FloatingIP object
737- """
738- conn = get_openstack_conn ()
739- ip = conn .network .update_ip (floating_ip_id , description = description )
740- return self ._convert_to_floating_ip_model (ip )
741-
742- def reassign_floating_ip_to_port (
743- self ,
744- floating_ip_id : str ,
745- port_id : str ,
746- fixed_ip_address : str | None = None ,
747- ) -> FloatingIP :
748- """
749- Reassign a Floating IP to a different Port.
750-
751- :param floating_ip_id: Floating IP ID
752- :param port_id: New port ID to attach
753- :param fixed_ip_address: Specific fixed IP on the port (optional)
754- :return: Updated Floating IP object
755- """
756- conn = get_openstack_conn ()
757- update_args : dict = {"port_id" : port_id }
758- if fixed_ip_address is not None :
759- update_args ["fixed_ip_address" ] = fixed_ip_address
760- ip = conn .network .update_ip (floating_ip_id , ** update_args )
761- return self ._convert_to_floating_ip_model (ip )
762-
763752 def create_floating_ips_bulk (
764753 self ,
765754 floating_network_id : str ,
0 commit comments