Ask Your Question
0

how should I use neutron CLI option --request-format

asked 2014-07-22 00:48:40 -0500

zhouhan gravatar image

updated 2014-07-23 05:37:03 -0500

The help message is not helpful: --request-format {json,xml} The xml or json request format

What does it mean exactly? Does it mean that I can use this option to specify the query conditions? If yes, how?

For example, using admin role I want to list security-groups for a specific tenant instead of listing security-groups of all tenant. Can I do it with the neutron CLI?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-22 04:03:45 -0500

dbaxps gravatar image

updated 2014-07-23 04:59:53 -0500

For example, I want to list security-groups for a specific tenant. Can I do it with the neutron CLI?

Source tenants credentials and run :-
[root@icehouse1 ~(keystone_boris)]# neutron security-group-list
+--------------------------------------+---------+-------------+
| id                                   | name    | description |
+--------------------------------------+---------+-------------+
| 0945d280-6b39-4add-ae63-6f6824e55992 | default | default     |
+--------------------------------------+---------+-------------

Via database query :-

MariaDB [neutron]> select * from securitygrouprules where tenant_id='36332faa2be945cebf7a52157c2c0437' ;
+----------------------------------+--------------------------------------+--------------------------------------+--------------------------------------+-----------+-----------+----------+----------------+----------------+------------------+
| tenant_id                        | id                                   | security_group_id                    | remote_group_id                      | direction | ethertype | protocol | port_range_min | port_range_max | remote_ip_prefix |
+----------------------------------+--------------------------------------+--------------------------------------+--------------------------------------+-----------+-----------+----------+----------------+----------------+------------------+
| 36332faa2be945cebf7a52157c2c0437 | 0fb3068a-b87d-40d5-8818-90a961998e2b | 0945d280-6b39-4add-ae63-6f6824e55992 | NULL                                 | egress    | IPv6      | NULL     |           NULL |           NULL | NULL             |
| 36332faa2be945cebf7a52157c2c0437 | 1bea98d6-1cf7-478e-a452-9a708027654f | 0945d280-6b39-4add-ae63-6f6824e55992 | 0945d280-6b39-4add-ae63-6f6824e55992 | ingress   | IPv6      | NULL     |           NULL |           NULL | NULL             |
| 36332faa2be945cebf7a52157c2c0437 | 2a2dfb2b-2432-4554-9e11-4e528223d783 | 0945d280-6b39-4add-ae63-6f6824e55992 | NULL                                 | ingress   | IPv4      | tcp      |             22 |             22 | 0.0.0.0/0        |
| 36332faa2be945cebf7a52157c2c0437 | 3acd54fb-36ed-4b74-9b47-28a36e5fb092 | 0945d280-6b39-4add-ae63-6f6824e55992 | NULL                                 | egress    | IPv4      | NULL     |           NULL |           NULL | NULL             |
| 36332faa2be945cebf7a52157c2c0437 | 99e19e09-f910-472a-905b-f7fc127b5a5b | 0945d280-6b39-4add-ae63-6f6824e55992 | NULL                                 | ingress   | IPv4      | icmp     |           NULL |           NULL | 0.0.0.0/0        |
| 36332faa2be945cebf7a52157c2c0437 | acbd76f5-7b70-4683-90ba-87eabe063756 | 0945d280-6b39-4add-ae63-6f6824e55992 | 0945d280-6b39-4add-ae63-6f6824e55992 | ingress   | IPv4      | NULL     |           NULL |           NULL | NULL             |
+----------------------------------+--------------------------------------+--------------------------------------+--------------------------------------+-----------+-----------+----------+----------------+----------------+------------------+
6 rows in set (0.00 sec)
edit flag offensive delete link more

Comments

Sorry, you still didn't specify the tenant. Suppose you have 1000 tenants, and each has their own secgroups. How do you list only secgroups for tenant A?

zhouhan gravatar imagezhouhan ( 2014-07-22 22:32:44 -0500 )edit

Please view updated answer . Tenant_id is a key in where clause of database query.

dbaxps gravatar imagedbaxps ( 2014-07-23 05:01:32 -0500 )edit

Thank you dbaxps. Sure, we can get it from DB, or even neutron restful API. But what I really wanted to know is how to do this in neutron CLI. And I noticed the option --request-format and I wonder if it is for this purpose: to specify the query condition in json or xml. But there is no document for it.

zhouhan gravatar imagezhouhan ( 2014-07-23 05:30:26 -0500 )edit

P.S. if using SQL you can do this to get secgoups (rather than get rules): select * from securitygroups where tenant_id='xxxxxxx'

zhouhan gravatar imagezhouhan ( 2014-07-23 05:33:28 -0500 )edit

Yes, you are right :-

MariaDB [neutron]> select * from securitygroups ;
+----------------------------------+--------------------------------------+---------+-------------+
| tenant_id                        | id                                   | name    | description |
+----------------------------------+--------------------------------------+---------+-------------+
| 36332faa2be945cebf7a52157c2c0437 | 0945d280-6b39-4add-ae63-6f6824e55992 | default | default     |
| 1230ab7aca164e8f8baa878ac1279793 | 188ea87e-73ef-4ae2-a40b-7258f7ddc650 | default | default     |
| 47b59e88aee04eb2908146e04eb39a15 | 1c25d5c1-307a-42e4-84ca-3e55ba38d8a7 | default | default     |
| c83cc84f13bd48a6bbd2e90497956cb7 | 1c38510d-cfc4-4a13-8187-ed4872a35cc1 | default | default     |
+----------------------------------+--------------------------------------+---------+-------------+
4 rows in set (0.00 sec)
dbaxps gravatar imagedbaxps ( 2014-07-23 05:45:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-07-22 00:48:40 -0500

Seen: 171 times

Last updated: Jul 23 '14