Forum Discussion

vinzclortho's avatar
vinzclortho
Icon for Nimbostratus rankNimbostratus
Mar 10, 2014

Using System::Connections::delete_active_connection in ruby iControl Gem

I am attempting to delete active connections for a particular IP using the ruby iControl gem. I want to mirror the functionality of the tmsh command :

 

delete /sys connection cs-client-addr 

To do this, I'm trying to use System::Connections::delete_active_connection as detailed here. We are using the ruby iControl gem version 11.3.0.0. Here is sample code to delete a connection by IP :

 

    def delete_active_connections(ip_addr)
      result = conn["System.Connections"].delete_active_connection(["connections" => ["clientside_client" => {"address" => ip_addr}]])
      result
  end

This does not work and results in the error :

 

Exception:

Could not find element by name: address

I have not been able to find any working examples of System::Connections::delete_active_connection on devcentral. Does anyone have a working example or experience with this call? I have attempted specifying the entire connection (clientside_client, clientside_server, serverside_client, protocol) with ports, but get the same error. Any help would be appreciated.

 

4 Replies

  • in python, I have the following structure working (for get/delete). I'm asking internally about whether you can null a value you don't want to match, but haven't heard back yet.

    b.System.Connections.delete_active_connection(connections = [
      {'protocol': 'PROTOCOL_TCP', 
       'clientside_server': {'port': 443, 'address': '10.10.10.15'},
       'serverside_server': {'port': 80, 'address': '10.10.20.30'},
       'clientside_client': {'port': 0, 'address': '10.10.30.200'}}
       ])
    
  • OK, so I'm told you can use 0 for all ports, and 0.0.0.0 for all IPs.

     

  • Got this working with 0 for all ports and "0.0.0.0" for all IPs. I also had to change the format a bit. Evidently the ruby gem is not expecting a "connections" hash key, just an array. Thanks for the help, Jason.

     

    Working code :

     

        def delete_active_connections(ip_addr)
          result = conn["System.Connections"].delete_active_connection([{
              "clientside_client" => {"port" => 0, "address" => ip_addr}, 
              "clientside_server" => {"port" => 0, "address" => "0.0.0.0"}, 
              "serverside_server" => {"port" => 0, "address" => "0.0.0.0"}, 
              "protocol" => "PROTOCOL_ANY"
            }])
          result
        end
  • The connections keyword is optional in bigsuds (python), I provided it for clarity. Glad you got it working!