Interacting with the ACS db - Subscriber Object
Scripts can interact with the Device Manager ACS database by referencing the: Device, Subscriber and Settings objects.
This article disucsses the subscriber object; specifically the use of labels for automated device provisioning.
The Subscriber Object provides access to labels assigned to the subscriber associated with the device with which the script is currently interacting.
Subscriber labels can be used as a powerful tool for automating device provisioning. By referencing a subscriber’s labels, scripts can tailor their execution based on the presence of labels. The following process demonstrates how to automate device provisioning:
- Create a new subscriber/device record in the ACS. Add subscriber labels indicating the services to be enabled for the new subscriber (e.g. IPTV, VoIP, etc.).
- Create scripts to automate device configuration in support of those services. At the top of the script check the subscriber record for a service label and only continue executing the script if the label is present. See the example IPTV Bridge Group Script in Appendix B – Example Scripts for details.
- Associate the service configuration script with the Subscriber Associated event under ADMINISTRATION > Events.
NOTE: You cannot count on a subscriber object always being present as devices are not required to be associated with a subscriber. Always check for this object before using a subscriber object in your scripts.
The following subscriber related functions are supported:
subscriber.labels.add()
function subscriber.labels.add (label); | |
Description | Add a label to the Subscriber 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 subscriber = acs.subscriber; if (subscriber !== null) { log.info("Subscriber: " + subscriber.toSource()); try { subscriber.labels.add("Test Label"); } catch(err) { log.error(“Unable to add Test Label”); } } |
subscriber.labels.remove()
function subscriber.labels.remove (label); | |
Description | Remove a label from the Subscriber 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 subscriber = acs.subscriber; if (subscriber !== null) { log.info("Subscriber: " + subscriber.toSource()); try { subscriber.labels.remove("Test Label"); } catch(err) { log.error(“Unable to remove Test Label”); } } |
subscriber.labels.contains()
function subscriber.labels.contains (label); | |
Description | Check if the label is associated with the Subscriber Object |
Parameters | label – name of the label to confirm (case sensitive) |
Returns | Returns true if the label is associated with the Subscriber Object, otherwise false |
Required Libraries | useLibrary('acs'); |
Example |
useLibrary('acs');
var subscriber = acs.subscriber; if (subscriber !== null) { log.info("Subscriber: " + subscriber.toSource()); if (subscriber.labels.contains("Test Label") === true) log.info("Subscriber contains label"); } |