README
NodeJS for Viptela
NodeJS library of Viptela vManage API.
Work in progress, not for production
About
Viptela is an SD-WAN vendor with a solid rest API.
The API is documented on the vManage host and can be found by going to
https://vmanage-hostname:port/apidocs
. Additional API documentation can be
found on the viptela site support portal http://viptela.com/support/
(login required)
Installation
connect to vManage API
vManage API use a cookie authentication and the library is based on request. So first, import required libraries
var promise = require('promise');
var request = require('request-promise');
and create a structure for the authentication
let session =
{
host: <hostname>,
j : request.jar(),
'user': <login>,
'pass': <password>'
};
last step
var session =ViptelaLogins(session);
session().login()
.then(function ()
{
console.log("connected");
<YOUR CODE>
})
.catch(function (err)
{
console.log(JSON.stringify( err , null, "\t"));
}
select a Tenant
For Multi-Tenant instances, you have to select the tenant before using methods such as getDevices etc...
var tenant =ViptelaTenant(session);
tenant().selectTenant(<TENANT ID>)
.then(function (sessionID)
{
session.sessionId = sessionID.VSessionId;
})
.catch(function (err)
{
console.log(JSON.stringify( err , null, "\t"));
})
It is very impostant to save the VSessionId in the session object.
List Devices
For listing Viptela devices, the method is simple
First, load the library on the top of you file
var ViptelaDevices = require("./lib/devices")
next steps are
var devices = ViptelaDevices(auth);
devices().findDevisesMap({})
.then(function (items)
{
//device list is in the data attribute
console.log(JSON.stringify( items.data , null, "\t") );
})
.catch(function (err)
{
console.log(JSON.stringify( err , null, "\t"));
});;
Functions of ViptelaDevices
findvEdges()/system/device/vedges
findControllers()/system/device/controllers
findDevices()/dataservice/device
findDevisesMap()/dataservice/group/map/devices
findDeviceStatus()/dataservice/device/status
getDeviceStatus()/dataservice/device/devicestatus
getDeviceHardwareStatus(