aciphysobject module

API Reference

// ACI Toolkit Class Hierarchy
digraph "ACI Toolkit Class Hierarchy" {
    node [color=lightblue2 style=filled]
    edge [arrowhead=none]
    PhysicalModel [label=PhysicalModel]
    Pod [label=Pod]
    ExternalSwitch [label=ExternalSwitch]
    Link [label=Link]
    "Node " [label="Node "]
    Powersupply [label=Powersupply]
    Linecard [label=Linecard]
    Interface [label=Interface]
    Supervisorcard [label=Supervisorcard]
    Fantray [label=Fantray]
    Fan [label=Fan]
    Systemcontroller [label=Systemcontroller]
            PhysicalModel -> Pod
            Pod -> ExternalSwitch
            Pod -> Link
            Pod -> "Node "
            "Node " -> Powersupply
            Linecard -> Interface
            "Node " -> Linecard
            "Node " -> Supervisorcard
            "Node " -> Fantray
            Fantray -> Fan
            "Node " -> Systemcontroller
}

ACI Toolkit module for physical objects

class acitoolkit.aciphysobject.Cluster(name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Represents the global settings of the Cluster

Parameters:name – String containing the name of this Cluster object.
add_child(obj)

Add a child to the children list.

Parameters:obj – Child object to add to the children list of the called object.
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the Clusters from the APIC.

Returns:Instance of Cluster class.
get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_apics()
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(only_class=None)

Get a list of the immediate child objects of this object.

Parameters:only_class – Optional parameter that will be used to limit the objects returned to only those belonging to the class passed in this parameter.
Returns:List of children objects.
get_cluster_size()

reads information about the APIC cluster :return:

get_config_size()
Returns:configured size of the cluster, i.e. # of APICs
get_deep(full_data, working_data, parent=None, limit_to=(), subtree='full', config_only=False)

Gets all instances of this class from the APIC and gets all of the children as well.

Parameters:
  • full_data
  • working_data
  • parent
  • limit_to
  • subtree
  • config_only
get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json(obj_class, attributes=None, children=None, get_children=True)

Get the JSON representation of this class in the actual APIC Object Model.

Parameters:
  • obj_class – Object Class Name within the APIC model.
  • attributes – Additional attributes that should be set in the JSON.
  • children – Children objects to traverse as well.
  • get_children – Indicates whether the children objects should be included.
Returns:

JSON dictionary to be pushed to the APIC.

get_parent()
Returns:Parent of this object.
get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.ExternalSwitch(name=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysObject

External Node. This class is for switch nodes that are connected to the pod, but are not ACI nodes, i.e. are not under control of the APIC. Examples would be external layer 2 switches, external routers, or hypervisor based switches.

This class will look as much as possible like the Node class recognizing that not as much information is available to the APIC about them as is available about ACI nodes. Nearly all of the information used to create this class comes from LLDP.

add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the loose nodes from the APIC.

Parameters:
  • session – APIC session
  • parent – optional parent object of type Topology
Returns:

list of ENodes

getRole()

retrieves the node role :returns: role

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
classmethod get_event(session)

not yet fully implemented

get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Gets serial number.

Returns:serial number string
get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
role

Getter for role. :return: role

set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Fabric(session=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

This is the root class for the acitoolkit. It is a container that can hold all of the other instances of the acitoolkit classes.

From this class, you can populate all of the children classes.

Initialization method that sets up the Fabric. :return:

add_child(obj)

Add a child to the children list.

Parameters:obj – Child object to add to the children list of the called object.
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session)
Parameters:session
get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(only_class=None)

Get a list of the immediate child objects of this object.

Parameters:only_class – Optional parameter that will be used to limit the objects returned to only those belonging to the class passed in this parameter.
Returns:List of children objects.
classmethod get_deep(session, include_concrete=False)

Will return the entire tree of the fabric. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json(obj_class, attributes=None, children=None, get_children=True)

Get the JSON representation of this class in the actual APIC Object Model.

Parameters:
  • obj_class – Object Class Name within the APIC model.
  • attributes – Additional attributes that should be set in the JSON.
  • children – Children objects to traverse as well.
  • get_children – Indicates whether the children objects should be included.
Returns:

JSON dictionary to be pushed to the APIC.

get_parent()
Returns:Parent of this object.
get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Fan(parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysModule

Class for the fan of a fan tray

Initialize the basic fan.

Parameters:parent – optional parent Fantray object
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the fans from the APIC. If parent is specified, it will only get fantrays that are children of the the parent. The fantrays will also be added as children to the parent Node.

The fan object is derived mostly from the APIC ‘eqptFan’ class.

Parameters:
  • session – APIC session
  • parent – optional parent fantray of class Fantray
Returns:

list of fans

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_obj(session, apic_classes, parent_node)

Gets all of the Nodes from the APIC. This is called by the module specific get() methods. The parameters passed include the APIC object class, apic_classes, so that this will work for different kinds of modules.

Parameters:
  • parent_node – parent object or node id
  • session – APIC session to use when retrieving the nodes
  • apic_classes – The object class in APIC to retrieve
Returns:

list of module objects derived from the specified apic_classes

get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Returns the serial number. :returns: serial number string

get_slot()

Gets slot id

Returns:slot id
static get_table(modules, title='')

Will create table of fantry information :param title: :param modules:

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Fantray(pod, node, slot, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysModule

Class for the fan tray of a node

Initialize the basic object. It will create the name of the fan tray and set the type before calling the base class __init__ method :param pod: pod id :param node: node id :param slot: slot id :param parent: optional parent object

add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the fantrays from the APIC. If parent is specified, it will only get fantrays that are children of the the parent. The fantrays will also be added as children to the parent Node.

The fantray object is derived mostly from the APIC ‘eqptFt’ class.

Parameters:
  • session – APIC session
  • parent – optional parent switch of class Node
Returns:

list of fantrays

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_obj(session, apic_classes, parent_node)

Gets all of the Nodes from the APIC. This is called by the module specific get() methods. The parameters passed include the APIC object class, apic_classes, so that this will work for different kinds of modules.

Parameters:
  • parent_node – parent object or node id
  • session – APIC session to use when retrieving the nodes
  • apic_classes – The object class in APIC to retrieve
Returns:

list of module objects derived from the specified apic_classes

get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Returns the serial number. :returns: serial number string

get_slot()

Gets slot id

Returns:slot id
static get_table(modules, title='')

Will create table of fantry information :param title: :param modules:

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Interface(interface_type, pod, node, module, port, parent=None, session=None, attributes=None)

Bases: acitoolkit.acibaseobject.BaseInterface

This class defines a physical interface.

add_child(obj)

Add a child to the children list.

Parameters:obj – Child object to add to the children list of the called object.
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
classmethod create_from_name(name)
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
disable_cdp()

Disables CDP on this interface.

disable_lldp()

Disables LLDP on this interface.

enable_cdp()

Enables CDP on this interface.

enable_lldp()

Enables LLDP on this interface.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, pod_parent=None, node=None, module=None, port=None)

Gets all of the physical interfaces from the APIC if no parent is specified. If a parent of type Linecard is specified, then only those interfaces on that linecard are returned and they are also added as children to that linecard.

If the pod, node, module and port are specified, then only that specific interface is read.

If the pod and node are specified, then only those interfaces are read

Parameters:
  • session – the instance of Session used for APIC communication
  • pod_parent – Linecard instance to limit interfaces or pod number (optional)
  • node – Node id string. This specifies the switch to read. (optional)
  • module – Module id string. This specifies the module or slot of the port. (optional)
  • port – Port number. This is the port to read. (optional)
Returns:

list of Interface instances

get_adjacent_port()

This will return the port ID of the port at the other end of the link.

For Access ports, it will only have a result if it is connected to a controller node.

If no link is found, then the result will be None. That does not mean that nothing is connected, just that a fabric link is not connected.

:returns : Port ID string

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(only_class=None)

Get a list of the immediate child objects of this object.

Parameters:only_class – Optional parameter that will be used to limit the objects returned to only those belonging to the class passed in this parameter.
Returns:List of children objects.
get_deep(full_data, working_data, parent=None, limit_to=(), subtree='full', config_only=False)

Gets all instances of this class from the APIC and gets all of the children as well.

Parameters:
  • full_data
  • working_data
  • parent
  • limit_to
  • subtree
  • config_only
get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Get the json for an interface. Returns a tuple since the json is required to be sent in multiple posts. A call to get_url will return the URLs which the JSON can be sent.

Returns:Tuple containing the phys_domain, fabric, infra JSONs
get_parent()
Returns:Parent of this object.
get_port_channel_selector_json(port_name)

Get the JSON for the Port Channel selector

Parameters:port_name – String containing the port name
Returns:Dictonary containing the JSON for the Port Channel selector
get_port_selector_json()

Returns the port selector.

Returns:
get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

static get_serial()

getter for the serial number

Returns:None
get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

getter method for object.type

Returns:the type
static get_url()

Gets URLs for physical domain, fabric, and infra.

Returns:
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_cdp_disabled()

Returns whether this interface has CDP configured as disabled.

Returns:True or False
is_cdp_enabled()

Returns whether this interface has CDP configured as enabled.

Returns:True or False
is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_dn_vpc(dn)

Check if the DN is a VPC

Parameters:dn – String containing the DN
Returns:True if the the DN is a VPC. False otherwise.
is_interface()

Returns whether this instance is considered an interface.

Returns:True
is_lldp_disabled()

Returns whether this interface has LLDP configured as disabled.

Returns:True or False
is_lldp_enabled()

Returns whether this interface has LLDP configured as enabled.

Returns:True or False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
classmethod parse_dn(dn)

Parses the pod, node, module, port from a distinguished name of the interface.

Parameters:dn – String containing the interface distinguished name
Returns:interface_type, pod, node, module, port
static parse_name(name)

Parses a name that is of the form: <type> <pod>/<mod>/<port> :param name: Distinguished Name (dn)

populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
push_to_apic(session)

Push the configuration to the APIC

Parameters:session – the instance of Session used for APIC communication
Returns:Response class instance from the requests library. response.ok is True if request is sent successfully.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Linecard(arg0=None, arg1=None, slot=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysModule

class for a linecard of a switch

Initialize the basic object. It will create the name of the linecard and set the type before calling the base class __init__ method. If arg1 is an instance of a Node, then pod, and node are derived from the Node and the slot_id is from arg0. If arg1 is not a Node, then arg0 is the pod, arg1 is the node id, and slot is the slot_id

In other words, this Linecard object can either be initialized by

>>> lc = Linecard(slot_id, parent_switch)

or

>>> lc = Linecard(pod_id, node_id, slot_id)

or

>>> lc = Linecard(pod_id, node_id, slot_id, parent_switch)

Parameters:
  • arg0 – pod_id if arg1 is a node_id, slot_id if arg1 is of type Node
  • arg1 – node_id string or parent Node of type Node
  • slot – slot_id if arg1 is node_id Not required if arg1 is a Node
  • parent – parent switch of type Node. Not required if arg1 is used instead.
Returns:

None

add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the linecards from the APIC. If parent is specified, it will only get linecards that are children of the the parent. The linecards will also be added as children to the parent Node.

The lincard object is derived mostly from the APIC ‘eqptLC’ class.

Parameters:
  • session – APIC session
  • parent – optional parent of class Node
Returns:

list of linecards

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_obj(session, apic_classes, parent_node)

Gets all of the Nodes from the APIC. This is called by the module specific get() methods. The parameters passed include the APIC object class, apic_classes, so that this will work for different kinds of modules.

Parameters:
  • parent_node – parent object or node id
  • session – APIC session to use when retrieving the nodes
  • apic_classes – The object class in APIC to retrieve
Returns:

list of module objects derived from the specified apic_classes

get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Returns the serial number. :returns: serial number string

get_slot()

Gets slot id

Returns:slot id
static get_table(linecards, super_title='')

Will create table of line card information :param super_title: :param linecards:

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

Bases: acitoolkit.acibaseobject.BaseACIPhysObject

Link class, equivalent to the fabricLink object in APIC

Parameters:parent – optional parent object
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent_pod=None, node_id=None)

Gets all of the Links from the APIC. If the parent_pod is specified, only links of that pod will be retrieved. If the parent_pod is a Pod object then the links will be added as children of that pod.

If node is specified, then only links of that originate at the specific node will be returned. If node is specified, pod must be specified.

Parameters:
  • session – APIC session
  • parent_pod – Optional parent Pod object or identifier string.
  • node_id – Optional node number string
Returns:

list of links

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_node1()

Returns the Node object that corresponds to the first node of the link. The Node must be a child of the Pod that this link is a member of, i.e. it must already have been read from the APIC. This can most easily be done by populating the entire physical heirarchy from the Pod down.

Returns:Node object at first end of link
get_node2()

Returns the Node object that corresponds to the second node of the link. The Node must be a child of the Pod that this link is a member of, i.e. it must already have been read from the APIC. This can most easily be done by populating the entire physical heirarchy from the Pod down.

Returns:Node object at second end of link
get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_port1()

Returns the Interface object that corresponds to the first port of the link. The port must be a child of the Linecard in the Node in the Pod that this link is a member of, i.e. it must already have been read from the APIC. This can most easily be done by populating the entire physical heirarchy from the Pod down.

Returns:Interface object at first end of link
get_port2()

Returns the Interface object that corresponds to the second port of the link. The port must be a child of the Linecard in the Node in the Pod that this link is a member of, i.e. it must already have been read from the APIC. This can most easily be done by populating the entire physical heirarchy from the Pod down.

Returns:Interface object at second end of link
get_port_id1()

Returns the port ID of the first end of the link in the format pod/node/slot/port

Returns:port ID string
get_port_id2()

Returns the port ID of the second end of the link in the format pod/node/slot/port

Returns:port ID string
get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Gets serial number.

Returns:serial number string
get_slot1()

Returns the Linecard object that corresponds to the first slot of the link. The Linecard must be a child of the Node in the Pod that this link is a member of, i.e. it must already have been read from the APIC. This can most easily be done by populating the entire physical heirarchy from the Pod down.

Returns:Linecard object at first end of link
get_slot2()
Returns the Linecard object that corresponds to the
second slot of the link. The Linecard must be a child of

the Node in the Pod that this link is a member of, i.e. it must already have been read from the APIC. This can most easily be done by populating the entire physical heirarchy from the Pod down.

Returns:Linecard object at second end of link
get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Node(name=None, pod=None, node=None, role=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysObject

Node : roughly equivalent to fabricNode

Parameters:
  • pod – String representation of the pod number
  • node – String representation of the node number
  • name – Name of the node
  • role – Role of the node. Valid roles are None, ‘spine’, ‘leaf’, ‘controller’, ‘loosenode’
  • parent – Parent pod object of the node.
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None, node_id=None)

Gets all of the Nodes from the APIC. If the parent pod is specified, only nodes of that pod will be retrieved.

If parent pod and node_id is specified, only the matching switch will be retrieved.

APIC controller nodes will have a ‘role’ of ‘controller’, while switch nodes will have a ‘role’ of ‘leaf’ or ‘spine’

Parameters:
  • session – APIC session
  • parent – optional parent object or pod_id
  • node_id – optional node_id of switch
Returns:

list of Nodes

getFabricSt()

retrieves the fabric state.

Returns:fabric state
get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_chassis_type()

Returns the chassis type of this node. The chassis type is derived from the model number. This is a chassis type that is compatible with Cisco’s Cable Plan XML.

Returns:chassis type of node of type str
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
classmethod get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_firmware(working_data)

retrieves firmware version :param working_data:

get_from_json(data, parent=None)

returns a Tenant object from a json

get_health()

This will get the health of the switch node

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_role()

retrieves the node role :returns: role

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Gets serial number.

Returns:serial number string
static get_table(switches, title='')

Creates report of basic switch information :param switches: Array of Node objects :param title: optional title for this table

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
operSt

changed value to “oper_st” so this makes the class backward compatible :return:

populate_children(deep=False, include_concrete=False)

Will populate all of the children modules such as linecards, fantrays and powersupplies, of the node.

Parameters:
  • deep – boolean that when true will cause the entire sub-tree to be populated. When false, only the immediate children are populated
  • include_concrete – boolean to indicate that concrete objects should also be populated
Returns:

List of children objects

remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.PhysicalModel(session=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

This is the root class for the physical part of the network. It’s corrolary is the LogicalModel class. It is a container that can hold all of physical model instances. Initially this is only an instance of Pod.

From this class, you can populate all of the children classes.

Initialization method that sets up the Fabric. :return:

add_child(obj)

Add a child to the children list.

Parameters:obj – Child object to add to the children list of the called object.
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session=None, parent=None)

Method to get all of the PhysicalModels. It will get one and return it in a list. :param session: :param parent: :return: list of PhysicalModel

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(only_class=None)

Get a list of the immediate child objects of this object.

Parameters:only_class – Optional parameter that will be used to limit the objects returned to only those belonging to the class passed in this parameter.
Returns:List of children objects.
classmethod get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json(obj_class, attributes=None, children=None, get_children=True)

Get the JSON representation of this class in the actual APIC Object Model.

Parameters:
  • obj_class – Object Class Name within the APIC model.
  • attributes – Additional attributes that should be set in the JSON.
  • children – Children objects to traverse as well.
  • get_children – Indicates whether the children objects should be included.
Returns:

JSON dictionary to be pushed to the APIC.

get_parent()
Returns:Parent of this object.
get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Pod(pod, dn=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysObject

Pod : roughly equivalent to fabricPod

Initialize the basic object. It will create the name of the pod and set the type before calling the base class __init__ method. Typically the pod_id will be 1.

Parameters:
  • pod – pod id string
  • dn – distinguished name
  • parent – optional parent object
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the Pods from the APIC. Generally there will be only one.

Parameters:
  • parent – optional parent of class PhysicalModel
  • session – APIC session
Returns:

list of Pods. Note that this will be a list even though there typically will only be one item in the list.

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Gets serial number.

Returns:serial number string
get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Powersupply(pod, node, slot, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysModule

class for a power supply in a node

Initialize the basic object. It will create the name of the powersupply and set the type before calling the base class __init__ method :param pod: pod id :param node: node id :param slot: slot id :param parent: optional parent object

add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the power supplies from the APIC. If parent is specified, it will only get power supplies that are children of the the parent. The power supplies will also be added as children to the parent Node.

The Powersupply object is derived mostly from the APIC ‘eqptPsu’ class.

Parameters:
  • session – APIC session
  • parent – optional parent switch of class Node
Returns:

list of powersupplies

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_obj(session, apic_classes, parent_node)

Gets all of the Nodes from the APIC. This is called by the module specific get() methods. The parameters passed include the APIC object class, apic_classes, so that this will work for different kinds of modules.

Parameters:
  • parent_node – parent object or node id
  • session – APIC session to use when retrieving the nodes
  • apic_classes – The object class in APIC to retrieve
Returns:

list of module objects derived from the specified apic_classes

get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Returns the serial number. :returns: serial number string

get_slot()

Gets slot id

Returns:slot id
static get_table(modules, super_title='')

Will create table of power supply information :param super_title: :param modules:

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Process

Bases: acitoolkit.acibaseobject.BaseACIPhysObject

Class to hold information about a process running on a node - either switch or controller

Returns:
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent)
Parameters:
  • session
  • parent
Returns:

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Gets serial number.

Returns:serial number string
static get_table(aci_objects, title='Process')
Parameters:
  • aci_objects – list of process objects to build table for
  • title – Title of the table
Returns:

Table

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Supervisorcard(pod, node, slot, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysModule

Class representing the supervisor card of a switch

Initialize the basic object. This should be called by the init routines of inheriting subclasses.

Parameters:
  • pod – pod id
  • node – node id
  • slot – slot id
  • parent – optional parent object
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent_node=None)

Gets all of the supervisor cards from the APIC. If parent is specified, it will only get the supervisor card that is a child of the the parent Node. The supervisor will also be added as a child to the parent Node.

The Supervisorcard object is derived mostly from the APIC ‘eqptSupC’ class.

If parent_node is a str, then it is the Node id of the switch for the supervisor.

Parameters:
  • session – APIC session
  • parent_node – optional parent switch of class Node or the node id of a switch
Returns:

list of linecards

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_obj(session, apic_classes, parent_node)

Gets all of the Nodes from the APIC. This is called by the module specific get() methods. The parameters passed include the APIC object class, apic_classes, so that this will work for different kinds of modules.

Parameters:
  • parent_node – parent object or node id
  • session – APIC session to use when retrieving the nodes
  • apic_classes – The object class in APIC to retrieve
Returns:

list of module objects derived from the specified apic_classes

get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Returns the serial number. :returns: serial number string

get_slot()

Gets slot id

Returns:slot id
static get_table(modules, super_title='')

Will create table of supervisor information :param super_title: :param modules:

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.Systemcontroller(pod, node, slot, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIPhysModule

class of the motherboard of the APIC controller node

Initialize the basic object. It will create the name of the Systemcontroller and set the type before calling the base class __init__ method.

Parameters:
  • pod – pod id
  • node – node id
  • slot – slot id
  • parent – optional parent object
add_child(child_obj)

Add a child to the children list. All children must be unique so it will first delete the child if it already exists.

Parameters:child_obj – a child object to be added as a child to this object. This will be put into the _children list.
Returns:None
add_tag(tag)

Assign this object a particular tag. Tags are strings that can be used to classify objects. More than 1 tag can be assigned to an object.

Parameters:tag – string containing the tag to assign to this object or an instance of _Tag
attach(item)

Attach the object to the other object.

Parameters:item – Object to be attached.
check_parent(parent)

If a parent is specified, it will check that it is the correct class of parent If not, then an exception is raised. :param parent: :return:

check_session(session)

This will check that the session is of type Session and raise exception if it not

Parameters:session – the session to check
Returns:
delete_tag(tag)

Mark a particular tag as being deleted from this object.

Parameters:tag – string containing the tag to delete from this object or an instance of _Tag
detach(item)

Detach the object from the other object. A relationship is either ‘attached’, ‘detached’, or does not exist. A detached relationship will cause the relationship to be deleted when pushed to the APIC.

Parameters:item – Object to be detached.
exists(session, phys_obj)

Check if an apic phys_obj exists on the APIC. Returns True if the phys_obj does exist.

Parameters:
  • session – APIC session to use when accessing the APIC controller.
  • phys_obj – The object that you are checking for.
Returns:

True if the phys_obj exists, False if it does not.

find(search_object)

This will check to see if self is a match with search_object and then call find on all of the children of search. If there is a match, a list containing self and any matches found by the children will be returned as a list.

The criteria for a match is that all attributes of self are compared to all attributes of search_object. If search_object.<attr> exists and is the same as self.<attr> or search_object.<attr> is ‘None’, then that attribute matches. If all such attributes match, then there is a match and self will be returned in the result.

If there is an attribute of search_object that does not exist in self, it will be considered a mismatch. If there is an attribute of self that does not exist in search_object, it will be ignored.

Parameters:search_object – ACI object to search
Returns:List of objects
classmethod get(session, parent=None)

Gets all of the System controllers from the APIC. This information comes from the APIC ‘eqptBoard’ class.

If parent is specified, it will only get system controllers that are children of the the parent. The system controlles will also be added as children to the parent Node.

Parameters:
  • session – APIC session
  • parent – parent Node
Returns:

list of Systemcontrollers

get_all_attached(attached_class, status='attached', relation_type=None)

Get all of the relations of objects belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_all_attachments(attached_class, status='attached', relation_type=None)

Get all of the attachments to an object belonging to the specified class with the specified status.

Parameters:
  • attached_class – The class that is the subject of the search.
  • status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
get_attributes(name=None)

Will return the value of the named attribute in a dictionary format. If no name is given, then it will return all attributes.

Note that attributes that start with _ (underbar) will NOT be included unless explicitly named

This method should be over-written as appropriate by inheriting objects to handle how their local attributes are implemented.

This is intended to normalize how all attributes on all objects can be accessed since the implementations were not consistent.

Parameters:name – optional name of attribute to return
Returns:dictionary of attributes and their values
get_child(child_type, child_name)

Gets a specific immediate child of this object

Parameters:
  • child_type – Class of the child to return
  • child_name – Name of the child to return
Returns:

The specific instance of child_type or None if not found

get_children(child_type=None)

Returns the list of children. If childType is provided, then it will return all of the children of the matching type.

Parameters:child_type – This optional parameter will cause this method to return only those children that match the type of childType. If this parameter is ommitted, then all of the children will be returned.
Returns:list of children
get_deep(session, include_concrete=False)

Will return the atk object and the entire tree under it. :param session: APIC session to use :param include_concrete: flag to indicate that concrete objects should also be included :return:

get_deep_apic_classes(include_concrete=False)

Get all the apic classes needed for this acitoolkit class and all of its children. :return: list of all apic classes

get_dn_from_attributes(attributes)

Will get the dn from the attributes or construct it using the dn of the parent plus the rn. Failing those, it will return None

Parameters:attributes
Returns:String containing dn or None
get_event(session)

Gets the event that is pending for this class. Events are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_fault(session, extension='')

Gets the fault that is pending for this class. Faults are returned in the form of objects. Objects that have been deleted are marked as such.

Parameters:session – the instance of Session used for APIC communication
get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interface relations. Note that multiple classes are considered “interfaces” such as Interface, L2Interface, L3Interface, etc.

Parameters:status – Valid values are ‘attached’ and ‘detached’. Default is ‘attached’.
Returns:List of interfaces that this object has relations and the status matches.
get_json()

Returns json representation of the object

Returns:JSON of contained Interfaces
get_name()

Gets name.

Returns:Name string
get_node()

Gets node id

Returns:id of node
get_obj(session, apic_classes, parent_node)

Gets all of the Nodes from the APIC. This is called by the module specific get() methods. The parameters passed include the APIC object class, apic_classes, so that this will work for different kinds of modules.

Parameters:
  • parent_node – parent object or node id
  • session – APIC session to use when retrieving the nodes
  • apic_classes – The object class in APIC to retrieve
Returns:

list of module objects derived from the specified apic_classes

get_parent()
Returns:Parent of this object.
get_pod()

Gets pod_id :returns: id of pod

get_searchable()

Method to recursively retrieve all of the searchable items from all the children objects, add the current object to them as additional context, append the local searchable terms, and return the result.

get_serial()

Returns the serial number. :returns: serial number string

get_slot()

Gets slot id

Returns:slot id
get_table(aci_object, title='')

Abstract method that should be replaced by a version that is specific to the object

Parameters:
  • aci_object
  • title – String containing the table title
Returns:

list of Table objects

get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_type()

Gets physical object type

Returns:type string of the object.
get_url(fmt='json')

Get the URL used to push the configuration to the APIC if no fmt parameter is specified, the format will be ‘json’ otherwise it will return ‘/api/mo/uni.’ with the fmt string appended.

Parameters:fmt – optional fmt string
Returns:Nothing - physical objects are not modifiable
has_attachment(item)

Indicates whether this object is attached to the item/ :returns: True or False, True indicates the object is attached.

has_child(obj)

Check for existence of a child in the children list

Parameters:obj – Child object that is the subject of the check.
Returns:True or False, True indicates that it does indeed have the obj object as a child.
has_detachment(item)

Indicates whether the object is detached from this item. :returns: True or False, True indicates the object is detached.

has_events(session, extension='')

Check for pending events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
Returns:True or False. True if there are events pending.
has_parent()

returns True if this object has a parent

Returns:bool
has_tag(tag)

Checks whether this object has a particular tag assigned.

Parameters:tag – string containing the tag name or an instance of _Tag
Returns:True or False. True indicates the object has this tag assigned.
has_tags()

Checks whether this object has any tags assigned at all.

Returns:True or False. True indicates the object has at least one tag assigned.
info()

Node information summary.

Returns:Formatted string that has a summary of all of the info gathered about the node.
infoList()

Node information. Returns a list of (attr, value) tuples.

Returns:list of [(attr, value),]
is_attached(item)

Indicates whether the item is attached to this object/ :returns: True or False, True indicates the item is attached.

is_deleted()

Check if the object has been deleted.

Returns:True or False, True indicates the object has been deleted.
is_detached(item)

Indicates whether the item is detached from this object.

Returns:True or False, True indicates the item is detached.
is_interface()

Indicates whether this object is considered an Interface. The default is False.

Returns:False
mark_as_deleted()

Mark the object as deleted. This will cause the JSON status to be set to deleted.

mask_class_from_graphs()

Mask (hide) this class from graph creation

Returns:False indicating that this class should not be masked.
populate_children(deep=False, include_concrete=False)

Populates all of the children and then calls populate_children of those children if deep is True. This method should be overridden by any object that does have children.

If include_concrete is True, then if the object has concrete objects below it, i.e. is a switch, then also populate those conrete object.

Parameters:
  • include_concrete – True or False. Default is False
  • deep – True or False. Default is False.
remove_child(obj)

Remove a child from the children list

Parameters:obj – Child object that is to be removed.
remove_tag(tag)

Remove a particular tag from being assigned to this object. Note that this does not delete the tag from the APIC.

Parameters:tag – string containing the tag to remove from this object or an instance of _Tag
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
subscribe(session, extension='', only_new=False)

Subscribe to events from the APIC that pertain to instances of this class.

Parameters:
  • session – the instance of Session used for APIC communication
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
subscribe_to_fault_instances_subtree(session, extension='', deep=False)

Subscribe to faults instances for the whole subtree.

Parameters:
  • session – the instance of Session used for APIC communication
  • extension – Optional string that can be used to extend the URL
  • only_new – Boolean indicating whether to get all events or only the new events. All events (indicated by setting only_new to False) will queue a create event for all of the currently existing objects. Setting only_new to True will only queue events that occur after the initial subscribe. The default has only_new set to False.
unsubscribe(session)

Unsubscribe for events from the APIC that pertain to instances of this class.

Parameters:session – the instance of Session used for APIC communication
update_db(session, subscribed_classes, deep=False)
Parameters:
  • session – Session class instance representing the connection to the APIC
  • subscribed_classes – List of subscribed classes
  • deep – Boolean indicating whether to go deep or not. Default is False
Returns:

List of subscribed classes

class acitoolkit.aciphysobject.WorkingData(session=None, toolkit_class=None, url=None, deep=False, include_concrete=False)

Bases: object

This class will hold the entire json tree from topSystem down, for a switch. The attributes of a specific class can be retrieved in which case it will be as a list of objects. It will allow all children of an object to be retrieved result is list of objects It will allow an instance of a class to be retrieved returned as a single object.

add(session=None, toolkit_class=None, url=None, deep=False, include_concrete=False)
Parameters:
  • session
  • toolkit_class
  • url
  • deep
  • include_concrete
Returns:

build_vnid_dictionary()

Will build a dictionary that is indexed by vnid and will return context or bridge_domain and the name of that segment. :param self:

get_class(class_name)

returns all the objects of a given class :param class_name: The name of the class you are looking for.

get_object(dname)

Will return the object specified by dn. :param dname: Distinguished Name (dn)

get_subtree(class_name, dname)

will return list of matching classes and their attributes

It will get all classes that are classes under dn. :param class_name: name of class you are looking for :param dname: Distinguished Name (dn)

Future Work

Future work items to be added to aciphysobject include:

  • Add an events sub-object. This would work similarly to the stats object.
  • Add a top level object called Topology that would have Pod as its child. This object would also contain devices attached to the fabric, so called loose nodes, external links, and discovered end-points.