Forum Discussion

mhite_60883's avatar
mhite_60883
Icon for Cirrocumulus rankCirrocumulus
Mar 24, 2011

set_address_class_member_data_value method help

Hello! I'm having no luck getting the set_address_class_member_data_value method to work.

 

 

In short, I'm issuing the following API command using pycontrol:

 

 

c.set_address_class_member_data_value([dealloc_address_class], [["pending"]])

 

 

where c is a BIG-IP class object.

 

 

dealloc_address_class contains:

 

 

(LocalLB.Class.AddressClass){

 

name = "dev_staging_allocation"

 

members[] =

 

(LocalLB.Class.AddressEntry){

 

address = "5.5.5.7"

 

netmask = "255.255.255.255"

 

},

 

}

 

 

"dev_staging_allocation" is a class/data-group on the BIG-IP that contains a list of "unallocated" IP addresses.

 

I am trying to update the associated value -- which is currently the string "unallocated" -- and want to change it to "pending." The API call succeeds with no error but the value is not updated on the BIG-IP. I see the following in the icontrol debug logs:

 

 

Mar 23 16:08:06 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB:-------------------------------------

 

Mar 23 16:08:06 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: Portal:User/Partition map:

 

Mar 23 16:08:06 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: Portal: User: admin, Partition: Common

 

Mar 23 16:08:07 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB:+++++++++++++++++++++++++++++++++++++

 

Mar 23 16:08:07 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB:Class::set_address_class_member_data_value ( ) called by user "admin"

 

Mar 23 16:08:07 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB: Class name: dev_staging_allocation

 

Mar 23 16:08:07 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB: Value class members:

 

Mar 23 16:08:07 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB: [0] 5.5.5.7/255.255.255.255 -> p[<)(0[?[HdHdhV`:`:[ar 23 16:08:07 local/s0-bigip-lb2 debug iControlPortal.cgi[16402]: LocalLB:---------------------------------

 

 

The garbage characters in the last log line are obviously concerning. Any idea what's going on?

 

6 Replies

  • I think so. Let me look at this and get back to you (on list). I want to get a working sample going that is clear - these can be tricky.

     

    -Matt
  • Thanks for checking it out, Matt. You are a scholar and a gentleman!

     

     

    -M

     

  • Ok. First off, let me give you a heads up in advance: this one is odd, and it's definitely one of the outliers I've seen in the API. So typically we do a SequenceSequence object like this to represent the items:

    seq_seq.items = ['you_stuff_here']

    So far so good. But in this case, the actual XML that the call requires looks different. In other words, it seems (to me, at least) like there's an inconsistency in the API. For data group values (in the classes WSDL), you need to actually do this to get suds to setup the correct XML to work:

    Setup a sequence via the type factory, then:

    seq.values = ['YOUR_NEW_VALUE']

    Now set your seq_seq up like this:

    seq_seq.items = [values]

    And make the call like this!

    c.set_address_class_member_data_value(class_members = [cl_member],values= [seq_seq])

    See that last structure, the [seq_seq] part? That's the departure from the norm, as is the 'values' attribute we have to set against the inner sequence object. Anyhow, here's a working sample, I hope it helps.

    
    c = b.LocalLB.Class
    
     Setup our types.
    add_entry = c.typefactory.create('LocalLB.Class.AddressEntry')
    cl_member = c.typefactory.create('LocalLB.Class.AddressClass')
    seq = c.typefactory.create('Common.StringSequence')
    seq_seq = c.typefactory.create('Common.StringSequenceSequence')
    
     Set our attributes.
    
    add_entry.address='192.168.1.100'
    add_entry.netmask='255.255.255.255'
    cl_member.name = 'dc-post'
    cl_member.members = [add_entry]
    
     Ok, now for the wierd part.
    seq.values = ['MY_NEW_VALUE']
    seq_seq.items = [seq.values]
    
    orig_val = c.get_address_class_member_data_value(class_members = [cl_member])
    print "Here is the original value: ", orig_val
    
    print "Setting new value..."
    c.set_address_class_member_data_value(class_members = [cl_member],values= [seq_seq])
    
    new_val = c.get_address_class_member_data_value(class_members = [cl_member])
    print "Getting new value...", new_val
    

    Let me know if this works for you.

    -Matt

    P.S.: thanks to one of our customers, D. Whitt for some absolutely excellent analysis of this.

    P.S.S: this should also work for string data groups as well.

  • It works! You made my day -- thanks. I'd gladly buy you and our D. Whitt friend a beer or two for your time and help!

     

     

    -M
  • Sweet! Come out to the customer summit in Chicago this year and I'll take you up on the offer :)

     

    -Matt