ciscoconfparse.ConfigList Object

class ciscoconfparse.ConfigList(initlist=None, comment_delimiter='!', debug=0, factory=False, ignore_blank_lines=True, syntax='ios', **kwargs)

A custom list to hold BaseCfgLine objects. Most people will never need to use this class directly.

Initialize the class.

Parameters:
initlistlist

A list of parsed IOSCfgLine objects

comment_delimiterstr

A comment delimiter. This should only be changed when parsing non-Cisco IOS configurations, which do not use a ! as the comment delimiter. comment defaults to ‘!’

debugint

debug defaults to 0, and should be kept that way unless you’re working on a very tricky config parsing problem. Debug output is not particularly friendly

ignore_blank_linesbool

ignore_blank_lines defaults to True; when this is set True, ciscoconfparse ignores blank configuration lines. You might want to set ignore_blank_lines to False if you intentionally use blank lines in your configuration (ref: Github Issue #3).

Returns:
An instance of an ConfigList object.
CiscoConfParse = None
__add__(other)
__class_getitem__ = <bound method GenericAlias of <class 'ciscoconfparse.ciscoconfparse.ConfigList'>>
__contains__(value)
__copy__()
__delitem__(ii)
__enter__()
__eq__(other)

Return self==value.

__exit__(*args, **kwargs)
__ge__(other)

Return self>=value.

__getattribute__(arg)

Call arg on ConfigList() object, and if that fails, call arg from the ccp_ref attribute

__getitem__(ii)
__gt__(other)

Return self>value.

__hash__ = None
__iadd__(other)
__imul__(val)
__iter__()
__le__(other)

Return self<=value.

__len__()
__lt__(other)

Return self<value.

__mul__(val)
__radd__(other)
__repr__()

Return repr(self).

__reversed__()
__rmul__(val)
__setitem__(ii, val)
__slots__ = ()
__str__()

Return str(self).

property access_list

Return a dictionary of ACL name to ACE (list) mappings

property all_parents
append(**kwargs)

S.append(value) – append value to the end of the sequence

property as_text

Return the configuration as a list of text lines

bootstrap_obj_init_ng(text_list=None, debug=0)

Accept a text list, and format into a list of *CfgLine() objects.

This method returns a list of *CfgLine() objects.

ccp_ref = None
clear() None -- remove all items from S
comment_delimiter = None
config_hierarchy()

Walk this configuration and return the following tuple at each parent ‘level’: (list_of_parent_sibling_objs, list_of_nonparent_sibling_objs)

copy()
count(value) integer -- return number of occurrences of value
debug = None
dna = 'ConfigList'
extend(other)

S.extend(iterable) – extend sequence by appending elements from the iterable

factory = None
ignore_blank_lines = None
index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(**kwargs)

S.insert(index, value) – insert value before index

insert_after(**kwargs)
insert_before(exist_val=None, new_val=None, atomic=False)

Insert new_val before all occurances of exist_val.

Parameters:
exist_valstr

An existing text value. This may match multiple configuration entries.

new_valstr

A new value to be inserted in the configuration.

atomicbool

A boolean that controls whether the config is reparsed after the insertion (default False)

Returns:
list

An ios-style configuration list (indented by stop_width for each configuration level).

Examples

>>> parse = CiscoConfParse(config=["a a", "b b", "c c", "b b"])
>>> # Insert 'g' before any occurance of 'b'
>>> retval = parse.insert_before("b b", "X X")
>>> parse.commit()
>>> parse.ioscfg
... ["a a", "X X", "b b", "c c", "X X", "b b"]
>>>
iter_no_comments(begin_index=0)
iter_with_comments(begin_index=0)
property last_index
property names

Return a dictionary of name to address mappings

property object_group_network

Return a dictionary of name to object-group network mappings

pop([index]) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

reassign_linenums()
remove(val)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

sort(_unknown_arg, *args, **kwds)
syntax = None