diff --git a/confluent_osdeploy/el8/initramfs/usr/lib/dracut/hooks/pre-trigger/01-confluent.sh b/confluent_osdeploy/el8/initramfs/usr/lib/dracut/hooks/pre-trigger/01-confluent.sh index 95b74586..d060a969 100644 --- a/confluent_osdeploy/el8/initramfs/usr/lib/dracut/hooks/pre-trigger/01-confluent.sh +++ b/confluent_osdeploy/el8/initramfs/usr/lib/dracut/hooks/pre-trigger/01-confluent.sh @@ -96,6 +96,25 @@ if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then fi cd /sys/class/net if ! grep MANAGER: /etc/confluent/confluent.info; then + confluentsrv=$(getarg confluent) + if [ ! -z "$confluentsrv" ]; then + if [[ "$confluentsrv" = *":"* ]]; then + /usr/libexec/nm-initrd-generator ip=:dhcp6 + else + /usr/libexec/nm-initrd-generator ip=:dhcp + fi + NetworkManager --configure-and-quit=initrd --no-daemon + myids=uuid=$(cat /sys/devices/virtual/dmi/id/product_uuid) + for mac in $(ip -br link|grep -v LOOPBACK|awk '{print $3}'); do + myids=$myids"/mac="$mac + done + myname=$(curl -sH "CONFLUENT_IDS: $myids" https://$confluentsrv/confluent-api/self/whoami) + if [ ! -z "$myname" ]; then + echo NODENAME: $myname > /etc/confluent/confluent.info + echo MANAGER: $confluentsrv >> /etc/confluent/confluent.info + echo EXTMGRINFO: $confluentsrv'||1' >> /etc/confluent/confluent.info + fi + fi while ! grep ^EXTMGRINFO: /etc/confluent/confluent.info | awk -F'|' '{print $3}' | grep 1 >& /dev/null && [ "$TRIES" -lt 60 ]; do TRIES=$((TRIES + 1)) for currif in *; do diff --git a/confluent_server/confluent/netutil.py b/confluent_server/confluent/netutil.py index b927ea75..39178613 100644 --- a/confluent_server/confluent/netutil.py +++ b/confluent_server/confluent/netutil.py @@ -237,6 +237,8 @@ class NetManager(object): if ipv6addr: myattribs['ipv6_method'] = 'static' myattribs['ipv6_address'] = ipv6addr + else: + myattribs['ipv6_method'] = 'dhcp' if attribs.get('ipv6_gateway', None) and 'ipv6_method' in myattribs: myattribs['ipv6_gateway'] = attribs['ipv6_gateway'] if 'ipv4_method' not in myattribs and 'ipv6_method' not in myattribs: diff --git a/confluent_server/confluent/selfservice.py b/confluent_server/confluent/selfservice.py index 1e9cc144..e084fff5 100644 --- a/confluent_server/confluent/selfservice.py +++ b/confluent_server/confluent/selfservice.py @@ -71,6 +71,22 @@ def handle_request(env, start_response): cfg = configmanager.ConfigManager(None) nodename = env.get('HTTP_CONFLUENT_NODENAME', None) clientip = env.get('HTTP_X_FORWARDED_FOR', None) + if env['PATH_INFO'] == '/self/whoami': + clientids = env.get('HTTP_CONFLUENT_IDS', None) + if not clientids: + start_response('400 Bad Request', []) + yield 'Bad Request' + return + for ids in clientids.split('/'): + _, v = ids.split('=', 1) + repname = disco.get_node_by_uuid_or_mac(v) + if repname: + start_response('200 OK', []) + yield repname + return + start_response('404 Unknown', []) + yield '' + return if env['PATH_INFO'] == '/self/registerapikey': crypthmac = env.get('HTTP_CONFLUENT_CRYPTHMAC', None) if int(env.get('CONTENT_LENGTH', 65)) > 64: