summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--ovsdb/ovsdb-server.c39
-rw-r--r--ovsdb/storage.c10
-rw-r--r--ovsdb/storage.h1
4 files changed, 53 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 2f67d5047..a9c50add2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Post-v2.14.0
---------------------
+ - OVSDB:
+ * New unixctl command 'ovsdb-server/get-db-storage-status' to show the
+ status of the storage that's backing a database.
v2.14.0 - 17 Aug 2020
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index fd7891a72..d772edbe0 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -90,6 +90,7 @@ static unixctl_cb_func ovsdb_server_set_active_ovsdb_server_probe_interval;
static unixctl_cb_func ovsdb_server_set_sync_exclude_tables;
static unixctl_cb_func ovsdb_server_get_sync_exclude_tables;
static unixctl_cb_func ovsdb_server_get_sync_status;
+static unixctl_cb_func ovsdb_server_get_db_storage_status;
struct server_config {
struct sset *remotes;
@@ -453,6 +454,9 @@ main(int argc, char *argv[])
unixctl_command_register("ovsdb-server/sync-status", "",
0, 0, ovsdb_server_get_sync_status,
&server_config);
+ unixctl_command_register("ovsdb-server/get-db-storage-status", "DB", 1, 1,
+ ovsdb_server_get_db_storage_status,
+ &server_config);
/* Simulate the behavior of OVS release prior to version 2.5 that
* does not support the monitor_cond method. */
@@ -1702,6 +1706,41 @@ ovsdb_server_get_sync_status(struct unixctl_conn *conn, int argc OVS_UNUSED,
}
static void
+ovsdb_server_get_db_storage_status(struct unixctl_conn *conn,
+ int argc OVS_UNUSED,
+ const char *argv[],
+ void *config_)
+{
+ struct server_config *config = config_;
+ struct shash_node *node;
+
+ node = shash_find(config->all_dbs, argv[1]);
+ if (!node) {
+ unixctl_command_reply_error(conn, "Failed to find the database.");
+ return;
+ }
+
+ struct db *db = node->data;
+
+ if (!db->db) {
+ unixctl_command_reply_error(conn, "Failed to find the database.");
+ return;
+ }
+
+ struct ds ds = DS_EMPTY_INITIALIZER;
+ char *error = ovsdb_storage_get_error(db->db->storage);
+
+ if (!error) {
+ ds_put_cstr(&ds, "status: ok");
+ } else {
+ ds_put_format(&ds, "status: %s", error);
+ free(error);
+ }
+ unixctl_command_reply(conn, ds_cstr(&ds));
+ ds_destroy(&ds);
+}
+
+static void
parse_options(int argc, char *argv[],
struct sset *db_filenames, struct sset *remotes,
char **unixctl_pathp, char **run_command,
diff --git a/ovsdb/storage.c b/ovsdb/storage.c
index 7b4ad16f6..f662e9056 100644
--- a/ovsdb/storage.c
+++ b/ovsdb/storage.c
@@ -198,6 +198,16 @@ ovsdb_storage_get_memory_usage(const struct ovsdb_storage *storage,
}
}
+char *
+ovsdb_storage_get_error(const struct ovsdb_storage *storage)
+{
+ if (storage->error) {
+ return ovsdb_error_to_string(storage->error);
+ }
+
+ return NULL;
+}
+
void
ovsdb_storage_run(struct ovsdb_storage *storage)
{
diff --git a/ovsdb/storage.h b/ovsdb/storage.h
index a22396891..02b6e7e6c 100644
--- a/ovsdb/storage.h
+++ b/ovsdb/storage.h
@@ -42,6 +42,7 @@ const struct uuid *ovsdb_storage_get_sid(const struct ovsdb_storage *);
uint64_t ovsdb_storage_get_applied_index(const struct ovsdb_storage *);
void ovsdb_storage_get_memory_usage(const struct ovsdb_storage *,
struct simap *usage);
+char *ovsdb_storage_get_error(const struct ovsdb_storage *);
void ovsdb_storage_run(struct ovsdb_storage *);
void ovsdb_storage_wait(struct ovsdb_storage *);