- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2019 10:18 AM
Hello,
I need to apply via API template configurations, but I was looking and can't find any example about how I can do it.
Please, can someone share an example, please?
Thanks.
Solved! Go to Solution.
- Labels:
-
Other SD-WAN
-
SD-WAN App Experience
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2019 08:12 AM - edited 05-17-2019 08:19 AM
Sure Juraj, let me present an example with manual execution. For you information:
- I did all API request via https://vmanage/apidocs/, but you can use any other tool or script.
- I'm showing only relevant output, not the full API output.
- The steps described below are just showing an example to help you understand. There might be other ways to achieve same results, and some points could potentially be simplified.
Let's say I have a very basic device template with single VPN0 interface:
system host-name {{hostname}} system-ip {{system_ip}} site-id {{site_id}} admin-tech-on-failure no route-consistency-check sp-organization-name xxx organization-name xxx vbond xxx aaa auth-order local radius tacacs usergroup basic task system read write task interface read write ! usergroup netadmin ! usergroup operator task system read task interface read task policy read task routing read task security read ! user admin password xxx ! ! ! vpn 0 name "Transport VPN" interface {{gold_interface_name}} ip address {{gold_ip_and_mask}} tunnel-interface encapsulation ipsec color gold restrict ! no shutdown ! ip route 0.0.0.0/0 {{gold_default_ip}} ! vpn 512 interface eth0 shutdown ! !
In order to attach it:
1. Get the templateID from API
https://vmanage/dataservice/template/device
Input:
-
Output:
{ "deviceType": "vedge-cloud", "lastUpdatedBy": "tzarski", "factoryDefault": false, "templateName": "api-test", "devicesAttached": 1, "templateDescription": "api-test", "lastUpdatedOn": 1558102175069, "configType": "file", "templateId": "0372c72d-85dc-4d6e-9638-8af5606c943e", "templateAttached": 0 },
2. Get ID of the device to which you want to attach the template
https://vmanage:443/dataservice/device
Input:
-
Output:
{ "deviceId": "55.10.10.10", "system-ip": "55.10.10.10", "host-name": "BR10", "reachability": "reachable", "status": "normal", "personality": "vedge", "device-type": "vedge", "timezone": "UTC", "device-groups": [ "\"No groups\"" ], "lastupdated": 1558086976605, "bfdSessionsUp": 1, "domain-id": "1", "board-serial": "C9D90A7F", "certificate-validity": "Valid", "max-controllers": "0", "uuid": "476b71d4-308b-3f38-807e-982e8360cb9d", "bfdSessions": "1", "controlConnections": "2", "device-model": "vedge-cloud", "version": "18.3.5", "connectedVManages": [ "\"10.0.0.1\"" ],
3. Generate Device Input Variables
https://vmanage/dataservice/template/device/config/input
Input:
{ "templateId":"0372c72d-85dc-4d6e-9638-8af5606c943e", "deviceIds": [ "476b71d4-308b-3f38-807e-982e8360cb9d" ], "isEdited":false, "isMasterEdited":false } }
Output:
"data": [ { "csv-status": "in_complete", "csv-deviceId": "476b71d4-308b-3f38-807e-982e8360cb9d", "csv-deviceIP": "55.10.10.10", "csv-host-name": "BR10", "hostname": "", "system_ip": "", "site_id": "", "gold_interface_name": "", "gold_ip_and_mask": "", "gold_default_ip": "" } ]
4. Fill the variables in output from previous point
5. Preview Device Configuration with variables filled
https://vmanage:443/dataservice/template/device/config/config
Input (change the device section here with filled data from point 4):
{ "templateId":"0372c72d-85dc-4d6e-9638-8af5606c943e", "device":{ "csv-status": "complete", "csv-deviceId": "476b71d4-308b-3f38-807e-982e8360cb9d", "csv-deviceIP": "55.10.10.10", "csv-host-name": "BR10", "hostname": "BR10", "system_ip": "55.10.10.10", "site_id": "55", "gold_interface_name": "ge0/0", "gold_ip_and_mask": "31.2.0.10/24", "gold_default_ip": "31.2.0.1" }, "isEdited":false, "isMasterEdited":false }
Output:
system device-model vedge-cloud host-name BR10 system-ip 55.10.10.10 site-id 55 admin-tech-on-failure no route-consistency-check sp-organization-name xxx organization-name xxx vbond xxx port 12346 aaa auth-order local radius tacacs usergroup basic task system read write task interface read write ! usergroup netadmin ! usergroup operator task system read task interface read task policy read task routing read task security read ! user admin password xxx ! ! logging disk enable ! ! ! omp no shutdown graceful-restart ! vpn 0 name "Transport VPN" interface ge0/0 ip address 31.2.0.10/24 tunnel-interface encapsulation ipsec color gold restrict no allow-service bgp allow-service dhcp allow-service dns allow-service icmp no allow-service sshd no allow-service netconf no allow-service ntp no allow-service ospf no allow-service stun allow-service https ! no shutdown ! ip route 0.0.0.0/0 31.2.0.1 ! vpn 512 interface eth0 shutdown ! ! ! !
6. Attach Device Template
https://vmanage:443/dataservice/template/device/config/attachcli
Input (fill "device" data with same data as input in previous point):
{ "deviceTemplateList":[ { "templateId":"0372c72d-85dc-4d6e-9638-8af5606c943e", "device":[ { "csv-status": "complete", "csv-deviceId": "476b71d4-308b-3f38-807e-982e8360cb9d", "csv-deviceIP": "55.10.10.10", "csv-host-name": "BR10", "hostname": "BR10", "system_ip": "55.10.10.10", "site_id": "55", "gold_interface_name": "ge0/0", "gold_ip_and_mask": "31.2.0.10/24", "gold_default_ip": "31.2.0.1" } ], "isEdited":false, "isMasterEdited":false } ] }
Output:
{ "id": "push_file_template_configuration-89f5f490-45de-4dab-8f0f-23b2d09a2444" }
7. Check the template push status
https://vmanage:443/dataservice/device/action/status/push_file_template_configuration-89f5f490-45de-4dab-8f0f-23b2d09a2444
Output:
"data": [ { "activity": [ "[17-May-2019 10:16:23 UTC] Configuring device with cli template: api-test", "[17-May-2019 10:16:23 UTC] Generating configuration from template", "[17-May-2019 10:16:23 UTC] Checking and creating device in vManage", "[17-May-2019 10:16:24 UTC] Device is online", "[17-May-2019 10:16:24 UTC] Updating device configuration in vManage", "[17-May-2019 10:16:25 UTC] Pushing configuration to device, vManage Transaction Id: 2019-05-17T10:16:25.415000+00:00", "[17-May-2019 10:16:25 UTC] Verification of configuration push may take several minutes", "[17-May-2019 10:18:27 UTC] Template successfully attached to device" ], "statusType": "push_file_template_configuration", "local-system-ip": "55.10.10.10", "vmanageIP": "10.0.0.1", "system-ip": "55.10.10.10", "site-id": "5510", "host-name": "BR10", "deviceID": "476b71d4-308b-3f38-807e-982e8360cb9d", "uuid": "476b71d4-308b-3f38-807e-982e8360cb9d", "@rid": 3406, "statusId": "success", "currentActivity": "Done - Push CLI Template Configuration",
8. Check device is in sync
https://vmanage:443/dataservice/device/sync_status
Input:
-
Output:
{ "device-model": "vedge-cloud", "syncCompleted": 1558104382742, "local-system-ip": "55.10.10.10", "syncState": "Completed", "host-name": "BR10", "deviceId": "55.10.10.10", "uuid": "476b71d4-308b-3f38-807e-982e8360cb9d", "syncScheduled": 0, "layoutLevel": 4, "syncQueued": 1558104381441, "_id": 2242, "reachability": "reachable" },
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2019 12:21 PM - edited 05-16-2019 12:23 PM
The process is described on: https://sdwan-docs.cisco.com/Product_Documentation/Command_Reference/vManage_REST_APIs/Device_Configuration_APIs/Device_Templates#Attach_Device_Templates
1. Generate Device Input Variables: https://vmanage-ip-address/dataservice/template/device/config/input
2. Preview Device Configuration with variables filled: https://vmanage-ip-address/dataservice/template/device/config/config
3. Attach Device Template: https://vmanage-ip-address/dataservice/template/device/config/attachcli or https://vmanage-ip-address/dataservice/template/device/config/attachfeature
4. Monitor attach action: https://vmanage-ip-address/dataservice/device/action/status/{attachID}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2019 12:30 PM
Hello,
I just check the link you posted and still not clear, do you have any kind of examples I can check?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2019 08:12 AM - edited 05-17-2019 08:19 AM
Sure Juraj, let me present an example with manual execution. For you information:
- I did all API request via https://vmanage/apidocs/, but you can use any other tool or script.
- I'm showing only relevant output, not the full API output.
- The steps described below are just showing an example to help you understand. There might be other ways to achieve same results, and some points could potentially be simplified.
Let's say I have a very basic device template with single VPN0 interface:
system host-name {{hostname}} system-ip {{system_ip}} site-id {{site_id}} admin-tech-on-failure no route-consistency-check sp-organization-name xxx organization-name xxx vbond xxx aaa auth-order local radius tacacs usergroup basic task system read write task interface read write ! usergroup netadmin ! usergroup operator task system read task interface read task policy read task routing read task security read ! user admin password xxx ! ! ! vpn 0 name "Transport VPN" interface {{gold_interface_name}} ip address {{gold_ip_and_mask}} tunnel-interface encapsulation ipsec color gold restrict ! no shutdown ! ip route 0.0.0.0/0 {{gold_default_ip}} ! vpn 512 interface eth0 shutdown ! !
In order to attach it:
1. Get the templateID from API
https://vmanage/dataservice/template/device
Input:
-
Output:
{ "deviceType": "vedge-cloud", "lastUpdatedBy": "tzarski", "factoryDefault": false, "templateName": "api-test", "devicesAttached": 1, "templateDescription": "api-test", "lastUpdatedOn": 1558102175069, "configType": "file", "templateId": "0372c72d-85dc-4d6e-9638-8af5606c943e", "templateAttached": 0 },
2. Get ID of the device to which you want to attach the template
https://vmanage:443/dataservice/device
Input:
-
Output:
{ "deviceId": "55.10.10.10", "system-ip": "55.10.10.10", "host-name": "BR10", "reachability": "reachable", "status": "normal", "personality": "vedge", "device-type": "vedge", "timezone": "UTC", "device-groups": [ "\"No groups\"" ], "lastupdated": 1558086976605, "bfdSessionsUp": 1, "domain-id": "1", "board-serial": "C9D90A7F", "certificate-validity": "Valid", "max-controllers": "0", "uuid": "476b71d4-308b-3f38-807e-982e8360cb9d", "bfdSessions": "1", "controlConnections": "2", "device-model": "vedge-cloud", "version": "18.3.5", "connectedVManages": [ "\"10.0.0.1\"" ],
3. Generate Device Input Variables
https://vmanage/dataservice/template/device/config/input
Input:
{ "templateId":"0372c72d-85dc-4d6e-9638-8af5606c943e", "deviceIds": [ "476b71d4-308b-3f38-807e-982e8360cb9d" ], "isEdited":false, "isMasterEdited":false } }
Output:
"data": [ { "csv-status": "in_complete", "csv-deviceId": "476b71d4-308b-3f38-807e-982e8360cb9d", "csv-deviceIP": "55.10.10.10", "csv-host-name": "BR10", "hostname": "", "system_ip": "", "site_id": "", "gold_interface_name": "", "gold_ip_and_mask": "", "gold_default_ip": "" } ]
4. Fill the variables in output from previous point
5. Preview Device Configuration with variables filled
https://vmanage:443/dataservice/template/device/config/config
Input (change the device section here with filled data from point 4):
{ "templateId":"0372c72d-85dc-4d6e-9638-8af5606c943e", "device":{ "csv-status": "complete", "csv-deviceId": "476b71d4-308b-3f38-807e-982e8360cb9d", "csv-deviceIP": "55.10.10.10", "csv-host-name": "BR10", "hostname": "BR10", "system_ip": "55.10.10.10", "site_id": "55", "gold_interface_name": "ge0/0", "gold_ip_and_mask": "31.2.0.10/24", "gold_default_ip": "31.2.0.1" }, "isEdited":false, "isMasterEdited":false }
Output:
system device-model vedge-cloud host-name BR10 system-ip 55.10.10.10 site-id 55 admin-tech-on-failure no route-consistency-check sp-organization-name xxx organization-name xxx vbond xxx port 12346 aaa auth-order local radius tacacs usergroup basic task system read write task interface read write ! usergroup netadmin ! usergroup operator task system read task interface read task policy read task routing read task security read ! user admin password xxx ! ! logging disk enable ! ! ! omp no shutdown graceful-restart ! vpn 0 name "Transport VPN" interface ge0/0 ip address 31.2.0.10/24 tunnel-interface encapsulation ipsec color gold restrict no allow-service bgp allow-service dhcp allow-service dns allow-service icmp no allow-service sshd no allow-service netconf no allow-service ntp no allow-service ospf no allow-service stun allow-service https ! no shutdown ! ip route 0.0.0.0/0 31.2.0.1 ! vpn 512 interface eth0 shutdown ! ! ! !
6. Attach Device Template
https://vmanage:443/dataservice/template/device/config/attachcli
Input (fill "device" data with same data as input in previous point):
{ "deviceTemplateList":[ { "templateId":"0372c72d-85dc-4d6e-9638-8af5606c943e", "device":[ { "csv-status": "complete", "csv-deviceId": "476b71d4-308b-3f38-807e-982e8360cb9d", "csv-deviceIP": "55.10.10.10", "csv-host-name": "BR10", "hostname": "BR10", "system_ip": "55.10.10.10", "site_id": "55", "gold_interface_name": "ge0/0", "gold_ip_and_mask": "31.2.0.10/24", "gold_default_ip": "31.2.0.1" } ], "isEdited":false, "isMasterEdited":false } ] }
Output:
{ "id": "push_file_template_configuration-89f5f490-45de-4dab-8f0f-23b2d09a2444" }
7. Check the template push status
https://vmanage:443/dataservice/device/action/status/push_file_template_configuration-89f5f490-45de-4dab-8f0f-23b2d09a2444
Output:
"data": [ { "activity": [ "[17-May-2019 10:16:23 UTC] Configuring device with cli template: api-test", "[17-May-2019 10:16:23 UTC] Generating configuration from template", "[17-May-2019 10:16:23 UTC] Checking and creating device in vManage", "[17-May-2019 10:16:24 UTC] Device is online", "[17-May-2019 10:16:24 UTC] Updating device configuration in vManage", "[17-May-2019 10:16:25 UTC] Pushing configuration to device, vManage Transaction Id: 2019-05-17T10:16:25.415000+00:00", "[17-May-2019 10:16:25 UTC] Verification of configuration push may take several minutes", "[17-May-2019 10:18:27 UTC] Template successfully attached to device" ], "statusType": "push_file_template_configuration", "local-system-ip": "55.10.10.10", "vmanageIP": "10.0.0.1", "system-ip": "55.10.10.10", "site-id": "5510", "host-name": "BR10", "deviceID": "476b71d4-308b-3f38-807e-982e8360cb9d", "uuid": "476b71d4-308b-3f38-807e-982e8360cb9d", "@rid": 3406, "statusId": "success", "currentActivity": "Done - Push CLI Template Configuration",
8. Check device is in sync
https://vmanage:443/dataservice/device/sync_status
Input:
-
Output:
{ "device-model": "vedge-cloud", "syncCompleted": 1558104382742, "local-system-ip": "55.10.10.10", "syncState": "Completed", "host-name": "BR10", "deviceId": "55.10.10.10", "uuid": "476b71d4-308b-3f38-807e-982e8360cb9d", "syncScheduled": 0, "layoutLevel": 4, "syncQueued": 1558104381441, "_id": 2242, "reachability": "reachable" },
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2023 08:43 AM
Is it possible to attach a new feature template to an existing device template and then add the device info in one call?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 03:23 AM
It's not possible to do it in one API call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:31 PM
Hi tzarski,
Can we create a cli template using API call? If yes, then can you please show how? Thanks!!
//vpawar
