Difference between revisions of "Useful Functions"
From Observer GigaFlow Support | VIAVI Solutions Inc.
Kevin Wilkie (Talk | contribs) |
Kevin Wilkie (Talk | contribs) |
||
Line 9: | Line 9: | ||
actions.addMACAttribute("a4:ba:db:ff:18:bc","State","Washington"); //Add "Washington" Attribute to "State" category for this mac | actions.addMACAttribute("a4:ba:db:ff:18:bc","State","Washington"); //Add "Washington" Attribute to "State" category for this mac | ||
actions.addMACAttribute("a4:ba:db:ff:18:bc","City","Colorado"); | actions.addMACAttribute("a4:ba:db:ff:18:bc","City","Colorado"); | ||
+ | |||
+ | |||
+ | Base64 encoding and decoding | ||
+ | var utils = Java.type('ros.CROSUtils'); | ||
+ | var user='Kevin' | ||
+ | var password = '!£$%^&*()1234kevin' | ||
+ | var encodeduser=utils.base64EncodeString(user); | ||
+ | var encodedpass=utils.base64EncodeString(password); | ||
+ | var decodeduser=utils.base64DecodeString(encodeduser); | ||
+ | var decodedpass=utils.base64DecodeString(encodedpass); | ||
+ | log.warn("user:"+user+" password:"+password+" encodeduser:"+encodeduser+" encodedpass:"+encodedpass) | ||
+ | log.warn("user:"+user+" password:"+password+" decodeduser:"+decodeduser+" decodedpass:"+decodedpass) |
Revision as of 10:59, 15 March 2017
Sleep
function sleep(delay) { var start = new Date().getTime(); while (new Date().getTime() < start + delay); }
Adding Attributes, automaticaly creating the category if it doesn't exists
actions.addIPAttribute("172.21.40.14","State","New York"); //Add "New York" Attribute to "State" category for this ip actions.addMACAttribute("a4:ba:db:ff:18:bc","State","Washington"); //Add "Washington" Attribute to "State" category for this mac actions.addMACAttribute("a4:ba:db:ff:18:bc","City","Colorado");
Base64 encoding and decoding
var utils = Java.type('ros.CROSUtils'); var user='Kevin' var password = '!£$%^&*()1234kevin' var encodeduser=utils.base64EncodeString(user); var encodedpass=utils.base64EncodeString(password); var decodeduser=utils.base64DecodeString(encodeduser); var decodedpass=utils.base64DecodeString(encodedpass); log.warn("user:"+user+" password:"+password+" encodeduser:"+encodeduser+" encodedpass:"+encodedpass) log.warn("user:"+user+" password:"+password+" decodeduser:"+decodeduser+" decodedpass:"+decodedpass)