Skip to content

Commit 1ab3905

Browse files
lukaszrzasikblp
authored andcommitted
ovsdb-data: Add support for integer ranges in database commands
Adding / removing a range of integers to a column accepting a set of integers requires enumarating all of the integers. This patch simplifies it by introducing 'range' concept to the database commands. Two integers separated by a hyphen represent an inclusive range. The patch adds positive and negative tests for the new syntax. The patch was tested by 'make check'. Covarage was tested by 'make check-lcov'. Signed-off-by: Lukasz Rzasik <lukasz.rzasik@gmail.com> Suggested-by: <my_ovs_discuss@yahoo.com> Suggested-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
1 parent 84d0ca5 commit 1ab3905

11 files changed

Lines changed: 284 additions & 67 deletions

File tree

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ Luca Giraudo lgiraudo@nicira.com
190190
Lucian Petrut lpetrut@cloudbasesolutions.com
191191
Luigi Rizzo rizzo@iet.unipi.it
192192
Luis E. P. l31g@hotmail.com
193+
Lukasz Rzasik lukasz.rzasik@gmail.com
193194
Madhu Challa challa@noironetworks.com
194195
Mario Cabrera mario.cabrera@hpe.com
195196
Mark D. Gray mark.d.gray@intel.com

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Post-v2.6.0
5959
* Ports now have a "protected" flag. Protected ports can not forward
6060
frames to other protected ports. Unprotected ports can receive and
6161
forward frames to protected and other unprotected ports.
62+
- ovs-vsctl, ovn-nbctl, ovn-sbctl, vtep-ctl:
63+
* Database commands now accept integer ranges, e.g. "set port
64+
eth0 trunks=1-10" to enable trunking VLANs 1 to 10.
6265

6366
v2.6.0 - 27 Sep 2016
6467
---------------------

lib/db-ctl-base.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ is_condition_satisfied(const struct ctl_table_class *table,
677677
column->name);
678678
}
679679

680-
die_if_error(ovsdb_atom_from_string(&want_key, &column->type.key,
680+
die_if_error(ovsdb_atom_from_string(&want_key, NULL, &column->type.key,
681681
key_string, symtab));
682682

683683
type.key = type.value;
@@ -823,7 +823,7 @@ cmd_get(struct ctl_context *ctx)
823823
column->name);
824824
}
825825

826-
die_if_error(ovsdb_atom_from_string(&key,
826+
die_if_error(ovsdb_atom_from_string(&key, NULL,
827827
&column->type.key,
828828
key_string, ctx->symtab));
829829

@@ -1118,13 +1118,13 @@ set_column(const struct ctl_table_class *table,
11181118
column->name);
11191119
}
11201120

1121-
die_if_error(ovsdb_atom_from_string(&key, &column->type.key,
1121+
die_if_error(ovsdb_atom_from_string(&key, NULL, &column->type.key,
11221122
key_string, symtab));
1123-
die_if_error(ovsdb_atom_from_string(&value, &column->type.value,
1123+
die_if_error(ovsdb_atom_from_string(&value, NULL, &column->type.value,
11241124
value_string, symtab));
11251125

11261126
ovsdb_datum_init_empty(&datum);
1127-
ovsdb_datum_add_unsafe(&datum, &key, &value, &column->type);
1127+
ovsdb_datum_add_unsafe(&datum, &key, &value, &column->type, NULL);
11281128

11291129
ovsdb_atom_destroy(&key, column->type.key.type);
11301130
ovsdb_atom_destroy(&value, column->type.value.type);

lib/db-ctl-base.man

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ single comma. When multiple values are present, duplicates are not
2929
allowed, and order is not important. Conversely, some database
3030
columns can have an empty set of values, represented as \fB[]\fR, and
3131
square brackets may optionally enclose other non-empty sets or single
32-
values as well.
32+
values as well. For a column accepting a set of integers, database commands
33+
accept a range. A range is represented by two integers separated by
34+
\fB-\fR. A range is inclusive. A range has a maximum size of 4096
35+
elements. If more elements are needed, they can be specified in seperate
36+
ranges.
3337
.PP
3438
A few database columns are ``maps'' of key-value pairs, where the key
3539
and the value are each some fixed database type. These are specified

0 commit comments

Comments
 (0)