diff --git a/confluent_osdeploy/utils/copernicus.c b/confluent_osdeploy/utils/copernicus.c index 807f5dc1..a3aa1d19 100644 --- a/confluent_osdeploy/utils/copernicus.c +++ b/confluent_osdeploy/utils/copernicus.c @@ -27,6 +27,20 @@ int add_uuid(char* destination, int maxsize) { return uuidsize + 6; } +int add_confluent_uuid(char* destination, int maxsize) { + int uuidf; + int uuidsize; + uuidf = open("/confluent_uuid", O_RDONLY); + if (uuidf < 1) { return 0; } + strncpy(destination, "/confluentuuid=", maxsize); + uuidsize = read(uuidf, destination + 15, maxsize - 15); + close(uuidf); + if (destination[uuidsize + 14] == '\n') { + destination[uuidsize + 14] = 0; + } + return uuidsize + 15; +} + void add_macs(char* destination, int maxsize) { struct ifaddrs *ifc, *ifa; struct sockaddr_ll *lla; @@ -107,6 +121,8 @@ int main(int argc, char* argv[]) { offset = strnlen(msg, 1024); add_uuid(msg + offset, 1024 - offset); offset = strnlen(msg, 1024); + add_confluent_uuid(msg + offset, 1024 - offset); + offset = strnlen(msg, 1024); add_macs(msg + offset, 1024 - offset); offset = strnlen(msg, 1024); ns = socket(AF_INET6, SOCK_DGRAM, 0); diff --git a/confluent_server/bin/osdeploy b/confluent_server/bin/osdeploy index e849cfd8..38ade0b5 100644 --- a/confluent_server/bin/osdeploy +++ b/confluent_server/bin/osdeploy @@ -315,6 +315,16 @@ def initialize(cmdset): opath = os.getcwd() os.chdir('/var/lib/confluent/public/site') totar = [] + if not os.path.exists('confluent_uuid'): + c = client.Command() + for rsp in c.read('/uuid'): + uuid = rsp.get('uuid', {}}).get('value', None) + if uuid: + with open('confluent_uuid') as uuidout: + uuidout.write(uuid) + uuidout.write('\n') + totar.append('confluent_uuid') + topack.append('confluent_uuid') if os.path.exists('ssh'): totar.append('ssh') topack.append('ssh/') diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index fd9aa58e..741db4fa 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -158,7 +158,7 @@ def _merge_dict(original, custom): rootcollections = ['deployment/', 'discovery/', 'events/', 'networking/', 'noderange/', 'nodes/', 'nodegroups/', 'usergroups/' , - 'users/', 'version'] + 'users/', 'uuid', 'version'] class PluginRoute(object): @@ -1216,6 +1216,8 @@ def handle_path(path, operation, configmanager, inputdata=None, autostrip=True): configmanager, inputdata, operation, pathcomponents) elif pathcomponents[0] == 'version': return (msg.Attributes(kv={'version': confluent.__version__}),) + elif pathcomponents[0] == 'uuid': + return (msg.Attributes(kv={'uuid': cfm.get_global('confluent_uuid')}),) elif pathcomponents[0] == 'usergroups': # TODO: when non-administrator accounts exist, # they must only be allowed to see their own user