Example #1
0
def lab5(modir, tenant_name, application_name):
    """Following the lab guide, we create 3Tiers application profile"""

    vlan_model = 'dynamic'
    vm_provider = 'VMware'
    vmm_domain = 'My_vCenter'
    account_profile_name = 'administrator'

    # Create a VLAN_Pool
    create_vlan_pool(modir, tenant_name + '_VALN_Pool', vlan_model, '1001',
                     '1100')
    # Create VMM domain
    create_vmm_domain(modir,
                      vm_provider,
                      vmm_domain,
                      vlan_name=tenant_name + '_VALN_Pool',
                      vlan_mode=vlan_model)
    # Set up VMM Credential
    create_vcenter_credential(modir, vm_provider, vmm_domain,
                              account_profile_name, 'student', 'P@ssw0rd')
    # Set up VMM Controller
    create_vcenter_controller(modir,
                              vm_provider,
                              vmm_domain,
                              'ACILab',
                              '192.168.1.100',
                              'ACILab',
                              associated_credential=account_profile_name)

    # Associating EPG to vCenter Domain.
    add_vmm_domain_association(modir,
                               tenant_name,
                               application_name,
                               'Web_EPG',
                               vmm_domain,
                               deployment_immediacy='immediate',
                               resolution_immediacy='immediate')
    add_vmm_domain_association(modir,
                               tenant_name,
                               application_name,
                               'App_EPG',
                               vmm_domain,
                               deployment_immediacy='immediate',
                               resolution_immediacy='immediate')
    add_vmm_domain_association(modir,
                               tenant_name,
                               application_name,
                               'DB_EPG',
                               vmm_domain,
                               deployment_immediacy='immediate',
                               resolution_immediacy='immediate')
