Hey there, I exclusively use jq with CloudMonkey
There a few options that I set for compatibility: export TERM=vt100 cloudmonkey set display json cloudmonkey set color false Here are a few examples: NETID=`cloudmonkey list virtualmachines listall=true name="$VMNAME" filter=name,nic | jq -r '.virtualmachine[] | .nic[] |.networkid'` VRIP=`cloudmonkey list routers listall="true" filter=name,nic name=$VRNAME | jq -r '.router[] | .nic[] | select(.traffictype=="Control") | .ipaddress'` HOSTDETAILS=`cloudmonkey list routers listall=true name=$VRNAME filter=name,hostname,hostid | jq '.router[]'` Regards, Paul Angus VP Technology/Cloud Architect D: +44 20 3468 5163 |S: +44 20 3603 0540 | M: +44 7711 418 784 | T: @CloudyAngus paul.an...@shapeblue.com -----Original Message----- From: create...@gmail.com [mailto:create...@gmail.com] On Behalf Of Carlos Reategui Sent: 28 August 2015 16:13 To: users@cloudstack.apache.org Subject: Re: [ANNOUNCE] Apache CloudStack CloudMonkey 5.3.2 On Wed, Aug 26, 2015 at 9:15 AM, ilya <ilya.mailing.li...@gmail.com> wrote: > Hi Rohit > > Thanks for doing great job in maitaining CloudMonkey. > > I'm curious, is there any way I can filter on json sub-block? > > For example, list virtualmachines id=123 filter=name,nic[ipaddress] > > I cant seem to figure out the way to get the content of sub-block > without using "grep". > > Thanks > ilya > > Ilya, I have recently discovered jq [1] and it does a very nice job at parsing json. I have not tried it with CloudMonkey output but I do use it with the output of AWS CLI and it does wonders. Cheers, Carlos [1] https://stedolan.github.io/jq/ Find out more about ShapeBlue and our range of CloudStack related services IaaS Cloud Design & Build<http://shapeblue.com/iaas-cloud-design-and-build//> CSForge – rapid IaaS deployment framework<http://shapeblue.com/csforge/> CloudStack Consulting<http://shapeblue.com/cloudstack-consultancy/> CloudStack Software Engineering<http://shapeblue.com/cloudstack-software-engineering/> CloudStack Infrastructure Support<http://shapeblue.com/cloudstack-infrastructure-support/> CloudStack Bootcamp Training Courses<http://shapeblue.com/cloudstack-training/> This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Shape Blue Ltd or related companies. If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone. Please contact the sender if you believe you have received this email in error. Shape Blue Ltd is a company incorporated in England & Wales. ShapeBlue Services India LLP is a company incorporated in India and is operated under license from Shape Blue Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in Brasil and is operated under license from Shape Blue Ltd. ShapeBlue SA Pty Ltd is a company registered by The Republic of South Africa and is traded under license from Shape Blue Ltd. ShapeBlue is a registered trademark.