How to use the cobra.mit.request.ConfigRequest function in cobra

To help you get started, we’ve selected a few cobra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datacenter / cobra / tests / rest / test_rest.py View on Github external
def test_createtenant(self, moDir, tenantname):
        """
        create a tenant and commit it
        """
        dcid = str(time.time()).replace('.', '')

        polUni = cobra.model.pol.Uni('')
        tenant = cobra.model.fv.Tenant(polUni, tenantname[0])

        configRequest = cobra.mit.request.ConfigRequest()
        configRequest.addMo(tenant)
        configRequest.subtree = 'full'
        configRequest.id = dcid

        mos = moDir.commit(configRequest)
        assert mos

        mo = mos[0]
        assert len(mos) > 0
        assert str(mo.dn) == str(tenant.dn)
        assert len(list(mo.children)) >= 1
github datacenter / cobra / tests / mit / test_session_CertSession.py View on Github external
def test_post_cert_to_local_user(self, moDir, certobject, userobject):
        # Update the user object with the cert data
        userobject.aaaUserCert.data = certobject.readFile(
            fileName=certobject.certfile)
        # Commit the user to the APIC with the cert
        cr = ConfigRequest()
        cr.addMo(userobject.aaaUser)
        r = moDir.commit(cr)
        assert r.status_code == 200
github datacenter / cobra / tests / mit / test_request.py View on Github external
def test_ConfigRequest_getUrl(self, sessionUrl, mo, requestType):
        session = LoginSession(sessionUrl, 'admin', 'password',
                               requestFormat=requestType)
        expected = sessionUrl + '/api/mo/' + str(mo.dn) + '.' + requestType
        cr = ConfigRequest()
        cr.addMo(mo)
        assert cr.getUrl(session) == expected
github datacenter / cobra / tests / mit / test_request.py View on Github external
def test_ConfigRequest_removeMo_no_configMos_left(self):
        fvTenant = Tenant('uni', 'testing')
        fvnsVlanInstP = VlanInstP('uni/infra', 'namespace1', 'dynamic')
        cr = ConfigRequest()
        cr.addMo(fvTenant)
        cr.removeMo(fvTenant)
        assert not cr.hasMo(fvTenant.dn)
github datacenter / ACI / configuration-python / Lab3 / utility.py View on Github external
def commit_change(modir, changed_object):
    """Commit the changes to APIC"""
    config_req = ConfigRequest()
    config_req.addMo(changed_object)
    modir.commit(config_req)
github datacenter / cobra / docs / source / api-examples / tenants.py View on Github external
print('Creating Application Profile: %s' % app['name'])
            fvApMo = Ap(fvTenantMo, app['name'])
            
            # Create EPGs 
            for epg in app['epgs']:
                
                print("Creating EPG: %s..." % (epg['name'])) 
                fvAEPgMo = AEPg(fvApMo, epg['name'])
                
                # Associate EPG to Bridge Domain 
                RsBd(fvAEPgMo, tnFvBDName=tenant['bd'])
                # Associate EPG to VMM Domain
                RsDomAtt(fvAEPgMo, vmmDomPMo.dn)

        # Commit each tenant seperately
        tenantCfg = ConfigRequest()
        tenantCfg.addMo(fvTenantMo)
        moDir.commit(tenantCfg)
    print('All done!')
github CiscoDevNet / aci-learning-labs-code-samples / apic_fabric_setup / create_snv_apps.py View on Github external
bd_snv = cobra.model.fv.BD(tenant_snv, name='antigravity')
	bd_snv_vrf = cobra.model.fv.RsCtx(bd_snv, tnFvCtxName='Superverse')
	bd_snv_subnet = cobra.model.fv.Subnet(bd_snv, ip='10.2.10.1/23')

	contracts = (('web', 'http', 'tcp', '80', 'context'), ('database', 'sql', 'tcp', '1433', 'application-profile'))
	for contract in contracts:
		create_contract(tenant_snv, contract[1], contract[2], contract[3], contract[0], contract[4])

	app_names = (('Evolution_X', 'vlan-121', 'vlan-122'),
				 ('Rescue', 'vlan-123', 'vlan-124'),
				 ('Chaos', 'vlan-125', 'vlan-126'),
				 ('Power_Up', 'vlan-127', 'vlan-128'))
	for app in app_names:
		create_app(tenant_snv, app[0], bd_snv, app[1], app[2])

	config_request = cobra.mit.request.ConfigRequest()
	config_request.addMo(tenant_snv)
	session.commit(config_request)
github datacenter / ACI / configuration-python / generic_code / apicPython / createMo.py View on Github external
def commit_change(self, changed_object=None, print_xml=True, pretty_print=True):
        """Commit the changes to APIC"""
        changed_object = self.mo if changed_object is None else changed_object
        if print_xml:
            print_query_xml(changed_object, pretty_print=pretty_print)
        config_req = ConfigRequest()
        config_req.addMo(changed_object)
        self.modir.commit(config_req)
github datacenter / cobra / cobra / mit / request.py View on Github external
def __init__(self):

        super(ConfigRequest, self).__init__()
        self.__options = {}
        self.__ctxRoot = None
        self.__configMos = {}
        self.__rootMo = None
        self.uriBase = "/api/mo"