Skip to content

Commit 573c385

Browse files
examples: add I&T studio onboarding example
Change-Id: I3d78f546d2fa6d9d9e383cd4061e9675f574cc4a
1 parent 3ec5177 commit 573c385

File tree

2 files changed

+427
-0
lines changed

2 files changed

+427
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Studios examples
2+
3+
These examples use multiple resources including studio.v1, workspace.v1, studio_topology.v1.
4+
5+
## Authenticating with CloudVision
6+
7+
### CloudVision On-Prem
8+
9+
Service accounts are the recommended way to generate tokens (same steps can be used as on [CVaaS](#cloudvision-as-a-service)).
10+
11+
For quick tests the [get_token.py](../../get_token.py) script can be used to get the token and the certificate from
12+
the CloudVision server:
13+
14+
`python3 get_token.py --server 192.0.2.79 --username cvpadmin --password arastra --ssl`
15+
16+
The two files that will be saved can then be used to authenticate:
17+
- token.txt
18+
- cvp.crt
19+
20+
### CloudVision as a Service
21+
22+
To access the CloudVision as-a-Service and send API requests, “Service Account Token” is needed.
23+
After obtaining the service account token, it can be used for authentication when sending API requests.
24+
25+
Service accounts can be created from the Settings page where a service token can be generated as seen below:
26+
27+
![serviceaccount1](../../Connector/media/serviceaccount1.png)
28+
![serviceaccount2](../../Connector/media/serviceaccount2.png)
29+
![serviceaccount3](../../Connector/media/serviceaccount3.png)
30+
31+
## studio_onboarding.py
32+
33+
The `studio_onboarding.py` script can be used to manage the `Inventory & Topology` studio to onboard
34+
devices and their interfaces.
35+
36+
```shell
37+
python examples/resources/studio/studio_onboarding.py --help
38+
usage: studio_onboarding.py [-h] --server SERVER --token-file TOKEN_FILE [--cert-file CERT_FILE] [--wsid WSID]
39+
[--operation {set,get,set-all}] [--update-id UPDATE_ID] [--build-only BUILD_ONLY]
40+
41+
options:
42+
-h, --help show this help message and exit
43+
--server SERVER CloudVision server to connect to in <host>:<port> format
44+
--token-file TOKEN_FILE
45+
file with access token
46+
--cert-file CERT_FILE
47+
certificate to use as root CA
48+
--wsid WSID existing workspace ID, if not wanting to create a new one
49+
--operation {set,get,set-all}
50+
whether to get or set inputs
51+
--update-id UPDATE_ID
52+
Update ID from UpdateService call to set
53+
--build-only BUILD_ONLY
54+
whether to stop after building the changes (no submission)
55+
```
56+
57+
58+
### Get the updates
59+
60+
```shell
61+
python studio_onboarding.py --server www.arista.io:443 --token-file token.tok --build-only True
62+
63+
Creating workspace "Accepting new devices and interfaces into I&T Studio"
64+
WorkspaceID created: 5f88c496-71ca-469d-af19-2a17a5f5d583
65+
modified::CONNECTION::{"deviceId":"3AB1C9E6B1A1D4DC6B11990838D1D5E9","hostname":"ag-dc1-spine2","interfaceName":"Management0","newValue":{"neighborDeviceId":"D60EC473E29C51A45C50D84B9D89F756","neighborHostname":"ag-dc1-leaf1b","neighborInterfaceName":"Management0"},"oldValue":{"neighborDeviceId":"1207F35678E44BD8E7C7EC8BB18DDB8C","neighborHostname":"ag-dc1-leaf1a","neighborInterfaceName":"Management0"}}
66+
add::DEVICE::{"deviceId":"C7CEA9FC9030555D54E33DA26E0DC09B","hostname":"dc1-leaf2c","interfaceSize":1}
67+
add::DEVICE::{"deviceId":"ZZZ7777777","hostname":"leaf503","interfaceSize":73}
68+
remove::DEVICE::{"deviceId":"SN-dc1-leaf1","hostname":"dc1-leaf1","interfaceSize":6}
69+
remove::DEVICE::{"deviceId":"ZZZ9999999","hostname":"leaf401","interfaceSize":73}
70+
Building workspace
71+
Build request 09e4c82c-173e-4c79-a235-ca2fd48ce2be sent
72+
Waiting for build to complete
73+
Build succeeded
74+
```
75+
76+
### Accept all updates
77+
78+
```shell
79+
python studio_onboarding.py --server www.arista.io:443 --token-file token.tok \
80+
--wsid 5f88c496-71ca-469d-af19-2a17a5f5d583 --operation set-all
81+
```
82+
83+
### Accept specific updates
84+
85+
```shell
86+
python studio_onboarding.py --server www.cv-staging.corp.arista.io:443 --token-file token.tok \
87+
--wsid 5f88c496-71ca-469d-af19-2a17a5f5d583 --operation set \
88+
--update-id 'add::DEVICE::{"deviceId":"ZZZ7777777","hostname":"leaf503","interfaceSize":73}'
89+
```

0 commit comments

Comments
 (0)