Created
May 12, 2017 09:09
-
-
Save sarandafl/3969201a31fd66d623365dff7847e5b4 to your computer and use it in GitHub Desktop.
VLAN func
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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