Set tags on any element (node, link, service, component or interface). Tags are lists of strings of length under 255. They are immutable.
# assuming n1 is a Node
n1.tags = f.Tags('blue', 'heavy')
# tags are immutable but iterable
self.assertTrue('blue' in n1.tags)
# unset the tags
n1.tags = None
self.assertEqual(n1.tags, None)
Set measurement framework data on any element (node, link, service, component or interface). mf_data is a JSON-friendly object representing measurement configuration (combination of dicts, lists). You can set it directly to the .mf_data field of e.g. a VM. If the object is not JSON friendly or serializes into a string longer than 1M, you will get a MeasurementDataError exception:
# for most uses, just set the object
my_meas_data_object = {'key1': {'key2': ['some', 'config', 'info']}}
n1.mf_data = my_meas_data_object
# you get back your object (in this case a dict)
self.assertTrue(isinstance(n1.mf_data, dict))
mf_object2 = n1.mf_data
self.assertTrue(mf_object2['key1'] == {'key2': ['some', 'config', 'info']})
class MyClass:
def __init__(self, val):
self.val = val
# this is not a valid object - json.dumps() will fail on it
bad_meas_data_object = {'key1': MyClass(3)}
with self.assertRaises(MeasurementDataError):
n1.mf_data = bad_meas_data_object
# most settable properties can be unset by setting them to None
n1.mf_data = None
self.assertIsNone(n1.mf_data)
Set boot script on Node elements
#boot script on nodes only
n1.boot_script = """
#!/bin/bash
echo *
"""
self.assertTrue("bash" in n1.boot_script)
n1.boot_script = None
self.assertIsNone(n1.boot_script)
Added the ability to
Set measurement framework data on any element (node, link, service, component or interface). mf_data is a JSON-friendly object representing measurement configuration (combination of dicts, lists). You can set it directly to the
.mf_data
field of e.g. a VM. If the object is not JSON friendly or serializes into a string longer than 1M, you will get a MeasurementDataError exception:Set boot script on Node elements