More pythonic trace recording
As a follow-on to #93 (closed) , we should make the recorded traces more "pythonic" and easier to use.
Instead of recording a string containing XML for the operation parameters, we should encode operation parameters in a python dictionary that
-
records items (optionally only items with non-default values) as key-value pairs with the item's path as the key and either an array or dictionary.
- If an array is provided, then the item is enabled, resized, and set to the values in the array. None indicates a value should be unset.
- If a dictionary is provided, the item's enabled/disabled state, is-set state of each value, etc.
- Records associations and reference item members with commented-out code to fetch components/resources by name. Since UUIDs of newly-created components will not be consistent across runs, record component names.
-
records comments for fetching created/modified components from operation results. Users can uncoment these and assign them to variables.
An example trace of running an operation (recorded at WILL_OPERATE
):
op = operationManager.create('super_awesome.hyper')
configureOperation(op, {
'associations': [
# resource.filter('* [string{'name'='bar'}]') # 15107e36-e1c6-43b9-aa7f-53825c8deeec
# resource.filter('* [string{'name'='foo'}]') # d408644a-664d-414d-8005-22f375548aff
],
'/doubleItem': [3.2],
'/doubleItem/conditionalInt': [12, 13, 5],
'/someitemIdontlike': { 'enabled': False }
'/doubleItem/yetanotherConditionalInt': [12, None, 5],
'/doubleItem/anotherConditionalInt': { 'isSet': [ True, False, True], 'values': [12, 13, 5] }
'/group/0/itemFoo', ['bar', 'baz'],
'/group/1/itemFoo', ['baz'],
'/group/2/itemFoo', [],
'/somereferenceitem', [
# resource.filter('* [string{'name'='bar'}]') # 15107e36-e1c6-43b9-aa7f-53825c8deeec
]
})
result = op.operate()
An example trace of operation result-processing (recorded at DID_OPERATE
):
# result.findComponent('created').value(0) # name: "foo" UUID: d408644a-664d-414d-8005-22f375548aff
# result.findComponent('modified').value(0) # name: "bar" UUID: 15107e36-e1c6-43b9-aa7f-53825c8deeec