There is no existing external tools that parse that output. So there is no backwards compatibility issue.
the problem as I have explained in the patch is that the yaml 3rd party library that we use does not parse input such as [0,1...]. It has to be enclosed in double quotes. This causes a problem since the output can be without the double quotes, but if you take that output and try to pipe it into lnetctl again (ex: lnetctl import < config.yaml), it'll have a parse error.
The requirement that the lnetclt export output has to be usable with lnetctl import, is higher priority than having the CPT parameter as parsable from python. Therefore the above solution was implemented.
Another possible solution is to simply have the output as:
However, that would parse in python as a string as well. So, you'll end up with the same issue.
An easy way to deal with this is simply to parse out the CPT output into a list as below
YAML output:
net:
- net: tcp
nid: 192.168.205.158@tcp
status: up
interfaces:
0: eth4
tunables:
peer_timeout: 180
peer_credits: 8
peer_buffer_credits: 0
clnetredits: 256
CPT: "[1,0]"
Python Interpetation:
{'net': [{'CPT': '[1,0]',
'interfaces': {0: 'eth4'},
'net': 'tcp',
'nid': '192.168.205.158@tcp',
'status': 'up',
'tunables': {'clnetredits': 256,
'peer_buffer_credits': 0,
'peer_credits': 8,
'peer_timeout': 180}}]}
if we assign the above python expression to a variable x, then you can do the following
cpt_list = x['net'][0]['CPT'].replace('[', '').replace(']', '').split(',')
then you can print items in the list by:
int(cpt_list[0])
You can also create a loop
>>> for item in cpt_list:
... print int(item)
If you have a better solution please share it.
I see. Sorry, it appeared to me that CPT was a list/array (and valid YAML). If it's not, then yes, using quotes is fine. The application just has to parse the string.