[openstack-dev] [openstackclient] Use and practices of --format shell for defining individual variables

Doug Hellmann doug at doughellmann.com
Tue May 26 17:19:56 UTC 2015


Excerpts from Ronald Bradford's message of 2015-05-26 11:18:09 -0400:
> Hi list,
> 
> I came across the following neutron client specific syntax and decided to
> see if I could reproduce using the openstack client and it's flexible
> formatting capabilities
> 
> 
> $ NIC_ID1=$(neutron net-show public | awk '/ id /{print $4}')
> 
> $  echo $NIC_ID1
> 210d976e-16a3-42dc-ac31-f01810dbd297
> 
> I can get similar syntax (unfortunately lowercase variable name only) with:
> NOTE: It may be nice to be able to pass an option to UPPERCASE all shell
> variables names.
> 
> $ openstack network show public -c id --format shell --prefix nic_
> nic_id="210d976e-16a3-42dc-ac31-f01810dbd297"
> 
> However to use this I effectively have to place in a file and source that
> file to expose this variable to my current running shell.
> Reproducing the same syntax does not work obviously.

It's actually meant to be used with an eval statement:

 $ eval $(openstack network show public -c id --format shell --prefix nic_)
 $ echo $nic_id

Doug



More information about the OpenStack-dev mailing list