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


Python acitoolkit.Credentials类代码示例

本文整理汇总了Python中acitoolkit.acitoolkit.Credentials的典型用法代码示例。如果您正苦于以下问题:Python Credentials类的具体用法?Python Credentials怎么用?Python Credentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

def main():
    """ Create 2 EPGs within the same Context and have
        1 EPG provide a contract to the other EPG.
    """
    description = ('Create 2 EPGs within the same Context and have'
                   '1 EPG provide a contract to the other EPG.')
    creds = Credentials('apic', description)
    args = creds.get()

    # Create the Tenant
    tenant = Tenant('aci-toolkit-demo')

    # Create the Application Profile
    app = AppProfile('my-demo-app', tenant)

    # Create the EPGs
    web_epg = EPG('web-frontend', app)
    db_epg = EPG('database-backend', app)
    web_epg.set_intra_epg_isolation(False)
    db_epg.set_intra_epg_isolation(True)

    # Create a Context and BridgeDomain
    # Place both EPGs in the Context and in the same BD
    context = Context('VRF-1', tenant)
    bd = BridgeDomain('BD-1', tenant)
    bd.add_context(context)
    web_epg.add_bd(bd)
    db_epg.add_bd(bd)

    # Define a contract with a single entry
    contract = Contract('mysql-contract', tenant)
    entry1 = FilterEntry('entry1',
                         applyToFrag='no',
                         arpOpc='unspecified',
                         dFromPort='3306',
                         dToPort='3306',
                         etherT='ip',
                         prot='tcp',
                         sFromPort='1',
                         sToPort='65535',
                         tcpRules='unspecified',
                         parent=contract)

    # Provide the contract from 1 EPG and consume from the other
    db_epg.provide(contract)
    web_epg.consume(contract)

    # Login to APIC and push the config
    session = Session(args.url, args.login, args.password)
    session.login()
    
    # Cleanup (uncomment the next line to delete the config)
    #tenant.mark_as_deleted()
    resp = tenant.push_to_apic(session)

    if resp.ok:
        # Print what was sent
        print('Pushed the following JSON to the APIC')
        print('URL: ' + str(tenant.get_url()))
        print('JSON: ' + str(tenant.get_json()))
开发者ID:JMSrulez,项目名称:acitoolkit,代码行数:60,代码来源:aci_demo_contract.py

示例2: main

def main():
    """
    Main execution routine

    :return: None
    """
    # Take login credentials from the command line if provided
    # Otherwise, take them from your environment variables
    description = "Simple application that logs on to the APIC and displays" " the physical inventory."
    creds = Credentials("apic", description)
    args = creds.get()

    # 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)

    # Print the inventory of each Pod
    pods = Pod.get(session)
    for pod in pods:
        pod.populate_children(deep=True)
        pod_name = "Pod: %s" % pod.name
        print(pod_name)
        print("=" * len(pod_name))
        print_inventory(pod)
开发者ID:mtimm,项目名称:acitoolkit,代码行数:27,代码来源:aci-show-physical-inventory.py

示例3: main

def main(argv):
    global session, tenant, vmmInput
    if len(argv) > 2:
        vmmInput = argv[2]
        argv.remove(vmmInput)
    if len(argv) > 1:
        tenant = argv[1]
        argv.remove(tenant)

    # Setup or credentials and session
    description = ('Create some stuff.')
    creds = Credentials('apic', description)
    args = creds.get()
    
    # Login to APIC
    session = Session(args.url, args.login, args.password)
    session.login()

    # Get a good Virtual Domain to use
    while True:
        if check_virtual_domain():
            break
        else:
            collect_vmmdomain()
 
    create_base()
    create_common_contracts.create_all_contracts(theTenant, session)
    create_ospf_egress.create_interface(theTenant, session, {'provide':'Outbound_Server', 'consume':'Web'})
    create_application_profiles()

    print ("Everything seems to have worked if you are seeing this.")
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:31,代码来源:create_complex_tenant.py

示例4: main

def main():
    """
    Main execution routine

    :return: None
    """
    # 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 all'
                   ' of the physical nodes; both belonging to and connected to the fabric.')
    creds = Credentials('apic', description)
    args = creds.get()

    # 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)

    # List of classes to get and print
    phy_classes = (Node, ExternalSwitch)

    for phy_class in phy_classes:
        # Print the class name
        class_name = phy_class.__name__
        print(class_name)
        print('=' * len(class_name))

        # Get and print all of the items from the APIC
        items = phy_class.get(session)
        for item in items:
            print(item.info())
开发者ID:SangheeKim,项目名称:acitoolkit,代码行数:33,代码来源:aci-show-nodes.py

示例5: main

def main():
    global session
    # Setup or credentials and session
    description = ('Converts an IOS config to ACI EPGs in a Applicaiton Profile.')
    creds = Credentials('apic', description)
    args = creds.get()

    readconfigfile()
    
    print "\n\n"
    # printsvis()

    # Login to APIC
    session = Session(args.url, args.login, args.password)
    session.login()

    # Get a Tenant name
    while not get_tenant():
            pass

    # Get a good Virtual Domain to use
    while not check_virtual_domain():
            collect_vmmdomain()
            

    print "\nPushing configuration into the APIC now.  Please wait."
    
    build_base()

    print ("\nCreated {} SVIs from a total of {} SVIs that we found.".format(pushcount, str(len(all_svi))))
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:30,代码来源:ios_2_aci.py

示例6: main

def main():
    global session
 
    # Setup or credentials and session
    description = ('Duplicate an application profile with the associate BD and PN')
    creds = Credentials('apic', description)
    args = creds.get()
    
    # Login to APIC
    session = Session(args.url, args.login, args.password)
    session.login()

    oldTenant = getOldTenant()
    newTenant = raw_input('Please enter the new Tenant name: ')
    if newTenant == '':
        error_message ([3,'You must specify a new tenant name.', True])

    if oldTenant.name == newTenant:
       error_message ([3,'The same Tenant name can not be used.', True])


    fullTenantInfo = getFullTeanantInfo(oldTenant)

    #  Login to the system again so I can make direct rest calls without the acitoolkit
    admin = {"ip_addr":args.url,"user":args.login,"password":args.password}
    add_admin = oldSchoolLogin(admin)
    ''' Add the session urlToken for future use with security, and the refresh timeout for future use '''
    admin.update({'urlToken':add_admin[0],'refreshTimeoutSeconds':add_admin[1], 'APIC-cookie':add_admin[2]})

    createTenant(admin, newTenant, oldTenant.name, fullTenantInfo)
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:30,代码来源:duplicate_tenant.py

示例7: main

def main():
    creds = Credentials('apic')
    args = creds.get()
    session = Session(args.url, args.login, args.password)
    session.login()

    tenant = 'A_SCRIPT_MADE_ME'
    theTenant = Tenant(tenant)
    create_interface(theTenant, session, {'provide':'Outbound_Server', 'consume':'Web'})

    print ("Created a Layer 3 External gateway in tenant {}.".format(theTenant))
    print ("Everything seems to have worked if you are seeing this.")
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:12,代码来源:create_ospf_egress.py

示例8: main

def main():
    """
    Main execution routine
    """
    creds = Credentials('apic')
    args = creds.get()
    session = Session(args.url, args.login, args.password)
    session.login()

    tenant = Tenant('Cisco-Demo')
    context = Context('ctx1', tenant)
    outside_l3 = OutsideL3('out-1', tenant)
    outside_l3.add_context(context)
    phyif = Interface('eth', '1', '101', '1', '46')
    phyif.speed = '1G'
    l2if = L2Interface('eth 1/101/1/46', 'vlan', '1')
    l2if.attach(phyif)
    l3if = L3Interface('l3if')
    l3if.set_l3if_type('l3-port')
    l3if.set_mtu('1500')
    l3if.set_addr('1.1.1.2/30')
    l3if.add_context(context)
    l3if.attach(l2if)
    rtr = OSPFRouter('rtr-1')
    rtr.set_router_id('23.23.23.23')
    rtr.set_node_id('101')
    ifpol = OSPFInterfacePolicy('myospf-pol', tenant)
    ifpol.set_nw_type('p2p')
    ospfif = OSPFInterface('ospfif-1', router=rtr, area_id='1')
    ospfif.set_area_type('nssa')
    ospfif.auth_key = 'password'
    ospfif.int_policy_name = ifpol.name
    ospfif.auth_keyid = '1'
    ospfif.auth_type = 'simple'
    tenant.attach(ospfif)
    ospfif.networks.append('55.5.5.0/24')
    ospfif.attach(l3if)
    contract1 = Contract('contract-1')
    outside_epg = OutsideEPG('outepg', outside_l3)
    outside_epg.provide(contract1)
    contract2 = Contract('contract-2')
    outside_epg.consume(contract2)
    outside_l3.attach(ospfif)

    print(tenant.get_json())
    resp = session.push_to_apic(tenant.get_url(),
                                tenant.get_json())

    if not resp.ok:
        print('%% Error: Could not push configuration to APIC')
        print(resp.text)
开发者ID:amney,项目名称:acitoolkit,代码行数:51,代码来源:aci-create-ospf-external.py

示例9: main

def main():
    # Setup or credentials and session
    description = ('Common contracts and filters')
    creds = Credentials('apic', description)
    args = creds.get()
    
    # Login to APIC
    session = Session(args.url, args.login, args.password)
    session.login()

    # This creates the tenant object
    theTenant = Tenant(tenant)

    create_all_contracts(theTenant, session)

    print ("Created common contracts and filters in the {} tenant.".format(theTenant))
    print ("Everything seems to have worked if you are seeing this.")
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:17,代码来源:create_common_contracts.py

示例10: main

def main():
    global session
    # Setup or credentials and session
    description = ('Find the VMM Domain to use for EPGs')
    creds = Credentials('apic', description)
    args = creds.get()

    # Login to APIC
    session = Session(args.url, args.login, args.password)
    session.login()

    # Get a good Virtual Domain to use
    while True:
        if check_virtual_domain():
            break
        else:
            collect_vmmdomain()
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:17,代码来源:toolforVmm.py

示例11: send_to_apic

def send_to_apic(tenant):
    """
    Login to APIC and push the config

    :param tenant: Tenant class instance
    :return: request response object
    """
    description = 'Basic Connectivity Example'
    creds = Credentials('apic', description)
    args = creds.get()

    # Login to APIC
    session = Session(args.url, args.login, args.password, False)
    session.login()
    resp = tenant.push_to_apic(session)
    if resp.ok:
        print('Success')
    return resp
开发者ID:KarlHarrisSungardAS,项目名称:acitoolkit,代码行数:18,代码来源:aci_demo_script.py

示例12: main

def main():
    """
    Main execution routine

    :return: None
    """
    creds = Credentials('apic')
    args = creds.get()
    session = Session(args.url, args.login, args.password)
    session.login()

    tenant = Tenant('cisco')
    context = Context('ctx1', tenant)
    outside_l3 = OutsideL3('out-1', tenant)
    phyif = Interface('eth', '1', '101', '1', '46')
    phyif.speed = '1G'
    l2if = L2Interface('eth 1/101/1/46', 'vlan', '1')
    l2if.attach(phyif)
    l3if = L3Interface('l3if')
    l3if.set_l3if_type('l3-port')
    l3if.set_addr('1.1.1.2/30')
    l3if.add_context(context)
    l3if.attach(l2if)
    bgpif = BGPSession('test', peer_ip='1.1.1.1', node_id='101')
    bgpif.router_id = '172.1.1.1'
    bgpif.attach(l3if)
    bgpif.options = 'send-ext-com'
    bgpif.networks.append('0.0.0.0/0')
    contract1 = Contract('icmp')
    outside_epg = OutsideEPG('outepg', outside_l3)
    outside_epg.provide(contract1)
    outside_l3.add_context(context)
    outside_epg.consume(contract1)
    outside_l3.attach(bgpif)
    bgp_json = bgpif.get_json()

    resp = session.push_to_apic(tenant.get_url(),
                                tenant.get_json())

    if not resp.ok:
        print('%% Error: Could not push configuration to APIC')
        print(resp.text)
开发者ID:JMSrulez,项目名称:acitoolkit,代码行数:42,代码来源:aci-create-bgp-peer.py

示例13: main

def main():
    global session
    # Setup or credentials and session
    description = ('Create a number of demo application profiles.')
    creds = Credentials('apic', description)
    args = creds.get()

    # Login to APIC
    session = Session(args.url, args.login, args.password)
    session.login()

    # Get a good Virtual Domain to use
    while True:
        if check_virtual_domain():
            break
        else:
            collect_vmmdomain()

    create_base()
    create_application_profiles()

    print ("Everything seems to have worked if you are seeing this.")
开发者ID:tigelane,项目名称:cisco_aci-scripts,代码行数:22,代码来源:create_demo-APs.py

示例14: acilint

def acilint():
    """
    Main execution routine

    :return: None
    """
    description = ('acilint - A static configuration analysis tool. '
                   'Checks can be individually disabled by generating'
                   ' and editing a configuration file.  If no config '
                   'file is given, all checks will be run.')
    creds = Credentials('apic', description)
    creds.add_argument('-c', '--configfile', type=argparse.FileType('r'))
    creds.add_argument('-g', '--generateconfigfile',
                       type=argparse.FileType('w'))
    args = creds.get()

    if args.generateconfigfile:
        print 'Generating configuration file....'
        f = args.generateconfigfile
        f.write(('# acilint configuration file\n# Remove or comment out any '
                 'warnings or errors that you no longer wish to see\n'))
        methods = dir(Checker)
        for method in methods:
            if method.startswith(('warning_', 'critical_', 'error_')):
                f.write(method + '\n')
        f.close()
        sys.exit(0)

    methods = []
    if args.configfile:
        f = args.configfile
        for line in f:
            method = line.split('\n')[0]
            if method in dir(Checker) and method.startswith(('warning_', 'error_', 'critical_')):
                methods.append(method)
        f.close()
    else:
        for method in dir(Checker):
            if method.startswith(('warning_', 'error_', 'critical_')):
                methods.append(method)

    if args.snapshotfiles:
        session = FakeSession(filenames=args.snapshotfiles)
    else:
        # 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)

    checker = Checker(session)
    checker.execute(methods)
开发者ID:KarlHarrisSungardAS,项目名称:acitoolkit,代码行数:53,代码来源:acilint.py

示例15: output

    output("                                              |_|            |___/ ")
    output("                                                                   ")
    output("  == A tool to deploy physical configuration on an ACI fabric ==   \n")

# Start of the execution
if __name__ == "__main__":
    
    # Argument parsing. We use the ACI toolkit logic here, which tries to
    # retrieve credentials from the following places:
    # 1. Command line options
    # 2. Configuration file called credentials.py
    # 3. Environment variables
    # 4. Interactively querying the user
    # At the end, we should have an object args with all the necessary info.
    description = 'APIC credentials'
    creds = Credentials('apic', description)
    creds.add_argument('-i', "--input", default=None, help='Input file')
    creds.add_argument('-d', "--debug", default=None, help='Input file')
    args = creds.get()
    
    # Let's check if the user passed all relevant parameters
    if args.input is None:
        fatal("[E] Input filename missing. Please pass it using --input <filename>")
    if args.debug is not None:
        debug_enable()

    # First of all, parse the input file.
    data = parse_spreadsheet(args.input)
    
    interfaces = [] # List of interfaces to push to the fabric
    
开发者ID:datacenter,项目名称:aci-fabric-deploy,代码行数:30,代码来源:aci-fabric-deploy.py


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