Forum Discussion

dfo's avatar
dfo
Icon for Nimbostratus rankNimbostratus
Jun 06, 2018

Python SDK: How to assign an interface to a VLAN on BIG-IP ?

I'm trying to attached an interface to a VLAN using the Python SDK but I get the following error => "Instance contains a string". Here is my code:

 

vlan = mgmt.tm.net.vlans.vlan.load(name='TEST_4001_TEST_DFO')
if not vlan.interfaces_s.interfaces.exists(name='1.2'):    
    interface = vlan.interfaces_s.interfaces.create(name='1.2', tagMode='none', tagged='True')

3 Replies

  • dfo's avatar
    dfo
    Icon for Nimbostratus rankNimbostratus

    I get the same result without

    tagmode='none'

  • Ah...you are supplying the boolean as a string for the tagged state. Remove your quotes and it'll work fine:

    v10 = b.tm.net.vlans.vlan.load(name='v10')
    v10.interfaces_s.get_collection()
    []
    v10.interfaces_s.interfaces.exists(name='1.3')
    False
    if not v10.interfaces_s.interfaces.exists(name='1.3'):
        v10int = v10.interfaces_s.interfaces.create(name='1.3', untagged=True)
    v10.interfaces_s.interfaces.exists(name='1.3')
    True