Naming Module

The APIC system configuration and state are modeled as a collection of managed objects (MOs), which are abstract representations of a physical or logical entity that contain a set of configurations and properties. For example, servers, chassis, I/O cards, and processors are physical entities that are represented as MOs; resource pools, user roles, service profiles, and policies are logical entities represented as MOs.

At runtime, all MOs are organized in a tree structure, which is called the Management Information Tree (MIT). This tree provides structured and consistent access to all MOs in the system. Each MO is identified by its relative name (RN) and distinguished name (DN). You can manage MO naming by using the naming module of the Python API.

You can use the naming module to create and parse object names, as well as access a variety of information about the object, including the relative name, parent or ancestor name, naming values, meta class, or MO class. You can also perform operations on an MO such as appending an Rn to a Dn or cloning an MO.

Relative Name (RN)

A relative name (RN) identifies an object from its siblings within the context of the parent MO. An Rn is a list of prefixes and properties that uniquely identify the object from its siblings.

For example, the Rn for an MO of type aaaUser is user-john. user- is the naming prefix and john is the name value.

You can use an RN class to convert between an MO’s RN and constituent naming values.

The string form of an RN is {prefix}{val1}{prefix2}{Val2} (…)

Note

The naming value is enclosed in brackets ([]) if the meta object specifies that properties be delimited.

class cobra.mit.naming.Rn(classMeta, *namingVals)[source]

The relative name (Rn) of the managed object (MO).

You can use Rn to convert between Rn of an MO its constituent naming values. The string form of Rn is {prefix}{val1}{prefix2}{Val2} (…)

Note

The naming value is enclosed in brackets ([]) if the meta object specifies that properties be delimited.

namingVals

An interator for the naming values - readonly

Type:tupleiterator
meta

The class meta for this Rn - readonly

Type:cobra.mit.meta.ClassMeta
moClass

The class of the Mo for this Rn - readonly

Type:cobra.mit.mo.Mo
__eq__(other)[source]

Implement ==.

__ge__(other)[source]

Implement >=.

__gt__(other)[source]

Implement >.

__init__(classMeta, *namingVals)[source]

Initalize a Rn object.

Parameters:
__le__(other)[source]

Implement <=.

__lt__(other)[source]

Implement <.

__ne__(other)[source]

Implement !=.

classmethod fromString(classMeta, rnStr)[source]

Create a relative name instance from a string and classMeta.

Parameters:
Raises:

ValueError – If the Rn prefix is not valid or the Rn does not follow the proper rnFormat

Returns:

The Rn object

Return type:

cobra.mit.naming.Rn

meta

Get the meta object for this Rn.

Returns:The meta object for this Rn.
Return type:cobra.mit.meta.ClassMeta
moClass

Get the Mo class from the meta for this Rn.

Returns:The Mo class from the meta for this Rn.
Return type:cobra.mit.mo.Mo
namingVals

Get the naming vals for this Rn as an iterator.

Returns:The naming vals for this Rn.
Return type:iterator

Distinguished Name (DN)

A distinguished name (DN) uniquely identifies a managed object (MO). A DN is an ordered list of relative names, such as the following:

dn = rn1/rn2/rn3/….

In the next example, the DN provides a fully qualified path for user-john from the top of the MIT to the MO.

dn = “uni/userext/user-john”

This DN consists of these relative names:

Relative Name Class Description
uni polUni Policy universe
userext aaaUserEp User endpoint
user-john aaaUser Local user account

Note

When using the API to filter by distinguished name (DN), we recommend that you use the full DN rather than a partial DN.

class cobra.mit.naming.Dn(rns=None)[source]

A Distinguised name class.

The distinguished name (Dn) uniquely identifies a managed object (MO). A Dn is an ordered list of relative names, such as:

dn = rn1/rn2/rn3/….

In this example, the Dn provides a fully qualified path for user-john from the top of the Mit to the Mo.

dn = “uni/userext/user-john”

rns

Iterator for all the rns from topRoot to the target Mo

Type:listiterator
meta

class meta of the mo class for this Dn

Type:cobra.mit.meta.ClassMeta
moClass

Mo class for this Dn

Type:cobra.mit.mo.Mo
contextRoot

The context root for this Dn

Type:cobra.mit.mo.Mo
__eq__(other)[source]

Implement ==.

__ge__(other)[source]

Implement >=.

__gt__(other)[source]

Implement >.

__init__(rns=None)[source]

Initialize a Dn instance from list of Rn objects.

Parameters:rns (list) – list of Rns
__le__(other)[source]

Implement <=.

__lt__(other)[source]

Implement <.

__ne__(other)[source]

Implement !=.

appendRn(rn)[source]

Append an Rn to this Dn.

Note

This changes the target MO

Parameters:rn (cobra.mit.naming.Rn) – The Rn to append to this Dn
Raises:ValueError – If the Dn can not contain the Rn
clone()[source]

Get a new copy of this Dn.

Returns:Copy of this Dn
Return type:cobra.mit.naming.Dn
contextRoot

Get the Dn’s context root.

Returns:If the Dn has no context root. cobra.mit.meta.ClassMeta: The class meta for this Dn’s Rn.
Return type:None
classmethod findCommonParent(dns)[source]

Find the common parent for the given set of dn objects.

Parameters:dns (list) – The Dn objects to find the common parent of
Returns:
Dn object of the common parent if any, else Dn
for topRoot
Return type:cobra.mit.naming.Dn
classmethod fromString(dnStr)[source]

Create a distingushed name instance from a dn string.

Parses the dn string into its constituent Rn strings and creates the Rn objects.

Parameters:dnStr (str) – string form of Dn
Raises:ValueError – If an Rn in the Dn is found to not be consistent with the ACI model

Returns (cobra.mit.naming.Dn): The Dn instance

getAncestor(level)[source]

Get the ancestor Dn based on the number of levels.

Parameters:level (int) – number of levels
Returns:The Dn object of the ancestor as specified by the level argument
Return type:cobra.mit.naming.Dn
getParent()[source]

Get the parent Dn of the current Dn.

Same as:

self.getAncetor(1)
Returns:Dn object of the immediate parent
Return type:cobra.mit.naming.Dn
isAncestorOf(descendantDn)[source]

Check if a Dn is an ancestor of this Dn.

Parameters:descendantDn (cobra.mit.naming.Dn) – Dn being compared for ancestary
Returns:True if this Dn is an ancestor of the other Dn else False
Return type:bool
isDescendantOf(ancestorDn)[source]

Check if a Dn is a descendant of this Dn.

Parameters:ancestorDn (cobra.mit.naming.Dn) – Dn being compared for descendants
Returns:True if this Dn is a descendant of the other Dn else False
Return type:boo
meta

Get the meta object for this Dn.

Returns:The class meta for this Dn.
Return type:cobra.mit.meta.ClassMeta
moClass

Get the Mo class for this Dn.

Returns:The Mo class for this Dn.
Return type:cobra.mit.mo.Mo
rn(index=None)[source]

Get a Rn at a specified index.

If index is None, then the Rn of the target Mo is returned

Parameters:index (None or int) – index of the Rn object, this must be between 0 and the length of the Dn (i.e. number of Rns) or None. The default is None

Returns (cobra.mit.naming.Rn): Rn object at the specified index

rns

Get the Rn’s that make up this Dn as an iterator.

Returns:An iterator object reprsenting the Rn’s for this Dn.
Return type:iterator