<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API Script in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/api-script/m-p/3488843#M222</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Juraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is at 'EncapBlk(vlanPhysDomPMo, "vlan-3000", "vlan-3000", name="PhysVlanPoolCCIE")', where you&amp;nbsp; can give your vlan range, the second and third parameters are nothing but 'start-vlan' and 'end-vlan'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Thumu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 22 Jul 2017 14:51:02 GMT</pubDate>
    <dc:creator>sandeepthumu</dc:creator>
    <dc:date>2017-07-22T14:51:02Z</dc:date>
    <item>
      <title>API Script</title>
      <link>https://community.cisco.com/t5/controllers/api-script/m-p/3488841#M220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this script and I have the issue to understand where I can change myvlanrange.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# createNewStudent-* tenants&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fromcobra.mit.access import MoDirectory&lt;/P&gt;&lt;P&gt;fromcobra.mit.session import LoginSession&lt;/P&gt;&lt;P&gt;fromcobra.mit.request importConfigRequest&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fromcobra.model.fvnsimport VlanInstP, EncapBlk&lt;/P&gt;&lt;P&gt;fromcobra.model.infra import RsVlanNs, RsDomP, AttEntityP&lt;/P&gt;&lt;P&gt;from cobra.model.fv import Tenant, Ctx, BD, RsCtx, Ap, AEPg, RsBd, RsDomAtt, RsPathAtt&lt;/P&gt;&lt;P&gt;fromcobra.model.vmmimport DomP, UsrAccP, CtrlrP, RsAcc&lt;/P&gt;&lt;P&gt;fromcobra.model.physimportDomP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;importjson&lt;/P&gt;&lt;P&gt;importrequests&lt;/P&gt;&lt;P&gt;fromrequests.packages.urllib3.exceptions import InsecureRequestWarning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;requests.packages.urllib3.disable_warnings(InsecureRequestWarning)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data= []&lt;/P&gt;&lt;P&gt;withopen('StudentTenants.json') as f:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; forline in f:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data.append(json.loads(line))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;physDomainObj= data[0]&lt;/P&gt;&lt;P&gt;print"Physical Domains"&lt;/P&gt;&lt;P&gt;printdata[0]&lt;/P&gt;&lt;P&gt;print"\nTenants:\n"&lt;/P&gt;&lt;P&gt;printdata[1:]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tenants= data[1:]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;physDomainInst= data[0]['physDomainInst']&lt;/P&gt;&lt;P&gt;printphysDomainInst&lt;/P&gt;&lt;P&gt;printphysDomainInst['name']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;printtenants&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;user= 'admin'&lt;/P&gt;&lt;P&gt;password= 'F4l4b3ll42017'&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;apicUrl= '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://172.16.18.21:443" rel="nofollow" target="_blank"&gt;https://172.16.18.21:443&lt;/A&gt;&lt;SPAN&gt;' &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;moDir= MoDirectory(LoginSession(apicUrl, user, password))&lt;/P&gt;&lt;P&gt;moDir.login()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Get the top level Policy Universe Directory&lt;/P&gt;&lt;P&gt;uniMo=moDir.lookupByDn('uni')&lt;/P&gt;&lt;P&gt;uniInfraMo=moDir.lookupByDn('uni/infra')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Domain for All Student Tenants&lt;/P&gt;&lt;P&gt;# fromjsonfile and use it to create our Physical Domain&lt;/P&gt;&lt;P&gt;#physDomainInst['name'] =&amp;gt; Physical Domain name&lt;/P&gt;&lt;P&gt;#physDomainObj['physDomainInst']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;physDomPMo=DomP(uniMo,physDomainInst['name'])&lt;/P&gt;&lt;P&gt;domcfg=ConfigRequest()&lt;/P&gt;&lt;P&gt;domcfg.addMo(physDomPMo)&lt;/P&gt;&lt;P&gt;moDir.commit(domcfg)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# VLAN Pool for All Student Tenants&lt;/P&gt;&lt;P&gt;# VLAN Pool name to beexact sameas Physical Domain&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vlanPhysDomPMo= VlanInstP(uniInfraMo,physDomainInst['name'], 'static')&lt;/P&gt;&lt;P&gt;EncapBlk(vlanPhysDomPMo, "vlan-3000", "vlan-3000", name="PhysVlanPoolCCIE")&lt;/P&gt;&lt;P&gt;physCfg=ConfigRequest()&lt;/P&gt;&lt;P&gt;physCfg.addMo(vlanPhysDomPMo)&lt;/P&gt;&lt;P&gt;moDir.commit(physCfg)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#relationship to Physical Domain&lt;/P&gt;&lt;P&gt;RsVlanNs(physDomPMo,tDn=vlanPhysDomPMo.dn)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;domCfg=ConfigRequest()&lt;/P&gt;&lt;P&gt;domCfg.addMo(physDomPMo)&lt;/P&gt;&lt;P&gt;moDir.commit(domCfg)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Physical Domain Relationship to Attached Entity Profile&lt;/P&gt;&lt;P&gt;AttEntityPmo= AttEntityP(uniInfraMo, "ATTENTITYP")&lt;/P&gt;&lt;P&gt;infra_rsdomp = RsDomP(AttEntityPmo,physDomPMo.dn)&lt;/P&gt;&lt;P&gt;attCfg=ConfigRequest()&lt;/P&gt;&lt;P&gt;attCfg.addMo(AttEntityPmo)&lt;/P&gt;&lt;P&gt;moDir.commit(attCfg)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# #Creation of Tenants and VLAN Ranges&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print"Printing full tenant JSON, for debug"&lt;/P&gt;&lt;P&gt;fortenant in tenants:&lt;/P&gt;&lt;P&gt; print"Tenant name: " + tenant['name']&lt;/P&gt;&lt;P&gt; print"BD name: " + tenant['bd']&lt;/P&gt;&lt;P&gt; print"PVN name: " + tenant['ctx']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; vlanRangeArgs= tenant['vlanRangeArgs']&lt;/P&gt;&lt;P&gt; print"VLAN Range name: " +vlanRangeArgs['name'] + ", from: " +vlanRangeArgs['from'] + ",to: " +vlanRangeArgs['to']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; app= tenant['aps']&lt;/P&gt;&lt;P&gt; print"App Name: " + app['name']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; forepgin app['epgs']:&lt;/P&gt;&lt;P&gt; printepg['name']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print"\nStarting tenant configuration...\n"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fortenant in tenants:&lt;/P&gt;&lt;P&gt;&amp;nbsp; # VLAN range for Student ---&amp;gt;vlanRange['name'])&lt;/P&gt;&lt;P&gt; print"==================== Creating Tenant: " + tenant['name'] + " ===================="&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; vlanRangeArgs= tenant['vlanRangeArgs']&lt;/P&gt;&lt;P&gt; print"Creating VLAN range: " +vlanRangeArgs['name']&lt;/P&gt;&lt;P&gt; fvnsVlanInstPMo= VlanInstP(uniInfraMo,vlanRangeArgs['name'], 'dynamic')&lt;/P&gt;&lt;P&gt;&amp;nbsp; EncapBlk(fvnsVlanInstPMo, vlanRangeArgs['from'], vlanRangeArgs['to'], name=vlanRangeArgs['name'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # commit VLAN Range to APIC&lt;/P&gt;&lt;P&gt; nsCfg=ConfigRequest()&lt;/P&gt;&lt;P&gt; nsCfg.addMo(fvnsVlanInstPMo)&lt;/P&gt;&lt;P&gt;&amp;nbsp; moDir.commit(nsCfg)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; fvTenantMo= Tenant(uniMo, tenant['name'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Create Private Network under Tenant&lt;/P&gt;&lt;P&gt; print"Creating Private Network: " + tenant['ctx']&lt;/P&gt;&lt;P&gt; Ctx(fvTenantMo, tenant['ctx'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Create Bridge Domain under Tenant&lt;/P&gt;&lt;P&gt; print"Creating Bridge Domain: " + tenant['bd']&lt;/P&gt;&lt;P&gt; fvBDMo= BD(fvTenantMo, name=tenant['bd'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Create association to private network under Tenant&lt;/P&gt;&lt;P&gt; print"Creating VRF to BD association"&lt;/P&gt;&lt;P&gt; fvRsCtx= RsCtx(fvBDMo,tnFvCtxName=tenant['ctx'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; app= tenant['aps']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # creatingApplication Profile---&amp;gt; app['name']&lt;/P&gt;&lt;P&gt; print"Creating Application profile: " + app['name']&lt;/P&gt;&lt;P&gt; fvApMo=Ap(fvTenantMo, app['name'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # for all EPGS from JSON and create each EPG under Application&lt;/P&gt;&lt;P&gt; print"Creating EPGs: "&lt;/P&gt;&lt;P&gt; forepgin app['epgs']:&lt;/P&gt;&lt;P&gt; print"EPG: " +epg['name']&lt;/P&gt;&lt;P&gt; fvAEPgMo= AEPg(fvApMo,epg['name'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Associate EPG to Bridge Domain&lt;/P&gt;&lt;P&gt; RsBd(fvAEPgMo,tnFvBDName=tenant['bd'])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Associate EPG to Phys Domain&lt;/P&gt;&lt;P&gt; RsDomAtt(fvAEPgMo,physDomPMo.dn)&lt;/P&gt;&lt;P&gt; encap=epg['encap']&lt;/P&gt;&lt;P&gt; print"Associating EPG to VLAN: " +str(encap) &lt;/P&gt;&lt;P&gt;&amp;nbsp; RsPathAtt(fvAEPgMo, tDn="topology/pod-1/", encap=('vlan-' + str(encap)))&lt;/P&gt;&lt;P&gt; RsPathAtt(fvAEPgMo,tDn="topology/pod-1/paths-102",encap=('vlan'))&lt;/P&gt;&lt;P&gt; RsPathAtt(fvAEPgMo,tDn="topology/pod-1/paths-103",encap=('vlan'))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Commit changes to the Configuration&lt;/P&gt;&lt;P&gt; tenantCfg=ConfigRequest()&lt;/P&gt;&lt;P&gt; tenantCfg.addMo(fvTenantMo)&lt;/P&gt;&lt;P&gt;&amp;nbsp; moDir.commit(tenantCfg)&lt;/P&gt;&lt;P&gt; print"\n"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Associate EPG to Static Path to node-103 and node-102&lt;/P&gt;&lt;P&gt;&amp;nbsp; # ch encap VLAN numbers from epg dictionary key encap, like this epg['encap]&lt;/P&gt;&lt;P&gt;&amp;nbsp; # mat EPG VLAN encap number by concatenating string "vlan-" and value of ep&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # ['encap'] =&amp;gt; VLAN encap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # fvRsPathAtt(fvAEPgMo, tDn=epg['path'], encap=('vlan-' + str(epg)))&lt;/P&gt;&lt;P&gt;&amp;nbsp; # fvRsPathAtt(fvAEPgMo,tDn=epg['path'].replace('paths-103','paths-102'),encap=('vlan'))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jun 2017 01:19:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/api-script/m-p/3488841#M220</guid>
      <dc:creator>Juraj Papic</dc:creator>
      <dc:date>2017-06-14T01:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: API Script</title>
      <link>https://community.cisco.com/t5/controllers/api-script/m-p/3488842#M221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what about the json file? you can change the vlan value within the json file.&lt;/P&gt;&lt;P&gt;You can send the json file to me, I will fix your problem.&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-email-small" href="mailto:simon_hu1983@hotmail.com"&gt;simon_hu1983@hotmail.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 10:26:58 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/api-script/m-p/3488842#M221</guid>
      <dc:creator>odysseus_hu163</dc:creator>
      <dc:date>2017-07-13T10:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: API Script</title>
      <link>https://community.cisco.com/t5/controllers/api-script/m-p/3488843#M222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Juraj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is at 'EncapBlk(vlanPhysDomPMo, "vlan-3000", "vlan-3000", name="PhysVlanPoolCCIE")', where you&amp;nbsp; can give your vlan range, the second and third parameters are nothing but 'start-vlan' and 'end-vlan'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Thumu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Jul 2017 14:51:02 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/api-script/m-p/3488843#M222</guid>
      <dc:creator>sandeepthumu</dc:creator>
      <dc:date>2017-07-22T14:51:02Z</dc:date>
    </item>
  </channel>
</rss>

