Using Tags
Tags defined in Paragon Active Assurance can be applied to:
- monitors
- monitor templates
- Test Agents
- TWAMP reflectors
- Ping hosts.
For example, you can tag a monitor with the same tag as a subset of Test Agents that are going to run the monitor. This feature is particularly helpful if you have a large number of monitors and templates defined.
If you have set up an alarm with SNMP traps for a monitor, then the SNMP traps will be assigned the same tags as the monitor, if any.
Creating Tags
Below we show how to create a tag with name and color as defined by the XML
<tag> substructure.
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<tags>
<tag>
<name>{tag}</name>
<color>#00ff00</color>
</tag>
</tags>
</account>
</accounts>
</config>""".format(account=args.netrounds_account,
tag=args.tag_name)
monitor = m.edit_config(target='running', config=xml)
print "ok" if monitor.ok else monitor.errorsAssigning a Tag
To assign a tag to a resource, you add it as a new <tag>
element under the <tags> element for that resource.
Here is how to assign a tag to a Test Agent:
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<test-agents>
<test-agent>
<name>vta1</name>
<tags>
<tag>
<name>{tag}</name>
</tag>
</tags>
</test-agent>
</test-agents>
</account>
</accounts>
</config>""".format(account=args.netrounds_account,
tag=args.tag_name)
monitor = m.edit_config(target='running', config=xml, default_operation='merge')
print "ok" if monitor.ok else monitor.errorsTo assign a tag to a TWAMP reflector, do the following:
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<twamp-reflectors>
<twamp-reflector>
<name>{name}</name>
<tags>
<tag>
<name>{tag}</name>
</tag>
</tags>
</twamp-reflector>
</twamp-reflectors>
</account>
</accounts>
</config>""".format(account=args.netrounds_account,
name='Name',
tag='Tag1')
monitor = m.edit_config(target='running', config=xml, default_operation='merge')
print "ok" if monitor.ok else monitor.errorsAssigning a tag to a monitor is handled similarly:
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<monitors>
<monitor>
<name>{name}</name>
<tags>
<tag>
<name>{tag}</name>
</tag>
</tags>
</monitor>
</monitors>
</account>
</accounts>
</config>""".format(account=args.netrounds_account,
name='HTTP monitor',
tag='Tag 1')
monitor = m.edit_config(target='running', config=xml, default_operation='merge')
print "ok" if monitor.ok else monitor.errorsAlternatively, you can assign an existing tag to any of these resource types when
creating the resource, by including the <tags> element
containing the tag in question.
Updating a Tag
Updating an existing tag with new attributes is analogous to creating a tag:
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<tags>
<tag>
<name>{tag}</name>
<color>#ff0000</color>
</tag>
</tags>
</account>
</accounts>
</config>""".format(account=args.netrounds_account, tag=args.tag_name)
monitor = m.edit_config(target='running', config=xml, default_operation='merge')
print "ok" if monitor.ok else monitor.errorsUnassigning a Tag
To unassign a tag from a resource, add the attribute
nc:operation="delete" to the <tag>
element belonging to the resource. Below, we unassign a tag from a monitor.
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<monitors>
<monitor>
<name>{name}</name>
<tags>
<tag nc:operation="delete">
<name>{tag}</name>
</tag>
</tags>
</monitor>
</monitors>
</account>
</accounts>
</config>""".format(account=args.netrounds_account,
name='HTTP monitor',
tag='Tag 1')
monitor = m.edit_config(target='running', config=xml, default_operation='merge')
print "ok" if monitor.ok else monitor.errorsDeleting a Tag
In order to delete a tag altogether from Control Center, the attribute
nc:operation="delete" is again used, but this time applied to
the tag itself, defined under <account>.
with manager.connect(host=args.host, port=args.port, username=args.username,
password=args.password, hostkey_verify=False) as m:
xml = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<accounts xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="http://ncc.netrounds.com">
<account>
<name>{account}</name>
<tags>
<tag nc:operation="delete">
<name>{tag}</name>
</tag>
</tags>
</account>
</accounts>
</config>""".format(account=args.netrounds_account, tag=args.tag_name)
monitor = m.edit_config(target='running', config=xml)
print "ok" if monitor.ok else monitor.errors