Stage Template¶
In this section you can find the skeleton code that all clean stages will start from. The class inheritance differs slightly depending on if you are writing an entirely new stage or abstracting an existing stage.
Entirely New Stage¶
For entirely new stages, write a new class that inherits the BaseStage
class from genie.libs.clean
. Choose a short name that describes what the stage does. Finally, the class must contain three main sections (including the comments in the below example): Stage Schema
, Argument Defaults
, and Execution order of Stage steps
.
For ease, just copy/paste this example, and change the name of the class.
1from genie.libs.clean import BaseStage
2
3class ChangeBootVariable(BaseStage):
4
5 # ============
6 # Stage Schema
7 # ============
8 schema = {
9
10 }
11
12 # =================
13 # Argument Defaults
14 # =================
15
16 # ==============================
17 # Execution order of Stage steps
18 # ==============================
19 exec_order = [
20
21 ]
Abstract an Existing Stage¶
Say we have a current implementation of ChangeBootVariable that is designated as an IOSXE stage an IOSXE cat9k device that the existing implementation doesn’t work with. What we can do is write a new class and inherit the IOSXE one. This allows us to reuse the code that works and overwrite the code that doesn’t.
For ease, just copy/paste this example, change the import, and change the name of the class.
1from genie.libs.clean.stages.iosxe.stages import ChangeBootVariable as ChangeBootVariableIosxe
2
3class ChangeBootVariable(ChangeBootVariableIosxe):
4
5 # ============
6 # Stage Schema
7 # ============
8 schema = {
9
10 }
11
12 # =================
13 # Argument Defaults
14 # =================
15
16 # ==============================
17 # Execution order of Stage steps
18 # ==============================
19 exec_order = [
20
21 ]