2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Implement deployment binding for new installs

When doing osdeploy initialize,
save the uuid and have deployment
targets specifically pair back with site via
uuid.
This commit is contained in:
Jarrod Johnson 2022-02-08 10:41:27 -05:00
parent b0b8ee128b
commit 358b719cec
3 changed files with 29 additions and 1 deletions

View File

@ -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);

View File

@ -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/')

View File

@ -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