Forum Discussion

Bin_Qiu_195313's avatar
Bin_Qiu_195313
Icon for Nimbostratus rankNimbostratus
Apr 23, 2015

How to use REST to create a Virtual Server with profile

I want to use REST to create a virtual server with profile. Below code is not work. The virtual server got created, but profiles are not set right

 

def create_http_virtual(bigip, name, address, port, pool):
36      payload = {}
37   
38       define test virtual
39      payload['kind'] = 'tm:ltm:virtual:virtualstate'
40      payload['name'] = name
41      payload['description'] = 'A Python REST client test virtual server'
42      payload['destination'] = '%s:%s' % (address, port)
43      payload['mask'] = '255.255.255.255'
44      payload['ipProtocol'] = 'tcp'
45      payload['sourceAddressTranslation'] = { 'type' : 'automap' }
46      payload['profiles'] = [
47          { 'kind' : 'ltm:virtual:profile', 'name' : 'http' },
48          { 'kind' : 'ltm:virtual:profile', 'name' : 'tcp' }
49      ]
50      payload['pool'] = pool
51   
52      bigip.post('%s/ltm/virtual' % BIGIP_URL_BASE, data=json.dumps(payload))
53