+function node_userdata {
+ name="$1"
+ username="$2"
+ password="$3"
+ COMPUTE_NODE_FQDN="$name.akraino.icn.org"
+
+ # validate that the user isn't expecting the deprecated
+ # COMPUTE_NODE_PASSWORD to be used
+ if [ "$password" != "${COMPUTE_NODE_PASSWORD:-$password}" ]; then
+ cat <<EOF
+COMPUTE_NODE_PASSWORD "$COMPUTE_NODE_PASSWORD" not equal to nodes.json $name password "$password".
+Unset COMPUTE_NODE_PASSWORD and retry.
+EOF
+ exit 1
+ fi
+
+ printf "userData:\n"
+ if [ -n "$username" ]; then
+ printf " name: ${username}\n"
+ fi
+ if [ -n "$password" ]; then
+ passwd=$(mkpasswd --method=SHA-512 --rounds 4096 "$password")
+ printf " hashedPassword: ${passwd}\n"
+ fi
+
+ if [ -n "$COMPUTE_NODE_FQDN" ]; then
+ printf " fqdn: ${COMPUTE_NODE_FQDN}\n"
+ fi
+
+ if [ ! -f $HOME/.ssh/id_rsa.pub ]; then
+ yes y | ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsa
+ fi
+
+ printf " sshAuthorizedKey: $(cat $HOME/.ssh/id_rsa.pub)\n"
+}
+