Forum Discussion

Radim_Bosticka_'s avatar
Radim_Bosticka_
Icon for Nimbostratus rankNimbostratus
Jan 23, 2009

Server disabling structure

Hi,

 

 

I have problems to use function set_session_enabled_state from PoolMember class.

 

 

Everywhere is description some object structure as described:

 

http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=254

 

 

Object is called LocalLBPoolMemberMemberMonitorState. After creating of it in description is information about creating of subobject called CommonIPPortDefinition.

 

 

Everything is in Java. Problem is, that creating of second object is not working for me and by mistake I guess it is problem in Jython itself. Is there some command which could return whole one object with subobjects? Then problem I guess is in code name "member" which does problem to Jython.

 

 

I have tried to create array like this:

 

 

oServer = [['10.192.2.196','80'],'STATE_DISABLED=0'];

 

 

Sadly got information that is not possible to convert it:

 

 

TypeError: set_session_enabled_state(): 2nd arg can't be coerced to iControl.LocalLBPoolMemberMemberSessionState[][]

 

 

Is possible to create some array instead of object which could be passed to function without problem?

 

 

Thanks

 

4 Replies

  • The java proxies cannot dynamically convert string arrays into native iControl types. You need to create an array of LocalLBPoolMemberMemberSessionState objects, allocate those objects, fill those objects up with their data and pass those along to the method call.

    Something like this should work for you:

    public void setPoolMemberSessionState(    
          String poolname, String memberaddr, long memberport, String state) throws Exception    
        {    
        String [] pool_list = new String [] { poolname };    
        iControl.LocalLBPoolMemberMemberSessionState [][] statesAofA = new iControl.LocalLBPoolMemberMemberSessionState[ 1 ][];    
        statesAofA[ 0 ] = new iControl.LocalLBPoolMemberMemberSessionState[1];    
        statesAofA[ 0 ][ 0 ] = new iControl.LocalLBPoolMemberMemberSessionState();    
        statesAofA[ 0 ][ 0 ].setMember(new iControl.CommonIPPortDefinition());    
        statesAofA[ 0 ][ 0 ].getMember().setAddress(memberaddr);    
        statesAofA[ 0 ][ 0 ].getMember().setPort(memberport);    
        if ( state.equals("enable") )    
        {     
        statesAofA[ 0 ][ 0 ].setSession_state(iControl.CommonEnabledState.STATE_ENABLED);    
        }    
        else    
        {    
        statesAofA[ 0 ][ 0 ].setSession_state(iControl.CommonEnabledState.STATE_DISABLED);    
        }    
        m_interfaces.getLocalLBPoolMember().set_session_enabled_state(pool_list, statesAofA);    
        }

    Make sense?

    -Joe
  • I understand your pain. In 4.x, we had a flat API structure but it provide completely unusable for large configurations - modifying 100's of objects, required 100's of calls. In v9.x, we opted to make the syntax more expandable by enabling bulk objects for all our methods. This dramatically improved performance for multi-step operations with the consolation that it made the API a bit more complex for those that just want to do a single task.

     

     

    As for Jython, I have no experience with it so I wouldn't even no where to start with regards to array declarations. The code I gave you works with Java and Apache Axis 1.0. Anyone out there know how to create 2-d arrays in Jython?

     

     

    -Joe
  • Have you looked at the pyControl Python library for iControl? There might be something in there that points you in the right direction. Select pyControl from the Labs menu here on DevCentral for the project homepage.

     

     

    -Joe
  • Also, look in the iControl CodeShare wiki for pyControl samples that may help you with the array creation problems.

     

     

    http://devcentral.f5.com/Wiki/default.aspx/iControl/CodeShare.html

     

    Click here

     

     

     

    Look for the ones starting with "py*".

     

     

    -Joe