From the following 2 python line scripts can create ONE BD into the tenant,
BUT what i need is creating 3000 BDs,
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')
Need to setup a Python loop to dynamically replace the following colorful text
Try--
for num in range (1,3001):
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. The O/P is printed out --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).
Comments
0 comments
Please sign in to leave a comment.