[occi-wg] Syntax of OCCI API

Andre Merzky andre at merzky.net
Fri Apr 17 04:02:50 CDT 2009


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 at 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 at ogf.org
> http://www.ogf.org/mailman/listinfo/occi-wg



-- 
Nothing is ever easy.



More information about the occi-wg mailing list