Managed Object (MO) Module

A Managed Object (MO) is an abstract representation of a physical or logical entity that contain a set of configurations and properties, such as a server, processor, or resource pool. The MO module represents MOs.

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

Accessing Properties

When you create a managed object (MO), you can access properties as follows:

userMo = User('uni/userext', 'george')
userMo.firstName = 'George'
userMo.lastName = 'Washington'

Managing Properties

You can use the following methods to manage property changes on a managed object (MO):
  • dirtyProps-Returns modified properties that have not been committed.
  • isPropDirty-Indicates if there are unsaved changes to the MO properties.
  • resetProps-Resets MO properties, discarding uncommitted changes.

Verifying Object Status

You can use the status property to access the status of the Mo.

class cobra.mit.mo.Mo(parentMoOrDn, markDirty, *namingVals, **creationProps)[source]

Represents managed objects (MOs).

Managed objects (MOs) represent a physical or logical entity with a set of configurations and properties.

dn

The distinguished name (Dn) of the managed object (MO) - readonly

Type:cobra.mit.naming.Dn
rn

The relative name (Rn) of the managed object (MO) - readonly

Type:cobra.mit.naming.Rn
status

The status of the MO - readonly

Type:cobra.internal.base.moimpl.MoStatus
parentDn

The parent managed object (MO) distinguished name (Dn) - readonly

Type:cobra.mit.naming.Dn
parent

The parent managed object (MO) - readonly

Type:cobra.mit.mo.Mo
dirtyProps

modified properties that have not been committed - readonly

Type:set
children

A container for the children of this managed object - readonly

Type:cobra.internal.base.moimpl.BaseMo._ChildContainer
numChildren

The number of direct decendents for this managed object - readonly

Type:int
contextRoot

The managed object that is the context root for this managed object

Type:None or cobra.mit.mo.Mo
__getattr__(propName)[source]

Implement getattr().

__init__(parentMoOrDn, markDirty, *namingVals, **creationProps)[source]

Initialize a managed object (MO).

This should not be called directly. Instead initialize the Mo from the model that you need.

Parameters:
  • parentMoOrDn (str or cobra.mit.naming.Dn or cobra.mit.mo.Mo) – The parent managed object (MO) or distinguished name (Dn).
  • markDirty (bool) – If True, the MO is marked has having changes that need to be committed. If False the Mo is not marked as having changes that need to be committed.
  • *namingVals – Required values that are used to name the Mo, i.e. they become part of the MOs distinguished name.
  • **creationProps – Properties to be set at the time the MO is created, these properties can also be set after the property is created if needed.
Raises:

NotImplementedError – If this class is called directly

__setattr__(propName, propValue)[source]

Implement setattr().

children

Get the children iterator.

Returns:An iterator for the children of this Mo.
Return type:iterator
contextRoot

Get the context root of the distinguished name.

Returns:If the Dn has no context root. cobra.mit.mo.Mo: The managed object that is the context root for
this managed object if the Dn has a context root.
Return type:None
delete()[source]

Mark the Mo ad deleted.

If this mo is committed, the corresponding mo in the backend will be deleted.

dirtyProps

Get the properties that are marked as dirty.

Returns:The set of properties that are dirty.
Return type:set
dn

Get the distinguished name.

Returns:The Dn for this Mo.
Return type:cobra.mit.naming.Dn
isPropDirty(propName)[source]

Check if a property has been modified on this managed object.

Parameters:propName (str) – The property name as a string
Returns:
True if the property has been modified and not commited, False
otherwise
Return type:bool
numChildren

Get the number of children.

Returns:The number of children that this Mo has.
Return type:int
parent

Get the parent Mo.

Returns:The parent Mo.
Return type:cobra.mit.mo.Mo
parentDn

Get the parent distinguished name.

Returns:The parent Dn.
Return type:cobra.mit.naming.Dn
resetProps()[source]

Reset the managed object (MO) properties.

This will discard uncommitted changes.

rn

Get the relative name.

Returns:The relative name for this Mo.
Return type:cobra.mit.naming.Rn
status

Get the status.

Returns:The status for this Mo.
Return type:cobra.internal.base.moimpl.MoStatus