Forum Discussion
Arden_109503
Sep 27, 2011Nimbostratus
Creating a Monitor
Hi, Loving pycontrol, got it to create vips, pools and nodes but having trouble creating a HTTP monitor. Does anyone have an example of a HTTP monitor? I'm trying to create a m...
L4L7_53191
Sep 28, 2011Nimbostratus
Arden: Here's a working example. Lots and lots of objects to set up, then some attributes to set.
Start setting up your types. We'll do the monitor template first.
tmplt = m.typefactory.create('LocalLB.Monitor.MonitorTemplate')
tmplt.template_name = 'matt_test'
Create the template_type
tmplt_type = m.typefactory.create('LocalLB.Monitor.TemplateType')
tmplt.template_type = tmplt_type.TTYPE_HTTP
Ditto Attrs, and the IPPort stuff that goes inside.
tmplt_attrs = m.typefactory.create('LocalLB.Monitor.CommonAttributes')
dest_ipport = m.typefactory.create('LocalLB.MonitorIPPort')
Create the address type structure for the dest_ipport object.
addr_type = m.typefactory.create('LocalLB.AddressType')
tmplt_attrs.dest_ipport.address_type.value = addr_type.ATYPE_STAR_ADDRESS
tmplt_attrs.dest_ipport.address_type.value = addr_type.ATYPE_STAR_ADDRESS_STAR_PORT
ipport = m.typefactory.create('Common.IPPortDefinition')
ipport.address='172.16.200.131'
ipport.port=80
Now start setting attributes.
tmplt_attrs.parent_template='http'
tmplt_attrs.interval=5
tmplt_attrs.timeout=16
tmplt_attrs.is_directly_usable=True
tmplt_attrs.is_read_only=False
tmplt_attrs.dest_ipport.ipport = ipport
Whew! Now create :)
m.create_template(templates=[tmplt],template_attributes=[tmplt_attrs])
When you're done with your code, this would be a good code share sample 🙂
--Matt Cauthorn
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects