示例#1
0
def lab2(modir, tenant_name):
    """Following the Lab Guide, we create a tenant"""

    #  SystemExit:. The tenant is defined by the user.
    create_tenant(modir, tenant_name)
    # Add two security domain
    add_security_domain(modir, tenant_name, 'all')
    add_security_domain(modir, tenant_name, 'mgmt')
    # Create private network
    private_l3_network = tenant_name+'_VRF'
    add_private_l3_network(modir, tenant_name, private_l3_network)
    # Create two bridge domains. Each one contains one subnet.
    add_bridge_domain_subnet(modir, tenant_name, tenant_name+'_BD1', '10.10.10.1/24', private_l3_network)
    add_bridge_domain_subnet(modir, tenant_name, tenant_name+'_BD2', '20.20.20.1/24', private_l3_network)
示例#2
0
        description='Create a Tenant with a config file in yaml.')
    parser.add_argument('yaml', help='Imported yaml file.')
    args = vars(parser.parse_args())

    try:
        data = read_config_yaml_file(args['yaml'], login_info=False)
    except IOError:
        print 'No such file or directory:', args['yaml']
        sys.exit()
    else:
        host, user, password = get_login_info(data)
        tenant = data['tenant']
        private_l3_network = data['private_network']
    modir = apic_login(host, user, password)

    #  SystemExit:. The tenant is defined by the user.
    create_tenant(modir, tenant)

    # Add security domains
    for i in data['security_domain']:
        add_security_domain(modir, tenant, i)

    # Create private network
    add_private_l3_network(modir, tenant, private_l3_network)

    # Create two bridge domains. Each one contains one subnet.
    for i in data['bridge_domain']:
        add_bridge_domain_subnet(modir, tenant, i['name'], i['subnet_ip'],
                                 private_l3_network)
    modir.logout()
示例#3
0

if __name__ == '__main__':

    # Login
    hostname, username, password = input_login_info(msg='')
    try:
        modir = apic_login(hostname, username, password)
        print 'Login succeed.'
    except KeyError:
        print 'Login fail.'
        sys.exit()

    # Wizard starts asking inputs step by step
    tenant_name = input_tenant_name()
    security_domain_array = add_mos(addSecurityDomain.input_key_args, 'Add a Security Domain')
    network_array = add_mos(addPrivateL3Network.input_key_args, 'Add a Private L3 Network')
    bridge_domain_array = add_mos(addBridgeDomainSubnet.input_key_args, 'Add a Bridge Domain')

    # Running
    createEmptyTenant.create_tenant(modir, tenant_name)
    for security_domain in security_domain_array:
        addSecurityDomain.add_security_domain(modir, tenant_name, security_domain)
    for network in network_array:
        addPrivateL3Network.add_private_l3_network(modir, tenant_name, network)
    for bridge_domain in bridge_domain_array:
        bridge_domain_name, subnet_ip, network_name = bridge_domain
        addBridgeDomainSubnet.add_bridge_domain_subnet(modir, tenant_name, bridge_domain_name, subnet_ip, network_name)

    modir.logout()
示例#4
0
    parser = argparse.ArgumentParser(description="Create a Tenant with a config file in yaml.")
    parser.add_argument("yaml", help="Imported yaml file.")
    args = vars(parser.parse_args())

    try:
        data = read_config_yaml_file(args["yaml"], login_info=False)
    except IOError:
        print "No such file or directory:", args["yaml"]
        sys.exit()
    else:
        host, user, password = get_login_info(data)
        tenant = data["tenant"]
        private_l3_network = data["private_network"]
    modir = apic_login(host, user, password)

    #  SystemExit:. The tenant is defined by the user.
    create_tenant(modir, tenant)

    # Add security domains
    for i in data["security_domain"]:
        add_security_domain(modir, tenant, i)

    # Create private network
    add_private_l3_network(modir, tenant, private_l3_network)

    # Create two bridge domains. Each one contains one subnet.
    for i in data["bridge_domain"]:
        add_bridge_domain_subnet(modir, tenant, i["name"], i["subnet_ip"], private_l3_network)
    modir.logout()