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

2015-05-27 Thread Ronald Bradford
Thanks Doug,

I knew there would be a more definitive and simple use.
eval is that way!

Ronald


Ronald Bradford

Web Site: http://ronaldbradford.com
LinkedIn:  http://www.linkedin.com/in/ronaldbradford
Twitter:@RonaldBradford 
Skype: RonaldBradford
GTalk: Ronald.Bradford
IRC: rbradfor


On Tue, May 26, 2015 at 1:19 PM, Doug Hellmann 
wrote:

> 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
>
> __
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2015-05-26 Thread Terry Howe
>
>
> 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
> ...


The show commands for neutron client and OSC  have a format 'value' option
that may help:

$ os network show -c id -f value netty
00d7e1af-8749-411f-96da-3bda20601cb3
$ NETTY_ID=$(os network show -c id -f value netty)
$ echo $NETTY_ID
00d7e1af-8749-411f-96da-3bda20601cb3
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2015-05-26 Thread Doug Hellmann
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

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2015-05-26 Thread Dean Troyer
On Tue, May 26, 2015 at 10:18 AM, Ronald Bradford 
wrote:

> 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
>

I'll just say off the top it is unlikely as there are only two resources
implemented using the Network API.  The remaining networking functions use
the Compute API for nova-net.

We have not really mapped the requried commands to OSC form yet, that is
going to be the hardest part of implementing them.  They need to be
consistent with the rest of OSC.

Some of what you mentioned is common to all OSC commands, like the output
formatting is all done with cliff.  I don't know how much of that would be
common to neutronclient too since it also uses cliff, but sometimes in a
different way.

dt

-- 

Dean Troyer
dtro...@gmail.com
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2015-05-26 Thread Ronald Bradford
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.

$ NIC_ID2=$(openstack network show public -c id --format shell)
$  echo $NIC_ID2
id="210d976e-16a3-42dc-ac31-f01810dbd297"

And even stripping out the "name=" portion still results in a quoted
response.

$ NIC_ID3=$(openstack network show public -c id --format shell | cut -d=
-f2)
$ echo $NIC_ID3
"210d976e-16a3-42dc-ac31-f01810dbd297"

So in order to accurately reproduce I need the following which seems more
long winded then the original.

$ NIC_ID4=$(openstack network show public -c id --format shell | cut -d=
-f2 | tr -d '"')
$ echo $NIC_ID4
210d976e-16a3-42dc-ac31-f01810dbd297

While I presume the intended use to create a file to source variables is
there any merit it supporting per variable definition as in this example?

Any thoughts appreciated.


Regards

Ronald
__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev