Skip to content

Instantly share code, notes, and snippets.

@sarandafl
Created May 12, 2017 09:09
Show Gist options
  • Save sarandafl/3969201a31fd66d623365dff7847e5b4 to your computer and use it in GitHub Desktop.
Save sarandafl/3969201a31fd66d623365dff7847e5b4 to your computer and use it in GitHub Desktop.
VLAN func
/* Get all VLANs on switch */
function vlans(session, cb) {
let vlans = []
session.getSubtree({ oid: Mibs.vlans }, function (error, varbinds) {
if (error) {
console.log('Fail :(');
console.log(error)
} else {
varbinds.forEach(function (varbind) {
vlans.push(varbind.oid[varbind.oid.length -1])
})
}
cb(vlans)
})
}
function vlans2(session) {
let vlans = []
return new Promise(function (resolve, reject) {
session.getSubtree({ oid: Mibs.vlans }, function (err, res) {
if (err) {
reject(err)
} else {
res.forEach(varbind => { vlans.push(varbind.oid[varbind.oid.length -1])})
resolve(vlans)
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment