-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestQueryClass.py
More file actions
executable file
·32 lines (27 loc) · 980 Bytes
/
TestQueryClass.py
File metadata and controls
executable file
·32 lines (27 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from cobra.mit.access import MoDirectory
from cobra.mit.session import LoginSession
from cobra.mit.access import DnQuery
from cobra.mit.access import ClassQuery
from cobra.model.fv import Tenant, Ctx, BD, RsCtx, Ap, AEPg, RsBd, RsDomAtt, RsPathAtt
import yaml
import argparse
#parser = argparse.ArgumentParser(description="Display EPG by Ap")
#parser.add_argument('tenantName', help='tenant name')
#parser.add_argument('apName', help='ap name')
#args = parser.parse_args()
# open yaml files
f = open('credentials.yaml', 'r')
credentials = yaml.load(f)
f.close()
apicUrl = credentials['host']
loginSession = LoginSession(apicUrl, credentials['user'], credentials['pass'])
moDir = MoDirectory(loginSession)
moDir.login()
#dnQuery = DnQuery('uni/tn-' + args.tenantName + '/ap-' + args.apName)
#dnQuery.queryTarget = 'children'
#dnQuery.subtreeClassFilter = 'fvAEPg'
cQuery = ClassQuery(AEPg)
epgMo = moDir.lookupByClass(cQuery)
for epg in epgMo:
print epg.dn
moDir.logout()