Forum Discussion

rahvee's avatar
rahvee
Icon for Cirrus rankCirrus
Oct 14, 2022

How to use partitions with BIGREST

Hi, I'm using BIGREST, and I'm able to create a BIGIP object,

f5 = BIGIP(hostname, username, password...)

I'm able to get a list of partitions:

 

 

def f5_get_partitions(f5_session: BIGIP) -> List[str]:
    result = f5_session.load("/mgmt/tm/sys/folder")  # type: List[RESTObject]
    partitions: List[str] = []
    for r in result:
        if len(r.properties['fullPath']) < 2:
            # The '/' path should be ignored
            continue
        if r.properties['fullPath'].count('/') > 1:
            # Skip things like /Common/foo and /Common/bar
            continue
        partitions.append(r.properties['name'])
    return partitions

 

 

But I haven't figured out how to load something from a partition other than 'Common'. I tried this. It doesn't work:

for partition in partitions:
f5.load("/mgmt/tm/sys/crypto/cert", partition=partition) 

 The error I get is:

 

 

TypeError: load() got an unexpected keyword argument 'partition'

 

 

How do you load from a partition?

    • rahvee's avatar
      rahvee
      Icon for Cirrus rankCirrus

      It seems, by default, I actually am getting all results, so I don't need to use the `options=recursive` setting. In fact, when I try `options=recursive` I get no results. But applying the filter as shown `?\$filter=partition+eq+<partition name>` works, so that's helpful. Thanks

    • rahvee's avatar
      rahvee
      Icon for Cirrus rankCirrus

      Yes, I noticed the partition name is embedded in the response, but it's only returning results from Common. Not from any other partition. I'll try Dario's answer and see if that helps...

      • rahvee's avatar
        rahvee
        Icon for Cirrus rankCirrus

        My mistake. By default, all results *are* returned, and I only need to examine the `fullPath` property, as you said.