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 Rn class is 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.
-
__init__
(classMeta, *namingVals)[source]¶ Relative Name (Rn) of the Mo from class meta and list of naming values
Parameters: - classMeta (cobra.mit.meta.ClassMeta) – class meta of the mo class
- namingVals (list) – list of naming values
-
classmethod
fromString
(classMeta, rnStr)[source]¶ Create a relative name object from the string form given the class meta
Parameters: - classMeta (cobra.mit.meta.ClassMeta) – class meta of the mo class
- rnStr (str) – string form of rn
Returns: Rn object
Return type:
-
meta
¶ class meta of the mo class for this Rn
Returns: class meta of the mo for this Rn Return type: cobra.mit.meta.ClassMeta
-
moClass
¶ Mo class for this Rn
Returns: Mo class for this Rn Return type: cobra.mit.mo.Mo
-
namingVals
¶ Iterator of naming values for this rn
Returns: iterator of the naming values 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]¶ 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”
-
__init__
(rns=None)[source]¶ Create a Dn from list of Rn objects.
Parameters: rns (list) – list of Rns
-
clone
()[source]¶ Return a new copy of this Dn
Returns: copy of this Dn Return type: cobra.mit.naming.Dn
-
classmethod
findCommonParent
(dns)[source]¶ Find the common parent for the given set of dn objects.
Parameters: dns (list) – list of Dn objects 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 Dn from the string form of Dn. This method parses the dn string into its constituent Rn strings and creates the Rn objects.
Parameters: dnStr (str) – string form of Dn Returns: Dn object Return type: cobra.mit.naming.Dn
-
getAncestor
(level)[source]¶ Returns the ancestor Dn based on the number of levels
Parameters: level (int) – number of levels Returns: Dn object of the ancestor as specified by the level param Return type: cobra.mit.naming.Dn
-
getParent
()[source]¶ - Returns the parent Dn, same as::
- self.getAncetor(1)
Returns: Dn object of the immediate parent Return type: cobra.mit.naming.Dn
-
isAncestorOf
(descendantDn)[source]¶ Return True if this Dn is an ancestor of the other Dn
Parameters: descendantDn (cobra.mit.naming.Dn) – Dn being compared for descendants Returns: True if this Dn is an ancestor of the other Dn else False Return type: boolean
-
isDescendantOf
(ancestorDn)[source]¶ Return True if this Dn is a descendant of the other Dn
Parameters: ancestorDn (cobra.mit.naming.Dn) – Dn being compared for ancestory Returns: True if this Dn is a descendant of the other Dn else False Return type: boolean
-
meta
¶ class meta of the mo class for this Dn
Returns: class meta of the mo for this Dn Return type: cobra.mit.meta.ClassMeta
-
moClass
¶ Mo class for this Dn
Returns: Mo class for this Dn Return type: cobra.mit.mo.Mo
-
rn
(index=None)[source]¶ Returns the Rn object at the specified index. If index is None, then the Rn of the target Mo is returned
Parameters: index (int) – index of the Rn object, this must be betwee 0 and the length of the Dn Returns: Rn object at the specified index Return type: cobra.mit.naming.Rn
-
rns
¶ Iterator for all the rns from topRoot to the target Mo
Returns: iterator of Rns in this Dn Return type: iterator
-