Forum Discussion

Vladimir_Budilo's avatar
Vladimir_Budilo
Icon for Nimbostratus rankNimbostratus
Jan 06, 2010

GTM Load Balancing using iControl & iControlIntermediary

Hello All!

 

 

I am currently working on a web-based application to manage GTM.

 

 

I've downloaded the iControl java code (as well as the iControl Wrapper jar), and see that the architecture centers around LTM, not GTM.

 

 

So, for example, the following code will print out all of the pool names defined for the LTM (stored in the bigip.conf file, and not the wide-ip.conf file that I need):

 

 
                 import iControlIntermediary.LBPool; 
  
                 .......... 
  
 LBPool lbPool = new LBPool(USERNAME, PASSWORD, ADDRESS); 
  
 String poolArray[] = lbPool.getList(); 
  
 for (String poolName : poolArray) { 
 System.out.println("PoolName: " + poolName); 
 } 
 

 

 

Is there an API that deals with GTM management?

 

 

What I'm trying to do is create the functionality that will allow for switching between members of a specific GTM pool .

 

 

Any help would be appreciated!!

 

 

Thanks!

 

Vladimir

4 Replies

  • That is true for the intermediary library. Try downloading the standalone iControl Library for Java on the iControl Assembly labs project. This contains all the core iControl interfaces (GTM included).

     

     

    The wrappers were developed as an example use case but were not fully baked to include all of the product modules. If you go with the Core iControl library, you can get to everything. Let me know once you get it up and running if you need any example code to get you started and I'll see what I can whip up.

     

     

    BTW, the source for the iControl library for Java is available as a download as well if you want to see how it works.

     

     

    Let us know how it goes and if there's anything else I can do to help.

     

     

    -Joe
  • Hello again!

    This is a sample method that returns a boolean based on a status of a pool member (it's very rough -- almost no error checking is done here, so it's not something you'd want to use in PRD, but it's just a sample I wanted to share, since I can't find many java examples on this website, especially utilizing GlobalLB):

      
     /** 
      * 1. Retrieves the WideIP  
      * 2. Gets the WideIP's pool name (There could be 
      * more than one pool, but that's improbable here  
      * 3. Retrieves the pool 
      * member information for this one particular pool  
      * 4. Checks whether the 
      * pool member is enabled/disabled 
      *  
      * @param aInterfaces 
      * @param aWideIp 
      * @param aPoolMember 
      * @return 
      * @throws RemoteException 
      * @throws Exception 
      */ 
     public static boolean isPoolMemberEnabled(Interfaces aInterfaces, 
     String aWideIp, String aPoolMember) throws RemoteException, 
     Exception { 
      
     String poolName = null; 
      
     GlobalLBWideIPBindingStub wideIpStub = aInterfaces.getGlobalLBWideIP(); 
      
     String wideIpArr[] = { aWideIp }; // Need to make this into an array 
      
     /* 
      * Check to see if the WideIp is enabled or disabled If the WideIp is 
      * disabled we can't check the status of the farm, so an exception is 
      * thrown. 
      */ 
     CommonEnabledState enabled[] = wideIpStub.get_enabled_state(wideIpArr); 
     if (!CommonEnabledState._STATE_ENABLED.equals(enabled[0].getValue())) { 
     throw new Exception( 
     "The WideIp " 
     + aWideIp 
     + " is not enabled. Cannot check the status of the pool members"); 
     } 
      
     // Get an array of wide ips, specifically the one in question 
     GlobalLBWideIPWideIPPool wideIpPools[][] = wideIpStub 
     .get_wideip_pool(wideIpArr); 
      
     // Get the wideip pool object 
     GlobalLBWideIPWideIPPool wideIpPool = wideIpPools[0][0]; 
      
     // Get the pool name in question 
     poolName = wideIpPool.getPool_name(); 
     System.out.println("Pool Name: " + poolName); 
     String poolNameArr[] = { poolName }; // Need to make this into an array 
      
     GlobalLBPoolMemberBindingStub poolMemberStub = aInterfaces 
     .getGlobalLBPoolMember(); 
      
     // I need to pass it in to the get_enabled_state() method 
     CommonIPPortDefinition testPoolMember[][] = new CommonIPPortDefinition[1][1]; 
     CommonIPPortDefinition pMember1 = new CommonIPPortDefinition(aPoolMember, 443); 
     testPoolMember[0][0] = pMember1; 
      
     GlobalLBPoolMemberMemberEnabledState[][] poolMembers = poolMemberStub 
     .get_enabled_state(poolNameArr, testPoolMember); 
      
     CommonEnabledState state = poolMembers[0][0].getState(); 
      
     System.out.println("state value: " + state.getValue()); 
      
     return CommonEnabledState._STATE_ENABLED.equals(state.getValue()); 
     } 
      
  • Great post, thanks for passing this along. I'll go ahead and add this to the iControl CodeShare. One question though:

     

     

    I seems that there are only two possible exits from this routing. First, it throws an exception for "Pool name wasn't found". Otherwise it always returns false. Are you missing the section where you check the "state" variable and then assign the isEnabled boolean accordingly?

     

     

    Again, thanks for taking the time to post this up, we really appreciate it!

     

     

    -Joe
  • I copied and pasted the older version of the method, sorry. The one you see there now is the updated one.

     

     

    Also, this code is probably not ready for the iControl Code Share -- it's too messy and doesn't have much error checking -- this was just a quick solution for a proof-of-concept. But it's up to you....

     

     

    Vladimir Budilov