(context, fix_port_id, cluster)
Deletes the floating IP associated with the fix_port_id.

    Only delete the floating IP if it's created and associated with the
    the load balancers that corresponding to the services and ingresses in
    Kubernetes cluster.

    This method only works with the Kubernetes cluster with
    cloud-provider-openstack controller manager deployed.
Deletes the floating IP associated with the fix_port_id.
Deletes the floating IP associated with the fix_port_id .
def delete_floatingip(context, fix_port_id, cluster):
    """Deletes the floating IP associated with the fix_port_id.

    Only delete the floating IP if it's created and associated with the
    the load balancers that corresponding to the services and ingresses in
    Kubernetes cluster.

    This method only works with the Kubernetes cluster with
    cloud-provider-openstack controller manager deployed.
    """
    pattern = (r'Floating IP for Kubernetes .+ from cluster %s$' %
               cluster.uuid)

    try:
        n_client = clients.OpenStackClients(context).neutron()
        fips = n_client.list_floatingips(port_id=fix_port_id)
        if len(fips["floatingips"]) == 0:
            return

        # Liberty Neutron doesn't support description field, although Liberty
        # is no longer supported, we write good code here.
        desc = fips["floatingips"][0].get("description", "")
        id = fips["floatingips"][0]["id"]

        if re.match(pattern, desc):
            LOG.info("Deleting floating ip %s for cluster %s", id,
                     cluster.uuid)
            n_client.delete_floatingip(id)
    except Exception as e:
        raise exception.PreDeletionFailed(cluster_uuid=cluster.uuid,
                                          msg=str(e))
def delete_floatingip ( context , fix_port_id , cluster ) : pattern = ( r'Floating IP for Kubernetes .+ from cluster %s$' % cluster . uuid ) try : n_client = clients . OpenStackClients ( context ) . neutron ( ) fips = n_client . list_floatingips ( port_id = fix_port_id ) if len ( fips [ "floatingips" ] ) == 0 : return # Liberty Neutron doesn't support description field, although Liberty # is no longer supported, we write good code here. desc = fips [ "floatingips" ] [ 0 ] . get ( "description" , "" ) id = fips [ "floatingips" ] [ 0 ] [ "id" ] if re . match ( pattern , desc ) : LOG . info ( "Deleting floating ip %s for cluster %s" , id , cluster . uuid ) n_client . delete_floatingip ( id ) except Exception as e : raise exception . PreDeletionFailed ( cluster_uuid = cluster . uuid , msg = str ( e ) )