
+1 -----Original Message----- From: occi-wg-bounces@ogf.org [mailto:occi-wg-bounces@ogf.org] On Behalf Of Alexis Richardson Sent: 17 April 2009 10:08 To: Andre Merzky Cc: occi-wg@ogf.org Subject: Re: [occi-wg] Syntax of OCCI API +1 Is there any way to put the FORMAT discussion to one side for now? I really liked Chris' example, and can say that we've found similar approaches very powerful in our work with RabbitMQ. But as Andre says, the issue is secondary to noun/verb. Right? On Fri, Apr 17, 2009 at 10:02 AM, Andre Merzky <andre@merzky.net> wrote:
Once we get the noun/verb/attribute part settled, there is no harm in doing an ini and a key/val binding. In fact, a translator would be trivial...
You can argue endlessly about the better format: there are too many PROs and CONs for both of them to come to an conclusive answer, IMHO.
My $0.02, Andre.
Quoting [Chris Webb] (Apr 17 2009):
Sam Johnston <samj@samj.net> writes:
but in any case INI files are simple, standard across platforms, well defined, etc.
You can parse them in shell like this<http://www.debian-administration.org/articles/55#comment_24> :
#!/bin/sh [ -z "$1" ] || [ -z "$2" ] && exit 1 sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \ -e 's/;.*$//' \ -e 's/[[:space:]]*$//' \ -e 's/^[[:space:]]*//' \ -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \ < $1 \ | sed -n -e "/^\[$2\]/,/^\s*\[/{/^[^;].*\=.*/p;}"
You've completely missed the point again. (Perhaps understandably, since you're not in the target audience for this format.)
while read K V; do FOO; done
is something you can type in a shell one-liner, which is the most interesting 'use case' (sorry, horrible jargon!) for shell people. This complex hack is not, and I note that you had to google for it rather than writing it off the top of your head, which should have been enough to make the point clear. (Incidentally, it doesn't get INI quoting right. Doing it correctly and allowing for backslash escapes is somewhat harder.)
Whitespace separated KEY VALUE is better-defined than INI[1], can be parsed by shell read, by C strtok() or strsep(), and is generally pleasant to work with in languages without sophisticated string handling or data structures. Here's your sample translated to that format:
id decca5a5-8952-4004-9793-cdbbf05c3c63 category server title Debian GNU/Linux 5.0 Virtual Appliance summary Base installation of Debian GNU/Linux 5.0 content.cpu 2 content.memory 4Gb link.disk[0].id 4696b561-a253-42b4-bd27-7aa4950e0a60 link.disk[0].dev sda link.network[0].id 45a73b80-c957-4ae1-97c6-b70652eba1d1 link.network[0].dev eth0 mc.state RUNNING br.meter.rate 0.10 br.meter.currency USD br.meter.unit hours br.meter.total 35.27 pm.monitor.cpu 75.2 pm.monitor.mem 1059374258 mc.ops.start http://example.com/decca5a5-8952-4004-9793-cdbbf05c3c63/ops/start mc.ops.stop http://example.com/decca5a5-8952-4004-9793-cdbbf05c3c63/ops/stop mc.ops.restart http://example.com/decca5a5-8952-4004-9793-cdbbf05c3c63/ops/restart mc.ops.suspend http://example.com/decca5a5-8952-4004-9793-cdbbf05c3c63/ops/suspend
id 4696b561-a253-42b4-bd27-7aa4950e0a60 category storage content.size 148251374 link.self virtual-disk.vmdk
id 45a73b80-c957-4ae1-97c6-b70652eba1d1 category network content.vlan 4095 content.dhcp true content.subnet 192.168.0.0 content.netmask 255.255.0.0 content.gateway 192.168.0.1 vnd.com.cisco.cdp true
I'll not comment on the key space or conflation of objects into one namespace with a category key in this post.
Cheers,
Chris.
[1] See http://en.wikipedia.org/wiki/Initialization_file for details on some of the variation seen in the wild. There's no formal spec to disambiguate. _______________________________________________ occi-wg mailing list occi-wg@ogf.org http://www.ogf.org/mailman/listinfo/occi-wg
-- Nothing is ever easy. _______________________________________________ occi-wg mailing list occi-wg@ogf.org http://www.ogf.org/mailman/listinfo/occi-wg
_______________________________________________ occi-wg mailing list occi-wg@ogf.org http://www.ogf.org/mailman/listinfo/occi-wg ------------------------------------------------------------- Intel Ireland Limited (Branch) Collinstown Industrial Park, Leixlip, County Kildare, Ireland Registered Number: E902934 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.