API Reference

Helper methods

pandevice library is a framework for interacting with Palo Alto Networks devices

Documentation available at http://pandevice.readthedocs.io

class pandevice.PanOSVersion(vstring=None)[source]

LooseVersion with convenience properties to access version components

pandevice.convert_if_int(string)[source]

Convert a string to an int, only if it is an int

Parameters:string (str) – The string to convert if it’s an integer
Returns:int or str of the original value, dependin if it could be converted to an int
pandevice.string_or_list(value)[source]

Return a list containing value

This method allows flexibility in class __init__ arguments, allowing you to pass a string, object, list, or tuple. In all cases, a list will be returned.

Parameters:value – a string, object, list, or tuple
Returns:list

Examples

“string” -> [string] (“t1”, “t2”) -> [“t1”, “t2”] [“l1”, “l2”] -> [“l1”, “l2”] None -> None

pandevice.string_or_list_or_none(value)[source]

Return a list containing value

This method allows flexibility in class __init__ arguments, allowing you to pass a string, object, list, tuple, or None. In all cases, a list will be returned.

Parameters:value – a string, object, list, tuple, or None
Returns:list

Examples

“string” -> [string] (“t1”, “t2”) -> [“t1”, “t2”] [“l1”, “l2”] -> [“l1”, “l2”] None -> []

pandevice.tree_legend()[source]

Display a legend for the colors of the tree method

pandevice.tree_legend_dot()[source]

Create a graphviz dot string for a legend graph

pandevice.xml_combine(root, elements)[source]

Combine two xml elements and their subelements

This method will modify the ‘root’ argument and does not return anything.

Parameters:
  • root (Element) – The Element that will contain the merger
  • elements (Element or list) – If an Element, merge all subelements of this element into root. If a list, merge all Elements in the list into root.
pandevice.yesno(value)[source]

Convert ‘yes’ or ‘no’ to True or False

Parameters:value (str) – The string containing ‘yes’ or ‘no’
Returns:True if value is ‘yes’, False if value is ‘no’
Return type:bool