From 9987cb5c03b2a02b0980b76e44c23cf002361717 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 27 Jul 2022 07:51:41 -0400 Subject: [PATCH] Advance state of routed esxi deployment --- .../common/initramfs/opt/confluent/bin/apiclient | 2 +- .../initramfs/opt/confluent/bin/initconfluent.sh | 1 + confluent_osdeploy/esxi7/initramfs/bin/dcuiweasel | 15 +++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient b/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient index 72581207..9c345c38 100644 --- a/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient +++ b/confluent_osdeploy/common/initramfs/opt/confluent/bin/apiclient @@ -435,4 +435,4 @@ if __name__ == '__main__': status, rsp = client.grab_url_with_status(sys.argv[1], data) sys.stdout.write(rsp.decode()) else: - sys.stdout.write(HTTPSClient(usejson, errout=errout).grab_url(sys.argv[1], data, phmac=phmac).decode()) + sys.stdout.write(HTTPSClient(usejson, errout=errout, phmac=phmac).grab_url(sys.argv[1], data).decode()) diff --git a/confluent_osdeploy/coreos/initramfs/opt/confluent/bin/initconfluent.sh b/confluent_osdeploy/coreos/initramfs/opt/confluent/bin/initconfluent.sh index 86a8e522..0cacc6b4 100755 --- a/confluent_osdeploy/coreos/initramfs/opt/confluent/bin/initconfluent.sh +++ b/confluent_osdeploy/coreos/initramfs/opt/confluent/bin/initconfluent.sh @@ -20,6 +20,7 @@ if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then else v4addr=$(grep ^ipv4_address: $tcfg) v4addr=${v4addr#ipv4_address: } + v4addr=${v4addr%/*} v4gw=$(grep ^ipv4_gateway: $tcfg) v4gw=${v4gw#ipv4_gateway: } if [ "$v4gw" = "null" ]; then diff --git a/confluent_osdeploy/esxi7/initramfs/bin/dcuiweasel b/confluent_osdeploy/esxi7/initramfs/bin/dcuiweasel index 3f3facee..2c254879 100644 --- a/confluent_osdeploy/esxi7/initramfs/bin/dcuiweasel +++ b/confluent_osdeploy/esxi7/initramfs/bin/dcuiweasel @@ -20,6 +20,7 @@ if [ ! -z "$personality" ]; then mkdir -p /tmp/confluentident mcopy -i $personality ::* /tmp/confluentident/ fi +touch /etc/confluent/confluent.apikey if [ -e /tmp/confluentident/cnflnt.yml ]; then cat /tls/*.pem >> /etc/confluent/ca.pem deploysrvs=$(sed -n '/^deploy_servers:/,/^[^-]/p' /tmp/confluentident/cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :) @@ -35,6 +36,7 @@ if [ -e /tmp/confluentident/cnflnt.yml ]; then if [ "$autoconfigmethod" = "static" ]; then v4addr=$(grep ^ipv4_address: $tcfg) v4addr=${v4addr#ipv4_address: } + v4addr=${v4addr%/*} v4gw=$(grep ^ipv4_gateway: $tcfg) v4gw=${v4gw#ipv4_gateway: } if [ "$v4gw" = "null" ]; then @@ -46,14 +48,15 @@ if [ -e /tmp/confluentident/cnflnt.yml ]; then localcli network ip route ipv4 add -n default -g $v4gw fi hmackeyfile=$(mktemp) - echo -n $(grep ^apitoken: cnflnt.yml|awk '{print $2}') > $hmackeyfile + echo -n $(grep ^apitoken: /tmp/confluentident/cnflnt.yml|awk '{print $2}') > $hmackeyfile cd - passfile=$(mktemp) passcrypt=$(mktemp) hmacfile=$(mktemp) ln -s /opt/confluent/bin/clortho /opt/confluent/bin/genpasshmac /opt/confluent/bin/genpasshmac $passfile $passcrypt $hmacfile $hmackeyfile - + /opt/confluent/bin/apiclient -p $hmacfile /confluent-api/self/registerapikey $passcrypt + cp $passfile /etc/confluent/confluent.apikey fi while ! grep NODENAME /etc/confluent/confluent.info; do echo "Searching for deployment service on local network..." @@ -73,9 +76,13 @@ while ! grep NODENAME /etc/confluent/confluent.info; do done node=$(grep NODENAME: /etc/confluent/confluent.info|head -n 1|awk '{print $2}') mgr=$(grep MANAGER: /etc/confluent/confluent.info|head -n 1|awk '{print $2}') -cp /opt/confluent/bin/clortho /clortho -(/clortho $node $mgr || /opt/confluent/bin/clortho $node $mgr) > /etc/confluent/confluent.apikey APIKEY=$(cat /etc/confluent/confluent.apikey) + +if [ -z "$APIKEY" ]; then + cp /opt/confluent/bin/clortho /clortho + (/clortho $node $mgr || /opt/confluent/bin/clortho $node $mgr) > /etc/confluent/confluent.apikey + APIKEY=$(cat /etc/confluent/confluent.apikey) +fi while [ -z "$APIKEY" ]; do if [ ! -f /var/run/vmware/show-esx-shell-login ]; then chvt 1