當前位置: 首頁>>代碼示例>>Python>>正文


Python Credentials.add_argument方法代碼示例

本文整理匯總了Python中acitoolkit.acitoolkitlib.Credentials.add_argument方法的典型用法代碼示例。如果您正苦於以下問題:Python Credentials.add_argument方法的具體用法?Python Credentials.add_argument怎麽用?Python Credentials.add_argument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在acitoolkit.acitoolkitlib.Credentials的用法示例。


在下文中一共展示了Credentials.add_argument方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
def main():
    """
    Main show Process routine
    :return: None
    """
    description = 'Simple application that logs on to the APIC and displays process information for a switch'
    creds = Credentials('apic', description)

    creds.add_argument('-s', '--switch',
                       type=str,
                       default=None,
                       help='Specify a particular switch id, e.g. "102"')
    args = creds.get()

    session = ACI.Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    switches = ACI.Node.get(session, '1', args.switch)
    for switch in switches:
        if switch.role != 'controller':
            processes = ACI.Process.get(session, switch)
            tables = ACI.Process.get_table(processes, 'Process list for Switch ' + switch.name + '::')
            for table in tables:
                print table.get_text(tablefmt='fancy_grid') + '\n'
開發者ID:JMSrulez,項目名稱:acitoolkit,代碼行數:29,代碼來源:aci-show-process.py

示例2: main

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = "Search tool for APIC."
    creds = Credentials("apic", description)
    creds.add_argument(
        "-s", "--switch", type=str, default=None, help='Specify a particular switch id to perform search on, e.g. "102"'
    )
    creds.add_argument("-f", "--find", type=str, help="search string")
    creds.add_argument("--force", action="store_true", default=False, help="Force a rebuild of the search index")

    args = creds.get()
    print args
    try:
        sdb = SearchDb.load_db(args)
    except (LoginError, Timeout, ConnectionError):
        print "%% Could not login to APIC"
        sys.exit(0)

    results = sdb.search(args.find)
    count = 0
    for res in results:
        count += 1
        print res
開發者ID:nedimredzovic,項目名稱:acitoolkit,代碼行數:28,代碼來源:aciSearchDb.py

示例3: main

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Search tool for APIC.'
    creds = Credentials('apic', description)
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')

    args = creds.get()
    print args
    # load all objects
    session = SearchSession(args)
    try:
        fabric = Fabric.get(session.session)[0]
    except (LoginError, Timeout, ConnectionError):
        print '%% Could not login to APIC'
        sys.exit(0)

    fabric.populate_children(deep=True, include_concrete=True)

    index = SearchIndexLookup()
    store = SearchObjectStore()

    index.add_atk_objects(fabric)
    store.add_atk_objects(fabric)

    uids = index.search(args.find)
    result = store.get_by_uids_short(uids)

    count = 0
    for res in result:
        count += 1
        print res
開發者ID:JMSrulez,項目名稱:acitoolkit,代碼行數:39,代碼來源:aciSearchDb.py

示例4: main

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Search tool for APIC.'
    creds = Credentials('apic', description)
    creds.add_argument('-s', '--switch',
                       type=str,
                       default=None,
                       help='Specify a particular switch id to perform search on, e.g. "102"')
    creds.add_argument('-f', '--find',
                       type=str,
                       help='search string')
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')

    args = creds.get()
    print args
    sdb = SearchDb()
    sdb.set_login_credentials(args)
    try:
        sdb.load_db(args.force)
    except (LoginError, Timeout, ConnectionError):
        print '%% Could not login to APIC'
        sys.exit(0)

    results = sdb.search(args.find)
    count = 0
    for res in results:
        count += 1
        print 'score', res['pscore'], res['sscore'], res['terms'], res['title'], res['path']
        tables = res['primary'].get_table([res['primary'], ])
        for table in tables:
            if table.data != []:
                print table.get_text()
        if count > 10:
            print 'Showing 10 of', len(results), 'results'
            break
開發者ID:calvinha,項目名稱:acitoolkit,代碼行數:43,代碼來源:aciSearchDb.py

