{"id":380,"date":"2019-05-24T17:32:17","date_gmt":"2019-05-24T16:32:17","guid":{"rendered":"https:\/\/zed-network.fr\/?p=380"},"modified":"2020-08-24T19:24:34","modified_gmt":"2020-08-24T18:24:34","slug":"cisco-aci-arya","status":"publish","type":"post","link":"https:\/\/zed-network.fr\/?p=380","title":{"rendered":"Convert your code easily with APIC Rest Python Adapter (arya)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Arya is a tool to translate an XML or JSON to Python. Arya will convert your input and use the Cisco sdk COBRA.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"164\" src=\"https:\/\/zed-network.fr\/wp-content\/uploads\/Newtenant-xml.png\" alt=\"\" class=\"wp-image-386\" srcset=\"https:\/\/zed-network.fr\/wp-content\/uploads\/Newtenant-xml.png 784w, https:\/\/zed-network.fr\/wp-content\/uploads\/Newtenant-xml-300x63.png 300w, https:\/\/zed-network.fr\/wp-content\/uploads\/Newtenant-xml-768x161.png 768w, https:\/\/zed-network.fr\/wp-content\/uploads\/Newtenant-xml-500x105.png 500w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Generate the code with arya :<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">arya -f tenant.xml\n !\/usr\/bin\/env python\n '''\n Autogenerated code using arya\n Original Object Document Input:\n \n \n '''\n raise RuntimeError('Please review the auto generated code before ' +\n                     'executing the output. Some placeholders will ' +\n                     'need to be changed')\n list of packages that should be imported for this code to work\n import cobra.mit.access\n import cobra.mit.naming\n import cobra.mit.request\n import cobra.mit.session\n import cobra.model.fv\n import cobra.model.vns\n from cobra.internal.codec.xmlcodec import toXMLStr\n log into an APIC and create a directory object\n ls = cobra.mit.session.LoginSession('https:\/\/1.1.1.1', 'admin', 'password')\n md = cobra.mit.access.MoDirectory(ls)\n md.login()\n the top level object on which operations will be made\n Confirm the dn below is for your top dn\n topDn = cobra.mit.naming.Dn.fromString('uni\/tn-aaaaaaaa-tn')\n topParentDn = topDn.getParent()\n topMo = md.lookupByDn(topParentDn)\n build the request using cobra syntax\n fvTenant = cobra.model.fv.Tenant(topMo, ownerKey='', name='aaaaaaaa-tn', descr='', nameAlias='', ownerTag='')\n vnsSvcCont = cobra.model.vns.SvcCont(fvTenant)\n fvRsTenantMonPol = cobra.model.fv.RsTenantMonPol(fvTenant, tnMonEPGPolName='')\n commit the generated code to APIC\n print toXMLStr(topMo)\n c = cobra.mit.request.ConfigRequest()\n c.addMo(topMo)\n md.commit(c)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Arya is a tool to translate an XML or JSON to Python. Arya will convert your input and use the Cisco sdk COBRA. Generate the code with arya : arya -f tenant.xml !\/usr\/bin\/env python &#8221;&#8217; Autogenerated code using arya Original Object Document Input: &#8221;&#8217; raise RuntimeError(&#8216;Please review the auto generated code before &#8216; + &#8216;executing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"footnotes":""},"categories":[24,30,27,4],"tags":[],"class_list":["post-380","post","type-post","status-publish","format-standard","hentry","category-aci","category-aci-automation","category-automation","category-cisco"],"_links":{"self":[{"href":"https:\/\/zed-network.fr\/index.php?rest_route=\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zed-network.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zed-network.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zed-network.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zed-network.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=380"}],"version-history":[{"count":7,"href":"https:\/\/zed-network.fr\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":546,"href":"https:\/\/zed-network.fr\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions\/546"}],"wp:attachment":[{"href":"https:\/\/zed-network.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zed-network.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zed-network.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}