Example #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 main_function(self):

        # create Bridge Domain
        self.check_if_tenant_exist()
        createBridgeDomainSubnet.createBridgeDomainSubnet(
            self.mo, self.bridge_domain['name'],
            self.bridge_domain['subnet_ip'],
            self.bridge_domain['private_network'])

        # create Application
        fv_ap = createApplication.create_application(
            self.mo,
            self.application['name'],
            optional_args=self.application['optional_args'])
        self.commit_change()

        # create Application EPG
        fv_aepg = createApplicationEpg.create_application_epg(
            fv_ap,
            self.application['epg']['name'],
            optional_args=self.application['epg']['optional_args'])
        self.commit_change()

        # Add Consumed Contract to the EPG
        connectEpgContract.connect_epg_contract(fv_aepg,
                                                self.applied_contract['name'],
                                                self.applied_contract['type'])
Example #3
0
 def main_function(self):
     fv_tenant = self.check_if_tenant_exist()
     fv_ap = createApplication.create_application(fv_tenant, self.application, optional_args=self.application_optional_args)
     for epg in self.epgs:
         createApplicationEpg.create_application_epg(fv_ap, epg['name'], optional_args=epg['optional_args'])
     self.commit_change(changed_object=fv_tenant)
     for contract in self.applied_contracts:
         print '-------', contract
         fv_aepg = self.check_if_mo_exist('uni/tn-' + self.tenant + '/ap-' + self.application + '/epg-', contract['epg'], AEPg, description='Application EPG')
         connectEpgContract.connect_epg_contract(fv_aepg, contract['name'], contract['type'])
         self.commit_change(changed_object=fv_aepg)
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')
Example #5
0
 def main_function(self):
     fv_tenant = self.check_if_tenant_exist()
     fv_ap = createApplication.create_application(
         fv_tenant,
         self.application,
         optional_args=self.application_optional_args)
     for epg in self.epgs:
         createApplicationEpg.create_application_epg(
             fv_ap, epg['name'], optional_args=epg['optional_args'])
     self.commit_change(changed_object=fv_tenant)
     for contract in self.applied_contracts:
         print '-------', contract
         fv_aepg = self.check_if_mo_exist('uni/tn-' + self.tenant + '/ap-' +
                                          self.application + '/epg-',
                                          contract['epg'],
                                          AEPg,
                                          description='Application EPG')
         connectEpgContract.connect_epg_contract(fv_aepg, contract['name'],
                                                 contract['type'])
         self.commit_change(changed_object=fv_aepg)
        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()
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()
Example #8
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()
Example #9
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()