This commit adds improvement to 'show' command logic and allows it to print key->table_ref maps. The direct effect can be observed from the tests/vtep-ctl.at change. The improvement will also be used in the ovn-sbctl implementation.
Signed-off-by: Alex Wang <al...@nicira.com> --- lib/db-ctl-base.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/vtep-ctl.at | 6 ++++-- vtep/vtep-ctl.c | 13 ++++++++++--- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index a1147aa..10884b4 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1595,6 +1595,45 @@ cmd_show_row(struct ctl_context *ctx, const struct ovsdb_idl_row *row, } continue; } + } else if (ovsdb_type_is_map(&column->type) && + column->type.value.type == OVSDB_TYPE_UUID && + column->type.value.u.uuid.refTableName) { + struct cmd_show_table *ref_show; + size_t j; + + /* Prints the key to ref'ed table name map if the ref'ed table + * is also defined in 'cmd_show_tables'. */ + ref_show = cmd_show_find_table_by_name( + column->type.value.u.uuid.refTableName); + if (ref_show && ref_show->name_column) { + ds_put_char_multiple(&ctx->output, ' ', (level + 1) * 4); + ds_put_format(&ctx->output, "%s:\n", column->name); + for (j = 0; j < datum->n; j++) { + const struct ovsdb_idl_row *ref_row; + + ref_row = ovsdb_idl_get_row_for_uuid(ctx->idl, + ref_show->table, + &datum->values[j].uuid); + + ds_put_char_multiple(&ctx->output, ' ', (level + 2) * 4); + ovsdb_atom_to_string(&datum->keys[j], column->type.key.type, + &ctx->output); + ds_put_char(&ctx->output, '='); + if (ref_row) { + const struct ovsdb_datum *ref_datum; + + ref_datum = ovsdb_idl_read(ref_row, + ref_show->name_column); + ovsdb_datum_to_string(ref_datum, + &ref_show->name_column->type, + &ctx->output); + } else { + ds_put_cstr(&ctx->output, "\"<null>\""); + } + ds_put_char(&ctx->output, '\n'); + } + continue; + } } if (!ovsdb_datum_is_default(datum, &column->type)) { diff --git a/tests/vtep-ctl.at b/tests/vtep-ctl.at index 67007bf..bb2df4f 100644 --- a/tests/vtep-ctl.at +++ b/tests/vtep-ctl.at @@ -897,14 +897,16 @@ AT_CHECK([RUN_VTEP_CTL( [add-port a a1], [add-ls ls1], [bind-ls a a1 100 ls1], - [set Physical_Switch a tunnel_ips=[[1.2.3.4]]])], [0], [ignore], [], [VTEP_CTL_CLEANUP]) + [set Physical_Switch a management_ips=[[4.3.2.1]] tunnel_ips=[[1.2.3.4]]])], [0], [ignore], [], [VTEP_CTL_CLEANUP]) AT_CHECK([vtep-ctl --timeout=5 -vreconnect:emer --db=unix:socket show | tail -n+2 | sed 's/=[[a-f0-9-]][[a-f0-9-]]*\}/=<ls>\}/' ], [0], [dnl Manager "tcp:4.5.6.7" Physical_Switch a + management_ips: [["4.3.2.1"]] tunnel_ips: [["1.2.3.4"]] Physical_Port "a1" - vlan_bindings: {100=<ls>} + vlan_bindings: + 100="ls1" ], [], [VTEP_CTL_CLEANUP]) VTEP_CTL_CLEANUP diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 309c0b3..7f455df 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -357,9 +357,9 @@ struct cmd_show_table cmd_show_tables[] = { {&vteprec_table_physical_switch, &vteprec_physical_switch_col_name, - {&vteprec_physical_switch_col_tunnel_ips, - &vteprec_physical_switch_col_ports, - NULL}, + {&vteprec_physical_switch_col_management_ips, + &vteprec_physical_switch_col_tunnel_ips, + &vteprec_physical_switch_col_ports}, false}, {&vteprec_table_physical_port, @@ -369,6 +369,13 @@ struct cmd_show_table cmd_show_tables[] = { NULL}, false}, + {&vteprec_table_logical_switch, + &vteprec_logical_switch_col_name, + {NULL, + NULL, + NULL}, + false}, + {NULL, NULL, {NULL, NULL, NULL}, false} }; -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev