cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
481
Views
5
Helpful
3
Replies

Can we automate the CLI commands?

hrmt92
Beginner
Beginner

I want to automate the process where I have to shut down a particular interface of vEdge whenever needed using python code.

 

Is this possible at all, because I was searching for it in the API documentation and not sure it is there?

3 REPLIES 3

bigevilbeard
Cisco Employee
Cisco Employee

@hrmt92 there isn't a single API if this is what you are looking for. With SD-WAN you would need to attach (POST) a device template, you could use the following API call

 

 https://vmanage-ip:port/dataservice/template/device/cli/

 

Sample JSON Payload

 

  "templateName": "br2_vedge1",
  "templateDescription": "br2_vedge1",
  "deviceType": "vedge-cloud",
  "templateConfiguration": "system\r\n host-name               vedge\r\n admin-tech-on-failure\r\n no route-consistency-check\r\n vbond ztp.viptela.com\r\n aaa\r\n  auth-order local radius tacacs\r\n  usergroup basic\r\n   task system read write\r\n   task interface read write\r\n  !\r\n  usergroup netadmin\r\n  !\r\n  usergroup operator\r\n   task system read\r\n   task interface read\r\n   task policy read\r\n   task routing read\r\n   task security read\r\n  !\r\n  user admin\r\n   password <password-value>\r\n  !\r\n !\r\n logging\r\n  disk\r\n   enable\r\n  !\r\n !\r\n!\r\nomp\r\n no shutdown\r\n graceful-restart\r\n advertise connected\r\n advertise static\r\n!\r\nsecurity\r\n ipsec\r\n  authentication-type ah-sha1-hmac sha1-hmac\r\n !\r\n!\r\nvpn 0\r\n interface ge0/0\r\n  ip dhcp-client\r\n  ipv6 dhcp-client\r\n  tunnel-interface\r\n   encapsulation ipsec\r\n   no allow-service bgp\r\n   allow-service dhcp\r\n   allow-service dns\r\n   allow-service icmp\r\n   no allow-service sshd\r\n   no allow-service netconf\r\n   no allow-service ntp\r\n   no allow-service ospf\r\n   no allow-service stun\r\n   allow-service https\r\n  !\r\n  no shutdown\r\n !\r\n!\r\nvpn 512\r\n interface eth0\r\n  ip address <ip-address/subnet-mask>\r\n  no shutdown\r\n !\r\n ip route 0.0.0.0/0 <ip-address>\r\n!\r\n",
  "factoryDefault": false,
  "configType": "file"
}

@bigevilbeard, i did see this previously but wasn't sure how to use this. If i just want to shut a certain interface, what all should i send in the payload?

@hrmt92 you can use this just revert the command to shutdown instead of no shutddown

 

URL: https://vmanage-ip:port/dataservice/template/device/cli/

Method: POST

POST Request Parameters:

 

{
  "templateName": "",
  "templateDescription": "",
  "deviceType": "",
  "templateConfiguration": "",
  "factoryDefault": false,
  "configType": "file"
}

 

JSON Payload

 

{
  "templateName": "br2_vedge1",
  "templateDescription": "br2_vedge1",
  "deviceType": "vedge-cloud",
  "templateConfiguration": "system\r\n host-name               vedge\r\n admin-tech-on-failure\r\n no route-consistency-check\r\n vbond ztp.viptela.com\r\n aaa\r\n  auth-order local radius tacacs\r\n  usergroup basic\r\n   task system read write\r\n   task interface read write\r\n  !\r\n  usergroup netadmin\r\n  !\r\n  usergroup operator\r\n   task system read\r\n   task interface read\r\n   task policy read\r\n   task routing read\r\n   task security read\r\n  !\r\n  user admin\r\n   password <password-value>\r\n  !\r\n !\r\n logging\r\n  disk\r\n   enable\r\n  !\r\n !\r\n!\r\nomp\r\n no shutdown\r\n graceful-restart\r\n advertise connected\r\n advertise static\r\n!\r\nsecurity\r\n ipsec\r\n  authentication-type ah-sha1-hmac sha1-hmac\r\n !\r\n!\r\nvpn 0\r\n interface ge0/0\r\n  ip dhcp-client\r\n  ipv6 dhcp-client\r\n  tunnel-interface\r\n   encapsulation ipsec\r\n   no allow-service bgp\r\n   allow-service dhcp\r\n   allow-service dns\r\n   allow-service icmp\r\n   no allow-service sshd\r\n   no allow-service netconf\r\n   no allow-service ntp\r\n   no allow-service ospf\r\n   no allow-service stun\r\n   allow-service https\r\n  !\r\n  no shutdown\r\n !\r\n!\r\nvpn 512\r\n interface eth0\r\n  ip address <ip-address/subnet-mask>\r\n  no shutdown\r\n !\r\n ip route 0.0.0.0/0 <ip-address>\r\n!\r\n",
  "factoryDefault": false,
  "configType": "file"
}

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: