Cleaning Devices¶
For cleaning devices that are unlike
each other (different os/platform/steps required) it is best to use the devices
block inside the Clean Yaml
. This block allows you to customize the clean on a per-device basis. The devices
block is an optional block (although most commonly used).
It is responsible for housing the clean information at a device-specific level such as:
Images to load
Stages to use
Order that the Stages should be executed in
The topics covered in this section are:
Adding the Devices Block¶
In the Clean YAML
that has the Cleaner Class
added, add the devices
block as shown below.
1 2 3 4 5 6 | cleaners: PyatsDeviceClean: module: genie.libs.clean devices: [] devices: |
Adding a Device¶
Next, add the device to the Clean YAML
in which we want to write a Clean for. This device must exist in your
Testbed YAML and for the purposes of this guide, the device is named PE1
.
1 2 3 4 5 6 7 | cleaners: PyatsDeviceClean: module: genie.libs.clean devices: [PE1] devices: PE1: |
It is supported to add any amount of devices under the devices block. Below shows how to add another device named PE2
.
1 2 3 4 5 6 7 8 9 | cleaners: PyatsDeviceClean: module: genie.libs.clean devices: [PE1, PE2] devices: PE1: PE2: |
Adding Stages¶
Note
In the event you do not know what a stage is, what it does, and what arguments they accept, you can find that information in the Intro to Stages document.
There are three steps in order to add a stage to the clean.
Find a suitable stage from the Clean Stage Browser.
Choose which device to add the stage under.
Choose the order the stage(s) will execute in.
Below is an example of adding the connect
stage under PE1
in the Clean YAML
. This stage has a few arguments that are all optional. If in the case you are satisfied
with the default values, you can leave the value side of the key-value pair empty as shown in the example.
The order
key must also be defined, even if there is only one stage.
1 2 3 4 5 6 7 8 9 10 11 12 13 | cleaners: PyatsDeviceClean: module: genie.libs.clean devices: [PE1, PE2] devices: PE1: connect: order: - connect PE2: |
It is supported to add as many stages as needed. Below is an example of adding another stage called
apply_configuration
under PE1
in the Clean YAML
. To pass any arguments for the stage, simply add it under the stage as shown in
the example.
It will run after the connect
stage as defined under the order
key.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | cleaners: PyatsDeviceClean: module: genie.libs.clean devices: [PE1, PE2] devices: PE1: connect: apply_configuration: configuration: hostname PE1 order: - connect - apply_configuration PE2: |