Example #2
0
    def main_function(self):
        # check if tenant and application both are existed.

        fv_tenant = self.check_if_tenant_exist()
        fv_ap = self.check_if_mo_exist('uni/tn-' + self.tenant + '/ap-', self.application, Ap, description='Application')

        # set self.mo to be the parent of VLAN Pool
        self.look_up_mo('uni/infra', '')
        createVlanPool.create_vlan_pool(self.mo, self.vlan, self.vlan_allocation_mode, self.vlan_range_from, self.vlan_range_to)
        self.commit_change()

        # set self.mo to be the parent of VMM Domain
        self.check_if_mo_exist('uni/vmmp-' + self.vmm_provider)
        createVcenterDomain.create_vcenter_domain(self.mo, self.vmm_domain, vlan=self.vlan, vlan_mode=self.vlan_allocation_mode)
        self.commit_change()

        # set self.mo to be the parent of vCenter Credential or vCenter Controller
        self.check_if_mo_exist('uni/vmmp-' + self.vmm_provider + '/dom-', self.vmm_domain, DomP, description='VMM Domain')
        createVcenterCredential.create_vcenter_credential(self.mo, self.vmm_credential_profile, self.vmm_user, self.vmm_password)
        vmm_ctrlrp = createVcenterController.create_vcenter_controller(self.mo, self.vcenter_controller, self.host_or_ip, self.data_center, stats_mode=self.stats_mode)
        createVcenterController.define_associated_credential(vmm_ctrlrp, 'uni/vmmp-' + self.vmm_provider + '/dom-' + self.vmm_domain + '/usracc-' + self.vmm_credential_profile)
        self.commit_change()

        for epg in self.vmm_domain_associations:
            fv_epg = self.check_if_mo_exist('uni/tn-' + self.tenant + '/ap-' + self.application + '/epg-', epg['name'], AEPg, description='EPG')
            addVmmDomainAssociation.add_vmm_domain_association(fv_epg, self.vmm_domain, optional_args=epg['optional_args'])
            self.commit_change()
    def main_function(self):

        # create Vlan Pool
        self.look_up_mo('uni/infra','')
        createVlanPool.create_vlan_pool(self.mo, self.vlan['vlan_name'], self.vlan['vlan_mode'], self.vlan['range_from'], self.vlan['range_to'])
        self.commit_change()

        # create Access Port Policy Group
        self.look_up_mo('uni/infra/funcprof/', '')
        createAccessPortPolicyGroup.create_access_port_port_policy_group(self.mo, self.configured_interfaces_pc_vpc['interface_policy_group'], optional_args={'entity_profile': self.attachable_entity_profile['name']})
        self.commit_change()

        # configure Interface PC and VPC
        self.look_up_mo('uni/infra', '')
        configureInterfacePcAndVpc.configure_interface_pc_and_vpc(self.mo, self.configured_interfaces_pc_vpc['switch_profile'], self.configured_interfaces_pc_vpc['switches'], self.configured_interfaces_pc_vpc['interface_type'], self.configured_interfaces_pc_vpc['interface_ports'], self.configured_interfaces_pc_vpc['interface_selector'], self.configured_interfaces_pc_vpc['interface_policy_group'])

        # create Attachable Access Entity profile
        createAttachableAccessEntityprofile.create_attachable_access_entity_profile(self.mo, self.attachable_entity_profile['name'], optional_args=self.attachable_entity_profile['optional_args'])
        self.commit_change()

        # create vCenter Domain
        self.check_if_mo_exist('uni/vmmp-' + self.vcenter_provider)
        vmm_domp = createVcenterDomain.create_vcenter_domain(self.mo, self.vcenter_domain, optional_args={'vlan': self.vlan['vlan_name'], 'vlan_mode': self.vlan['vlan_mode']})
        self.commit_change()

        # create Vcenter Credential and Controller
        createVcenterCredential.create_vcenter_credential(vmm_domp, self.vcenter_credential['profile'], self.vcenter_credential['vmm_user'], self.vcenter_credential['vmm_password'])
        vmm_ctrlrp = createVcenterController.create_vcenter_controller(vmm_domp, self.vcenter_controller['name'], self.vcenter_controller['host_or_ip'], self.vcenter_controller['data_center'], optional_args=self.vcenter_controller['optional_args'])
        vmm_usraccp_path = 'uni/vmmp-' + self.vcenter_provider + '/dom-' + self.vcenter_domain + '/usracc-' + self.vcenter_controller['optional_args']['associated_credential']
        createVcenterController.define_associated_credential(vmm_ctrlrp, vmm_usraccp_path)
    def main_function(self):
        # check if tenant and application both are existed.

        fv_tenant = self.check_if_tenant_exist()
        fv_ap = self.check_if_mo_exist('uni/tn-' + self.tenant + '/ap-', self.application, Ap, description='Application')

        # set self.mo to be the parent of VLAN Pool
        self.look_up_mo('uni/infra', '')
        createVlanPool.create_vlan_pool(self.mo, self.vlan, self.vlan_allocation_mode, self.vlan_range_from, self.vlan_range_to)
        self.commit_change()

        # set self.mo to be the parent of VMM Domain
        self.check_if_mo_exist('uni/vmmp-' + self.vmm_provider)
        createVmmDomain.create_vmm_domain(self.mo, self.vmm_domain, vlan=self.vlan, vlan_mode=self.vlan_allocation_mode)
        self.commit_change()

        # set self.mo to be the parent of vCenter Credential or vCenter Controller
        self.check_if_mo_exist('uni/vmmp-' + self.vmm_provider + '/dom-', self.vmm_domain, DomP, description='VMM Domain')
        createVcenterCredential.create_vcenter_credential(self.mo, self.vmm_credential_profile, self.vmm_user, self.vmm_password)
        vmm_ctrlrp = createVcenterController.create_vcenter_controller(self.mo, self.vcenter_controller, self.host_or_ip, self.data_center, stats_mode=self.stats_mode)
        createVcenterController.define_associated_credential(vmm_ctrlrp, 'uni/vmmp-' + self.vmm_provider + '/dom-' + self.vmm_domain + '/usracc-' + self.vmm_credential_profile)
        self.commit_change()

        for epg in self.vmm_domain_associations:
            fv_epg = self.check_if_mo_exist('uni/tn-' + self.tenant + '/ap-' + self.application + '/epg-', epg['name'], AEPg, description='EPG')
            addVmmDomainAssociation.add_vmm_domain_association(fv_epg, self.vmm_domain, optional_args=epg['optional_args'])
            self.commit_change()
