Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

F5-SDK

Mathew
Cirrus
Cirrus
def createmonitor(Node_Val😞
     pool_monitor = Node_Val[5]
     monitor= mgmt.tm.ltm.monitor
     monitor.create (partition='Common',name = pool_monitor + "_https_monitor",)
 
I am trying to create a monitor using F5 SDK and its getting error
 
raise InvalidResource(error_message)
f5.sdk_exception.InvalidResource: Only Resources support 'create'.
 
Can anyone share the link to understand the issue or please help to understand this.
1 ACCEPTED SOLUTION

JRahm
Community Manager
Community Manager

Hi @Mathew, if wanting to stick with one-off simple imperative scripts...I'd use the bigrest library over the f5-sdk, which is no longer under development or community support. But to answer the question for others, assuming this is for an https monitor, it would look something like this:

    resource = mgmt_root.tm.ltm.monitor.https_s.https.create(
        name=temp_name, partition='Common')

where mgmt_root is whatever you instantiated your session variable as.

If you wanted to do this in bigrest, it'd be similar to what you posted:

from bigrest.bigip import BIGIP
br = BIGIP('ltm3.test.local', 'admin', 'admin', session_verify=False)

data = {'name': 'monitor_object', ...additional required/optional key/value pairs}
resource = br.create('/mgmt/tm/ltm/monitor/https', data)

I just moved and don't have my lab up yet, so this is untested on both counts, but should be very close to what you want. Ping back if you need additional assistance.

If you do want to do a more mature/robust approach, what @Nikoolayy1 is suggesting is a great path forward.

View solution in original post

4 REPLIES 4

JRahm
Community Manager
Community Manager

Hi @Mathew, if wanting to stick with one-off simple imperative scripts...I'd use the bigrest library over the f5-sdk, which is no longer under development or community support. But to answer the question for others, assuming this is for an https monitor, it would look something like this:

    resource = mgmt_root.tm.ltm.monitor.https_s.https.create(
        name=temp_name, partition='Common')

where mgmt_root is whatever you instantiated your session variable as.

If you wanted to do this in bigrest, it'd be similar to what you posted:

from bigrest.bigip import BIGIP
br = BIGIP('ltm3.test.local', 'admin', 'admin', session_verify=False)

data = {'name': 'monitor_object', ...additional required/optional key/value pairs}
resource = br.create('/mgmt/tm/ltm/monitor/https', data)

I just moved and don't have my lab up yet, so this is untested on both counts, but should be very close to what you want. Ping back if you need additional assistance.

If you do want to do a more mature/robust approach, what @Nikoolayy1 is suggesting is a great path forward.

Mathew
Cirrus
Cirrus

Thanks Jason 

In the future you can review AS3 as to create a full configuration with one REST API request https://community.f5.com/t5/codeshare/code-comparison-between-deploying-as3-or-fast-api-declarations...