Forum Discussion

David_Murphy_22's avatar
David_Murphy_22
Icon for Nimbostratus rankNimbostratus
Sep 16, 2013

iControl - LocalLBVirtualServerVirtualServerPersistence[][] - list persistence profile for each Virtual Server

// ... code snippet
iControl.Interfaces interfaces = new iControl.Interfaces();
if (interfaces.initialize(bigip, port, user, pass))
{
  Vslist = interfaces.LocalLBVirtualServer.get_list();

  LocalLBVirtualServerVirtualServerPersistence[][] VSPersist =  interfaces.LocalLBVirtualServer.get_persistence_profile(Vslist);

  for (int rowNum = 1; rowNum <= Vslist.Length; rowNum++)
  {
    TableRow tempRow = new TableRow();
    TableCell tempCell = new TableCell();
    tempCell.Text = String.Format("{0}", Vslist[rowNum - 1]);
// end code snippet ...

I can successfully use the VsList variable above, however I'm trying to list the persistence 'profile_name' using the VSPersist variable with no success. If you could show me any example of how to get to the persistence 'profile_name', I think I can go forward from your example. Thanks

 

3 Replies

  • I'm not quite sure I'm getting what you are asking but I'll give a shot at a reply. I'm assuming you are asking how to iterate through the VSPersist array to get at the persistence profile information. If that's the case, then you'll need to pull the 2-d array apart to get at the elements. The first dimension of the array is for each virtual server passed in. The second dimension is for the list of persistence profiles for that given virtual. To continue your example, I'd do something like this

    for (int rowNum = 1; rowNum <= Vslist.Length; rowNum++)
    {
      TableRow tempRow = new TableRow();
      TableCell tempCell = new TableCell();
      tempCell.Text = String.Format("{0}", Vslist[rowNum - 1]);
    
      // Extract the list of profiles for the given virtual
      LocalLBVirtualServerVirtualServerPersistence [] profilesA = VSPersist[rowNum - 1];
      // Iterate through each of the profiles
      for(int j=0; j < profilesA.Length; j++)
      {
        LocalLBVirtualServerVirtualServerPersistence profiles = profilesA[j];
        String profile_name = profiles.profile_name;
        Boolean default_profile = profiles.default_profile;
      }
      ...
    

    Hopefully this is what you were getting at. If not, comment and let me know...

    -Joe

    • Joe_Pruitt's avatar
      Joe_Pruitt
      Icon for Cirrostratus rankCirrostratus
      Excellent! Any chance you can mark my answer as "correct"?