Forum Discussion
Nate_W_50838
Mar 31, 2010Historic F5 Account
Trying to create a region definition via pycontrol
I’m trying to write some pycontrol code to create a region on a 10.1.0 GTM, I can’t seem to get the create() statement correct. I’m trying to create a region entry like this:
region { ...
L4L7_53191
Nimbostratus
Apr 01, 2010Here's a working sample.
import pycontrol.pycontrol as pc
b = pc.BIGIP(hostname = '10.100.100.245', username='admin', password='admin', fromurl=True, wsdls=['GlobalLB.Region'])
reg = b.GlobalLB.Region
Create regions
regions = ['US/Alabama','US/Colorado','US/Nebraska','US/Nevada','US/Wyoming']
reg_list = []
Create region item type, append to reg_list
for x in range(1,6):
x = reg.typefactory.create('GlobalLB.Region.RegionItem')
x.type = 'REGION_TYPE_STATE'
x.negate = False
reg_list.append(x)
Bind the regions to the 'content' attribute
for index,region in enumerate(regions):
reg_list[index].content = region
create the sequence type
reg_seq = reg.typefactory.create('GlobalLB.Region.RegionItemSequence')
reg_seq.item = reg_list
create the region definition type
region_def = reg.typefactory.create('GlobalLB.Region.RegionDefinition')
region_def.name = 'myTestRegion-3'
region_def.db_type = 'REGION_TYPE_USER_DEFINED'
Create!
reg.create(regions = [region_def], items = [reg_seq])
-Matt
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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