当前位置: 首页>>代码示例>>Python>>正文


Python MoDirectory.login方法代码示例

本文整理汇总了Python中cobra.mit.access.MoDirectory.login方法的典型用法代码示例。如果您正苦于以下问题:Python MoDirectory.login方法的具体用法?Python MoDirectory.login怎么用?Python MoDirectory.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cobra.mit.access.MoDirectory的用法示例。


在下文中一共展示了MoDirectory.login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login_gui

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:chambear2809,项目名称:find_vlan,代码行数:34,代码来源:find_vlan.py

示例2: apic_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
 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
开发者ID:GDT-Labs,项目名称:Nexus9kBUVisit,代码行数:9,代码来源:test.py

示例3: do_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:GDT-Labs,项目名称:Nexus9kBUVisit,代码行数:9,代码来源:ACI_cobra_test.py

示例4: apic_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:Kantharaj,项目名称:ACI,代码行数:9,代码来源:createVmmDomain.py

示例5: APICHandler

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
class APICHandler():
    def __init__(self):
        self.host = 'https://192.168.1.100'
        self.user = 'admin'
        self.pwd = 'GDTlabs123'
        self.session = None

    def do_login(self):
        loginSession = LoginSession(self.host, self.user, self.pwd)
        self.session = MoDirectory(loginSession)
        self.session.login()
        # print loginSession.cookie
        return self.session

    def target_location_lookup(self, active_session, location):
        change_location = self.session.lookupByDn(location)
        return change_location

    def update_config(self, active_session, change_location):
        configReq = ConfigRequest()
        configReq.addMo(change_location)
        self.session.commit(configReq)

    def logout(self, active_session):
        self.session.logout()
开发者ID:GDT-Labs,项目名称:APICTools,代码行数:27,代码来源:APICCoreFuncs.py

示例6: login_cli

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:chambear2809,项目名称:display_if_status,代码行数:10,代码来源:display_if_status.py

示例7: apic_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
 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
开发者ID:bairointernet,项目名称:ACI,代码行数:10,代码来源:createMo.py

示例8: moDir

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:bischatt78,项目名称:cobra,代码行数:10,代码来源:test_session_CertSession.py

示例9: apic_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:jlopez2,项目名称:ACI_Devops,代码行数:11,代码来源:python1.py

示例10: main

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
def main(host, username, password, node, interface):
    apic = "https://%s" % host
    print("Connecting to APIC : %s" % apic)
    moDir = MoDirectory(LoginSession(apic, username, password))
    moDir.login()

    nodeblk_dict = defaultdict(list)
    nodeblk_list = moDir.lookupByClass("infraNodeBlk")
    node_found = False
    for nodeblkMO in nodeblk_list:
        if int(nodeblkMO.from_) > int(node) or int(nodeblkMO.to_) < int(node):
            continue
        else:
            node_found = True
            node_dn = '/'.join(str(nodeblkMO.dn).split('/')[:3])
            nodeblk_dict[node_dn].append(str(nodeblkMO.dn))
    if node_found is False:
        print("Switch Node {", node, "} DOES NOT exist!")
        exit(1)
    if debug is True:
        print("Printing nodeblk_dict.......")
        for key, value in nodeblk_dict.items():
            print(key, ":", value)
        print("-----------------------------")

    port_dict = {}
    RsAccPortP_list = moDir.lookupByClass("infraRsAccPortP")
    for RsAccPortPMO in RsAccPortP_list:
        portk = str(str(RsAccPortPMO.dn).split('[')[1])[:-1]
        port_dict[portk] = '/'.join(str(RsAccPortPMO.dn).split('/')[:3])

    if debug is True:
        print("Printing port_dict.......")
        for key, value in port_dict.items():
            print(key, ":", value)

        print("-----------------------------")

    Portblk_list = moDir.lookupByClass("infraPortBlk")
    interface_found = False
    for temp_port in Portblk_list:
        if int(interface) == int(temp_port.fromPort):
            interface_found = True
            intP = '/'.join(str(temp_port.dn).split('/')[:3])
            if port_dict[intP] in nodeblk_dict:
                m = re.match("accportprof-(?P<first>.+)", str(temp_port.dn).split('/')[2])
                print("Interface Profile Name => ", m.group("first"))
                print("Interface Profile DN =>", intP)
                n = re.match("nprof-(?P<first>.+)", str(port_dict[intP]).split('/')[2])
                print("Switch Node Profile Name =>", n.group("first"))
                print("Switch Node Profile DN =>", port_dict[intP])
    if interface_found is False:
        print("Interface {", interface, "} DOES NOT exist!")
        exit(1)
开发者ID:gent79reid,项目名称:ACI,代码行数:56,代码来源:find_node_port_profile.py

示例11: main

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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, "}")
开发者ID:gent79reid,项目名称:ACI,代码行数:14,代码来源:list_bd_in_tenant_v1.py

示例12: mo_apic_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:mijo77,项目名称:cisco_class,代码行数:14,代码来源:apic_epgStats.py

示例13: test_cleanup_user

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
 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 == []
开发者ID:bischatt78,项目名称:cobra,代码行数:15,代码来源:test_session_CertSession.py

示例14: apic_login

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:fancyTyphoonKitty,项目名称:cisco_class,代码行数:16,代码来源:ntp.py

示例15: login_cli

# 需要导入模块: from cobra.mit.access import MoDirectory [as 别名]
# 或者: from cobra.mit.access.MoDirectory import login [as 别名]
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
开发者ID:chambear2809,项目名称:find_vlan,代码行数:17,代码来源:find_vlan.py


注:本文中的cobra.mit.access.MoDirectory.login方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。