Forum Discussion

Chandu_14820's avatar
Chandu_14820
Icon for Nimbostratus rankNimbostratus
May 27, 2010

Retrive Virtual server name by passing Virtual address string

Hi Everyone, I am trying retrieve Virtual server name by passing virtual address as argument. Vis Versa is possible by fucntion. my_icontrol_interface.LocalLBVirtualServer.get_destination("vs_test") The above function gives the corresponding virtual Address for that Virtual server name. Please let me know how to retrieve virtual server by passing the virtual address. Thanks in advance. Chandu.
  • I can't find such calls in iControl API and can't see a similar functionality in the LTM Web GUI. You can find out the Virtual Address from the Virtual Server, but not vice versa.

     

     

    You will have to do it programmatically in your code, i.e. get the list of all Virtual Servers first using get_list() call and store it in an array, then get the list of all destinations for all Virtual Servers using get_destination call with the array of all Virtual Servers as a parameter - you will now have two arrays - one with all the names, another one with all addresses, so just match the arrays.

     

     

    Bear in mind that it is NOT a One-To-One relationship. One Virtual Address can belong to MANY Virtual Servers (for example you can have two Virtual Servers on the same IP, one for port 80 and another for port 443).
  • I think as Sam says, it makes sense that you can get the virtual address from the virtual server name as there only one virtual server address (IP) for a given virtual server (IP:port). However, there can be many virtual servers defined on the same virtual address.

     

     

    Aaron
  • Thank you Very much Sam & Hoolio. I appreciate your comments on this.

     

     

    Thank you

     

    chandu
  • Hi,

     

    Is there any way to get all the SSL virtual IPs ? This way we will get all Vitual IPs and associated ports. But is there any way to get all SSL configured virtual IPs ?

     

    One way could be get_profile() and loop through the VirtualServerProfileAttribute and if profile_type is PROFILE_TYPE_CLIENT_SSL then that virtualServer has SSL configured.

     

     

    Is this the right approach ?

     

     

    Thanks,

     

    Raghu
  • Here is the implementation for getAllSSLVirtualIPs for a given managment ip. If Experts this can be improved please respond.

     

     

    public Set getVirtalIPs() throws F5ServiceException{

     

    Set virutalAddresses = new TreeSet();

     

    try{

     

    String []vNames = virtualServerManagement.get_list();

     

    for ( String n:vNames){

     

    LocalLBVirtualServerVirtualServerProfileAttribute [][] attrs = virtualServerManagement.get_profile(new String[]{n});

     

    for (LocalLBVirtualServerVirtualServerProfileAttribute[] aa:attrs ){

     

    for (LocalLBVirtualServerVirtualServerProfileAttribute a:aa){

     

    //System.out.println(a.getProfile_context());

     

     

    if( LocalLBProfileType.PROFILE_TYPE_CLIENT_SSL.equals(a.getProfile_type())){

     

    System.out.println(a.getProfile_name());

     

    CommonIPPortDefinition [] ipPorts = virtualServerManagement.get_destination(new String[]{n});

     

    for ( CommonIPPortDefinition ip:ipPorts){

     

    virutalAddresses.add(ip.getAddress());

     

    }

     

    }

     

    }

     

    }

     

    }

     

    }catch(Exception e){

     

    throw new F5ServiceException(e);

     

    }

     

    return virutalAddresses;

     

    }

     

     

    Thanks,

     

    Raghu