gluon-respondd: emit "primary_domain_code" in nodeinfo

Closes #1974

Situation:
==========

$ ls -l /lib/gluon/domains/lindennord.json
lrwxrwxrwx    1 root     root            10 Jan  6 03:42 /lib/gluon/domains/lindennord.json -> dom17.json

Before:
=======

$ gluon-neighbour-info -d ::1 -p 1001 -r nodeinfo -c 1
{
   "node_id": "525400123456",
   "system": {
     "domain_code": "lindennord",
     "site_code": "ffh"
   },
...
}

After:
======

$ gluon-neighbour-info -d ::1 -p 1001 -r nodeinfo -c 1
{
   "node_id": "525400123456",
   "system": {
     "primary_domain_code": "dom17",
     "domain_code": "lindennord",
     "site_code": "ffh"
   },
...
}
This commit is contained in:
lemoer 2020-05-16 14:45:33 +02:00 committed by Matthias Schiffer
parent bcf57467dd
commit b9c1a026b1
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -64,6 +64,10 @@ static struct json_object * get_site_code(void) {
return ret; return ret;
} }
static struct json_object * get_primary_domain_code(void) {
return gluonutil_wrap_and_free_string(gluonutil_get_primary_domain());
}
static struct json_object * get_domain_code(void) { static struct json_object * get_domain_code(void) {
return gluonutil_wrap_and_free_string(gluonutil_get_domain()); return gluonutil_wrap_and_free_string(gluonutil_get_domain());
} }
@ -124,8 +128,10 @@ struct json_object * respondd_provider_nodeinfo(void) {
struct json_object *system = json_object_new_object(); struct json_object *system = json_object_new_object();
json_object_object_add(system, "site_code", get_site_code()); json_object_object_add(system, "site_code", get_site_code());
if (gluonutil_has_domains()) if (gluonutil_has_domains()) {
json_object_object_add(system, "domain_code", get_domain_code()); json_object_object_add(system, "domain_code", get_domain_code());
json_object_object_add(system, "primary_domain_code", get_primary_domain_code());
}
json_object_object_add(ret, "system", system); json_object_object_add(ret, "system", system);
return ret; return ret;