Skip to content

Commit

Permalink
DAOSGCP-122 Add internal IP support in io500
Browse files Browse the repository at this point in the history
  • Loading branch information
damokm4 committed Jun 16, 2022
1 parent 2b62168 commit b8af45e
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions terraform/examples/io500/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ ACTIVE_CONFIG="${CONFIG_DIR}/active_config.sh"
# bastion host for the IO500 example.
SSH_CONFIG_FILE="${IO500_TMP}/ssh_config"

# Use internal IP for SSH connection with the first daos client
USE_INTERNAL_IP=0

ERROR_MSGS=()


Expand All @@ -70,6 +73,8 @@ Options:
[ -u --repo-baseurl DAOS_REPO_BASE_URL ] Base URL of a repo.
[ -i --internal-ip ] Use internal IP for SSH to the first client
[ -f --force ] Force images to be re-built
[ -h --help ] Show help
Expand Down Expand Up @@ -152,6 +157,10 @@ opts() {
export CONFIG_FILE
shift 2
;;
--internal-ip|-i)
USE_INTERNAL_IP=1
shift
;;
--version|-v)
DAOS_VERSION="${2}"
if [[ "${DAOS_VERSION}" == -* ]] || [[ "${DAOS_VERSION}" = "" ]] || [[ -z ${DAOS_VERSION} ]]; then
Expand Down Expand Up @@ -297,33 +306,40 @@ run_terraform() {
popd
}

configure_first_client_nat_ip() {
configure_first_client_ip() {

log "Wait for DAOS client instances"
gcloud compute instance-groups managed wait-until ${TF_VAR_client_template_name} \
--stable \
--project="${TF_VAR_project_id}" \
--zone="${TF_VAR_zone}"

# Check to see if first client instance has an external IP.
# If it does, then don't attempt to add an external IP again.
FIRST_CLIENT_IP=$(gcloud compute instances describe "${DAOS_FIRST_CLIENT}" \
--project="${TF_VAR_project_id}" \
--zone="${TF_VAR_zone}" \
--format="value(networkInterfaces[0].accessConfigs[0].natIP)")

if [[ -z "${FIRST_CLIENT_IP}" ]]; then
log "Add external IP to first client"

gcloud compute instances add-access-config "${DAOS_FIRST_CLIENT}" \
if [[ "${USE_INTERNAL_IP}" -eq 1 ]]; then
FIRST_CLIENT_IP=$(gcloud compute instances describe "${DAOS_FIRST_CLIENT}" \
--project="${TF_VAR_project_id}" \
--zone="${TF_VAR_zone}" \
&& sleep 10

--format="value(networkInterfaces[0].networkIP)")
else
# Check to see if first client instance has an external IP.
# If it does, then don't attempt to add an external IP again.
FIRST_CLIENT_IP=$(gcloud compute instances describe "${DAOS_FIRST_CLIENT}" \
--project="${TF_VAR_project_id}" \
--zone="${TF_VAR_zone}" \
--format="value(networkInterfaces[0].accessConfigs[0].natIP)")

if [[ -z "${FIRST_CLIENT_IP}" ]]; then
log "Add external IP to first client"

gcloud compute instances add-access-config "${DAOS_FIRST_CLIENT}" \
--project="${TF_VAR_project_id}" \
--zone="${TF_VAR_zone}" \
&& sleep 10

FIRST_CLIENT_IP=$(gcloud compute instances describe "${DAOS_FIRST_CLIENT}" \
--project="${TF_VAR_project_id}" \
--zone="${TF_VAR_zone}" \
--format="value(networkInterfaces[0].accessConfigs[0].natIP)")
fi
fi
}

Expand Down Expand Up @@ -536,7 +552,7 @@ main() {
create_hosts_files
build_disk_images
run_terraform
configure_first_client_nat_ip
configure_first_client_ip
configure_ssh
copy_files_to_first_client
propagate_ssh_keys_to_all_nodes
Expand Down

0 comments on commit b8af45e

Please sign in to comment.