Skip to content

Commit ab2a200

Browse files
examples/resources: add script studio_static_config_simple.py (#45)
1 parent 9359532 commit ab2a200

5 files changed

Lines changed: 724 additions & 0 deletions

File tree

examples/resources/studio/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,64 @@ uv run studio_update.py --server 192.0.2.10:443 --token-file token.tok --cert-f
194194
--yaml-file=studio-avd-campus-fabric-inputs.yaml \
195195
--build-only True
196196
```
197+
198+
## studio_static_config_simple.py
199+
200+
The `studio_static_config_simple.py` script manages the **Static Configuration** studio. It creates
201+
containers, assigns configlets to containers and devices, and handles tag-based device matching.
202+
203+
The script is driven by the `INVENTORY` variable defined at the top of the file. It supports:
204+
205+
- **Containers** with their own configlets (matched via `location:<name>` tags).
206+
- **Devices** placed under containers, with per-device configlets.
207+
- **Configlet resolution**: create a new configlet from a file (`configlet_file`), or reference an
208+
existing one on CloudVision by name only.
209+
- **Automatic tag assignment**: devices inherit `location:<segment>` tags for every segment in their
210+
container path, so that container queries match correctly.
211+
212+
> **Note:** The script re-creates the container hierarchy from scratch on every run. Containers
213+
> created manually *inside* the same hierarchy will be removed. Containers outside the hierarchy
214+
> (e.g. `France/DC3` when the script only manages `US/...`) are not affected.
215+
216+
```shell
217+
python3 studio_static_config_simple.py --help
218+
usage: studio_static_config_simple.py [-h] --server SERVER --token-file TOKEN_FILE
219+
[--cert-file CERT_FILE] [--insecure]
220+
[--operation {get,set}] [--build-only]
221+
222+
options:
223+
-h, --help show this help message and exit
224+
--server SERVER CVP server in <host>:<port> format
225+
--token-file TOKEN_FILE
226+
File containing the service account token
227+
--cert-file CERT_FILE
228+
Path to CA certificate file
229+
--insecure Skip TLS certificate verification
230+
--operation {get,set} get: list configlets/assignments; set: assign configlets
231+
--build-only Stop after building (no submission)
232+
```
233+
234+
### List existing configlets and assignments
235+
236+
```shell
237+
python3 studio_static_config_simple.py \
238+
--server 192.0.2.10:443 --token-file token.tok --insecure \
239+
--operation get
240+
```
241+
242+
### Assign configlets defined in INVENTORY
243+
244+
```shell
245+
python3 studio_static_config_simple.py \
246+
--server 192.0.2.10:443 --token-file token.tok --insecure \
247+
--operation set
248+
```
249+
250+
### Build only (no submission)
251+
252+
```shell
253+
python3 studio_static_config_simple.py \
254+
--server 192.0.2.10:443 --token-file token.tok --insecure \
255+
--operation set --build-only
256+
```
257+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
! Configlet apply only to leaf1
2+
hostname leaf1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
! Configlet apply only to leaf2
2+
hostname leaf2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
! Configlet apply to all devices under US/DC1
2+
ntp server 8.8.8.8

0 commit comments

Comments
 (0)