示例5: Credentials

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
################################################################################
"""
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
from operator import attrgetter
import sys
import acitoolkit.acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Simple application that logs on to the APIC and displays reports for the logical model.'
creds = Credentials('apic', description)
creds.add_argument('-t', '--tenant',
                   type=str,
                   default=None,
                   help='Specify a particular tenant name')
creds.add_argument('-all', action="store_true",
                   help='Show all detailed information')
creds.add_argument('-basic', action="store_true", help='Show basic tenant info')
creds.add_argument('-context', action="store_true", help='Show Context info')
creds.add_argument('-bridgedomain', action="store_true", help='Show Bridge Domain info')
creds.add_argument('-contract', action="store_true", help='Show Contract info')
creds.add_argument('-taboo', action="store_true", help='Show Taboo (Deny) info')
creds.add_argument('-filter', action="store_true", help='Show Filter info')
creds.add_argument('-app_profile', action="store_true", help='Show Application Profile info')
creds.add_argument('-epg', action="store_true", help='Show Endpoint Group info')
# creds.add_argument('-svi', action="store_true", help='Show SVI info')
# creds.add_argument('-accessrule', action="store_true", help='Show Access Rule and Filter info')
creds.add_argument('-endpoint', action="store_true", help='Show End Point info')
# creds.add_argument('-portchannel', action="store_true", help='Show Port Channel and Virtual Port Channel info')
開發者ID:calvinha,項目名稱:acitoolkit,代碼行數:34,代碼來源:aci-report-logical.py

示例6: main

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
def main():
    """
    Main execution path when run from the command line
    """
    # Get all the arguments
    description = 'Connection Search tool for APIC.'
    creds = Credentials('apic', description)

    creds.add_argument('-tenant', type=str, default='*', help='Tenant name (wildcards, "*", accepted), default "*"')
    creds.add_argument('-context', type=str, default='*', help='Tenant name (wildcards, "*", accepted), default "*"')
    creds.add_argument('-sip', type=str, default='0/0', help='Source IP or subnet - e.g. 1.2.3.4/24, default: "0/0"')
    creds.add_argument('-dip', type=str, default='0/0',
                       help='Destination IP or subnet - e.g. 1.2.3.4/24, default: "0/0"')
    creds.add_argument('-dport', type=str, default='any',
                       help='Destination L4 Port value or range, e.g. 20-25 or 80. Default: "any"')
    creds.add_argument('-sport', type=str, default='any',
                       help='Source L4 Port value or range, e.g. 20-25 or 80. Default: "any"')
    creds.add_argument('-etherT', type=str, default='any', help='EtherType, e.g. "ip", "arp", "icmp". Default: "any"')
    creds.add_argument('-prot', type=str, default='any', help='Protocol, e.g. "tcp", "udp". Default: "any"')
    creds.add_argument('-arpOpc', type=str, default='any', help='ARP Opcode, e.g. "req", "ack". Default: "any"')
    creds.add_argument('-applyToFrag', type=str, default='any',
                       help='Apply to fragment, e.g. "yes", "no". Default: "any"')
    creds.add_argument('-tcpRules', type=str, default='any', help='TCP rules, e.g. "syn", "fin". Default: "any"')

    args = creds.get()

    flow_spec = build_flow_spec_from_args(args)
    # todo: verify that a dash can be used in port range.

    # Login to APIC
    session = Session(args.url, args.login, args.password)
    resp = session.login()
    if not resp.ok:
        print '%% Could not login to APIC'
        sys.exit(0)

    sdb = SearchDb(session)
    sdb.build()
    results = sorted(sdb.search(flow_spec))
    for result in results:
        print result
開發者ID:bischatt78,項目名稱:acitoolkit,代碼行數:43,代碼來源:aciConSearch.py

示例7: search_result_page

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
admin.add_view(About(name='About', endpoint='about'))
admin.add_view(Feedback(name='Feedback'))
admin.add_view(AciToolkitSearchView(name='Search'))
# admin.add_view(ShowObjectView(name='Object View', endpoint='atk_object'))


@app.route("/search/<search_terms>")
def search_result_page(search_terms='1/101/1/49'):
    """
    URL to request information about a specific port
    :param search_terms:
    """
    terms = str(request.args['first'])
    print 'search terms', terms

    result, total_hits = sdb.search(terms)
    return jsonify(result=result, total_hits=total_hits)

if __name__ == '__main__':
    description = 'ACI Search Tool.'
    creds = Credentials('server', description)
    creds.add_argument('--force',
                       action="store_true",
                       default=False,
                       help='Force a rebuild of the search index')
    args = creds.get()

    # Start app
    # app.run(debug=True, host=args.ip, port=int(args.port))
    app.run(debug=True, host=args.ip, port=5001)
開發者ID:rtrentin73,項目名稱:acitoolkit,代碼行數:32,代碼來源:aciSearchGui.py

示例8: Credentials

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
Simple application that logs on to the APIC and displays all
of the Interfaces.
"""
import datetime
from operator import attrgetter
import sys

