10-27-2014 06:39 PM - edited 03-01-2019 04:24 AM
HI, Experts
from the following 2 python line script,it can create ONE BD into the tenant,
BUT what i need is creating 3000 BDs,
So how can i setup a Python loop to dynamically replace the following colorful text
Thanks a lot!
/Ja
==========================
fvBD8 = cobra.model.fv.BD(fvTenant, ownerKey=u'', name=u'BD8', descr=u'', unkMacUcastAct=u'proxy', arpFlood=u'no', mac=u'00:22:BD:F8:19:FF', unicastRoute=u'yes', ownerTag=u'', unkMcastAct=u'flood')
fvRsABDPolMonPol8 = cobra.model.fv.RsABDPolMonPol(fvBD8, tnMonEPGPolName=u'default')
=========================
Solved! Go to Solution.
10-28-2014 07:10 AM
my_string = "fvBD{0} = cobra.model.fv.BD(fvTenant, ownerKey=u'', name=u'BD{0}', descr=u'', unkMacUcastAct=u'proxy', arpFlood=u'no', mac=u'00:22:BD:F8:19:FF', unicastRoute=u'yes', ownerTag=u'', unkMcastAct=u'flood') fvRsABDPolMonPol{0} = cobra.model.fv.RsABDPolMonPol(fvBD{0}, tnMonEPGPolName=u'default')".format (num)
print my_string
This will change each of the {0} in the string into whatever is in "num". The other key to the code is the .format (num) on the end of the string. I'm printing it out, but you probably will want to do something with it instead. You will get numbers from 1 - 3000 (range gives you one less than what you specify).
10-28-2014 07:10 AM
my_string = "fvBD{0} = cobra.model.fv.BD(fvTenant, ownerKey=u'', name=u'BD{0}', descr=u'', unkMacUcastAct=u'proxy', arpFlood=u'no', mac=u'00:22:BD:F8:19:FF', unicastRoute=u'yes', ownerTag=u'', unkMcastAct=u'flood') fvRsABDPolMonPol{0} = cobra.model.fv.RsABDPolMonPol(fvBD{0}, tnMonEPGPolName=u'default')".format (num)
print my_string
This will change each of the {0} in the string into whatever is in "num". The other key to the code is the .format (num) on the end of the string. I'm printing it out, but you probably will want to do something with it instead. You will get numbers from 1 - 3000 (range gives you one less than what you specify).
10-31-2014 07:56 PM
thanks tiphilli!!!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide