API Reference
ttp_templates.parse_output(data: str, platform: Optional[str] = None, command: Optional[str] = None, path: Optional[str] = None, yang: Optional[str] = None, misc: Optional[str] = None, structure: Optional[str] = 'list', template_vars: Optional[Dict] = None) -> Union[Dict, List]
Function to load template text and parse data provided
Valid combinations of template location
path
attribute is always more preferred
path="./misc/foo/bar.txt"
platform="cisco_ios", command="show version"
yang="ietf-interfaces", platform="cisco_ios"
misc="foo_folder/bar_template.txt"
Parameters:
-
data
(
str
) –data to parse
-
path
(
Optional[str]
) –OS path to template to load
-
platform
(
Optional[str]
) –name of the platform to load template for
-
command
(
Optional[str]
) –command to load template for
-
yang
(
Optional[str]
) –name of YANG module to load template for
-
misc
(
Optional[str]
) –OS path to template within repository misc folder
-
structure
(
Optional[str]
) –results structure list, dictionary or flat_list
-
template_vars
(
Optional[Dict]
) –variables to load in template object
Source code in ttp_templates\ttp_templates.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
ttp_templates.get_template(path: Optional[str] = None, platform: Optional[str] = None, command: Optional[str] = None, yang: Optional[str] = None, misc: Optional[str] = None) -> str
Function to locate template file and return it's content
Valid combinations of template location
path
attribute is always more preferred
path="./misc/foo/bar.txt"
platform="cisco_ios", command="show version"
yang="ietf-interfaces", platform="cisco_ios"
misc="foo_folder/bar_template.txt"
Parameters:
-
path
(
Optional[str]
) –OS path to template to load
-
platform
(
Optional[str]
) –name of the platform to load template for
-
command
(
Optional[str]
) –command to load template for
-
yang
(
Optional[str]
) –name of YANG module to load template for
-
misc
(
Optional[str]
) –OS path to template within repository misc folder
Source code in ttp_templates\ttp_templates.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
ttp_templates.list_templates(pattern: str = '*') -> dict
Function to list available templates matching given pattern.
Primary usecase for this function is to simplify integration with other applications by providing API interface to list available TTP templates.
Parameters:
-
pattern
(
str
) –glob pattern to filter templates by name
-
return
–
dictionary with platform, yang and misc keys
Source code in ttp_templates\ttp_templates.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|