acitoolkit module

// ACI Toolkit Class Hierarchy
digraph "ACI Toolkit Class Hierarchy" {
    node [color=lightblue2 style=filled]
    edge [arrowhead=none]
    ContractSubject [label=ContractSubject]
    OutputTerminal [label=OutputTerminal]
    EPG [label=EPG]
    IPEndpoint [label=IPEndpoint]
    Filter [label=Filter]
    AppProfile [label=AppProfile]
    OutsideL3 [label=OutsideL3]
    Tag [label=Tag]
    AttributeCriterion [label=AttributeCriterion]
    Taboo [label=Taboo]
    Endpoint [label=Endpoint]
    Tenant [label=Tenant]
    Context [label=Context]
    OutsideEPG [label=OutsideEPG]
    Fabric [label=Fabric]
    LogicalModel [label=LogicalModel]
    Contract [label=Contract]
    FilterEntry [label=FilterEntry]
    BridgeDomain [label=BridgeDomain]
    Subnet [label=Subnet]
    OutsideL2 [label=OutsideL2]
    OutsideL2EPG [label=OutsideL2EPG]
    ContractInterface [label=ContractInterface]
    OutsideNetwork [label=OutsideNetwork]
    InputTerminal [label=InputTerminal]
    AnyEPG [label=AnyEPG]
    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]
            ContractSubject -> OutputTerminal
            EPG -> IPEndpoint
            ContractSubject -> Filter
            AppProfile -> EPG
            OutsideL3 -> Tag
            EPG -> AttributeCriterion
            Taboo -> ContractSubject
            EPG -> Endpoint
            Tenant -> Context
            OutsideEPG -> Tag
            Fabric -> LogicalModel
            Contract -> FilterEntry
            BridgeDomain -> Subnet
            OutsideL2 -> OutsideL2EPG
            Tenant -> ContractInterface
            Contract -> ContractSubject
            Context -> Tag
            OutsideEPG -> OutsideNetwork
            BridgeDomain -> Tag
            Tenant -> Filter
            Tenant -> Tag
            Filter -> Tag
            LogicalModel -> Tenant
            Tenant -> Taboo
            ContractSubject -> InputTerminal
            OutsideL3 -> OutsideEPG
            EPG -> Tag
            Taboo -> FilterEntry
            Context -> AnyEPG
            OutsideL2 -> Tag
            Tenant -> AppProfile
            Tenant -> OutsideL3
            Filter -> FilterEntry
            Tenant -> Contract
            Tenant -> OutsideL2
            Fabric -> PhysicalModel
            Contract -> Tag
            Tenant -> BridgeDomain
            PhysicalModel -> Pod
            Pod -> ExternalSwitch
            Pod -> Link
            Pod -> "Node "
            "Node " -> Powersupply
            Linecard -> Interface
            "Node " -> Linecard
            "Node " -> Supervisorcard
            "Node " -> Fantray
            Fantray -> Fan
            "Node " -> Systemcontroller
}

Main ACI Toolkit module This is the main module that comprises the ACI Toolkit.

class acitoolkit.acitoolkit.AnyEPG(epg_name, parent=None)

Bases: acitoolkit.acitoolkit.CommonEPG

AnyEPG class, roughly equivalent to vz:Any

Parameters:
  • epg_name – String containing the name of this EPG
  • parent – Instance of the AppProfile class representing the Application Profile where this EPG is contained.
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:
consume(contract)

Make this EPG consume a Contract

Parameters:contract – Contract class instance to be consumed by this EPG.
Returns:True
consume_cif(contract_interface)

Make this EPG consume a ContractInterface

Parameters:contract_interface – ContractInterface class instance to be consumed by this EPG.
Returns:True
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.
does_consume(contract)

Check if this EPG consumes a specific Contract

Parameters:contract – Instance of Contract class to check if it is consumed by this EPG.
Returns:True or False. True if the EPG does consume the Contract.
does_consume_cif(contract_interface)

Check if this EPG consumes a specific Contract

Parameters:contract_interface
Returns:True or False. True if the EPG does consume the ContractInterface.
does_protect(taboo)

Check if this EPG is protected by a specific Taboo.

Parameters:taboo – Instance of Taboo class to check if it protects this EPG.
Returns:True or False. True if the EPG is protected by the Taboo.
does_provide(contract)

Check if this EPG provides a specific Contract.

Parameters:contract – Instance of Contract class to check if it is provided by this EPG.
Returns:True or False. True if the EPG does provide the Contract.
dont_consume(contract)

Make this EPG not consume a Contract. It does not check to see if the Contract was already consumed

Parameters:contract – Instance of Contract class to be no longer consumed by this EPG.
Returns:True
dont_consume_cif(contract_interface)

Make this EPG not consume a ContractInterface. It does not check to see if the ContractInterface was already consumed

Parameters:contract_interface
Returns:True
dont_protect(taboo)

Make this EPG not protected by a Taboo

Parameters:taboo – Instance of Taboo class to no longer protect this EPG.
Returns:True
dont_provide(contract)

Make this EPG not provide a Contract

Parameters:contract – Instance of Contract class to be no longer provided by this EPG.
Returns:True
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
get(session, parent=None, tenant=None)

Gets all of the EPGs from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • parent – Instance of the AppProfile class used to limit the EPGs retreived from the APIC.
  • tenant – Instance of Tenant class used to limit the EPGs retreived from the APIC.
Returns:

List of CommonEPG instances (or EPG instances if called from EPG 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_all_consumed(deleted=False)

Get all of the Contracts consumed by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are consumed or that the consumed was marked as deleted
Returns:List of Contract objects that are consumed by the EPG.
get_all_consumed_cif(deleted=False)

Get all of the ContractInterfaces consumed by this EPG

Parameters:deleted – Boolean indicating whether to get ContractInterfaces that are consumed or that the consumed was marked as deleted
Returns:List of ContractInterface objects that are consumed by the EPG.
get_all_protected(deleted=False)

Get all of the Taboos protecting this EPG

Parameters:deleted – Boolean indicating whether to get Taboos that are protected or that the protected was marked as deleted
Returns:List of Taboo objects that are protecting the EPG.
get_all_provided(deleted=False)

Get all of the Contracts provided by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are provided or that the provided was marked as deleted
Returns:List of Contract objects that are provided by the EPG.
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 interfaces that this EPG is attached. The default is to get list of ‘attached’ interfaces. If ‘status’ is set to ‘detached’ it will return the list of detached Interface objects (Those EPGs which are no longer attached to an Interface, but the configuration is not yet pushed to the APIC.)

Parameters:status – ‘attached’ or ‘detached’. Defaults to ‘attached’.
Returns:List of Interface objects
get_json()

Returns json representation of the EPG

Returns:json dictionary of the EPG
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.
protect(taboo)

Make this EPG protected by a Taboo

Parameters:taboo – Instance of Taboo class to protect this EPG.
Returns:True
provide(contract)

Make this EPG provide a Contract

Parameters:contract – Instance of Contract class to be provided by this EPG.
Returns:True
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.acitoolkit.AppProfile(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

The AppProfile class is used to represent the Application Profiles within the acitoolkit object model. In the APIC model, this class is roughly equivalent to the fvAp class.

Parameters:
  • name – String containing the Application Profile name
  • parent – An instance of Tenant class representing the Tenant which contains this Application Profile.
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, tenant)

Gets all of the Application Profiles from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant used to limit the Application Profiles retreived from the APIC
Returns:

List of AppProfile objects

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()

Returns json representation of the AppProfile object.

Returns:json dictionary of fvAp
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.

static get_table(app_profiles, title='')

Will create table of app_profile information for a given tenant

Parameters:
  • title
  • app_profiles
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.acitoolkit.AttributeCriterion(name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

AttributeCriterion : roughly equivalent to fvCrtrn

Initializes the AttributeCriterion with a name and optionally an EPG parent

Parameters:
  • name – String containing the AttributeCriterion name
  • parent – Instance of the EPG class representing where this AttributeCriterion is defined
Returns:

Instance of AttributeCriterion class

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_ip_address(ip_addr)

Add an IP address as an attribute

Parameters:ip_addr – String containing the IP address
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_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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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(full_data, working_data, parent=None, limit_to=(), subtree='full', config_only=False)
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_ip_addresses()

return the list of IP addresses

get_json()

Returns JSON representation of the AttributeCriterion :return:

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.
match

Return the match property :return: String containing the match property. Possible values are ‘any’ or ‘all’

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.acitoolkit.BGPSession(name, router_id=None, peer_ip=None, node_id=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Creates an BGP router interface that can be attached to a L3 interface. This interface defines the BGP AS, authentication, etc.

Parameters:
  • name – String containing the name of this BGPSession object.
  • router_id – String containing the IPv4 router-id
  • peer_ip – String containing the IP address of the BGP peer Default is None.
  • node_id – String Containing the node-id (e.g. ‘101’)
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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()

Returns json representation of BGPSession

Returns:json dictionary of BGP Session
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.

static is_bgp()
Returns:True if this interface is an BGP interface. In the case of BGPSession instances, this is always True.
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()

Returns whether this instance is considered an interface.

Returns:True
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.acitoolkit.BaseContract(contract_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

BaseContract : Base class for Contracts and Taboos

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_all_filter_entries(direction='bidirectional-only')

Get all of the filter entries contained within this Contract/Taboo

Parameters:direction – String containing the type of filter entries to gather Valid values are ‘bidirectional-only’, ‘input-only’, ‘output-only’, ‘all’ Default is ‘bidirectional-only’
Returns:List of FilterEntry instances
get_attributes(name=None)
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()

Returns json representation of the contract

Returns:json dictionary of the contract
get_parent()
Returns:Parent of this object.
get_scope()

Get the scope of this contract. Valid values are ‘context’, ‘global’, ‘tenant’, and ‘application-profile’

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.

classmethod mask_class_from_graphs()
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
set_scope(scope)

Set the scope of this contract. Valid values are ‘context’, ‘global’, ‘tenant’, and ‘application-profile’

Parameters:scope – String containing one of the following ‘context’, ‘global’, ‘tenant’, or ‘application-profile’
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.acitoolkit.BaseMonitorClass

Bases: object

Base class for monitoring policies. These are methods that can be used on all monitoring objects.

add_collection_policy(coll_obj)

Add a collection policy.

Parameters:coll_obj – A collection policy object of type CollectionPolicy
add_stats(stat_obj)

Adds a stats family object.

Parameters:stat_obj – Statistics family object of type MonitorStats.
add_target(target_obj)

Add a target object.

Parameters:target_obj – target object of type MonitorTarget
get_parent()
Returns:parent object
isModified()

Returns True if this policy and any children have been modified or created and not been written to the APIC

remove_collection_policy(collection)

Remove a collection_policy object. The object to remove is identified by its granularity, e.g. ‘5min’, ‘15min’, etc. This string can be found in the ‘CollectionPolicy.granularity’ attribute of the object.

Parameters:collection – CollectionPolicy to remove.
remove_stats(stats_family)

Remove a stats family object. The object to remove is identified by a string, e.g. ‘ingrPkts’, or ‘egrTotal’. This string can be found in the ‘MonitorStats.scope’ attribute of the object.

Parameters:stats_family – Statistics family string.
remove_target(target)

Remove a target object. The object to remove is identified by a string, e.g ‘l1PhysIf’. This string can be found in the ‘MonitorTarget.scope’ attribute of the object.

Parameters:target – target to remove.
set_description(description)
Sets the description of the MonitorStats.
Parameters:description – String to use as the description
set_name(name)
Sets the name of the MonitorStats.
Parameters:name – String to use as the name
class acitoolkit.acitoolkit.BaseSubnet(name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Base class for Subnet and OutsideNetwork

Parameters:
  • name – String containing the name of this instance.
  • parent – An instance of the parent class.
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
addr

Subnet address

Returns:String containing the subnet default gateway IP address and mask e.g. “1.2.3.4/24”
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
get_addr()

Get the subnet address

Returns:The subnet address as a string in the form of <ipaddr>/<mask>
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)
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(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_scope()

Get the subnet scope

Returns:The subnet scope as a 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_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),]
ip

IP address of the subnet in the form of Address/mask e.g. 10.1.1.1/16

Returns:String containing the IP address
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_addr(addr)

Set the subnet address

Parameters:addr – The subnet default gateway address as a string in the form of <ipaddr>/<mask>
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
set_scope(scope)

Set the subnet scope

Parameters:scope – String containing the subnet scope
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.acitoolkit.BaseTerminal(terminal_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Base class for Input terminal and output terminal

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_filter(filter_obj)

Add Filter to the Terminal, roughly equivalent to vzRsFiltAtt

Parameters:filter_obj – Instance of Filter class. Represents a Filter that is added to the Terminal. Multiple Filters can be assigned to a single Terminal.
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_filters()

Get all of the filters that are attached to this Terminal.

Returns:List of Filter objects
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 Terminal Object

Returns:json dictionary of the ContractSubject
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.

classmethod mask_class_from_graphs()
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.acitoolkit.BridgeDomain(bd_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

BridgeDomain : roughly equivalent to fvBD

Parameters:
  • bd_name – String containing the name of this BridgeDomain object.
  • parent – An instance of Tenant class representing the Tenant which contains this BridgeDomain.
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_context(context)

Set the Context for this BD

Parameters:context – Context to assign this BridgeDomain
add_l3out(l3out)

Set the L3Out for this BD

Parameters:l3out – OutsideL3 to assign this BridgeDomain
add_subnet(subnet)

Add a subnet to this BD.

Parameters:subnet – Instance of Subnet class to add to this BridgeDomain.
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, tenant)

Gets all of the Bridge Domains from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant used to limit the BridgeDomain instances retreived from the APIC
Returns:

List of BridgeDomain objects

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_arp_flood()

Get the ARP flooding policy for this BD

Returns:a string containing the ARP flooding policy of the BridgeDomain
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_context()

Get the Context for this BD

Returns:Instance of Context class that this BridgeDomain is assigned.
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
static 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 bridge domain

Returns:json dictionary of bridge domain
get_l3out()
Returns:List of OutsideL3 objects
get_mac()

Get the mac address for the BD

Returns:string containing the mac address of the BD (e.g. 00:22:BD:F8:19:FF)
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_subnets()

Get all of the subnets on this BD.

Returns:List of Subnet instances assigned to this BridgeDomain.
static get_table(bridge_domains, title='')

Will create table of context information

Parameters:
  • title
  • bridge_domains
get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
get_unicast_route()

Get the Unicast Routing policy for this BD

Returns:a string containing the unicast routing policy of the BridgeDomain
get_unknown_mac_unicast()

Gets the unknown mac unicast for this BD

Returns:unknown mac unicast of the BridgeDomain
get_unknown_multicast()

Gets the unknown multicast for this BD

Returns:unknown multicast of the BridgeDomain
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_context()

Check if the Context has been set for this BD

Returns:True or False. True if this BridgeDomain is assigned to a Context.
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_l3out()

Check if this BD has an OutsideL3 :return: True if the BD has an OutsideL3 configured. False, otherwise.

has_parent()

returns True if this object has a parent

Returns:bool
has_subnet(subnet)

Check if the BD has this particular subnet.

Parameters:subnet
Returns:True or False. True if this BridgeDomain has this particular Subnet.
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_arp_flood()

Check if ARP flooding is enabled

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
is_unicast_route()

Check if unicast routing is enabled

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_context()

Remove the assigned Context from this BD

remove_subnet(subnet)

Remove a subnet from this BD

Parameters:subnet – Instance of Subnet class to remove from this BridgeDomain.
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_arp_flood(arp_value)

Set the ARP flood for this BD

Parameters:arp_value – arp to assign this BridgeDomain
set_mac(mac)

Set the mac address for the BD

Parameters:mac – string mac address (XX:XX:XX:XX:XX:XX)
set_multidestination(multidestination)

Set the multidestination flood policy for this BD

Parameters:multidestination – policy to assign this BridgeDomain
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
set_unicast_route(route)

Set the unicast route for this BD

Parameters:route – route to assign this BridgeDomain
set_unknown_mac_unicast(unicast)

Set the unknown mac unicast for this BD

Parameters:unicast – Unicast to assign this BridgeDomain
set_unknown_multicast(multicast)

Set the unknown multicast for this BD

Parameters:multicast – Multicast to assign this BridgeDomain
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.acitoolkit.CollectionPolicy(parent, granularity, retention, adminState='enabled')

Bases: acitoolkit.acitoolkit.BaseMonitorClass

This class is a child of a MonitorPolicy object, MonitorTarget object or a MonitorStats object. It is where the statistics collection policy is actually specified. It applies to all of the statistics that are at the scope level of the parent object, i.e. all, specific to a target, or specific to a statistics family. What is specified in the CollectionPolicy is the time granularity of the collection and how much history to retain. For example, the granularity might be 5 minutes (5min) or 1 hour (1h). How much history to retain is similarly specified. For example you might specify that it be kept for 10 days (10d) or 2 years (2year).

If the CollectionPolicy is a child of a MonitorStats object, it can optionally have children that specify the policy for raising threshold alarms on the fields in the stats family specified in the MonitorStats object. This has yet to be implemented.

This object is roughly the same as the statsColl and statsHierColl objects in the APIC.

The CollectionPolicy must always be initialized with a parent object of type MonitorPolicy, MonitorTarget or MonitorStats. The granularity must also be specifically specified. The retention period can be specified, set to “none”, or set to “inherited”. Note that the “none” value is a string, not the Python None. When the retention period is set to “none” there will be no historical stats kept. However, assuming collection is enabled, stats will be kept for the current time period.

If the retention period is set to “inherited”, the value will be inherited from the less specific policy directly above this one. The same applies to the adminState value. It can be ‘disabled’, ‘enabled’, or ‘inherited’. If ‘disabled’, the current scope of counters are not gathered. If enabled, they are gathered. If ‘inherited’, it will be according to the next higher scope.

Having the ‘inherited’ option on the retention and administrative status allows these items independently controlled at the current stats granularity. For example, you can specify that ingress unknown packets are gathered every 15 minutes by setting adding a collection policy that specifies a 15 minutes granularity and an adminState of ‘enabled’ under a MonitorStats object that sets the scope to be ingress unknown packets. This might override a higher level policy that disabled collection at a 15 minute interval. However, you can set the retention in that same object to be “inherited” so that this specific policy does not change the retention behavior from that of the higher, less specific, policy.

When the CollectionPolicy is a child at the top level, i.e. of the MonitorPolicy, the ‘inherited’ option is not allowed because there is no higher level policy to inherit from. If this were to happen, ‘inherited’ will be treated as ‘enabled’.

Parameters:
  • parent – Parent object that this collection policy should be applied to. This must be an object of type MonitorStats, MonitorTarget, or MonitorPolicy.
  • granularity – String specifying the time collection interval or granularity of this policy. Possible values are: [‘5min’, ‘15min’, ‘1h’, ‘1d’, ‘1w’, ‘1mo’, ‘1qtr’, ‘1year’].
  • retention – String specifying how much history to retain the collected statistics for. The retention will be for time units of the granularity specified. Possible values are [‘none’, ‘inherited’, ‘5min’, ‘15min’, ‘1h’, ‘1d’, ‘1w’, ‘10d’, ‘1mo’, ‘1qtr’, ‘1year’, ‘2year’, ‘3year’].
  • adminState – Administrative status. String to specify whether stats should be collected at the specified granularity. Possible values are [‘enabled’, ‘disabled’, ‘inherited’]. The default if not specified is ‘enabled’.
add_collection_policy(coll_obj)

Add a collection policy.

Parameters:coll_obj – A collection policy object of type CollectionPolicy
add_stats(stat_obj)

Adds a stats family object.

Parameters:stat_obj – Statistics family object of type MonitorStats.
add_target(target_obj)

Add a target object.

Parameters:target_obj – target object of type MonitorTarget
get_parent()
Returns:parent object
granularityEnum = ['5min', '15min', '1h', '1d', '1w', '1mo', '1qtr', '1year']
isModified()

Returns True if this policy and any children have been modified or created and not been written to the APIC

remove_collection_policy(collection)

Remove a collection_policy object. The object to remove is identified by its granularity, e.g. ‘5min’, ‘15min’, etc. This string can be found in the ‘CollectionPolicy.granularity’ attribute of the object.

Parameters:collection – CollectionPolicy to remove.
remove_stats(stats_family)

Remove a stats family object. The object to remove is identified by a string, e.g. ‘ingrPkts’, or ‘egrTotal’. This string can be found in the ‘MonitorStats.scope’ attribute of the object.

Parameters:stats_family – Statistics family string.
remove_target(target)

Remove a target object. The object to remove is identified by a string, e.g ‘l1PhysIf’. This string can be found in the ‘MonitorTarget.scope’ attribute of the object.

Parameters:target – target to remove.
retentionEnum = ['none', 'inherited', '5min', '15min', '1h', '1d', '1w', '10d', '1mo', '1qtr', '1year', '2year', '3year']
setAdminState(adminState)

Sets the administrative status.

Parameters:adminState – Administrative status. String to specify whether stats should be collected at the specified granularity. Possible values are [‘enabled’, ‘disabled’, ‘inherited’]. The default if not specified is ‘enabled’.
setRetention(retention)
Sets the retention period.
Parameters:retention – String specifying how much history to retain the collected statistics for. The retention will be for time units of the granularity specified. Possible values are [‘none’, ‘inherited’, ‘5min’, ‘15min’, ‘1h’, ‘1d’, ‘1w’, ‘10d’, ‘1mo’, ‘1qtr’, ‘1year’, ‘2year’, ‘3year’].
set_description(description)
Sets the description of the MonitorStats.
Parameters:description – String to use as the description
set_name(name)
Sets the name of the MonitorStats.
Parameters:name – String to use as the name
class acitoolkit.acitoolkit.CommonEPG(epg_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Base class for EPG and OutsideEPG. Not meant to be instantiated directly

Parameters:
  • epg_name – String containing the name of this EPG
  • parent – Instance of the AppProfile class representing the Application Profile where this EPG is contained.
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:
consume(contract)

Make this EPG consume a Contract

Parameters:contract – Contract class instance to be consumed by this EPG.
Returns:True
consume_cif(contract_interface)

Make this EPG consume a ContractInterface

Parameters:contract_interface – ContractInterface class instance to be consumed by this EPG.
Returns:True
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.
does_consume(contract)

Check if this EPG consumes a specific Contract

Parameters:contract – Instance of Contract class to check if it is consumed by this EPG.
Returns:True or False. True if the EPG does consume the Contract.
does_consume_cif(contract_interface)

Check if this EPG consumes a specific Contract

Parameters:contract_interface
Returns:True or False. True if the EPG does consume the ContractInterface.
does_protect(taboo)

Check if this EPG is protected by a specific Taboo.

Parameters:taboo – Instance of Taboo class to check if it protects this EPG.
Returns:True or False. True if the EPG is protected by the Taboo.
does_provide(contract)

Check if this EPG provides a specific Contract.

Parameters:contract – Instance of Contract class to check if it is provided by this EPG.
Returns:True or False. True if the EPG does provide the Contract.
dont_consume(contract)

Make this EPG not consume a Contract. It does not check to see if the Contract was already consumed

Parameters:contract – Instance of Contract class to be no longer consumed by this EPG.
Returns:True
dont_consume_cif(contract_interface)

Make this EPG not consume a ContractInterface. It does not check to see if the ContractInterface was already consumed

Parameters:contract_interface
Returns:True
dont_protect(taboo)

Make this EPG not protected by a Taboo

Parameters:taboo – Instance of Taboo class to no longer protect this EPG.
Returns:True
dont_provide(contract)

Make this EPG not provide a Contract

Parameters:contract – Instance of Contract class to be no longer provided by this EPG.
Returns:True
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, tenant=None)

Gets all of the EPGs from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • parent – Instance of the AppProfile class used to limit the EPGs retreived from the APIC.
  • tenant – Instance of Tenant class used to limit the EPGs retreived from the APIC.
Returns:

List of CommonEPG instances (or EPG instances if called from EPG 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_all_consumed(deleted=False)

Get all of the Contracts consumed by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are consumed or that the consumed was marked as deleted
Returns:List of Contract objects that are consumed by the EPG.
get_all_consumed_cif(deleted=False)

Get all of the ContractInterfaces consumed by this EPG

Parameters:deleted – Boolean indicating whether to get ContractInterfaces that are consumed or that the consumed was marked as deleted
Returns:List of ContractInterface objects that are consumed by the EPG.
get_all_protected(deleted=False)

Get all of the Taboos protecting this EPG

Parameters:deleted – Boolean indicating whether to get Taboos that are protected or that the protected was marked as deleted
Returns:List of Taboo objects that are protecting the EPG.
get_all_provided(deleted=False)

Get all of the Contracts provided by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are provided or that the provided was marked as deleted
Returns:List of Contract objects that are provided by the EPG.
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 interfaces that this EPG is attached. The default is to get list of ‘attached’ interfaces. If ‘status’ is set to ‘detached’ it will return the list of detached Interface objects (Those EPGs which are no longer attached to an Interface, but the configuration is not yet pushed to the APIC.)

Parameters:status – ‘attached’ or ‘detached’. Defaults to ‘attached’.
Returns:List of Interface objects
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.
protect(taboo)

Make this EPG protected by a Taboo

Parameters:taboo – Instance of Taboo class to protect this EPG.
Returns:True
provide(contract)

Make this EPG provide a Contract

Parameters:contract – Instance of Contract class to be provided by this EPG.
Returns:True
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.acitoolkit.Context(context_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Context : roughly equivalent to fvCtx

Parameters:
  • context_name – String containing the Context name
  • parent – An instance of Tenant class representing the Tenant which contains this Context.
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, tenant=None)

Gets all of the Contexts from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant used to limit the Contexts retreived from the APIC
Returns:

List of Context objects

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_allow_all()

Returns the allow_all value from this Context. When set, contracts will not be enforced in this context.

Returns:True or False.
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()

Returns json representation of fvCtx object

Returns:json dictionary of fvCtx object
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.

static get_table(contexts, title='')

Will create table of context information

Parameters:
  • title
  • contexts
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_allow_all(value=True)

Set the allow_all value. When set, contracts will not be enforced in this context.

Parameters:value – True or False. Default is True.
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.acitoolkit.Contract(contract_name, parent=None)

Bases: acitoolkit.acitoolkit.BaseContract

Contract : Class for Contracts

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, tenant)

Gets all of the Contracts from the APIC for a particular tenant.

Parameters:
  • tenant
  • 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_all_consuming_epgs(deleted=False)

Get all of the EPGs consuming this contract

Parameters:deleted – Boolean indicating whether to get EPGs that are consuming or that the consuming relationship was marked as deleted
Returns:List of EPG instances
get_all_filter_entries(direction='bidirectional-only')

Get all of the filter entries contained within this Contract/Taboo

Parameters:direction – String containing the type of filter entries to gather Valid values are ‘bidirectional-only’, ‘input-only’, ‘output-only’, ‘all’ Default is ‘bidirectional-only’
Returns:List of FilterEntry instances
get_all_providing_epgs(deleted=False)

Get all of the EPGs providing this contract

Parameters:deleted – Boolean indicating whether to get EPGs that are providing or that the providing relationship was marked as deleted
Returns:List of EPG instances
get_attributes(name=None)
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()

Returns json representation of the contract

Returns:json dictionary of the contract
get_parent()
Returns:Parent of this object.
get_scope()

Get the scope of this contract. Valid values are ‘context’, ‘global’, ‘tenant’, and ‘application-profile’

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_table(contracts, title='')

Will create of each contract

Parameters:
  • title
  • contracts
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()
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
set_scope(scope)

Set the scope of this contract. Valid values are ‘context’, ‘global’, ‘tenant’, and ‘application-profile’

Parameters:scope – String containing one of the following ‘context’, ‘global’, ‘tenant’, or ‘application-profile’
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.acitoolkit.ContractInterface(contractif_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

ContractInterface : roughly equivalent to vzCPIf

Parameters:
  • contractif_name – String containing the ContractInterface name
  • parent – An instance of Tenant class representing the Tenant which contains this ContractInterface.
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.
does_import_contract(contract)

Check if this ContractInterface imports a specific Contract.

Parameters:contract – Instance of Contract class to check if it is imported by this ContractInterface.
Returns:True or False. True if the ContractInterface does import the Contract.
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, tenant=None)

Gets all of the ContractInterfaces from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant used to limit the ContractInterfaces retrieved from the APIC
Returns:

List of ContractInterface objects

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_import_contract(deleted=False)

Get the specific Contract that this ContractInterface is importing.

Parameters:contract – Instance of Contract class that is imported by this ContractInterface.
Returns:Contract class instance or None if not importing a contract
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 vzCPIf object

Returns:json dictionary of vzCPIf object
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_import_contract()

Check if the ContractInterface has any imported Contract :return: True or False. True if the ContractInterface does import a Contract.

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.
import_contract(contract)

Set the Contract that is imported by this ContractInterface

Parameters:contract – Instance of Contract
Returns:None
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.acitoolkit.ContractSubject(subject_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

ContractSubject : roughly equivalent to vzSubj

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_filter(filter_obj)

Add Filter to the ContractSubject, roughly equivalent to vzRsSubjFiltAtt

Parameters:filter_obj – Instance of Filter class. Represents a Filter that is added to the ContractSubject. Multiple Filter can be assigned to a single ContractSubject.
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_filters(deleted=False)

Get all of the filters that are attached to this ContractSubject.

Returns:List of Filter objects
static 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 ContractSubject or TabooContractSubject

Returns:json dictionary of the ContractSubject or TabooContractSubject
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.acitoolkit.EPG(epg_name, parent=None)

Bases: acitoolkit.acitoolkit.CommonEPG

EPG : roughly equivalent to fvAEPg

Initializes the EPG with a name and, optionally, an AppProfile parent. If the parent is specified and is not an AppProfile, an error will occur.

Parameters:
  • epg_name – String containing the name of the EPG.
  • parent – Instance of the AppProfile class representing the Application Profile where this EPG is contained.
add_bd(bridgedomain)

Add BridgeDomain to the EPG, roughly equivalent to fvRsBd

Parameters:bridgedomain – Instance of BridgeDomain class. Represents the BridgeDomain that this EPG will be assigned. An EPG can only be assigned to a single BridgeDomain.
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_infradomain(infradomain)

Add Infrastructure Domain to the EPG

Parameters:infradomain – Instance of InfraDomain class.
add_static_leaf_binding(leaf_id, encap_type, encap_id, encap_mode='regular', immediacy='lazy', pod=1)

Adds a static leaf binding to this EPG.

Parameters:
  • leaf_id – Integer containing the node ID (e.g. 101)
  • encap_type – String containing the encapsulation type. Valid values are ‘vlan’, ‘vxlan’, or ‘nvgre’.
  • encap_id – String containing the encapsulation specific identifier representing the virtual L2 network (i.e. for VXLAN, this is the numeric value of the VNID).
  • encap_mode – String containing the encapsulation mode. Use

“regular” for normal dot1q tagged traffic, “untagged” for traffic reaching the leaf without any dot1q tags, and “native” for traffic tagged with a 802.1P tag.

Parameters:
  • immediacy – String containing either “immediate” or “lazy”
  • pod – Integer containing the ACI Pod where the supplied leaf is located.
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:
consume(contract)

Make this EPG consume a Contract

Parameters:contract – Contract class instance to be consumed by this EPG.
Returns:True
consume_cif(contract_interface)

Make this EPG consume a ContractInterface

Parameters:contract_interface – ContractInterface class instance to be consumed by this EPG.
Returns:True
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.
does_consume(contract)

Check if this EPG consumes a specific Contract

Parameters:contract – Instance of Contract class to check if it is consumed by this EPG.
Returns:True or False. True if the EPG does consume the Contract.
does_consume_cif(contract_interface)

Check if this EPG consumes a specific Contract

Parameters:contract_interface
Returns:True or False. True if the EPG does consume the ContractInterface.
does_protect(taboo)

Check if this EPG is protected by a specific Taboo.

Parameters:taboo – Instance of Taboo class to check if it protects this EPG.
Returns:True or False. True if the EPG is protected by the Taboo.
does_provide(contract)

Check if this EPG provides a specific Contract.

Parameters:contract – Instance of Contract class to check if it is provided by this EPG.
Returns:True or False. True if the EPG does provide the Contract.
dont_consume(contract)

Make this EPG not consume a Contract. It does not check to see if the Contract was already consumed

Parameters:contract – Instance of Contract class to be no longer consumed by this EPG.
Returns:True
dont_consume_cif(contract_interface)

Make this EPG not consume a ContractInterface. It does not check to see if the ContractInterface was already consumed

Parameters:contract_interface
Returns:True
dont_protect(taboo)

Make this EPG not protected by a Taboo

Parameters:taboo – Instance of Taboo class to no longer protect this EPG.
Returns:True
dont_provide(contract)

Make this EPG not provide a Contract

Parameters:contract – Instance of Contract class to be no longer provided by this EPG.
Returns:True
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
get(session, parent=None, tenant=None)

Gets all of the EPGs from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • parent – Instance of the AppProfile class used to limit the EPGs retreived from the APIC.
  • tenant – Instance of Tenant class used to limit the EPGs retreived from the APIC.
Returns:

List of CommonEPG instances (or EPG instances if called from EPG 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_all_consumed(deleted=False, include_any_epg=False)

Get all of the Contracts consumed by this EPG

Parameters:
  • deleted – Boolean indicating whether to get Contracts that are consumed or that the consumed was marked as deleted
  • include_any_epg – Boolean indicating whether to include Contracts that are consumed due to inheritance from an AnyEPG within the same Context that this EPG is in.
Returns:

List of Contract objects that are consumed by the EPG.

get_all_consumed_cif(deleted=False)

Get all of the ContractInterfaces consumed by this EPG

Parameters:deleted – Boolean indicating whether to get ContractInterfaces that are consumed or that the consumed was marked as deleted
Returns:List of ContractInterface objects that are consumed by the EPG.
get_all_protected(deleted=False)

Get all of the Taboos protecting this EPG

Parameters:deleted – Boolean indicating whether to get Taboos that are protected or that the protected was marked as deleted
Returns:List of Taboo objects that are protecting the EPG.
get_all_provided(deleted=False, include_any_epg=False)

Get all of the Contracts provided by this EPG

Parameters:
  • deleted – Boolean indicating whether to get Contracts that are provided or that the provided was marked as deleted
  • include_any_epg – Boolean indicating whether to include Contracts that are provided due to inheritance from an AnyEPG within the same Context that this EPG is in.
Returns:

List of Contract objects that are provided by the EPG.

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_bd()

Return the assigned BridgeDomain. There should only be one item in the returned list.

Returns:List of BridgeDomain objects
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
static get_from_json(data, parent=None)

returns a Tenant object from a json

get_interfaces(status='attached')

Get all of the interfaces that this EPG is attached. The default is to get list of ‘attached’ interfaces. If ‘status’ is set to ‘detached’ it will return the list of detached Interface objects (Those EPGs which are no longer attached to an Interface, but the configuration is not yet pushed to the APIC.)

Parameters:status – ‘attached’ or ‘detached’. Defaults to ‘attached’.
Returns:List of Interface objects
get_json()

Returns json representation of the EPG

Returns:json dictionary of the EPG
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.

static get_table(epgs, title='')

Will create table of EPG information for a given tenant

Parameters:
  • epgs
  • title
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_bd()

Check if a BridgeDomain has been assigned to the EPG

Returns:True or False. True if the EPG has been assigned a BridgeDomain.
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_attributed_based

Get whether the EPG is attribute based :return: True if attribute based. False otherwise.

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.
protect(taboo)

Make this EPG protected by a Taboo

Parameters:taboo – Instance of Taboo class to protect this EPG.
Returns:True
provide(contract)

Make this EPG provide a Contract

Parameters:contract – Instance of Contract class to be provided by this EPG.
Returns:True
remove_bd()

Remove BridgeDomain from the EPG. Note that there should only be one BridgeDomain attached to the EPG.

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_base_epg(epg)

Sets the Base EPG. Used by Attribute-based EPGs to indicate that the BridgeDomain, NodeAttach, and PathAttach relations should be copied from the base EPG when generating JSON.

Parameters:epg – EPG class instance of the Base EPG
Returns:None
set_deployment_immediacy(immediacy)

Set the deployment immediacy of the EPG

Parameters:immediacy – String containing either “immediate” or “lazy”
set_dom_deployment_immediacy(immediacy)

Set the deployment immediacy for PhysDomain of the EPG

Parameters:immediacy – String containing either “immediate” or “lazy”
set_dom_resolution_immediacy(immediacy)

Set the resolution immediacy for PhysDomain of the EPG

Parameters:immediacy – String containing either “immediate” or “lazy”
set_intra_epg_isolation(isolation)

Set the intra-EPG isolation of the EPG

Parameters:isolation – String containing either “unenforced” or “enforced”
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.acitoolkit.EPGDomain(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

EPGDomain class

Parameters:
  • name – String containing the name of a source relation to an infrastructure domain profile associated with application endpoint groups. The domain profile can be either a VMM domain profile or a physical domain profile.
  • parent – An instance of EPG class representing the EPG which contains this Domain Profile.
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)

Gets all of the Physical Domains from the APIC

Parameters:session – the instance of Session used for APIC communication
Returns:List of Switch Profile objects
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
classmethod get_by_name(session, infra_name)

Gets all of the Physical Domains from the APIC

Parameters:
  • infra_name
  • session – the instance of Session used for APIC communication
Returns:

List of Switch Profile objects

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()

Returns json representation of the fvTenant object

Returns:A json dictionary of fvTenant
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.acitoolkit.Endpoint(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

Endpoint class

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
static get(session, endpoint_name=None)

Gets all of the endpoints connected to the fabric from the APIC

Parameters:
  • endpoint_name
  • session – Session instance used to communicate with the APIC. Assumed to be logged in
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’.
classmethod get_all_by_epg(session, tenant_name, app_name, epg_name, with_interface_attachments=True)

Get all of the Endpoints for a specified EPG

Parameters:
  • session – Session instance used to communicate with the APIC. Assumed to be logged in
  • tenant_name – String containing the tenant name
  • app_name – String containing the app name
  • epg_name – String containing the epg name
  • with_interface_attachments – Boolean indicating whether interfaces should be attached or not. True is default.
Returns:

List of Endpoint instances

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(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
classmethod get_event(session, with_relations=True)
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_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.

static get_table(endpoints, title='')

Will create table of taboo information for a given tenant

Parameters:
  • title
  • endpoints
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.acitoolkit.FexInterface(if_type, pod, node, fex, module, port)

Bases: acitoolkit.acibaseobject.BaseACIObject

This class describes a physical interface on a FEX device

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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(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.
classmethod is_dn_a_fex_interface(dn)
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.
classmethod parse_dn(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.
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.acitoolkit.Filter(filter_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Filter : roughly equivalent to vzFilter

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, tenant)

Gets all of the Filters for the current tenant from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant used to limit the Filters retreived from the APIC
Returns:

List of Filter objects

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
classmethod get_by_name_and_tenant(session, tenant, filter_name)

Returns the Filter Object with name == filter_name and tenant == tenant

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant used to limit the search scope
  • filter_name – the searched Filter Object
Returns:

a single Filter Object

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(full_data, working_data, parent=None, limit_to=(), subtree='full', config_only=False)
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
static 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 Filter

Returns:json dictionary of the Filter
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_entry(applyToFrag, arpOpc, dFromPort, dToPort, etherT, prot, sFromPort, sToPort, tcpRules, stateful, icmpv4T='not-given', icmpv6T='not-given')

Returns whether or not the Filter has a FilterEntry. All fields are compared except name.

Returns:True if the Filter has a matching FilterEntry. False otherwise
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.acitoolkit.FilterEntry(name, parent, applyToFrag='0', arpOpc='0', dFromPort='0', dToPort='0', etherT='0', prot='0', sFromPort='0', sToPort='0', tcpRules='0', stateful='0', icmpv4T='not-given', icmpv6T='not-given')

Bases: acitoolkit.acibaseobject.BaseACIObject

FilterEntry : roughly equivalent to vzEntry

Parameters:
  • name – String containing the name of this FilterEntry instance.
  • applyToFrag – True or False. True indicates that this FilterEntry should be applied to IP fragments.
  • arpOpc – ‘req’ or ‘reply’. Indicates that this FilterEntry should be applied to ARP Requests or ARP replies.
  • dFromPort – String containing the lower L4 destination port number of the L4 destination port number range.
  • dToPort – String containing the upper L4 destination port number of the L4 destination port number range.
  • etherT – String containing the EtherType of the frame to be matched by this FilterEntry.
  • prot – String containing the L4 protocol number to be matched by this FilterEntry.
  • sFromPort – String containing the lower L4 source port number of the L4 source port number range.
  • sToPort – String containing the upper L4 source port number of the L4 source port number range.
  • tcpRules – Bit mask consisting of the TCP flags to be matched by this FilterEntry.
  • stateful – True or False. True indicates that this FilterEntry should monitor the TCP ACK bit.
  • icmpv4T – String containing the ICMPv4 type.
  • icmpv6T – String containing the ICMPv6 type.
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_apic_json(data, parent)

create from the apic json

Parameters:
  • data – json dictionary
  • parent – parent object
Returns:

object created from json dictionary

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, tenant)

To get all of acitoolkit style Filter Entries APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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()

Returns json representation of the FilterEntry

Returns:json dictionary of the FilterEntry
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.

static get_table(filters, title='')

Will create table of filter information for a given tenant

Parameters:
  • title
  • filters
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.acitoolkit.IPEndpoint(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

Endpoint class

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
static get(session)

Gets all of the IP endpoints connected to the fabric from the APIC

Parameters:session – Session instance assumed to be logged into the APIC
Returns:List of IPEndpoint instances
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’.
classmethod get_all_by_epg(session, tenant_name, app_name, epg_name)

Get all of the IP Endpoints for the specified EPG

Parameters:
  • session – Session instance assumed to be logged into the APIC
  • tenant_name – String containing the Tenant name that holds the EPG
  • app_name – String containing the AppProfile name that holds the EPG
  • epg_name – String containing the EPG name
Returns:

List of IPEndpoint instances

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
classmethod get_event(session)
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_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.acitoolkit.InputTerminal(terminal_name, parent=None)

Bases: acitoolkit.acitoolkit.BaseTerminal

Input terminal for a graph. It is input with respect to the provider

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_filter(filter_obj)

Add Filter to the Terminal, roughly equivalent to vzRsFiltAtt

Parameters:filter_obj – Instance of Filter class. Represents a Filter that is added to the Terminal. Multiple Filters can be assigned to a single Terminal.
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_filters()

Get all of the filters that are attached to this Terminal.

Returns:List of Filter objects
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 Terminal Object

Returns:json dictionary of the ContractSubject
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()
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.acitoolkit.L2ExtDomain(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

L2ExtDomain class

Parameters:
  • name – String containing the L2ExtDomain name
  • parent – An instance of DomP class representing
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)

Gets all of the L2Ext Domains from the APIC

Parameters:session – the instance of Session used for APIC communication
Returns:List of L2ExtDomain objects
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
classmethod get_by_name(session, infra_name)

Gets all of the Physical Domainss from the APIC

Parameters:
  • infra_name
  • session – the instance of Session used for APIC communication
Returns:

List of L2ExtDomain objects

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()

Returns json representation of the l2extDomP object

Returns:A json dictionary of fvTenant
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.acitoolkit.L2Interface(name, encap_type, encap_id, encap_mode=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

The L2Interface class creates an logical L2 interface that can be attached to a physical interface. This interface defines the L2 encapsulation i.e. VLAN, VXLAN, or NVGRE

Parameters:
  • name – String containing the L2Interface instance name
  • encap_type – String containing the encapsulation type. Valid values are ‘VLAN’, ‘VXLAN’, or ‘NVGRE’.
  • encap_id – String containing the encapsulation specific identifier representing the virtual L2 network (i.e. for VXLAN, this is the numeric value of the VNID).
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_encap_id()

Get the encap_id of the L2 interface. The value is returned as a string and depends on the encap_type (i.e. VLAN VID, VXLAN VNID, or NVGRE VSID)

Returns:String containing encapsulation identifier value.
get_encap_type()

Get the encap_type of the L2 interface. Valid values are ‘vlan’, ‘vxlan’, and ‘nvgre’

Returns:String containing encap_type value.
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()

Returns whether this instance is considered an interface.

Returns:True
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.
static parse_encap(encap)

Parses the encap_type and encap_id from a json encap string Examples: vlan-515 / vxlan-5000

Parameters:encap – String containing the json encap format
Returns:encap_type, encap_id
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.acitoolkit.L3ExtDomain(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

L3ExtDomain class

Parameters:
  • name – String containing the name of the external routed domain
  • parent – An instance of DomP class
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)

Gets all of the Physical Domains from the APIC

Parameters:session – the instance of Session used for APIC communication
Returns:List of L3Ext Domain objects
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
classmethod get_by_name(session, infra_name)

Gets all of the L3Ext Domains from the APIC

Parameters:
  • infra_name
  • session – the instance of Session used for APIC communication
Returns:

List of L3Ext Domain objects

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()

Returns json representation of the fvTenant object

Returns:A json dictionary of fvTenant
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.acitoolkit.L3Interface(name)

Bases: acitoolkit.acibaseobject.BaseACIObject

Creates an L3 interface that can be attached to an L2 interface. This interface defines the L3 address i.e. IPv4

Parameters:name – String containing the name of this L3Interface 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_context(context)

Add context to the EPG

Parameters:context – Instance of Context class to assign to this L3Interface.
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
get_addr()

Get the L3 address assigned to this interface. The address is set via the L3Interface.set_addr() method

Returns:String containing the L3 address in dotted decimal notation.
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)
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_context()

Return the assigned context

Returns:Instance of Context class that this L3Interface is assigned. If no Context is assigned, None is returned.
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()

Returns json representation of L3Interface

Returns:json dictionary of L3Interface
get_l3if_type()

Get the l3if_type of this L3 interface.

Returns:L3 interface type. Valid values are ‘sub-interface’, ‘l3-port’, and ‘ext-svi’
get_mtu()

Get the MTU of this interface

Returns:MTU of the interface
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_context()

Check if the context has been assigned

Returns:True or False. True if a Context has been assigned to this L3Interface.
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()

Check if this is an interface object.

Returns:True
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_context()

Remove context from the EPG

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_addr(addr)

Set the L3 address assigned to this interface

Parameters:addr – String containing the L3 address in dotted decimal notation.
set_l3if_type(l3if_type)

Set the l3if_type of this L3 interface.

Parameters:l3if_type – L3 interface type. Valid values are ‘sub-interface’, ‘l3-port’, and ‘ext-svi’
set_mtu(mtu)

Set the L3 MTU of this interface

Parameters:mtu – String containing MTU
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.acitoolkit.LogicalModel(session=None, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

This is the root class for the logical part of the network. Its corollary is the PhysicalModel class. It is a container that can hold all of logical model instances such as Tenants.

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 LogicalModels. It will get one and return it in a list.

Parameters:
  • session
  • parent
Returns:

list of LogicalModel

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(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.acitoolkit.MonitorPolicy(policyType, name)

Bases: acitoolkit.acitoolkit.BaseMonitorClass

This class is the top-most container for a monitoring policy that controls how statistics are gathered. It has immediate children, CollectionPolicy objects, that control the default behavior for any network element that uses this monitoring policy. It may optionally have MonitorTarget objects as children that are used to override the default behavior for a particular target class such as Interfaces. There can be further granularity of control through children of the MonitorTarget sub-objects.

Children of the MonitorPolicy will be CollectionPolicy objects that define the collection policy plus optional MonitorTarget objects that allow finer grained control over specific target APIC objects such as ‘l1PhysIf’ (layer 1 physical interface).

The CollectionPolicy children are contained in a dictionary called “collection_policy” that is indexed by the granulariy of the CollectionPolicy, e.g. ‘5min’, ‘15min’, etc.

The MonitorTarget children are contained in a dictionary called “monitor_target” that is indexed by the name of the target object, e.g. ‘l1PhysIf’.

To make a policy take effect for a particular port, for example, you must attach that monitoring policy to the port.

Note that the name of the MonitorPolicy is used to construct the dn of the object in the APIC. As a result, the name cannot be changed. If you read a policy from the APIC, change the name, and write it back, it will create a new policy with the new name and leave the old, original policy, in place with its original name.

A description may be optionally added to the policy.

The MonitorPolicy is initialized with simply a policy type and a name. There are two policy types: ‘fabric’ and ‘access’. The ‘fabric’ monitoring policies can be applied to certain MonitorTarget types and ‘access’ monitoring policies can be applied to other MonitorTarget types. Initially however, both policies can have l1PhysIf as targets.

A name must be specified because it is used to build the distinguising name (dn) along with the policyType in the APIC. The dn for “fabric” policies will be /uni/fabric/monfabric-[name] and for “access” policies it will be /uni/infra/moninfra-[name] in the APIC.

Parameters:
  • policyType – String specifying whether this is a fabric or access policy
  • name – String specifying a name for the policy.
add_collection_policy(coll_obj)

Add a collection policy.

Parameters:coll_obj – A collection policy object of type CollectionPolicy
add_stats(stat_obj)

Adds a stats family object.

Parameters:stat_obj – Statistics family object of type MonitorStats.
add_target(target_obj)

Add a target object.

Parameters:target_obj – target object of type MonitorTarget
flat(target='l1PhysIf')

This method will return a data structure that is a flattened version of the monitor policy. The flattened version is one that walks through the heirarchy of the policy and determines the administrative state and retention policy for each granularity of each statistics family. This is done for the target specified, i.e. ‘l1PhysIf’

For example, if ‘foo’ is a MonitorPolicy object, then flatPol = foo.flat(‘l1PhysIf’) will return a dictionary that looks like the following:

adminState = flatPol[‘counter_family’][‘granularity’].adminState retention = flatPol[‘counter_family’][‘granularity’].retention

The dictionary will have all of the counter families for all of the granularities and the value returned is the administrative state and retention value that is the final result of resolving the policy hierarchy.

Parameters:target – APIC target object. This will default to ‘l1PhysIf’
Returns:Dictionary of statistic administrative state and retentions indexed by counter family and granularity.
classmethod get(session)
get() will get all of the monitor policies from the APIC and return them as a list. It will get both fabric and access (infra) policies including default policies.
Parameters:session – the instance of Session used for APIC communication
Returns:List of MonitorPolicy objects
get_parent()
Returns:parent object
isModified()

Returns True if this policy and any children have been modified or created and not been written to the APIC

remove_collection_policy(collection)

Remove a collection_policy object. The object to remove is identified by its granularity, e.g. ‘5min’, ‘15min’, etc. This string can be found in the ‘CollectionPolicy.granularity’ attribute of the object.

Parameters:collection – CollectionPolicy to remove.
remove_stats(stats_family)

Remove a stats family object. The object to remove is identified by a string, e.g. ‘ingrPkts’, or ‘egrTotal’. This string can be found in the ‘MonitorStats.scope’ attribute of the object.

Parameters:stats_family – Statistics family string.
remove_target(target)

Remove a target object. The object to remove is identified by a string, e.g ‘l1PhysIf’. This string can be found in the ‘MonitorTarget.scope’ attribute of the object.

Parameters:target – target to remove.
set_description(description)
Sets the description of the MonitorStats.
Parameters:description – String to use as the description
set_name(name)
Sets the name of the MonitorStats.
Parameters:name – String to use as the name
class acitoolkit.acitoolkit.MonitorStats(parent, statsFamily)

Bases: acitoolkit.acitoolkit.BaseMonitorClass

This class is a child of a MonitorTarget object. It is used to specify a scope for applying a monitoring policy that is more fine grained than the MonitorTarget. Specifically, the MonitorStats object specifies a statistics family such as “ingress packets” or “egress bytes”.

The MonitorStats object must always be initialized with a parent object of type MonitorTarget. It sets the scope of its children collection policies (CollectionPolicy) to a particular statistics family.

The MonitorStats object contains a dictionary of collection policies called collection_policy. This is a dictionary of children CollectionPolicy objects indexed by their granularity, e.g. ‘5min’, ‘15min’, etc.

Parameters:
  • parent – Parent object that this monitor stats object should be applied to. This must be an object of type MonitorTarget.
  • statsFamily – String specifying the statistics family that the children collection policies should be applied to. Possible values are:[‘egrBytes’, ‘egrPkts’, ‘egrTotal’, ‘egrDropPkts’, ‘ingrBytes’, ‘ingrPkts’, ‘ingrTotal’, ‘ingrDropPkts’, ‘ingrUnkBytes’, ‘ingrUnkPkts’, ‘ingrStorm’]
add_collection_policy(coll_obj)

Add a collection policy.

Parameters:coll_obj – A collection policy object of type CollectionPolicy
add_stats(stat_obj)

Adds a stats family object.

Parameters:stat_obj – Statistics family object of type MonitorStats.
add_target(target_obj)

Add a target object.

Parameters:target_obj – target object of type MonitorTarget
get_parent()
Returns:parent object
isModified()

Returns True if this policy and any children have been modified or created and not been written to the APIC

remove_collection_policy(collection)

Remove a collection_policy object. The object to remove is identified by its granularity, e.g. ‘5min’, ‘15min’, etc. This string can be found in the ‘CollectionPolicy.granularity’ attribute of the object.

Parameters:collection – CollectionPolicy to remove.
remove_stats(stats_family)

Remove a stats family object. The object to remove is identified by a string, e.g. ‘ingrPkts’, or ‘egrTotal’. This string can be found in the ‘MonitorStats.scope’ attribute of the object.

Parameters:stats_family – Statistics family string.
remove_target(target)

Remove a target object. The object to remove is identified by a string, e.g ‘l1PhysIf’. This string can be found in the ‘MonitorTarget.scope’ attribute of the object.

Parameters:target – target to remove.
set_description(description)
Sets the description of the MonitorStats.
Parameters:description – String to use as the description
set_name(name)
Sets the name of the MonitorStats.
Parameters:name – String to use as the name
statsDictionary = {'eqptIngrDropPkts': 'ingrDropPkts', 'eqptIngrBytes': 'ingrBytes', 'eqptEgrPkts': 'egrPkts', 'eqptEgrDropPkts': 'egrDropPkts', 'eqptIngrPkts': 'ingrPkts', 'eqptIngrUnkBytes': 'ingrUnkBytes', 'eqptEgrBytes': 'egrBytes', 'eqptIngrStorm': 'ingrStorm', 'eqptEgrTotal': 'egrTotal', 'eqptIngrUnkPkts': 'ingrUnkPkts', 'eqptIngrTotal': 'ingrTotal'}
statsFamilyEnum = ['egrBytes', 'egrPkts', 'egrTotal', 'egrDropPkts', 'ingrBytes', 'ingrPkts', 'ingrTotal', 'ingrDropPkts', 'ingrUnkBytes', 'ingrUnkPkts', 'ingrStorm']
class acitoolkit.acitoolkit.MonitorTarget(parent, target)

Bases: acitoolkit.acitoolkit.BaseMonitorClass

This class is a child of a MonitorPolicy object. It is used to specify a scope for appling a monitoring policy. An example scope would be the Interface class, meaning that the monitoring policies specified here will apply to all Interface clas objects (l1PhysIf in the APIC) that use the parent MonitoringPolicy as their monitoring policy.

Children of the MonitorTarget will be CollectionPolicy objects that define the collection policy for the specified target plus optional MonitorStats objects that allow finer grained control over specific families of statistics such as ingress packets, ingrPkts.

The CollectionPolicy children are contained in a dictionary called “collection_policy” that is indexed by the granularity of the CollectionPolicy, e.g. ‘5min’, ‘15min’, etc.

The MonitorStats children are contained in a dictionary called “monitor_stats” that is indexed by the name of the statistics family, e.g. ‘ingrBytes’, ‘ingrPkts’, etc.

The MonitorTarget object is initialized with a parent of type MonitorPolicy, and a target string. Initially, this toolkit only supports a target of type ‘l1PhysIf’. The ‘l1PhyIf’ target is a layer 1 physical interface or “port”. The MonitorTarget will narrow the scope of the policy specified by the children of the MonitorTarget to be only the target class.
Parameters:
  • parent – Parent object that this monitor target is a child. It must be of type MonitorPolicy
  • target – String specifying the target class for the Monitor policy.
add_collection_policy(coll_obj)

Add a collection policy.

Parameters:coll_obj – A collection policy object of type CollectionPolicy
add_stats(stat_obj)

Adds a stats family object.

Parameters:stat_obj – Statistics family object of type MonitorStats.
add_target(target_obj)

Add a target object.

Parameters:target_obj – target object of type MonitorTarget
get_parent()
Returns:parent object
isModified()

Returns True if this policy and any children have been modified or created and not been written to the APIC

remove_collection_policy(collection)

Remove a collection_policy object. The object to remove is identified by its granularity, e.g. ‘5min’, ‘15min’, etc. This string can be found in the ‘CollectionPolicy.granularity’ attribute of the object.

Parameters:collection – CollectionPolicy to remove.
remove_stats(stats_family)

Remove a stats family object. The object to remove is identified by a string, e.g. ‘ingrPkts’, or ‘egrTotal’. This string can be found in the ‘MonitorStats.scope’ attribute of the object.

Parameters:stats_family – Statistics family string.
remove_target(target)

Remove a target object. The object to remove is identified by a string, e.g ‘l1PhysIf’. This string can be found in the ‘MonitorTarget.scope’ attribute of the object.

Parameters:target – target to remove.
set_description(description)
Sets the description of the MonitorStats.
Parameters:description – String to use as the description
set_name(name)
Sets the name of the MonitorStats.
Parameters:name – String to use as the name
class acitoolkit.acitoolkit.NetworkPool(name, encap_type, start_id, end_id, mode)

Bases: acitoolkit.acibaseobject.BaseACIObject

This class defines a pool of network ids

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_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
static get_url(fmt='json')

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

Parameters:fmt – optional format string, default is ‘json’
Returns:URL string
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.acitoolkit.OSPFInterface(name, router=None, area_id=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Creates an OSPF router interface that can be attached to a L3 interface. This interface defines the OSPF area, authentication, etc.

Parameters:
  • name – String containing the name of this OSPFInterface object.
  • area_id – String containing the OSPF area id of this interface. Default is None.
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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()

Returns json representation of OSPFInterface :returns: json dictionary of OSPFInterface

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()

Returns whether this instance is considered an interface. :returns: True

static is_ospf()
Returns:True if this interface is an OSPF interface. In the case of OSPFInterface instances, this is always True.
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_area_type(area_type)

Set the area_type for this OSPFInterface

Parameters:area_type – AreaType to use for this OSPFInterface
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.acitoolkit.OSPFInterfacePolicy(name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Represents the interface settings of an OSPF interface

param name: String containing the name of this OSPF interface policy param parent: Instance of the Tenant class representing the tenant owning this OSPF interface policy

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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()

Returns json representation of OSPFRouter

Returns:json dictionary of OSPFIRouter
get_nw_type()

Get the nw-type of this interface ospf policy :returns: string of the network type for this policy

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_nw_type(network_type)

sets the L3 nw_type with some validation

Parameters:network_type – string of bcast or p2p
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.acitoolkit.OSPFRouter(name)

Bases: acitoolkit.acibaseobject.BaseACIObject

Represents the global settings of the OSPF Router

Parameters:name – String containing the name of this OSPFRouter 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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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()

Returns json representation of OSPFRouter

Returns:json dictionary of OSPFIRouter
get_node_id()

:returns string containing the Node ID

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

:returns string containing the Router ID

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_node_id(node)

Sets the router id of the object

Parameters:node – String containing the node id
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
set_router_id(rid)

Sets the router id of the object

Parameters:rid – String containing the router id
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.acitoolkit.OutputTerminal(terminal_name, parent=None)

Bases: acitoolkit.acitoolkit.BaseTerminal

Input terminal for a graph. It is input with respect to the provider

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_filter(filter_obj)

Add Filter to the Terminal, roughly equivalent to vzRsFiltAtt

Parameters:filter_obj – Instance of Filter class. Represents a Filter that is added to the Terminal. Multiple Filters can be assigned to a single Terminal.
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_filters()

Get all of the filters that are attached to this Terminal.

Returns:List of Filter objects
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 Terminal Object

Returns:json dictionary of the ContractSubject
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()
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.acitoolkit.OutsideEPG(epg_name, parent=None)

Bases: acitoolkit.acitoolkit.CommonEPG

OutsideEPG class, roughly equivalent to l3ext:InstP

Parameters:
  • epg_name – String containing the name of this EPG
  • parent – Instance of the AppProfile class representing the Application Profile where this EPG is contained.
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:
consume(contract)

Make this EPG consume a Contract

Parameters:contract – Contract class instance to be consumed by this EPG.
Returns:True
consume_cif(contract_interface)

Make this EPG consume a ContractInterface

Parameters:contract_interface – ContractInterface class instance to be consumed by this EPG.
Returns:True
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.
does_consume(contract)

Check if this EPG consumes a specific Contract

Parameters:contract – Instance of Contract class to check if it is consumed by this EPG.
Returns:True or False. True if the EPG does consume the Contract.
does_consume_cif(contract_interface)

Check if this EPG consumes a specific Contract

Parameters:contract_interface
Returns:True or False. True if the EPG does consume the ContractInterface.
does_protect(taboo)

Check if this EPG is protected by a specific Taboo.

Parameters:taboo – Instance of Taboo class to check if it protects this EPG.
Returns:True or False. True if the EPG is protected by the Taboo.
does_provide(contract)

Check if this EPG provides a specific Contract.

Parameters:contract – Instance of Contract class to check if it is provided by this EPG.
Returns:True or False. True if the EPG does provide the Contract.
dont_consume(contract)

Make this EPG not consume a Contract. It does not check to see if the Contract was already consumed

Parameters:contract – Instance of Contract class to be no longer consumed by this EPG.
Returns:True
dont_consume_cif(contract_interface)

Make this EPG not consume a ContractInterface. It does not check to see if the ContractInterface was already consumed

Parameters:contract_interface
Returns:True
dont_protect(taboo)

Make this EPG not protected by a Taboo

Parameters:taboo – Instance of Taboo class to no longer protect this EPG.
Returns:True
dont_provide(contract)

Make this EPG not provide a Contract

Parameters:contract – Instance of Contract class to be no longer provided by this EPG.
Returns:True
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
get(session, parent=None, tenant=None)

Gets all of the EPGs from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • parent – Instance of the AppProfile class used to limit the EPGs retreived from the APIC.
  • tenant – Instance of Tenant class used to limit the EPGs retreived from the APIC.
Returns:

List of CommonEPG instances (or EPG instances if called from EPG 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_all_consumed(deleted=False)

Get all of the Contracts consumed by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are consumed or that the consumed was marked as deleted
Returns:List of Contract objects that are consumed by the EPG.
get_all_consumed_cif(deleted=False)

Get all of the ContractInterfaces consumed by this EPG

Parameters:deleted – Boolean indicating whether to get ContractInterfaces that are consumed or that the consumed was marked as deleted
Returns:List of ContractInterface objects that are consumed by the EPG.
get_all_protected(deleted=False)

Get all of the Taboos protecting this EPG

Parameters:deleted – Boolean indicating whether to get Taboos that are protected or that the protected was marked as deleted
Returns:List of Taboo objects that are protecting the EPG.
get_all_provided(deleted=False)

Get all of the Contracts provided by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are provided or that the provided was marked as deleted
Returns:List of Contract objects that are provided by the EPG.
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 interfaces that this EPG is attached. The default is to get list of ‘attached’ interfaces. If ‘status’ is set to ‘detached’ it will return the list of detached Interface objects (Those EPGs which are no longer attached to an Interface, but the configuration is not yet pushed to the APIC.)

Parameters:status – ‘attached’ or ‘detached’. Defaults to ‘attached’.
Returns:List of Interface objects
get_json()

Returns json representation of the EPG

Returns:json dictionary of the EPG
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.
protect(taboo)

Make this EPG protected by a Taboo

Parameters:taboo – Instance of Taboo class to protect this EPG.
Returns:True
provide(contract)

Make this EPG provide a Contract

Parameters:contract – Instance of Contract class to be provided by this EPG.
Returns:True
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.acitoolkit.OutsideL2(l2out_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Represents the L2Out for external connectivity

Parameters:
  • l2out_name – String containing the name of this OutsideL2
  • parent – Instance of the Tenant class representing the tenant owning this OutsideL2.
add_bd(bd)

Add BridgeDomain to the EPG

Parameters:bd – Instance of BridgeDomain class to assign to this OutsideL2.
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_l2extdom(extdom)

Set the L2ExternalDomain for this BD

Parameters:extdom
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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()

Returns json representation of OutsideL2

Returns:json dictionary of OutsideL2
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_bd()

Check if the BridgeDomain has been assigned

Returns:True or False. True if a BridgeDomain has been assigned to this L2Interface.
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_l2extdom()
Returns:Boolean indicating presence of L2 External Domain Attachment
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_bd()

Remove the BridgeDomain from the EPG

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.acitoolkit.OutsideL2EPG(epg_name, parent=None)

Bases: acitoolkit.acitoolkit.CommonEPG

OutsideL2EPG class, roughly equivalent to l2ext:InstP

Parameters:
  • epg_name – String containing the name of this EPG
  • parent – Instance of the AppProfile class representing the Application Profile where this EPG is contained.
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:
consume(contract)

Make this EPG consume a Contract

Parameters:contract – Contract class instance to be consumed by this EPG.
Returns:True
consume_cif(contract_interface)

Make this EPG consume a ContractInterface

Parameters:contract_interface – ContractInterface class instance to be consumed by this EPG.
Returns:True
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.
does_consume(contract)

Check if this EPG consumes a specific Contract

Parameters:contract – Instance of Contract class to check if it is consumed by this EPG.
Returns:True or False. True if the EPG does consume the Contract.
does_consume_cif(contract_interface)

Check if this EPG consumes a specific Contract

Parameters:contract_interface
Returns:True or False. True if the EPG does consume the ContractInterface.
does_protect(taboo)

Check if this EPG is protected by a specific Taboo.

Parameters:taboo – Instance of Taboo class to check if it protects this EPG.
Returns:True or False. True if the EPG is protected by the Taboo.
does_provide(contract)

Check if this EPG provides a specific Contract.

Parameters:contract – Instance of Contract class to check if it is provided by this EPG.
Returns:True or False. True if the EPG does provide the Contract.
dont_consume(contract)

Make this EPG not consume a Contract. It does not check to see if the Contract was already consumed

Parameters:contract – Instance of Contract class to be no longer consumed by this EPG.
Returns:True
dont_consume_cif(contract_interface)

Make this EPG not consume a ContractInterface. It does not check to see if the ContractInterface was already consumed

Parameters:contract_interface
Returns:True
dont_protect(taboo)

Make this EPG not protected by a Taboo

Parameters:taboo – Instance of Taboo class to no longer protect this EPG.
Returns:True
dont_provide(contract)

Make this EPG not provide a Contract

Parameters:contract – Instance of Contract class to be no longer provided by this EPG.
Returns:True
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
get(session, parent=None, tenant=None)

Gets all of the EPGs from the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • parent – Instance of the AppProfile class used to limit the EPGs retreived from the APIC.
  • tenant – Instance of Tenant class used to limit the EPGs retreived from the APIC.
Returns:

List of CommonEPG instances (or EPG instances if called from EPG 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_all_consumed(deleted=False)

Get all of the Contracts consumed by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are consumed or that the consumed was marked as deleted
Returns:List of Contract objects that are consumed by the EPG.
get_all_consumed_cif(deleted=False)

Get all of the ContractInterfaces consumed by this EPG

Parameters:deleted – Boolean indicating whether to get ContractInterfaces that are consumed or that the consumed was marked as deleted
Returns:List of ContractInterface objects that are consumed by the EPG.
get_all_protected(deleted=False)

Get all of the Taboos protecting this EPG

Parameters:deleted – Boolean indicating whether to get Taboos that are protected or that the protected was marked as deleted
Returns:List of Taboo objects that are protecting the EPG.
get_all_provided(deleted=False)

Get all of the Contracts provided by this EPG

Parameters:deleted – Boolean indicating whether to get Contracts that are provided or that the provided was marked as deleted
Returns:List of Contract objects that are provided by the EPG.
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 interfaces that this EPG is attached. The default is to get list of ‘attached’ interfaces. If ‘status’ is set to ‘detached’ it will return the list of detached Interface objects (Those EPGs which are no longer attached to an Interface, but the configuration is not yet pushed to the APIC.)

Parameters:status – ‘attached’ or ‘detached’. Defaults to ‘attached’.
Returns:List of Interface objects
get_json()

Returns json representation of the EPG

Returns:json dictionary of the EPG
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.
protect(taboo)

Make this EPG protected by a Taboo

Parameters:taboo – Instance of Taboo class to protect this EPG.
Returns:True
provide(contract)

Make this EPG provide a Contract

Parameters:contract – Instance of Contract class to be provided by this EPG.
Returns:True
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.acitoolkit.OutsideL3(l3out_name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

Represents the L3Out for external connectivity

Parameters:
  • l3out_name – String containing the name of this OutsideL3
  • parent – Instance of the Tenant class representing the tenant owning this OutsideL3.
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_context(context)

Add context to the EPG

Parameters:context – Instance of Context class to assign to this OutsideL3.
add_l3extdom(extdom)

Set the L3ExternalDomain for this BD

Parameters:extdom
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_context()

Return the assigned context

Returns:Instance of Context class that this OutsideL3 is assigned. If no Context is assigned, None is returned.
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()

Returns json representation of OutsideL3

Returns:json dictionary of OutsideL3
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_context()

Check if the context has been assigned

Returns:True or False. True if a Context has been assigned to this L3Interface.
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_l3extdom()
Returns:Boolean indicating presence of L3 External Domain Attachment
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_context()

Remove the context from the EPG

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.acitoolkit.OutsideNetwork(name, parent)

Bases: acitoolkit.acitoolkit.BaseSubnet

OutsideNetwork class, roughly equivalent to l3extSubnet in the APIC model

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
addr

Subnet address

Returns:String containing the subnet default gateway IP address and mask e.g. “1.2.3.4/24”
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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
get_addr()

Get the subnet address

Returns:The subnet address as a string in the form of <ipaddr>/<mask>
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)
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()

Returns json representation of the OutsideNetwork object.

Returns:json dictionary of OutsideNetwork
get_parent()
Returns:Parent of this object.
get_scope()

Get the subnet scope

Returns:The subnet scope as a 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_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),]
ip

IP address of the subnet in the form of Address/mask e.g. 10.1.1.1/16

Returns:String containing the IP address
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_addr(addr)

Set the subnet address

Parameters:addr – The subnet default gateway address as a string in the form of <ipaddr>/<mask>
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
set_scope(scope)

Set the subnet scope

Parameters:scope – String containing the scope
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.acitoolkit.PhysDomain(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

Physical Network domain

Parameters:
  • name – String containing the PhysDomain name
  • parent – An instance of DomP class representing
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)

Gets all of the Physical Domains from the APIC

Parameters:session – the instance of Session used for APIC communication
Returns:List of PhysDomain objects
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
classmethod get_by_name(session, infra_name)

Gets all of the Physical Domains from the APIC

Parameters:
  • infra_name
  • session – the instance of Session used for APIC communication
Returns:

List of PhysDomain objects

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()

Returns json representation of the fvTenant object

Returns:A json dictionary of fvTenant
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
static get_url(fmt='json')

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

Parameters:fmt – optional format string, default is ‘json’
Returns:URL string
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.
push_to_apic(session)

Push the appropriate configuration to the APIC for this Phys Domain. All of the subobject configuration will also be pushed.

Parameters:session – the instance of Session used for APIC communication
Returns:Requests Response code
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.acitoolkit.PortChannel(name)

Bases: acitoolkit.acibaseobject.BaseInterface

This class defines a port channel 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(interface)

Attach an interface to this PortChannel

Parameters:interface
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_dn(dn)

Create a PortChannel instance based on the specified DN

Parameters:dn – String containing the DN
Returns:Instance of PortChannel class
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(interface)

Detach an interface from this PortChannel

Parameters: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
static get(session)

Gets all of the port channel interfaces from the APIC

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.
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()
Returns json representation of the PortChannel
Returns:json dictionary of the PortChannel
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.

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
static get_url(fmt='json')

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

Parameters:fmt – optional format string, default is ‘json’
Returns:URL string
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_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 True since a PortChannel is an interface

is_vpc()

Returns True if the PortChannel is a VPC

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.acitoolkit.Search

Bases: acitoolkit.acibaseobject.BaseACIObject

This is an empty class used to create a search object for use with the “find” method.

Attaching attributes to this class and then invoking find will return all objects with matching attributes in the object hierarchy at and below where the find is invoked.

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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(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.acitoolkit.Subnet(subnet_name, parent=None)

Bases: acitoolkit.acitoolkit.BaseSubnet

Subnet : roughly equivalent to fvSubnet

Parameters:
  • subnet_name – String containing the name of this Subnet instance.
  • parent – An instance of BridgeDomain class representing the BridgeDomain which contains this Subnet.
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
addr

Subnet address

Returns:String containing the subnet default gateway IP address and mask e.g. “1.2.3.4/24”
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, bridgedomain, tenant)

Gets all of the Subnets from the APIC for a particular tenant and bridgedomain.

Parameters:
  • session – the instance of Session used for APIC communication
  • bridgedomain – the instance of BridgeDomain used to limit the Subnet instances retreived from the APIC
  • tenant – the instance of Tenant used to limit the Subnet instances retreived from the APIC
Returns:

List of Subnet objects

get_addr()

Get the subnet address

Returns:The subnet address as a string in the form of <ipaddr>/<mask>
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)
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
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_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 subnet

Returns:json dictionary of subnet
get_parent()
Returns:Parent of this object.
get_scope()

Get the subnet scope

Returns:The subnet scope as a 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_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),]
ip

IP address of the subnet in the form of Address/mask e.g. 10.1.1.1/16

Returns:String containing the IP address
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_addr(addr)

Set the subnet address

Parameters:addr – The subnet default gateway address as a string in the form of <ipaddr>/<mask>
set_parent(parent_obj)

Set the parent object

Parameters:parent_obj – Instance of the parent object
Returns:None
set_scope(scope)

Set the subnet scope

Parameters:scope – The scope of the subnet. Use “public” when the subnet

needs to be advertised externally, “private” when no external routing for the subnet is required (only internal), and “shared” when a route for the subnet needs to be leaked to a different VRF within the fabric. Note that “public” and “private” are mutually exclusive, but “shared” can be appended to any of them (“e.g. set_scope(“public,shared”)).

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.acitoolkit.Taboo(contract_name, parent=None)

Bases: acitoolkit.acitoolkit.BaseContract

Taboo : Class for Taboos

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_all_filter_entries(direction='bidirectional-only')

Get all of the filter entries contained within this Contract/Taboo

Parameters:direction – String containing the type of filter entries to gather Valid values are ‘bidirectional-only’, ‘input-only’, ‘output-only’, ‘all’ Default is ‘bidirectional-only’
Returns:List of FilterEntry instances
get_attributes(name=None)
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()

Returns json representation of the contract

Returns:json dictionary of the contract
get_parent()
Returns:Parent of this object.
get_scope()

Get the scope of this contract. Valid values are ‘context’, ‘global’, ‘tenant’, and ‘application-profile’

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_table(taboos, title='')

Will create table of taboo information for a given tenant

Parameters:
  • title
  • taboos
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()
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
set_scope(scope)

Set the scope of this contract. Valid values are ‘context’, ‘global’, ‘tenant’, and ‘application-profile’

Parameters:scope – String containing one of the following ‘context’, ‘global’, ‘tenant’, or ‘application-profile’
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.acitoolkit.Tag(name=None, parent=None)

Bases: acitoolkit.acibaseobject._Tag

Tag class.

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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(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()
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()
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.acitoolkit.Tenant(name, parent=None)

Bases: acitoolkit.acibaseobject.BaseACIObject

The Tenant class is used to represent the tenants within the acitoolkit object model. In the APIC model, this class is roughly equivalent to the fvTenant class.

Parameters:
  • name – String containing the Tenant name
  • parent – None or An instance of Fabric class representing the Pod which contains this Tenant.
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.
classmethod exists(session, tenant)

Check if a tenant exists on the APIC.

Parameters:
  • session – the instance of Session used for APIC communication
  • tenant – the instance of Tenant to check if exists on the APIC
Returns:

True or False

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 tenants from the APIC.

Parameters:
  • parent – Parent object of the Tenant
  • session – the instance of Session used for APIC communication
Returns:

a list of Tenant objects

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, names=(), limit_to=(), subtree='full', config_only=False, parent=None)

Get the Tenant objects and all of the children objects.

Parameters:
  • session – the instance of Session used for APIC communication
  • names – list of strings containing the tenant names. If no list is given, all tenants will be collected. It should be noted that if relations extend across tenants, the relation will only be populated if the tenants are included in this list.
  • limit_to – list of strings containing the APIC classes to limit the collection to i.e. [‘fvTenant’, ‘fvBD’]. If no list is given, all classes will be collected.
  • subtree – String containing the rsp-subtree option. Default is ‘full’.
  • config_only – Boolean containing whether to collect only configurable parameters
  • parent – The parent instance to assign to the tenant objects. If None, a Fabric instance will be created.
Returns:

Requests Response code

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 fvTenant object

Returns:A json dictionary of fvTenant
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.

static get_table(tenants, title='')

Will create table of switch context information

Parameters:
  • title
  • tenants
get_tags()

Get the tags assigned to this object.

Returns:List of tag instances
static get_url(fmt='json')

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

Parameters:fmt – optional format string, default is ‘json’
Returns:URL string
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.
push_to_apic(session)

Push the appropriate configuration to the APIC for this Tenant. All of the subobject configuration will also be pushed.

Parameters:session – the instance of Session used for APIC communication
Returns:Requests Response code
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.acitoolkit.TunnelInterface(if_type, pod, node, tunnel)

Bases: object

This class describes a tunnel interface

class acitoolkit.acitoolkit.VMM(name, ipaddr, credentials, vswitch_info, network_pool)

Bases: acitoolkit.acibaseobject.BaseACIObject

This class defines an instance of connectivity to a Virtual Machine Manager (such as VMware vCenter)

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)
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_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
static get_url(fmt='json')

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

Parameters:fmt – optional format string, default is ‘json’
Returns:URL string
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.acitoolkit.VMMCredentials(name, uid, pwd)

Bases: acitoolkit.acibaseobject.BaseACIObject

This class defines the credentials used to login to a Virtual Machine Manager

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
get(session, toolkit_class, apic_class, parent=None, tenant=None)

Generic classmethod to get all of a particular APIC class.

Parameters:
  • session – the instance of Session used for APIC communication
  • toolkit_class – acitoolkit class to return
  • apic_class – String containing class name from the APIC object model.
  • parent – Object to assign as the parent to the created objects.
  • tenant – Tenant object to assign the created objects.
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_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.acitoolkit.VMMvSwitchInfo(vendor, container_name, vswitch_name)

Bases: object

This class contains the information necessary for creating the vSwitch on the Virtual Machine Manager

class acitoolkit.acitoolkit.VmmDomain(name, parent)

Bases: acitoolkit.acibaseobject.BaseACIObject

VMMDomain class

Parameters:
  • name – String containing the VMM Domain name
  • parent – An instance of DomP class
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)

Gets all of the VMM Domains from the APIC

Parameters:session – the instance of Session used for APIC communication
Returns:List of VMM Domain objects
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
classmethod get_by_name(session, infra_name)

Gets all of the VMM Domains from the APIC

Parameters:
  • infra_name
  • session – the instance of Session used for APIC communication
Returns:

List of VMM Domain objects

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()

Returns json representation of the vmmDomP object

Returns:A json dictionary of vmmDomP
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

acitoolkit.acitoolkit.build_object_dictionary(objs)

Will build a dictionary indexed by object class that contains all the objects of that class

Parameters:objs
Returns: