summaryrefslogtreecommitdiff
path: root/ovn
diff options
context:
space:
mode:
authorRussell Bryant <russell@ovn.org>2016-03-21 22:29:38 -0400
committerRussell Bryant <russell@ovn.org>2016-03-23 15:36:30 -0400
commit2229f3ecc136559214fd8926819e2c99eed4f710 (patch)
treef804c8a316589824a8c59ce0275501aa1967ab15 /ovn
parenta96838a6668dd3aa269cf4d1ba5f3da60eab708a (diff)
downloadopenvswitch-2229f3ecc136559214fd8926819e2c99eed4f710.tar.gz
ovn: Add hostname to Chassis.
We currently use the system-id from the Open_vSwitch schema on each host to populate the unique name field of a Chassis in OVN_Southbound. On most systems, this is a UUID. It would be very convenient to also have the hostname available as that will allow people to more quickly identify which host a Chassis record is associated with in most cases. This is also useful for correlating an OVN Chassis with the knowledge of hosts that exists in other systems (such as OpenStack). Also add the hostname of each chassis to the output of "ovn-sbctl show". Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Diffstat (limited to 'ovn')
-rw-r--r--ovn/controller/chassis.c12
-rw-r--r--ovn/ovn-sb.ovsschema5
-rw-r--r--ovn/ovn-sb.xml6
-rw-r--r--ovn/utilities/ovn-sbctl.c4
4 files changed, 23 insertions, 4 deletions
diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c
index 67f3085e2..1e2aaec82 100644
--- a/ovn/controller/chassis.c
+++ b/ovn/controller/chassis.c
@@ -14,6 +14,8 @@
*/
#include <config.h>
+#include <unistd.h>
+
#include "chassis.h"
#include "lib/vswitch-idl.h"
@@ -89,7 +91,16 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id)
}
free(tokstr);
+ char hostname[HOST_NAME_MAX + 1];
+ if (gethostname(hostname, sizeof hostname)) {
+ hostname[0] = '\0';
+ }
+
if (chassis_rec) {
+ if (strcmp(hostname, chassis_rec->hostname)) {
+ sbrec_chassis_set_hostname(chassis_rec, hostname);
+ }
+
/* Compare desired tunnels against those currently in the database. */
uint32_t cur_tunnels = 0;
bool same = true;
@@ -127,6 +138,7 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id)
if (!chassis_rec) {
chassis_rec = sbrec_chassis_insert(ctx->ovnsb_idl_txn);
sbrec_chassis_set_name(chassis_rec, chassis_id);
+ sbrec_chassis_set_hostname(chassis_rec, hostname);
}
int n_encaps = count_1bits(req_tunnels);
diff --git a/ovn/ovn-sb.ovsschema b/ovn/ovn-sb.ovsschema
index ead733b88..32f874849 100644
--- a/ovn/ovn-sb.ovsschema
+++ b/ovn/ovn-sb.ovsschema
@@ -1,11 +1,12 @@
{
"name": "OVN_Southbound",
- "version": "1.1.0",
- "cksum": "1223981720 5320",
+ "version": "1.2.0",
+ "cksum": "1259182303 5368",
"tables": {
"Chassis": {
"columns": {
"name": {"type": "string"},
+ "hostname": {"type": "string"},
"encaps": {"type": {"key": {"type": "uuid",
"refTable": "Encap"},
"min": 1, "max": "unlimited"}},
diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml
index d62f1e4e1..e1a581207 100644
--- a/ovn/ovn-sb.xml
+++ b/ovn/ovn-sb.xml
@@ -162,6 +162,12 @@
not prescribe a particular format for chassis names.
</column>
+ <column name="hostname">
+ The hostname of the chassis, if applicable. ovn-controller will populate
+ this column with the hostname of the host it is running on.
+ ovn-controller-vtep will leave this column empty.
+ </column>
+
<group title="Encapsulation Configuration">
<p>
OVN uses encapsulation to transmit logical dataplane packets
diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
index 706ab2e55..d08095281 100644
--- a/ovn/utilities/ovn-sbctl.c
+++ b/ovn/utilities/ovn-sbctl.c
@@ -504,8 +504,8 @@ pre_get_info(struct ctl_context *ctx)
static struct cmd_show_table cmd_show_tables[] = {
{&sbrec_table_chassis,
&sbrec_chassis_col_name,
- {&sbrec_chassis_col_encaps,
- NULL,
+ {&sbrec_chassis_col_hostname,
+ &sbrec_chassis_col_encaps,
NULL},
{&sbrec_table_port_binding,
&sbrec_port_binding_col_logical_port,