APIC SDK

The following services are supported by the SDK (Cobra) connector for APIC.

query

Mimics same-name function from MoDirectory class (cobra.mit.access)

QUERY arguments

Argument

Description

Default

queryObject (obj)

A query object

Mandatory

For more information please visit the Cisco APIC Python API

commit

Mimics same-name function from MoDirectory class (cobra.mit.access)

COMMIT arguments

Argument

Description

Default

configObject (obj)

The configuration request to commit

Mandatory

For more information please visit the Cisco APIC Python API

lookupByDn

Mimics same-name function from MoDirectory class (cobra.mit.access)

LOOKUPBYDN arguments

Argument

Description

Default

dnStrOrDn (obj|str)

DN of the object to lookup

Mandatory

queryParams (dict)

Dictionary containing additional filters

Optional

For more information please visit the Cisco APIC Python API

lookupByClass

Mimics same-name function from MoDirectory class (cobra.mit.access)

LOOKUPBYCLASS arguments

Argument

Description

Default

classNames (str|list)

Class name or list of classes

Mandatory

parentDn (obj|str)

DN of the parent object

None

kwargs (dict)

Dictionary containing additional filters

Optional

For more information please visit the Cisco APIC Python API

exists

Mimics same-name function from MoDirectory class (cobra.mit.access)

EXISTS arguments

Argument

Description

Default

dnStrOrDn (obj|str)

DN of the object to check

Mandatory

get_model

Automatically import the required library and return the model class

GET_MODEL arguments

Argument

Description

Default

model (str)

Unique identifier of the module and class (eg. fv.Tenant)

Mandatory

# Assuming the device is already connected
tenant_class = device.cobra.get_model(model='fv.Tenant')

create

Automatically import the required library and instantiate the model object

CREATE arguments

Argument

Description

Default

model (str)

Unique identifier of the module and class (eg. “fv.Tenant”)

Mandatory

parent_mo_or_dn (obj|str)

The parent MO or DN

Mandatory

extra_parms (dict)

Dictionary containing additional attributes for the object

Optional

# Assuming the device is already connected
tenant = device.cobra.create(model='fv.Tenant',
                             parent_mo_or_dn='uni',
                             name='test')

config_and_commit

Add MO to ConfigRequest and push it to device

CONFIG_AND_COMMIT arguments

Argument

Description

Default

mo (obj)

Object to be committed

Mandatory

expected_status_code (int)

Expected result

200

# Assuming the device is already connected
# and tenant object is created (create function)
tenant = device.cobra.config_and_commit(mo=tenant)

Additional info on the Cobra SDK can be found on the Cisco APIC Python API

Section author: Romel Tolos <rtolos@cisco.com>