summaryrefslogtreecommitdiff
path: root/lib/db-ctl-base.h
Commit message (Collapse)AuthorAgeFilesLines
* db-ctl-base: Use partial map/set updates for last add/set commands.Ilya Maximets2022-12-061-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, command to add one item into a large set generates the transaction with the full new content of that set plus 'wait' operation for the full old content of that set. So, if we're adding one new load-balancer into a load-balancer group in OVN using ovn-nbctl, transaction will include all the existing load-balancers from that groups twice. IDL supports partial updates for sets and maps. The problem with that is changes are not visible to the IDL user until the transaction is committed. That will cause problems for chained ctl commands. However, we still can optimize the very last command in the list. It makes sense to do, since it's a common case for manual invocations. Updating the 'add' command as well as 'set' for a case where we're actually adding one new element to the map. One downside is that we can't check the set size without examining it and checking for duplicates, so allowing the transaction to be sent and constraints to be checked on the server side in that case. Not touching 'remove' operation for now, since removals may have different type, e.g. if elements from the map are removed by the key. The function will likely need to be fully re-written to accommodate all the corner cases. Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* db-ctl-base: Propagate errors from the commands parser.Jakub Sitnicki2018-07-231-3/+3
| | | | | | | | Let the caller decide how to handle the error. Prepare for using the parser in ovn-nbctl daemon mode. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Extend ctl_context with an error message.Jakub Sitnicki2018-07-031-0/+3
| | | | | | | | Prepare for the command handlers (pre_cmd_*() cmd_*() functions) to report errors by storing them in the context. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Don't die in ctl_set_column() on error.Jakub Sitnicki2018-07-031-3/+2
| | | | | | | | | Return the error message to the caller instead of reporting it and dying so that the caller can handle the error without terminating the process if needed. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Don't die in ctl_get_row() on error.Jakub Sitnicki2018-07-031-4/+3
| | | | | | | | | Return the error message to the caller instead of reporting it and dying so that the caller can handle the error without terminating the process if needed. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-vsctl, ovn-nbctl, ovn-sbctl, vtep-ctl: Parse options before logging.Ben Pfaff2018-05-251-1/+1
| | | | | | | | | | These utilities logged the command very early, before parsing the options or the command. This meant that logging options (like --log-file or -vsyslog:off) weren't considered for the purpose of logging the command. This fixes the problem. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ovs-vsctl: Include bfd_status in "show" output for interfacesMiguel Angel Ajo2018-03-141-1/+1
| | | | | | | | | | Since OVS 2.8 OVN provides L3HA capabilities via BFD monitoring, but checking the status of BFD is not obvious, and we provide a simple way to visualize the status with this simple patch. Signed-off-by: Miguel Angel Ajo <majopela@redhat.com> Tested-by: Miguel Angel Ajo <majopela@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Don't shadow 'invalidate_cache' callback.Justin Pettit2018-02-281-1/+1
| | | | | Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* Refer to database manpages in *ctl manpagesMark Michelson2018-02-261-7/+7
| | | | | | | | | | | | | | The ovn-nbctl, ovn-sbctl, and ovs-vsctl manpages are inconsistent in their "Database Commands" section when it comes to referring to what database tables exist. This commit amends this by making each *ctl manpage reference the corresponding database manpage instead. To aid in having a more handy list, the --help text of ovn-nbctl, ovn-sbctl, and ovs-vsctl have been modified to list the available tables. This is also referenced in the manpages for those applications. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovn-sbctl: Add --ovs option to "lflow-list", for listing OpenFlow flows.Ben Pfaff2017-05-031-1/+10
| | | | | | | | This is like the --ovs option to ovn-trace, but it applies to every flow dumped, so it has different applications. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovn-sbctl: Get rid of redundant code by using function from db-ctl-base.Ben Pfaff2017-05-031-0/+5
| | | | | | | | | This renames get_row() to ctl_get_row() and makes it public. It's unfortunate that it adds a cast, but getting rid of redundant code seems worth it to me. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovn-nbctl: Allow access to DHCP options via logical switch port name.Ben Pfaff2017-05-031-1/+1
| | | | | | | | After this, if port "myvif" has DHCPv4 or DHCPv6 options, you can use "ovn-nbctl list dhcp myvif" to see them. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Add support for identifying a row based on a value in a map.Ben Pfaff2017-05-031-1/+5
| | | | | | | | | This will be used in an upcoming commit to allow Datapath_Binding records in the OVN southbound database to be identified based on external-ids:name and other map values. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Drop redundant 'table' field from struct ctl_row_id.Ben Pfaff2017-05-031-1/+10
| | | | | | | | | | The 'table' field is redundant because the required 'column' field implies the table that the column is a part of. This simplifies the users and makes it harder to get these things wrong. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Always support all tables in schema.Ben Pfaff2017-01-131-5/+15
| | | | | | | | | | | | | | | | | When one adds a new table to a database schema, it's easy to forget to add the table to the list of tables in the *ctl.c program. When this happens, the database commands for that program don't work on that table at all, even for commands like "list" and "create" that don't need any special help. This patch fixes that problem, by making sure that db-ctl-base always has the complete list of tables. Previously, each ctl_table_class pointed directly to the corresponding ovsdb_idl_table_class. With this patch, there are instead two parallel arrays, one of ovsdb_idl_table_classes and the other of ctl_table_classes. This change accounts for the bulk of the change to the db-ctl-base code. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Lance Richardson <lrichard@redhat.com>
* Add read-only option to ovs-dpctl and ovs-ofctl commands.Ryan Moats2016-08-151-1/+1
| | | | | | | | | ovs-dpctl and ovs-ofctl lack a read-only option to prevent running of commands that perform read-write operations. Add it and the necessary scaffolding to each. Signed-off-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+1
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Allow print rows that weak reference to table inAlex Wang2015-08-131-0/+17
| | | | | | | | | | | | | | | | | | | | 'cmd_show_table'. Sometimes, it is desirable to print the table with weak reference to the table specified in 'struct cmd_show_table'. For example the Port_Binding table rows in OVN_Southbound database that refer to the same Chassis table row can be printed under the same chassis entry in 'ovn-sbctl show' output. To achieve it, this commit adds a new struct in 'struct cmd_show_table' that allows users to print a table with weak reference to 'table' specified in 'struct cmd_show_table'. The 'ovn-sbctl' which now prints the Port_Binding entries with Chassis table, is the first user of this new feature. Requested-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* db-ctl-base: make cmd_show_table privateAndy Zhou2015-07-231-14/+3
| | | | | | | | Instead of requiring user to declare a global variable, pass the value via ctl_init(). Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: remove the recurse member from struct cmd_show_tableAndy Zhou2015-07-231-4/+0
| | | | | | | | | | | | The 'recurse' is used during run time to suppress duplicated prints. It is not essential to describe how show command should work. This patch remove the 'recurse' member. Duplicated prints is now suppressed by maintaining an 'sset' of tables that have been printed at run time. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: make use of user supplied exit functionAndy Zhou2015-07-171-9/+2
| | | | | | | | | The user is required to expose the_idl and the_idl_txn global variables, so that memory can be cleaned up on fatal errors. This patch changes to ask user to supply an exit function via ctl_init(). What user needs to do on exit can now remain private. Signed-off-by: Andy Zhou <azhou@nicira.com>
* db-ctl-base: remove ctl_get_all_commands() functionAndy Zhou2015-07-171-1/+0
| | | | | | | all_commands currently is some times accessed directly, some times via a function call. Change to always access it directly. Signed-off-by: Andy Zhou <azhou@nicira.com>
* db-ctl-base: do not require client to expose the "tables" variableAndy Zhou2015-07-131-9/+2
| | | | | | | Instead, client now pass it via the modified ctl_init() API. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: do not expose get_table() APIAndy Zhou2015-07-131-4/+3
| | | | | | | | | | | | Both get_table() and set_cloum() APIs are mostly used within db-ctl-base library. This patch makes both private to the library. Add a new ctl_set_colum() API for library client. The changes are cleanups. No functional changes. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: fix a few typosAndy Zhou2015-07-091-3/+3
| | | | | | | Minor typo and style fixes. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: Librarize show command.Alex Wang2015-06-231-0/+34
| | | | | | | | This commit extracts the 'show' command code and puts it into the db-ctl-base module. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: Librarize code in parse_options().Alex Wang2015-06-231-0/+5
| | | | | | | | This commit extracts general code from parse_options() and puts it into db-ctl-base module. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: Make common database command code into library.Alex Wang2015-06-231-0/+219
This commit extracts common database command (e.g. ovs-vsctl, vtep-ctl) code into a new library module, db-ctl-base. Specifically, the module unifies the command syntax and common database-operating commands like (get, list, find, set ...), and provides apis which allow user to create more specific commands. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>