def get_full_aci_config(apic, user, password, outfile): try: url = "https://" + apic ls = cobra.mit.session.LoginSession(url, "apic:ACS\\" + user, password, secure=False, timeout=30) md = cobra.mit.access.MoDirectory(ls) md.login() #Get tenant config cq = ClassQuery('fvTenant') cq.subtree = 'full' cq.propInclude= 'config-only' tenant_config = md.query(cq) #Infra config dq = DnQuery('uni/infra') dq.subtree = 'full' dq.propInclude = 'config-only' infra_config = md.query(dq) #Fabric config dq = DnQuery('uni/fabric') dq.subtree = 'full' dq.propInclude = 'config-only' fabric_config = md.query(dq) file = open(outfile, 'w+') file.write("# " + apic + " #") file.write("\n###########" + '\n') file.write("# TENANTS ") file.write("\n###########" + '\n') for tenant in tenant_config: file.write(toJSONStr(tenant, prettyPrint=True)) file.write("\n###########" + '\n') file.write("# Infra ") file.write("\n###########" + '\n') for infra in infra_config: file.write(toJSONStr(infra, prettyPrint=True)) file.write("\n###########" + '\n') file.write("# Fabric ") file.write("\n###########" + '\n') for fabric in fabric_config: file.write(toJSONStr(fabric, prettyPrint=True)) file.close() except: print "Error in get_full_aci_config() for %s: %s" % (apic, sys.exc_info()[0])
def create_tenant(logon_session, tenant_name="Example_TN", description="Description"): from cobra.internal.codec.jsoncodec import toJSONStr from cobra.model.fv import Tenant, RsTenantMonPol from cobra.mit.request import ConfigRequest import cobra.model.pol import cobra.model.vns c = ConfigRequest() #apic_logon(apic_url, user, password) polUni = cobra.model.pol.Uni('') fvTenant = Tenant(polUni, ownerKey=u'', name=tenant_name, descr=description, nameAlias=tenant_name, ownerTag=u'', annotation=u'') vnsSvcCont = cobra.model.vns.SvcCont(fvTenant, annotation=u'') fvRsTenantMonPol = RsTenantMonPol(fvTenant, annotation=u'', tnMonEPGPolName=u'') tenant_data = toJSONStr(polUni) c.addMo(polUni) logon_session.commit(c) return tenant_data
def create_apn(logon_session, tenant_name="Example_TN", description="Description", ap_name=''): from cobra.internal.codec.jsoncodec import toJSONStr from cobra.model.fv import Tenant, RsTenantMonPol, Ap from cobra.mit.request import ConfigRequest import cobra.model.pol import cobra.model.vns c = ConfigRequest() #apic_logon(apic_url, user, password) polUni = cobra.model.pol.Uni('') fvTenant = Tenant(polUni, tenant_name) # build the request using cobra syntax fvAp = Ap(fvTenant, ownerKey=u'', name=ap_name, descr=description, nameAlias=u'', ownerTag=u'', prio=u'unspecified', annotation=u'') apn_data = toJSONStr(polUni) c.addMo(polUni) logon_session.commit(c) return apn_data
def create_bridge_domains(delete=''): bd_df = pd.read_excel("input-data/ACI_DD_Workbook.xlsx", sheet_name='Bridge_Domains') file = open("BD_Configuration.log", "w") logon = apic_logon() uniMo = logon.lookupByDn('uni') for index, row in bd_df.iterrows(): fvTenant = Tenant(uniMo, row['Tenant']) if delete == 'yes': fvBD = BD(fvTenant, name=row['Name'], status='deleted') else: fvBD = BD(fvTenant, name=row['Name'], arpFlood=row['ARP Flood'], ipLearning=row['EP_learn'], description=row['Description'], multiDstPktAct=row['MultiDest_Flood'], mcastAllow=row['mcastAllow'], unkMcastAct=row['L3Unk_Mcast'], limitIpLearnToSubnets=row['Limit_IP_Learn']) fvRsCtx = RsCtx(fvBD, tnFvCtxName=row['VRF']) if pd.isnull(row['L3O']) == False: fvRsBDToOut = RsBDToOut(fvBD, tnL3extOutName=row['L3O']) cfgRequest = ConfigRequest() cfgRequest.addMo(fvBD) logon.commit(cfgRequest) json_data = toJSONStr(fvBD, prettyPrint=True) file.write( '\n-------------------------------------------------------------------\n' ) file.write(json_data) file.close()
def create_vrfs(delete=''): vrf_df = pd.read_excel("input-data/ACI_DD_Workbook.xlsx", sheet_name='VRFs') file = open("VRF_Configuration.log", "w") logon = apic_logon() uniMo = logon.lookupByDn('uni') for index, row in vrf_df.iterrows(): fvTenant = Tenant(uniMo, row['Tenant']) if delete == 'yes': fvCtx = Ctx(fvTenant, name=row['Name'], status='deleted') else: fvCtx = Ctx(fvTenant, name=row['Name'], pcEnfDir=row['Enforcement Direction'], pcEndPref=row['Enforcement'], description=row['Description']) cfgRequest = ConfigRequest() cfgRequest.addMo(fvCtx) logon.commit(cfgRequest) json_data = toJSONStr(fvCtx, prettyPrint=True) file.write( '\n-------------------------------------------------------------------\n' ) file.write(json_data) file.close()
def create_bd(logon_session, tenant_name="Example_TN", description="Description", bd_name='', vrf_name=''): from cobra.internal.codec.jsoncodec import toJSONStr from cobra.model.fv import Tenant, RsTenantMonPol, BD, RsIgmpsn, RsCtx from cobra.model.fv import RsBdToEpRet, RsBDToNdP from cobra.mit.request import ConfigRequest import cobra.model.pol import cobra.model.vns c = ConfigRequest() #apic_logon(apic_url, user, password) polUni = cobra.model.pol.Uni('') fvTenant = Tenant(polUni, tenant_name) fvBD = BD(fvTenant, multiDstPktAct=u'bd-flood', mcastAllow=u'no', limitIpLearnToSubnets=u'yes', unicastRoute=u'no', unkMcastAct=u'flood', descr=u'', llAddr=u'::', nameAlias=u'', type=u'regular', ipLearning=u'no', vmac=u'not-applicable', mac=u'00:22:BD:F8:19:FF', epMoveDetectMode=u'', ownerTag=u'', intersiteBumTrafficAllow=u'no', annotation=u'', ownerKey=u'', name=bd_name, epClear=u'no', unkMacUcastAct=u'flood', arpFlood=u'yes', intersiteL2Stretch=u'no', OptimizeWanBandwidth=u'no') fvRsIgmpsn = RsIgmpsn(fvBD, tnIgmpSnoopPolName=u'', annotation=u'') fvRsCtx = RsCtx(fvBD, annotation=u'', tnFvCtxName=vrf_name) fvRsBdToEpRet = RsBdToEpRet(fvBD, resolveAct=u'resolve', annotation=u'', tnFvEpRetPolName=u'') fvRsBDToNdP = RsBDToNdP(fvBD, annotation=u'', tnNdIfPolName=u'') bd_data = toJSONStr(polUni) c.addMo(polUni) logon_session.commit(c) return bd_data
def create_vrf(logon_session, tenant_name="Example_TN", description="Description", vrf_name=''): from cobra.internal.codec.jsoncodec import toJSONStr from cobra.model.fv import Tenant, RsTenantMonPol, Ctx, RsOspfCtxPol from cobra.model.fv import RsCtxToExtRouteTagPol, RsBgpCtxPol, RsCtxToEpRet from cobra.model.fv import RsBgpCtxPol, RsVrfValidationPol from cobra.mit.request import ConfigRequest import cobra.model.pol import cobra.model.vns from cobra.model.vz import Any c = ConfigRequest() #apic_logon(apic_url, user, password) polUni = cobra.model.pol.Uni('') fvTenant = Tenant(polUni, tenant_name) fvCtx = Ctx(fvTenant, ownerKey=u'', name=vrf_name, descr=u'', knwMcastAct=u'permit', pcEnfDir=u'ingress', nameAlias=u'', ownerTag=u'', annotation=u'', pcEnfPref=u'enforced', bdEnforcedEnable=u'no') fvRsVrfValidationPol = RsVrfValidationPol(fvCtx, tnL3extVrfValidationPolName=u'', annotation=u'') vzAny = Any(fvCtx, matchT=u'AtleastOne', name=u'', descr=u'', prefGrMemb=u'disabled', nameAlias=u'', annotation=u'') fvRsOspfCtxPol = RsOspfCtxPol(fvCtx, annotation=u'', tnOspfCtxPolName=u'') fvRsCtxToEpRet = RsCtxToEpRet(fvCtx, annotation=u'', tnFvEpRetPolName=u'') fvRsCtxToExtRouteTagPol = RsCtxToExtRouteTagPol(fvCtx, annotation=u'', tnL3extRouteTagPolName=u'') fvRsBgpCtxPol = RsBgpCtxPol(fvCtx, tnBgpCtxPolName=u'', annotation=u'') ctx_data = toJSONStr(polUni) c.addMo(polUni) logon_session.commit(c) return ctx_data
def test_generate_from_apic(self, moDir, dn, codec): mo = lookupSubtreeByDn(moDir, dn) assert mo if codec == 'xml': instr = toXMLStr(mo, includeAllProps=True) print instr pycode = arya.arya().getpython(xmlstr=instr) elif codec == 'json': instr = toJSONStr(mo, includeAllProps=True) print instr pycode = arya.arya().getpython(jsonstr=instr) assert pycode
def respFormatJsonMos(mos, totalCount): jsonStr = '{"totalCount": "%s", "imdata": [' % totalCount first = True for mo in mos: if not first: jsonStr += ',' else: first = False jsonStr += toJSONStr(mo, includeAllProps=True) jsonStr += ']}' jsonDict = json.loads(jsonStr) print json.dumps(jsonDict['imdata']) return json.dumps(jsonDict['imdata'])
def respFormatJsonMos(mos, totalCount): jsonStr = '{"totalCount": "%s", "imdata": [' % totalCount first = True for mo in mos: if not first: jsonStr += ',' else: first = False jsonStr += toJSONStr(mo, includeAllProps=True) jsonStr += ']}' jsonDict = json.loads(jsonStr) return json.dumps(jsonDict)
def toStr(self, mo, includeAllProps=False, prettyPrint=False, excludeChildren=False): """Convert mo into json format. Args: mo (cobra.mit.mo.Mo): mo to be converted. includeAllProps (bool, optional): True if Dn and Rn are required to be included in to output. The default is False. prettyPrint (bool, optional): True if output needs to be human readable. The default is False. excludeChildren (bool, optional): True if child mo objects need not be included in the output. The default is False. Returns: str: string representing the mo in json format """ return toJSONStr(mo, includeAllProps, prettyPrint, excludeChildren)
def create_tenants(delete=''): tenant_df = pd.read_excel("input-data/ACI_DD_Workbook.xlsx", sheet_name='Tenants') file = open("Tenant_Configuration.log", "w") logon = apic_logon() uniMo = logon.lookupByDn('uni') for index, row in tenant_df.iterrows(): fvTenant = Tenant(uniMo, name=row["Tenant Name"], description=row["Tenant Description"]) cfgRequest = ConfigRequest() if delete == 'yes': fvTenant = Tenant(uniMo, name=row["Tenant Name"], status='deleted') cfgRequest.addMo(fvTenant) else: cfgRequest.addMo(fvTenant) logon.commit(cfgRequest) json_data = toJSONStr(fvTenant, prettyPrint=True) file.write( '\n-------------------------------------------------------------------\n' ) file.write(json_data) file.close()
def _jtree(self): """Return a json tree via the Cobra implementation.""" return json.loads(toJSONStr(self.root.mo))
vzEntry3 = cobra.model.vz.Entry(vzFilter3, etherT='ip', prot='6', dFromPort='3306', name='e1', dToPort='3306') # Create a contract, w vzBrCP = cobra.model.vz.BrCP(fvTenant, name='web-contract') vzSubj = cobra.model.vz.Subj(vzBrCP, name='http') vzRsSubjFiltAtt = cobra.model.vz.RsSubjFiltAtt(vzSubj, tnVzFilterName='http') vzRsSubjFiltAtt2 = cobra.model.vz.RsSubjFiltAtt(vzSubj, tnVzFilterName='https') vzBrCP3 = cobra.model.vz.BrCP(fvTenant, name='db-contract') vzSubj3 = cobra.model.vz.Subj(vzBrCP3, name='mysql') vzRsSubjFiltAtt4 = cobra.model.vz.RsSubjFiltAtt(vzSubj3, tnVzFilterName='mysql') fvCtx = cobra.model.fv.Ctx(fvTenant, name=tenant+'-ctx1') fvBD = cobra.model.fv.BD(fvTenant, name=tenant+'-bd1') fvBD2 = cobra.model.fv.BD(fvTenant, name=tenant+'-inside', unkMacUcastAct='flood',arpFlood='true',unicastRoute='false') fvRsCtx = cobra.model.fv.RsCtx(fvBD, tnFvCtxName=tenant+'-ctx1') fvRsCtx2 = cobra.model.fv.RsCtx(fvBD2, tnFvCtxName=tenant+'-ctx1') fvSubnet = cobra.model.fv.Subnet(fvBD, ip=gateway) fvAp = cobra.model.fv.Ap(fvTenant, name=app) fvAEPg = cobra.model.fv.AEPg(fvAp, name='web-epg') fvRsProv = cobra.model.fv.RsProv(fvAEPg, tnVzBrCPName='web-contract') fvRsBd = cobra.model.fv.RsBd(fvAEPg, tnFvBDName=tenant+'-bd1') fvRsCons2 = cobra.model.fv.RsCons(fvAEPg, tnVzBrCPName='db-contract') fvAEPg3 = cobra.model.fv.AEPg(fvAp, name='db-epg') fvRsProv3 = cobra.model.fv.RsProv(fvAEPg3, tnVzBrCPName='db-contract') fvRsBd3 = cobra.model.fv.RsBd(fvAEPg3, tnFvBDName=tenant+'-bd1') c = cobra.mit.request.ConfigRequest() c.addMo(fvTenant) md.commit(c) print toJSONStr(fvTenant, prettyPrint=True)
def getResponseMock(tenantname, apic): tenantname = tenantname[0] url, user, password, secure = apic TOKENS = { 'fakeToken': 'MockedTokenValue' } HEADERS = { 'Content-Type': 'application/json', 'Set-Cookie': TOKENS['fakeToken'] } CONTENT = { 'aaaLogin': json.dumps( { 'imdata': [ { 'aaaLogin': { 'attributes': { 'token': TOKENS['fakeToken'] } } } ] } ), 'aaaListDomains': json.dumps( { 'imdata': [ { 'name': 'fakeDomain' }, { 'name': 'DefaultAuth', 'guiBanner': 'fakeBanner' } ] } ), 'tenant': json.dumps( { 'imdata': [ { 'fvTenant': { 'attributes': { 'dn': 'uni/tn-{0}'.format(tenantname), 'name': tenantname, }, 'children': [ json.loads( toJSONStr(cobra.model.fv.BD( 'uni/tn-{0}'.format(tenantname), 'b'))), json.loads( toJSONStr(cobra.model.fv.Ap( 'uni/tn-{0}'.format(tenantname), 'a'))) ] } } ] } ), 'tenants': json.dumps( { 'imdata': [ { 'fvTenant': { 'attributes': { 'dn': 'uni/tn-{0}'.format(tenants), 'name': tenants, }, 'children': [] } } for tenants in ['common', 'mgmt', 'infra'] ] } ), } # This is a list of tuples, because we need to call responses.add in a # specific order URLMAP = [ ('{0}/api/aaaLogin.json'.format(url), { 'args': [responses.POST], 'kwargs': { 'body': CONTENT['aaaLogin'], 'adding_headers': HEADERS } }), ('{0}/api/aaaRefresh.json'.format(url), { 'args': [responses.POST], 'kwargs': { 'body': CONTENT['aaaLogin'], 'adding_headers': HEADERS } }), ('{0}/api/aaaListDomains.json'.format(url), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['aaaListDomains'], 'adding_headers': HEADERS } }), ('{0}/api/mo/uni/tn-{1}.json'.format(url, tenantname), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['tenant'], 'adding_headers': HEADERS } }), ('{0}/api/mo/uni/tn-{1}.json'.format(url, tenantname), { 'args': [responses.POST], 'kwargs': { 'body': CONTENT['tenant'], 'adding_headers': HEADERS } }), ('{0}/api/class/fvTenant.json?query-target-filter=eq(fvTenant.name, "{1}")'.format(url, tenantname), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['tenant'], 'adding_headers': HEADERS, 'match_querystring': True } }), ('{0}/api/class/fvTenant.json'.format(url), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['tenants'], 'adding_headers': HEADERS, 'match_querystring': True } }), ] logger.debug('getResponseMock creating responses') r = responses.RequestsMock() for url, parms in URLMAP: logger.debug('adding URL {0}'.format(url)) args = parms.get('args') + [url] r.add(*args, **parms.get('kwargs')) return r
def data(self): if self.getRootMo() is None: raise CommitError(0, "No mos in config request") return toJSONStr(self.getRootMo())
def getResponseMock(tenantname, apic): tenantname = tenantname[0] url, user, password, secure = apic TOKENS = {'fakeToken': 'MockedTokenValue'} HEADERS = { 'Content-Type': 'application/json', 'Set-Cookie': TOKENS['fakeToken'] } CONTENT = { 'aaaLogin': json.dumps({ 'imdata': [{ 'aaaLogin': { 'attributes': { 'token': TOKENS['fakeToken'] } } }] }), 'aaaListDomains': json.dumps({ 'imdata': [{ 'name': 'fakeDomain' }, { 'name': 'DefaultAuth', 'guiBanner': 'fakeBanner' }] }), 'tenant': json.dumps({ 'imdata': [{ 'fvTenant': { 'attributes': { 'dn': 'uni/tn-{0}'.format(tenantname), 'name': tenantname, }, 'children': [ json.loads( toJSONStr( cobra.model.fv.BD( 'uni/tn-{0}'.format(tenantname), 'b'))), json.loads( toJSONStr( cobra.model.fv.Ap( 'uni/tn-{0}'.format(tenantname), 'a'))) ] } }] }), 'tenants': json.dumps({ 'imdata': [{ 'fvTenant': { 'attributes': { 'dn': 'uni/tn-{0}'.format(tenants), 'name': tenants, }, 'children': [] } } for tenants in ['common', 'mgmt', 'infra']] }), } # This is a list of tuples, because we need to call responses.add in a # specific order URLMAP = [ ('{0}/api/aaaLogin.json'.format(url), { 'args': [responses.POST], 'kwargs': { 'body': CONTENT['aaaLogin'], 'adding_headers': HEADERS } }), ('{0}/api/aaaRefresh.json'.format(url), { 'args': [responses.POST], 'kwargs': { 'body': CONTENT['aaaLogin'], 'adding_headers': HEADERS } }), ('{0}/api/aaaListDomains.json'.format(url), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['aaaListDomains'], 'adding_headers': HEADERS } }), ('{0}/api/mo/uni/tn-{1}.json'.format(url, tenantname), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['tenant'], 'adding_headers': HEADERS } }), ('{0}/api/mo/uni/tn-{1}.json'.format(url, tenantname), { 'args': [responses.POST], 'kwargs': { 'body': CONTENT['tenant'], 'adding_headers': HEADERS } }), ('{0}/api/class/fvTenant.json?query-target-filter=eq(fvTenant.name, "{1}")' .format(url, tenantname), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['tenant'], 'adding_headers': HEADERS, 'match_querystring': True } }), ('{0}/api/class/fvTenant.json'.format(url), { 'args': [responses.GET], 'kwargs': { 'body': CONTENT['tenants'], 'adding_headers': HEADERS, 'match_querystring': True } }), ] logger.debug('getResponseMock creating responses') r = responses.RequestsMock() for url, parms in URLMAP: logger.debug('adding URL {0}'.format(url)) args = parms.get('args') + [url] r.add(*args, **parms.get('kwargs')) return r
def create_endpoint_groups(delete=''): epg_df = pd.read_excel("input-data/ACI_DD_Workbook.xlsx", sheet_name='End_Point_Groups') file = open("EPG_Configuration.log", "w") logon = apic_logon() uniMo = logon.lookupByDn('uni') for index, row in epg_df.iterrows(): fvTenant = Tenant(uniMo, row['Tenant']) fvAp = Ap(fvTenant, row['Application Profile']) if delete == 'yes': fvAEPg = AEPg(fvAp, name=row['Name'], status='deleted') else: fvAEPg = AEPg(fvAp, name=row['EPG Name'], description=row['EPG Description'], prefGrMemb=row['prefGrMemb']) if pd.isnull(row['Associated Bridge Domain']) == False: fvRsBD = RsBd(fvAEPg, tnFvBDName=row['Associated Bridge Domain']) if pd.isnull(row['Physical Domain']) == False: fvRsDomAtt = RsDomAtt(fvAEPg, tDn='uni/phys-%s' % row['Physical Domain']) if pd.isnull(row['Static Path']) == False: fvRsPathAtt = RsPathAtt(fvAEPg, tDn=row['Static Path'], encap='vlan-%s' % row['VLAN Encap']) if pd.isnull(row['Associated VMM1']) == False: fvRsDomAtt1 = RsDomAtt(fvAEPg, tDn='uni/vmmp-VMware/dom-' + row['Associated VMM1'], primaryEncap=u'unknown', classPref=u'encap', delimiter=u'', instrImedcy=u'lazy', encap=u'unknown', encapMode=u'auto', resImedcy=u'immediate') vmmSecP = SecP(fvRsDomAtt1, ownerKey=u'', name=u'', descr=u'', forgedTransmits=u'reject', ownerTag=u'', allowPromiscuous=u'reject', macChanges=u'reject') if pd.isnull(row['Associated VMM2']) == False: fvRsDomAtt2 = RsDomAtt(fvAEPg, tDn='uni/vmmp-VMware/dom-' + row['Associated VMM2'], primaryEncap=u'unknown', classPref=u'encap', delimiter=u'', instrImedcy=u'lazy', encap=u'unknown', encapMode=u'auto', resImedcy=u'immediate') vmmSecP2 = SecP(fvRsDomAtt2, ownerKey=u'', name=u'', descr=u'', forgedTransmits=u'reject', ownerTag=u'', allowPromiscuous=u'reject', macChanges=u'reject') cfgRequest = ConfigRequest() cfgRequest.addMo(fvAp) logon.commit(cfgRequest) json_data = toJSONStr(fvAp, prettyPrint=True) file.write( '\n-------------------------------------------------------------------\n' ) file.write(json_data) file.close()
def print_json(_objs): """ This function is to print objs """ for _obj in _objs: print(toJSONStr(_obj))
def create_epg(logon_session, tenant_name="Example_TN", description="Description", ap_name='', epg_name='', vpc_leaf_1='101', vpc_leaf_2='102', int_pol='', vlan_encap='', phy_dom='', bd=''): from cobra.internal.codec.jsoncodec import toJSONStr from cobra.model.fv import Tenant, RsTenantMonPol, Ap from cobra.mit.request import ConfigRequest import cobra.model.pol import cobra.model.vns c = ConfigRequest() #apic_logon(apic_url, user, password) polUni = cobra.model.pol.Uni('') fvTenant = Tenant(polUni, tenant_name) fvAp = cobra.model.fv.Ap(fvTenant, ap_name) # build the request using cobra syntax fvAEPg = cobra.model.fv.AEPg(fvAp, isAttrBasedEPg=u'no', matchT=u'AtleastOne', name=epg_name, descr=u'', fwdCtrl=u'', prefGrMemb=u'exclude', exceptionTag=u'', floodOnEncap=u'disabled', nameAlias=u'', prio=u'unspecified', annotation=u'', pcEnfPref=u'unenforced') fvRsPathAtt = cobra.model.fv.RsPathAtt( fvAEPg, tDn=u'topology/pod-1/protpaths-{}-{}/pathep-[{}]'.format( vpc_leaf_1, vpc_leaf_2, vpc_leaf_1, vpc_leaf_2, int_pol, phy_dom), descr=u'', primaryEncap=u'unknown', instrImedcy=u'lazy', mode=u'regular', encap=u'vlan-{}'.format(vlan_encap), annotation=u'') fvRsDomAtt = cobra.model.fv.RsDomAtt(fvAEPg, tDn=u'uni/phys-{}'.format(phy_dom), netflowDir=u'both', epgCos=u'Cos0', classPref=u'encap', netflowPref=u'disabled', secondaryEncapInner=u'unknown', resImedcy=u'immediate', delimiter=u'', instrImedcy=u'lazy', primaryEncapInner=u'unknown', encap=u'unknown', switchingMode=u'native', primaryEncap=u'unknown', encapMode=u'auto', annotation=u'', epgCosPref=u'disabled') fvRsCustQosPol = cobra.model.fv.RsCustQosPol(fvAEPg, annotation=u'', tnQosCustomPolName=u'') fvRsBd = cobra.model.fv.RsBd(fvAEPg, annotation=u'', tnFvBDName=bd) epg_data = toJSONStr(polUni) c.addMo(polUni) logon_session.commit(c) return epg_data