def lab5(modir, tenant_name, application_name):
    """Following the lab guide, we create 3Tiers application profile"""

    vlan_model = 'dynamic'
    vm_provider = 'VMware'
    vmm_domain = 'My_vCenter'
    account_profile_name = 'administrator'

    # Create a VLAN_Pool
    create_vlan_pool(modir, tenant_name+'_VALN_Pool', vlan_model, '1001', '1100')
    # Create VMM domain
    create_vmm_domain(modir, vm_provider, vmm_domain, vlan_name=tenant_name+'_VALN_Pool', vlan_mode=vlan_model)
    # Set up VMM Credential
    create_vcenter_credential(modir, vm_provider, vmm_domain, account_profile_name, 'student', 'P@ssw0rd')
    # Set up VMM Controller
    create_vcenter_controller(modir, vm_provider, vmm_domain, 'ACILab', '192.168.1.100', 'ACILab', associated_credential=account_profile_name)

    # Associating EPG to vCenter Domain.
    add_vmm_domain_association(modir, tenant_name, application_name, 'Web_EPG', vmm_domain, deployment_immediacy='immediate', resolution_immediacy='immediate')
    add_vmm_domain_association(modir, tenant_name, application_name, 'App_EPG', vmm_domain, deployment_immediacy='immediate', resolution_immediacy='immediate')
    add_vmm_domain_association(modir, tenant_name, application_name, 'DB_EPG', vmm_domain, deployment_immediacy='immediate', resolution_immediacy='immediate')
    def main_function(self):

        # create Vlan Pool
        self.look_up_mo('uni/infra', '')
        createVlanPool.create_vlan_pool(self.mo, self.vlan['vlan_name'],
                                        self.vlan['vlan_mode'],
                                        self.vlan['range_from'],
                                        self.vlan['range_to'])
        self.commit_change()

        # create Access Port Policy Group
        self.look_up_mo('uni/infra/funcprof/', '')
        createAccessPortPolicyGroup.create_access_port_port_policy_group(
            self.mo,
            self.configured_interfaces_pc_vpc['interface_policy_group'],
            optional_args={
                'entity_profile': self.attachable_entity_profile['name']
            })
        self.commit_change()

        # configure Interface PC and VPC
        self.look_up_mo('uni/infra', '')
        configureInterfacePcAndVpc.configure_interface_pc_and_vpc(
            self.mo, self.configured_interfaces_pc_vpc['switch_profile'],
            self.configured_interfaces_pc_vpc['switches'],
            self.configured_interfaces_pc_vpc['interface_type'],
            self.configured_interfaces_pc_vpc['interface_ports'],
            self.configured_interfaces_pc_vpc['interface_selector'],
            self.configured_interfaces_pc_vpc['interface_policy_group'])

        # create Attachable Access Entity profile
        createAttachableAccessEntityprofile.create_attachable_access_entity_profile(
            self.mo,
            self.attachable_entity_profile['name'],
            optional_args=self.attachable_entity_profile['optional_args'])
        self.commit_change()

        # create vCenter Domain
        self.check_if_mo_exist('uni/vmmp-' + self.vcenter_provider)
        vmm_domp = createVcenterDomain.create_vcenter_domain(
            self.mo,
            self.vcenter_domain,
            optional_args={
                'vlan': self.vlan['vlan_name'],
                'vlan_mode': self.vlan['vlan_mode']
            })
        self.commit_change()

        # create Vcenter Credential and Controller
        createVcenterCredential.create_vcenter_credential(
            vmm_domp, self.vcenter_credential['profile'],
            self.vcenter_credential['vmm_user'],
            self.vcenter_credential['vmm_password'])
        vmm_ctrlrp = createVcenterController.create_vcenter_controller(
            vmm_domp,
            self.vcenter_controller['name'],
            self.vcenter_controller['host_or_ip'],
            self.vcenter_controller['data_center'],
            optional_args=self.vcenter_controller['optional_args'])
        vmm_usraccp_path = 'uni/vmmp-' + self.vcenter_provider + '/dom-' + self.vcenter_domain + '/usracc-' + self.vcenter_controller[
            'optional_args']['associated_credential']
        createVcenterController.define_associated_credential(
            vmm_ctrlrp, vmm_usraccp_path)
    create_vmm_domain(modir, vm_provider, vmm_domain, vlan=vlan,
                      vlan_mode=vlan_mode)

    # Set up VMM Credential
    if type(data['vcenter_credential']) == list:
        for credential in data['vcenter_credential']:
            create_vcenter_credential(modir, vm_provider, vmm_domain,
                                      credential['profile'],
                                      credential['user'],
                                      credential['password'])
    else:
        create_vcenter_credential(modir, vm_provider, vmm_domain,
                                  data['vcenter_credential']['profile'],
                                  data['vcenter_credential']['user'],
                                  data['vcenter_credential']['password'])

    # Set up VMM Controller
    create_vcenter_controller(modir, vm_provider, vmm_domain,
                              data['vcenter_controller']['profile'],
                              data['vcenter_controller']['host_or_ip'],
                              data['vcenter_controller']['data_center'],
                              associated_credential=data['vcenter_controller'][
                                  'associated_credential'])

    # Associating EPG to vCenter Domain.
    for epg in data['associated_epg']:
        add_vmm_domain_association(modir, tenant, application, epg['name'],
                                   vmm_domain,
                                   deployment_immediacy=epg['dep_immediacy'],
                                   resolution_immediacy=epg['res_immediacy'])
    modir.logout()
    # 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()
    vlan_pool_array = add_mos(createVlanPool.input_key_args, 'Create a Vlan pool')
    vmm_domain_provider, vmm_domain_name = createVmmDomain.input_key_args()
    vmm_domain_options = createVmmDomain.input_optional_args()
    vcenter_credential_array = add_mos(createVcenterCredential.input_key_args, 'Create a vCenter Domain Credential')
    vcenter_controller = createVcenterController.input_key_args()
    vcenter_controller_options = createVcenterController.input_optional_args()
    vmm_domain_association_array = add_mos_with_options(addVmmDomainAssociation.input_key_args, addVmmDomainAssociation.input_optional_args, 'Add a VMM Domain Association')

    # Running
    for vlan_pool in vlan_pool_array:
        createVlanPool.create_vlan_pool(modir, vlan_pool[0], vlan_pool[1], vlan_pool[2], vlan_pool[3])
    createVmmDomain.create_vmm_domain(modir, vmm_domain_provider, vmm_domain_name, args_from_CLI=vmm_domain_options)
    for vcenter_credential in vcenter_credential_array:
        createVcenterCredential.create_vcenter_credential(modir, vmm_domain_provider, vmm_domain_name, vcenter_credential[0], vcenter_credential[1], vcenter_credential[2])
    createVcenterController.create_vcenter_controller(modir, vmm_domain_provider, vmm_domain_name, vcenter_controller[0], vcenter_controller[1], vcenter_controller[2], args_from_CLI=vcenter_controller_options)
    for vmm_domain_association in vmm_domain_association_array:
        addVmmDomainAssociation.add_vmm_domain_association(modir, tenant_name, application_name, vmm_domain_association[0][0], vmm_domain_association[0][1], args_from_CLI=vmm_domain_association[1])
    modir.logout()
Example #9
0
        for credential in data['vcenter_credential']:
            create_vcenter_credential(modir, vm_provider, vmm_domain,
                                      credential['profile'],
                                      credential['user'],
                                      credential['password'])
    else:
        create_vcenter_credential(modir, vm_provider, vmm_domain,
                                  data['vcenter_credential']['profile'],
                                  data['vcenter_credential']['user'],
                                  data['vcenter_credential']['password'])

    # Set up VMM Controller
    create_vcenter_controller(modir,
                              vm_provider,
                              vmm_domain,
                              data['vcenter_controller']['profile'],
                              data['vcenter_controller']['host_or_ip'],
                              data['vcenter_controller']['data_center'],
                              associated_credential=data['vcenter_controller']
                              ['associated_credential'])

    # Associating EPG to vCenter Domain.
    for epg in data['associated_epg']:
        add_vmm_domain_association(modir,
                                   tenant,
                                   application,
                                   epg['name'],
                                   vmm_domain,
                                   deployment_immediacy=epg['dep_immediacy'],
                                   resolution_immediacy=epg['res_immediacy'])
    modir.logout()