Forum Discussion

rob_carr's avatar
rob_carr
Icon for Cirrostratus rankCirrostratus
Apr 22, 2008

Trying to add a vlan to my config.

 

I'm trying to programmatically add a vlan to my running config. Of course, the create function in iControl::Networking::VLAN returns nothing (literally - the wiki for the api says 'null').

 

 

I'm not getting any SOAP errors when I execute the function, so how does one tell if the function has truly worked, and failing that, why it did not?

4 Replies

  • Which langauge are you using? The reason that I ask is that the dynamic languages like perl and python can get you into trouble if you are not packaging the arrays properly. If you pass a scalar when an array is expected, the server side will interpret that as a zero sized array and thus return with no error. If you could provide more details and possibly some sample code, I may be able to help diagnose things further.

     

     

    If you do want to verify a method succeeded such as the VLAN.create() call, you can always call the get_list() method after the fact and look for the entry you created.

     

     

    Again, if you pass along more details we'll see what we can do to get your VLANs created.

     

     

    -Joe
  • I'm trying to create and delete vlans using python, via the SOAPpy module. My code fragment is below:

     

     

    def create_vlan(url):

     

    db_proxy = SOAPpy.SOAPProxy(url,ICONTROL_VLAN_NAMESPACE)

     

    results = db_proxy.create(vlans='failsave_vlan',

     

    vlan_ids='3001',

     

    members=[[{'member_name':'1.3',

     

    'member_type':'1',

     

    'tag_state':'1'}]],

     

    failsafe_states='0',

     

    timeouts='30',

     

    mac_masquerade_addresses='')

     

     

    I know that my url is constructed properly, as I have other segments of code where I query for interface status, vlan membership, etc.
  • Ahhh, it's just as I suspected. The method signature for VLAN::create is

     

     

    Networking.VLAN.create(
        in String [] vlans,
        in long [] vlan_ids,
        in Networking.VLAN.MemberEntry [] [] members,
        in EnabledState [] failsafe_states,
        in long [] timeouts,
        in String [] mac_masquerade_addresses
    );

     

     

    You are passing in scalars for most of the arguments. All of the parameters are expected to be arrays except for the members parameter which is a 2-d array (first dimension for the VLAN, 2nd dimension for the members of that VLAN.

     

     

    The server code is converting the SOAP message and since there are no arrays, it is treating it as an array size 0 which is a no-op. You'll need to modify your code to pass in the correct arrays for this to work. I'd provide some suggestions, but I'm a definite noob at python.

     

     

    Good luck!

     

     

    -Joe
  • Got it working now:

     

     

    def create_vlan(url):

     

    db_proxy = SOAPpy.SOAPProxy(url,ICONTROL_VLAN_NAMESPACE)

     

    results = db_proxy.create(vlans=['failsave_vlan'],

     

    vlan_ids=['3001'],

     

    members=[[{'member_name':'1.3',

     

    'member_type':'MEMBER_INTERFACE',

     

    'tag_state':'MEMBER_UNTAGGED'}]],

     

    failsafe_states=['0'],

     

    timeouts=['30'],

     

    mac_masquerade_addresses=[''])

     

     

     

    Beyond the question of arrays vs. scalar values, I also had to change the member_type and tag_state to their string values rather than the enumerated values listed in the documentation.

     

     

    Thanks for your help.