本文整理汇总了Python中cobra.mit.access.MoDirectory类的典型用法代码示例。如果您正苦于以下问题:Python MoDirectory类的具体用法?Python MoDirectory怎么用?Python MoDirectory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MoDirectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apic_login
def apic_login(hostname, username, password):
"""Login to APIC"""
epoint = EndPoint(hostname, secure=False, port=80)
lsess = LoginSession(username, password)
modir = MoDirectory(epoint, lsess)
modir.login()
return modir
示例2: test_post_tn
def test_post_tn(self, apics, certobject, userobject):
apic = apics[0]
secure = False if apics[1] == 'False' else True
userobject.pkey = certobject.readFile(
fileName=certobject.pkeyfile)
session = CertSession(apic, userobject.certDn, userobject.pkey,
secure=secure, requestFormat='xml')
moDir = MoDirectory(session)
uni = Uni('')
fvTenant = Tenant(uni, name='t')
fvBD = BD(fvTenant, 't-bd')
fvAp = Ap(fvTenant, 't-app')
cr = ConfigRequest()
#cr.subtree = 'full'
cr.addMo(fvTenant)
if userobject.user == 'rouser':
with pytest.raises(RestError) as excinfo:
r = moDir.commit(cr)
assert ((excinfo.value.reason == ('user rouser does not have ' +
'domain access to config Mo, ' +
'class fvTenant')) or
(excinfo.value.reason == ('user rouser does not have ' +
'domain access to config Mo, ' +
'class fvBD')))
elif userobject.user == 'rwuser':
r = moDir.commit(cr)
else:
raise NotImplementedError
示例3: do_login
def do_login():
apicUrl = 'https://198.18.133.200'
loginSession = LoginSession(apicUrl, 'admin', 'C1sco12345')
active_session = MoDirectory(loginSession)
active_session.login()
# print loginSession.cookie
return active_session
示例4: login_gui
def login_gui():
root =Tk()
root.minsize(700,400)
root.title("Cisco APIC Login")
ment_1 = StringVar()
ment_2 = StringVar()
ment_3 = StringVar()
label_1 = Label(root, text = "ip address").pack()
mentry = Entry(root,textvariable = ment_1 ).pack()
label_2 = Label(root, text = "username").pack()
mentry_2 = Entry(root,textvariable = ment_2 ).pack()
label_3 = Label(root, text = "password").pack()
mentry_3 = Entry(root, show="*", width=20, bg = "gray",textvariable = ment_3 ).pack()
frame = Frame(root)
frame.pack()
button = Button(frame,text = "ok", command = lambda: close_device(root), bg = "gray",fg = "black")
button.pack()
root.mainloop()
apicIP = ment_1.get()
user = ment_2.get()
pw = ment_3.get()
try:
## login to APIC
apicUrl = 'https://'+apicIP # defaulting to https
loginSession = LoginSession(apicUrl, user, pw,secure=False)
moDir = MoDirectory(loginSession)
moDir.login()
except:
print "the username and/or password you entered is incorrect"
return apicUrl,moDir
示例5: apic_login
def apic_login(self):
"""Login to APIC"""
lsess = LoginSession('https://' + self.host, self.user, self.password)
modir = MoDirectory(lsess)
modir.login()
print lsess.cookie
return modir
示例6: login_cli
def login_cli(apicUrl, user, password):
try:
loginSession = LoginSession(apicUrl,user,password)
moDir = MoDirectory(loginSession)
moDir.login()
except:
print "the username and/or password you entered is incorrect"
return moDir
示例7: moDir
def moDir(request):
url, user, password, secure = request.param
secure = False if secure == 'False' else True
session = LoginSession(url, user, password,
secure=secure, requestFormat='json')
md = MoDirectory(session)
md.login()
return md
示例8: apic_login
def apic_login(self):
"""Login to APIC"""
if not self.host.startswith(('http', 'https')):
self.host = 'https://' + self.host
lsess = LoginSession(self.host, self.user, self.password)
modir = MoDirectory(lsess)
modir.login()
self.modir = modir
示例9: apic_login
def apic_login(hostname, username, password):
url = "http://" + hostname
sess = LoginSession(url, username, password) modir = MoDirectory(sess)
try:
modir.login()
except:
print 'Login error'
exit(1)
return modir
示例10: main
def main(host, username, password, tenant):
apic = "https://%s" % host
print("Connecting to APIC : %s" % apic)
moDir = MoDirectory(LoginSession(apic, username, password))
moDir.login()
dn_name = "uni/tn-" + tenant
print(dn_name)
dnq = DnQuery(dn_name)
dnq.subtree = 'children'
tenantMO = moDir.query(dnq)
for bdMO in tenantMO.BD:
print("BD NAME => {", bdMO.name, "}")
示例11: mo_apic_login
def mo_apic_login(hostname, username, password):
# Login to the APIC using cobra module
url = hostname
sess = LoginSession(url, username, password)
modir = MoDirectory(sess)
try:
modir.login()
except:
print 'Login error'
exit(1)
return modir
示例12: test_cleanup_user
def test_cleanup_user(self, apics, certobject, userobject):
apic = apics[0]
user = apics[2]
password = apics[3]
secure = False if apics[1] == 'False' else True
userobject.aaaUser.delete()
session = LoginSession(apic, user, password, secure=secure)
moDir = MoDirectory(session)
moDir.login()
cr = ConfigRequest()
cr.addMo(userobject.aaaUser)
r = moDir.commit(cr)
assert r == []
示例13: apic_login
def apic_login(hostname, username, password):
'''
Function that creates a session to communicate with the APIC
'''
url = "https://" + hostname
login_session = cobra.mit.session.LoginSession(url, username, password)
modir = MoDirectory(login_session)
print 'connecting to ' + hostname
try:
modir.login()
except:
print 'Login error'
exit(1)
return modir
示例14: login_cli
def login_cli(apicIP,userID,pw):
try:
## login to APIC
if apicIP == False:
apicIP = raw_input("\nWhat is the APIC IP ? Format xxx.xxx.xxx.xxx\n")
userID = raw_input("\nUser ID: ")
pw = getpass.getpass().strip("/\r")
apicUrl = 'https://'+apicIP # defaulting to https
loginSession = LoginSession(apicUrl, userID, pw,secure=False)
moDir = MoDirectory(loginSession)
moDir.login()
except:
print "the username and/or password you entered is incorrect"
return apicUrl,moDir
示例15: test_get_tn
def test_get_tn(self, apics, certobject, userobject):
apic = apics[0]
secure = False if apics[1] == 'False' else True
userobject.pkey = certobject.readFile(
fileName=certobject.pkeyfile)
session = CertSession(apic, userobject.certDn, userobject.pkey,
secure=secure, requestFormat='xml')
moDir = MoDirectory(session)
dnQuery = DnQuery('uni/tn-common')
#dnQuery.subtree = "full"
tq = moDir.query(dnQuery)
assert len(tq) == 1
tq = tq[0]
assert str(tq.parentDn) == 'uni'
assert str(tq.dn) == 'uni/tn-common'