Forum Discussion
PyControl: creating an LTM virtual on a single VLAN
I'm working on automating LTM virtual creation, and I have basic functionality in place. I'd like to configure the created VIPs to permit traffic on a single VLAN, somewhat similar to this example:
virtual hosted_00002201_a_443 {
pool hosted_00002201_a_443
destination 67.231.144.111:https
ip protocol tcp
vlans Hosting <-- I can't figure out what directive(s) to use for this.
LB-External enable
}
Thank you kindly for any help.
Phil
Here's what I have:
!/usr/bin/env python
import pycontrol.pycontrol as pc
import sys
if len(sys.argv) < 4:
print "Usage: ilavirt [LTM hostname] [Virtual Name] [Pool Name] [Destination] [Vlan]"
print "Example:\nilavirt asdfasdf test123 testpool 69.69.69.69:6969 Hosting"
sys.exit(1)
ltm = sys.argv[1]
virtname = sys.argv[2]
poolname = sys.argv[3]
destination = sys.argv[4]
vlan = sys.argv[5]
print "LTM:", sys.argv[1]
print "Virtual name:", sys.argv[2]
print "Pool name:", sys.argv[3]
print "Destination:", sys.argv[4]
print "Vlan:", sys.argv[5]
b = pc.BIGIP(hostname = ltm,
username = "admin",
password = "whargarbl",
fromurl = True,
wsdls = ['LocalLB.VirtualServer'])
v = b.LocalLB.VirtualServer
vs_def = v.typefactory.create('Common.VirtualServerDefinition')
vs_def.name = virtname
ip,port = destination.split(':')
vs_def.address = ip
vs_def.port = port
proto = v.typefactory.create('Common.ProtocolType')
vs_def.protocol = proto.PROTOCOL_TCP
vs_def_seq = v.typefactory.create('Common.VirtualServerSequence')
vs_def_seq.item = [vs_def]
vs_type = v.typefactory.create('LocalLB.VirtualServer.VirtualServerType')
resource = v.typefactory.create('LocalLB.VirtualServer.VirtualServerResource')
resource.type = vs_type.RESOURCE_TYPE_POOL
resource.default_pool_name = poolname
resource_seq = v.typefactory.create('LocalLB.VirtualServer.VirtualServerResourceSequence')
resource_seq.item = [resource]
v.create(definitions = vs_def_seq, wildmasks = ['255.255.255.255'], resources = resource_seq, profiles = [''])
sys.exit(0)
- L4L7_53191NimbostratusUnfortunately I think you may have to run a set_vlan() against your new virtual server after you've created it. There are some objects that require this I think. Assigning a SNAT is another example. Someone please correct me if I am wrong.
Recent Discussions
Related Content
* 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