Forum Discussion

JT_47697's avatar
JT_47697
Icon for Nimbostratus rankNimbostratus
Feb 13, 2009

Simple C# Examples Please

Guys,

 

 

I've written a few C apps but I'm still learning. I just downloaded IControl Assembly in hopes of writing a simple app that monitors member states - i.e. I want to know if a node drops out of a pool indicating a problem host.

 

 

The Visual Studio Quick Start guides say that three lines of code are all that's needed to access the thousands of methods in the API. Yet, I haven't seen a single example with those three lines of code in them. The only two examples provided in the SDK (DistributionMonitor and CSSamples) were auto created by wsdl and reference all the soap calls you said are no longer needed.

 

 

I even watched a video (I can't remember the name but it's the one that required some debugging) and one of the methods used required another method. Where is that documented? I've tried the WIKI and the SDK information but there's no C examples or requirements out there.

 

 

Please note that your audience is typically networking folk and although we're getting better at writing code for our own purposes, it would be nice to have some single purpose samples that we can put together to our liking.

 

 

Again, I'm not a newbe at development but it would sure help if there were some better documentation on the API with some examples to really get us started.

 

 

thanks,

 

John

3 Replies

  • Sorry for the confusion John. I guess I'll need to get around to updating all the samples in the SDK to use the iControl Assembly.

     

     

    As for getting started, Here's the following steps.

     

     

    1. Add the iControl Assembly as a reference in your Visual Studio Project with the Add.Reference option and select browse and point it at the iControl.dll

     

     

    2. Add References to the System.Web and System.Web.Services .NET assemblies in your project.

     

     

    3. Create an iControl.Interfaces class and initialize it with the BIG-IP information.

     

     

    4. Make iControl calls.

     

     

    The following code will create an instance of the Interfaces class, initialize it, and make the iControl.LocalLBPool.get_list() method to return a list of Pools.

     

     

    public void GetPools(String bigip, String username, String password) 
     { 
       iControl.Interfaces m_interfaces = new iControl.Interfaces(); 
       if ( m_interfaces.initialize(bigip_address, 443, username, password) ) 
       { 
         String [] pool_list = m_interfaces.LocalLBPool.get_list(); 
         Console.WriteLine("Available Pools..."); 
         for(int i=0; i     { 
           Console.WriteLine("[{0}] : {1}", i, pool_list[ i ]); 
         } 
       } 
     }

     

     

    The Interfaces class has members for all of the iControl interfaces (ie. LocalLB.Pool, System.SystemInfo, etc.). You can access all the methods off of them.

     

     

    If you would like to see what's going on inside the assembly, feel free to download the source and take a look. It's available on the iControl Assembly Labs page.

     

     

    As for tutorials, I've focused primarily on PowerShell as of late but I can see I've let C slip. I'll work on getting some sample applications in C out in the near future.

     

     

    In the mean time, if you get stuck, please feel free to post any questions and we'll do our best to help you out.

     

     

    Cheers!

     

     

    -Joe
  • Thanks Joe,

     

     

    I can only hope that one day I can code as easily as you. Things have changed since COBOL on old IBM hardware.

     

     

    John.
  • I've been doing the iControl thing since day 1 of it's existence so I've got a little bit of time on you. Keep it up, it's really not that hard. B-).

     

     

    Again, feel free to post any questions you have and we'll do our best to give you a hand.

     

     

    -Joe