Forum Discussion

droyo_148031's avatar
droyo_148031
Icon for Nimbostratus rankNimbostratus
Jan 25, 2016

Adding metadata to an iControl object using pycontrol

I am trying to add custom metadata to a virtual address using pycontrol. None of my calls fail, but

get_metadata
always returns an empty list. Here is my program:

from pycontrol import pycontrol
bigip = pycontrol.BIGIP(
    hostname='my-lb.example.net',
    username='admin',
    password='******',
    fromurl=True,
    wsdls=['LocalLB.VirtualAddressV2'])

 Any virtual address shows the same behavior
vip = bigip.LocalLB.VirtualAddressV2.get_list()[0]

bigip.LocalLB.VirtualAddressV2.add_metadata([vip], [['owner']], [['daryll']])
meta = bigip.LocalLB.VirtualAddressV2.get_metadata([vip])
print "%r" % (meta,)

The output of the program is

[[]]
. I have tried using an administrator account with the same results. Any tips would be appreciated. My BigIP is at version 11.4 and I am using pycontrol 2.1.

  • I'm using bigsuds instead of pycontrol, but I was able to get the following to work on 11.3 and 11.5.3.

    import bigsuds
    
    b = bigsuds.BIGIP(hostname='1.2.3.4')
    vip = b.LocalLB.VirtualAddressV2.get_list()[0]
    
    b.LocalLB.VirtualAddressV2.add_metadata([vip], [['owner']], [['daryll']])
    vip_metadata = b.LocalLB.VirtualAddressV2.get_metadata([vip])
    
    for meta_data in vip_metadata:
        print b.LocalLB.VirtualAddressV2.get_metadata_value([vip],[[meta_data]])
    

    If you are at the CLI of the bigip and run 'tmsh save sys config', then you should see metadata attached to the vip. Something like this in /config/bipip.conf:

    ltm virtual-address /Common/192.168.1.41 {
        address 192.168.1.41
        mask 255.255.255.255
        metadata {
            owner {
                value daryll
            }
    }
    

    Perhaps there is an issue with pycontrol? I used only bigsuds. Please let me know how that works out for you.

    -Kelly

  • Kelly_Jones_500's avatar
    Kelly_Jones_500
    Historic F5 Account

    I'm using bigsuds instead of pycontrol, but I was able to get the following to work on 11.3 and 11.5.3.

    import bigsuds
    
    b = bigsuds.BIGIP(hostname='1.2.3.4')
    vip = b.LocalLB.VirtualAddressV2.get_list()[0]
    
    b.LocalLB.VirtualAddressV2.add_metadata([vip], [['owner']], [['daryll']])
    vip_metadata = b.LocalLB.VirtualAddressV2.get_metadata([vip])
    
    for meta_data in vip_metadata:
        print b.LocalLB.VirtualAddressV2.get_metadata_value([vip],[[meta_data]])
    

    If you are at the CLI of the bigip and run 'tmsh save sys config', then you should see metadata attached to the vip. Something like this in /config/bipip.conf:

    ltm virtual-address /Common/192.168.1.41 {
        address 192.168.1.41
        mask 255.255.255.255
        metadata {
            owner {
                value daryll
            }
    }
    

    Perhaps there is an issue with pycontrol? I used only bigsuds. Please let me know how that works out for you.

    -Kelly

    • droyo_148031's avatar
      droyo_148031
      Icon for Nimbostratus rankNimbostratus
      Thank you. This indeed worked when I switched to the bigsuds library. The API is similar enough that it is less work for me to port my code to bigsuds than diagnose the issue with pycontrol.