Interacting with the ACS db - Device Object
Scripts can interact with the Device Manager ACS database by referencing the: Device, Subscriber and Settings objects. Let's first discuss CPE device objects.
The Device Object provides information about the device with which the script is currently interacting including:
- Labels
- Identification properties: serialNumber, oui, provisioningCode, manufacturer, productClass, hardwareVersion, softwareVersion
- Basic statistics: firstInform, informCount
To read the Device Object reference acs.device as follows:
useLibrary('acs');
var device = acs.device;
The following device related functions are supported...
device.labels.add()
function device.labels.add (label); | |
Description | Add a label to the Device Object. |
Parameters | label – name of the label to add (case sensitive). |
Returns | None – An exception will be thrown if the specified label does not exist. |
Required Libraries | useLibrary('acs'); |
Example |
useLibrary('acs');
var device = acs.device; log.info("Device: " + device.toSource()); try { device.labels.add("Test Label"); } catch(err) { log.error(“Unable to add Test Label”); } |
device.labels.remove()
function device.labels.remove (label); | |
Description | Remove a label from the Device Object |
Parameters | label – name of the label to remove (case sensitive) |
Returns | None – An exception will be thrown if the specified label does not exist |
Required Libraries | useLibrary('acs'); |
Example |
useLibrary('acs');
var device = acs.device; log.info("Device: " + device.toSource()); try { device.labels.remove("Test Label"); } catch(err) { log.error(“Unable to remove Test Label”); } |
device.labels.contains()
function device.labels.contains (label); | |
Description | Check if the label is associated with the Device Object |
Parameters | label – name of the label to confirm (case sensitive) |
Returns | Returns true if the label is associated with the Device Object, otherwise false |
Required Libraries | useLibrary('acs'); |
Example |
useLibrary('acs');
var device = acs.device; log.info("Device: " + device.toSource()); if (device.labels.contains("Test Label") === true) log.info("Device contains label"); |