Esempio n. 1
0
def lab4(modir, tenant_name, application_name):
    """Following the lab guide, we create 3Tiers application profile"""

    # Create a application profile
    create_application(modir, tenant_name, application_name)
    # Create three EPGs: Web_EPG, App_EPG and DB_EPG
    create_application_epg(modir,
                           tenant_name,
                           application_name,
                           'Web_EPG',
                           bridge_domain=tenant_name + '_BD1')
    create_application_epg(modir,
                           tenant_name,
                           application_name,
                           'App_EPG',
                           bridge_domain=tenant_name + '_BD1')
    create_application_epg(modir,
                           tenant_name,
                           application_name,
                           'DB_EPG',
                           bridge_domain=tenant_name + '_BD1')
    # Provide contracts between these EPGs
    connect_epg_contract(modir, tenant_name, application_name, 'Web_EPG',
                         'provided', 'Web_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'App_EPG',
                         'provided', 'App_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'DB_EPG',
                         'provided', 'DB_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'Web_EPG',
                         'consumed', 'App_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'App_EPG',
                         'consumed', 'DB_Con')
def lab4(modir, tenant_name, application_name):
    """Following the lab guide, we create 3Tiers application profile"""

    # Create a application profile
    create_application(modir, tenant_name, application_name)
    # Create three EPGs: Web_EPG, App_EPG and DB_EPG
    create_application_epg(modir, tenant_name, application_name, 'Web_EPG', bridge_domain=tenant_name+'_BD1')
    create_application_epg(modir, tenant_name, application_name, 'App_EPG', bridge_domain=tenant_name+'_BD1')
    create_application_epg(modir, tenant_name, application_name, 'DB_EPG', bridge_domain=tenant_name+'_BD1')
    # Provide contracts between these EPGs
    connect_epg_contract(modir, tenant_name, application_name, 'Web_EPG', 'provided', 'Web_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'App_EPG', 'provided', 'App_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'DB_EPG', 'provided', 'DB_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'Web_EPG', 'consumed', 'App_Con')
    connect_epg_contract(modir, tenant_name, application_name, 'App_EPG', 'consumed', 'DB_Con')
Esempio n. 3
0
        print 'Login fail.'
        sys.exit()

    # Wizard starts asking inputs step by step
    tenant_name = input_tenant_name()
    application_name = input_application_name()
    application_option = createApplication.input_optional_args()
    application_epg_array = add_mos_with_options(
        createApplicationEPG.input_key_args,
        createApplicationEPG.input_optional_args, 'Create an EPG')
    contracts_array = add_mos(connectEpgContract.input_key_args,
                              'Add a Provided/consumed Contract')

    # Running
    createApplication.create_application(modir,
                                         tenant_name,
                                         application_name,
                                         args_from_CLI=application_option)
    for application_epg in application_epg_array:
        createApplicationEPG.create_application_epg(
            modir,
            tenant_name,
            application_name,
            application_epg[0],
            args_from_CLI=application_epg[1])
    for contract in contracts_array:
        connectEpgContract.connect_epg_contract(modir, tenant_name,
                                                application_name, contract[0],
                                                contract[1], contract[2])
    modir.logout()
Esempio n. 4
0
import createApplicationEPG
import connectEpgContract

from utility import *

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()
    application_name = input_application_name()
    application_option = createApplication.input_optional_args()
    application_epg_array = add_mos_with_options(createApplicationEPG.input_key_args, createApplicationEPG.input_optional_args, 'Create an EPG')
    contracts_array = add_mos(connectEpgContract.input_key_args, 'Add a Provided/consumed Contract')

    # Running
    createApplication.create_application(modir, tenant_name, application_name, args_from_CLI=application_option)
    for application_epg in application_epg_array:
        createApplicationEPG.create_application_epg(modir, tenant_name,application_name, application_epg[0], args_from_CLI=application_epg[1])
    for contract in contracts_array:
        connectEpgContract.connect_epg_contract(modir, tenant_name, application_name, contract[0], contract[1], contract[2])
    modir.logout()
Esempio n. 5
0
from utility import *


if __name__ == '__main__':

    parser = argparse.ArgumentParser(description='Create a three tier application.')
    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']
        application = data['application']
    modir = apic_login(host, user, password)

    # create application
    create_application(modir, tenant, application)
    # create application EPG
    for epg in data['application_epg']:
        create_application_epg(modir, tenant, application, epg['name'], bridge_domain=epg['bridge_domain'])

    # Provide contracts between these EPGs
    for con in data['applied_contracts']:
        connect_epg_contract(modir, tenant, application, con['applied_epg'], con['type'], con['name'])

    modir.logout()
Esempio n. 6
0
        description='Create a three tier application.')
    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']
        application = data['application']
    modir = apic_login(host, user, password)

    # create application
    create_application(modir, tenant, application)
    # create application EPG
    for epg in data['application_epg']:
        create_application_epg(modir,
                               tenant,
                               application,
                               epg['name'],
                               bridge_domain=epg['bridge_domain'])

    # Provide contracts between these EPGs
    for con in data['applied_contracts']:
        connect_epg_contract(modir, tenant, application, con['applied_epg'],
                             con['type'], con['name'])

    modir.logout()