import acitoolkit as ACI
from acitoolkit.acitoolkitlib import Credentials


# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = "Simple application that logs on to the APIC and displays reports for the switches."
creds = Credentials("apic", description)
creds.add_argument("-s", "--switch", type=str, default=None, help='Specify a particular switch id, e.g. "102"')
creds.add_argument("-all", action="store_true", help="Show all detailed information")
creds.add_argument("-basic", action="store_true", help="Show basic switch info")
creds.add_argument("-linecard", action="store_true", help="Show Lincard info")
creds.add_argument("-supervisor", action="store_true", help="Show Supervisor Card info")
creds.add_argument("-fantray", action="store_true", help="Show Fantray info")
creds.add_argument("-powersupply", action="store_true", help="Show Power Supply info")
creds.add_argument("-arp", action="store_true", help="Show ARP info")
creds.add_argument("-context", action="store_true", help="Show Context (VRF) info")
creds.add_argument("-bridgedomain", action="store_true", help="Show Bridge Domain info")
creds.add_argument("-svi", action="store_true", help="Show SVI info")
creds.add_argument("-accessrule", action="store_true", help="Show Access Rule and Filter info")
creds.add_argument("-endpoint", action="store_true", help="Show End Point info")
creds.add_argument("-portchannel", action="store_true", help="Show Port Channel and Virtual Port Channel info")
creds.add_argument("-overlay", action="store_true", help="Show Overlay info")
creds.add_argument(
開發者ID:sochmans,項目名稱:acitoolkit,代碼行數:33,代碼來源:aci-report-switch.py

示例9: Credentials

# 需要導入模塊: from acitoolkit.acitoolkitlib import Credentials [as 別名]
# 或者: from acitoolkit.acitoolkitlib.Credentials import add_argument [as 別名]
of the Interfaces.
"""
import sys
from acitoolkit.aciConcreteLib import *
import acitoolkit.acitoolkit as ACI
import acitoolkit.aciphysobject as ACI_PHYS
from acitoolkit.acitoolkitlib import Credentials

#from SwitchJson import SwitchJson

# Take login credentials from the command line if provided
# Otherwise, take them from your environment variables file ~/.profile
description = 'Simple application that logs on to the APIC and displays reports for the switches.'
creds = Credentials('apic', description)
creds.add_argument('-s', '--switch',
                   type=str,
                   default=None,
                   help='Specify a particular switch id, e.g. "102"')
creds.add_argument('-all', action="store_true",
                   help='Show all detailed information')
creds.add_argument('-basic', action="store_true", help='Show basic switch info')
creds.add_argument('-linecard', action="store_true", help='Show Lincard info')
creds.add_argument('-supervisor', action="store_true", help='Show Supervisor Card info')
creds.add_argument('-fantray', action="store_true", help='Show Fantray info')
creds.add_argument('-powersupply', action="store_true", help='Show Power Supply info')
creds.add_argument('-arp', action="store_true", help='Show ARP info')
creds.add_argument('-context', action="store_true", help='Show Context (VRF) info')
creds.add_argument('-bridgedomain', action="store_true", help='Show Bridge Domain info')
creds.add_argument('-svi', action="store_true", help='Show SVI info')
creds.add_argument('-accessrule', action="store_true", help='Show Access Rule and Filter info')
creds.add_argument('-endpoint', action="store_true", help='Show End Point info')
creds.add_argument('-portchannel', action="store_true", help='Show Port Channel and Virtual Port Channel info')
開發者ID:KarlHarrisSungardAS,項目名稱:acitoolkit,代碼行數:34,代碼來源:aci-report-switch.py


注:本文中的acitoolkit.acitoolkitlib.Credentials.add_argument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。