Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 01_install_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ -z "${METAL3_DEV_ENV}" ]; then
# TODO -- come up with a plan for continuously updating this
# Note we only do this in the case where METAL3_DEV_ENV is
# unset, to enable developer testing of local checkouts
git reset d31a9c11651c4baaeb82c3db4a30b613713f3dba --hard
git reset 553e12f0f6c5f1af6761d7b4799e77b5df607572 --hard
popd
fi

Expand Down
1 change: 1 addition & 0 deletions 02_configure_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -xe

source logging.sh
source common.sh
source network.sh
source utils.sh
source ocp_install_env.sh

Expand Down
3 changes: 2 additions & 1 deletion 03_build_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ set -x
set -e

source logging.sh
source utils.sh
source common.sh
source network.sh
source utils.sh
source ocp_install_env.sh

# Extract an updated client tools from the release image
Expand Down
1 change: 1 addition & 0 deletions 04_setup_ironic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euxo pipefail

source logging.sh
source common.sh
source network.sh
source rhcos.sh
source ocp_install_env.sh
source utils.sh
Expand Down
7 changes: 4 additions & 3 deletions 05_create_install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ set -x
set -e

source logging.sh
source utils.sh
source common.sh
source network.sh
source utils.sh
source ocp_install_env.sh
source rhcos.sh

Expand All @@ -14,10 +15,10 @@ verify_pull_secret
if [ "$MANAGE_BR_BRIDGE" == "y" ] ; then
if [[ -z "${EXTERNAL_SUBNET_V4}" ]]; then
API_VIP=$(dig -t AAAA +noall +answer "api.${CLUSTER_DOMAIN}" @$(network_ip ${BAREMETAL_NETWORK_NAME}) | awk '{print $NF}')
INGRESS_VIP=$(python -c "from ansible.plugins.filter import ipaddr; print(ipaddr.nthhost('"$EXTERNAL_SUBNET_V6"', 4))")
INGRESS_VIP=$(nth_ip $EXTERNAL_SUBNET_V6 4)
else
API_VIP=$(dig +noall +answer "api.${CLUSTER_DOMAIN}" @$(network_ip ${BAREMETAL_NETWORK_NAME}) | awk '{print $NF}')
INGRESS_VIP=$(python -c "from ansible.plugins.filter import ipaddr; print(ipaddr.nthhost('"$EXTERNAL_SUBNET_V4"', 4))")
INGRESS_VIP=$(nth_ip $EXTERNAL_SUBNET_V4 4)
fi
echo "address=/api.${CLUSTER_DOMAIN}/${API_VIP}" | sudo tee -a /etc/NetworkManager/dnsmasq.d/openshift-${CLUSTER_NAME}.conf
echo "address=/.apps.${CLUSTER_DOMAIN}/${INGRESS_VIP}" | sudo tee -a /etc/NetworkManager/dnsmasq.d/openshift-${CLUSTER_NAME}.conf
Expand Down
3 changes: 2 additions & 1 deletion 06_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ set -x
set -e

source logging.sh
source utils.sh
source common.sh
source network.sh
source utils.sh
source ocp_install_env.sh
source rhcos.sh

Expand Down
136 changes: 11 additions & 125 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ source $CONFIG

export CLUSTER_NAME=${CLUSTER_NAME:-ostest}

export PROVISIONING_NETWORK_PROFILE=${PROVISIONING_NETWORK_PROFILE:-"Managed"}

# Network interface names can only be 15 characters long, so
# abbreviate provisioning and baremetal and add them as suffixes to
# the cluster name.
Expand All @@ -61,139 +63,19 @@ export SSH_PUB_KEY="${SSH_PUB_KEY:-$(cat $HOME/.ssh/id_rsa.pub)}"
# mirror images for installation in restricted network
export MIRROR_IMAGES=${MIRROR_IMAGES:-}

export IP_STACK=${IP_STACK:-"v6"}

EXTERNAL_SUBNET=${EXTERNAL_SUBNET:-""}
EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-""}
EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-""}
if [[ -n "${EXTERNAL_SUBNET}" ]] && [[ -z "${EXTERNAL_SUBNET_V4}" ]] && [[ -z "${EXTERNAL_SUBNET_V6}" ]]; then
# Backwards compatibility. If the old var was specified, and neither of the new
# vars are set, automatically adapt it to the right new var.
if [[ "${EXTERNAL_SUBNET}" =~ .*:.* ]]; then
export EXTERNAL_SUBNET_V6="${EXTERNAL_SUBNET}"
else
export EXTERNAL_SUBNET_V4="${EXTERNAL_SUBNET}"
fi
elif [[ -n "${EXTERNAL_SUBNET}" ]]; then
echo "EXTERNAL_SUBNET has been removed in favor of EXTERNAL_SUBNET_V4 and EXTERNAL_NETWORK_V6."
echo "Please update your configuration to drop the use of EXTERNAL_SUBNET."
exit 1
fi

SERVICE_SUBNET=${SERVICE_SUBNET:-""}
SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-""}
SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-""}
if [[ -n "${SERVICE_SUBNET}" ]] && [[ -z "${SERVICE_SUBNET_V4}" ]] && [[ -z "${SERVICE_SUBNET_V6}" ]]; then
# Backwards compatibility. If the old var was specified, and neither of the new
# vars are set, automatically adapt it to the right new var.
if [[ "${SERVICE_SUBNET}" =~ .*:.* ]]; then
export SERVICE_SUBNET_V6="${SERVICE_SUBNET}"
else
export SERVICE_SUBNET_V4="${SERVICE_SUBNET}"
fi
elif [[ -n "${SERVICE_SUBNET}" ]]; then
echo "SERVICE_SUBNET has been removed in favor of SERVICE_SUBNET_V4 and SERVICE_SUBNET_V6."
echo "Please update your configuration to drop the use of SERVICE_SUBNET."
exit 1
fi

CLUSTER_SUBNET=${CLUSTER_SUBNET:-""}
CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-""}
CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-""}
CLUSTER_HOST_PREFIX=${CLUSTER_HOST_PREFIX:-""}
CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-""}
CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-""}
if [[ -n "${CLUSTER_SUBNET}" ]] && [[ -z "${CLUSTER_SUBNET_V4}" ]] && [[ -z "${CLUSTER_SUBNET_V6}" ]]; then
# Backwards compatibility. If the old var was specified, and neither of the new
# vars are set, automatically adapt it to the right new var.
if [[ "${CLUSTER_SUBNET}" =~ .*:.* ]]; then
export CLUSTER_SUBNET_V6="${CLUSTER_SUBNET}"
export CLUSTER_HOST_PREFIX_V6="${CLUSTER_HOST_PREFIX_V6:-${CLUSTER_HOST_PREFIX}}"
else
export CLUSTER_SUBNET_V4="${CLUSTER_SUBNET}"
export CLUSTER_HOST_PREFIX_V4="${CLUSTER_HOST_PREFIX_V4:-${CLUSTER_HOST_PREFIX}}"
fi
elif [[ -n "${CLUSTER_SUBNET}" ]]; then
echo "CLUSTER_SUBNET has been removed in favor of CLUSTER_SUBNET_V4 and CLUSTER_SUBNET_V6."
echo "Please update your configuration to drop the use of CLUSTER_SUBNET."
exit 1
fi


if [[ "$IP_STACK" = "v4" ]]
then
export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"172.22.0.0/24"}
export EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-"192.168.111.0/24"}
export EXTERNAL_SUBNET_V6=""
export CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-"10.128.0.0/14"}
export CLUSTER_SUBNET_V6=""
export CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-"23"}
export CLUSTER_HOST_PREFIX_V6=""
export SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-"172.30.0.0/16"}
export SERVICE_SUBNET_V6=""
export NETWORK_TYPE=${NETWORK_TYPE:-"OpenShiftSDN"}
elif [[ "$IP_STACK" = "v6" ]]; then
export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"fd00:1101::0/64"}
export EXTERNAL_SUBNET_V4=""
export EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-"fd2e:6f44:5dd8:c956::/120"}
export CLUSTER_SUBNET_V4=""
export CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-"fd01::/48"}
export CLUSTER_HOST_PREFIX_V4=""
export CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-"64"}
export SERVICE_SUBNET_V4=""
export SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-"fd02::/112"}
export NETWORK_TYPE=${NETWORK_TYPE:-"OVNKubernetes"}
export MIRROR_IMAGES=true
elif [[ "$IP_STACK" = "v4v6" ]]; then
export PROVISIONING_NETWORK=${PROVISIONING_NETWORK:-"fd00:1101::0/64"}
export EXTERNAL_SUBNET_V4=${EXTERNAL_SUBNET_V4:-"192.168.111.0/24"}
export EXTERNAL_SUBNET_V6=${EXTERNAL_SUBNET_V6:-"fd2e:6f44:5dd8:c956::/120"}
export CLUSTER_SUBNET_V4=${CLUSTER_SUBNET_V4:-"10.128.0.0/14"}
export CLUSTER_SUBNET_V6=${CLUSTER_SUBNET_V6:-"fd01::/48"}
export CLUSTER_HOST_PREFIX_V4=${CLUSTER_HOST_PREFIX_V4:-"23"}
export CLUSTER_HOST_PREFIX_V6=${CLUSTER_HOST_PREFIX_V6:-"64"}
export SERVICE_SUBNET_V4=${SERVICE_SUBNET_V4:-"172.30.0.0/16"}
export SERVICE_SUBNET_V6=${SERVICE_SUBNET_V6:-"fd02::/112"}
export NETWORK_TYPE=${NETWORK_TYPE:-"OVNKubernetes"}
export MIRROR_IMAGES=true
else
echo "Unexpected setting for IP_STACK: '${IP_STACK}'"
exit 1
fi

if [[ "${IP_STACK}" = "v6" ]]; then
export DNS_VIP=${DNS_VIP:-$(python -c "import ipaddress; print(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V6\")[2])")}
else
export DNS_VIP=${DNS_VIP:-$(python -c "import ipaddress; print(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V4\")[2])")}
fi

# The DNS name for the registry that this cluster should use.
export LOCAL_REGISTRY_DNS_NAME=${LOCAL_REGISTRY_DNS_NAME:-"virthost.${CLUSTER_NAME}.${BASE_DOMAIN}"}
# All DNS names for the registry, to be included in the certificate.
export ALL_REGISTRY_DNS_NAMES=${ALL_REGISTRY_DNS_NAMES:-${LOCAL_REGISTRY_DNS_NAME}}

# Provisioning network information
export CLUSTER_PRO_IF=${CLUSTER_PRO_IF:-enp1s0}
export PROVISIONING_NETMASK=${PROVISIONING_NETMASK:-$(ipcalc --netmask $PROVISIONING_NETWORK | cut -d= -f2)}

# Hypervisor details
export REMOTE_LIBVIRT=${REMOTE_LIBVIRT:-0}
export PROVISIONING_HOST_USER=${PROVISIONING_HOST_USER:-$USER}

# ipcalc on CentOS 7 doesn't support the 'minaddr' option, so use python
# instead to get the first address in the network:
export PROVISIONING_HOST_IP=${PROVISIONING_HOST_IP:-$(python -c "import ipaddress; print(next(ipaddress.ip_network(u\"$PROVISIONING_NETWORK\").hosts()))")}
if [[ "${IP_STACK}" = "v6" ]]; then
export PROVISIONING_HOST_EXTERNAL_IP=${PROVISIONING_HOST_EXTERNAL_IP:-$(python -c "import ipaddress; print(next(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V6\").hosts()))")}
else
export PROVISIONING_HOST_EXTERNAL_IP=${PROVISIONING_HOST_EXTERNAL_IP:-$(python -c "import ipaddress; print(next(ipaddress.ip_network(u\"$EXTERNAL_SUBNET_V4\").hosts()))")}
fi
export MIRROR_IP=${MIRROR_IP:-$PROVISIONING_HOST_IP}

# The dev-scripts working directory
export WORKING_DIR=${WORKING_DIR:-"/opt/dev-scripts"}
OCP_DIR=${OCP_DIR:-ocp/${CLUSTER_NAME}}

# The DNS name for the registry that this cluster should use.
export LOCAL_REGISTRY_DNS_NAME=${LOCAL_REGISTRY_DNS_NAME:-"virthost.${CLUSTER_NAME}.${BASE_DOMAIN}"}
# All DNS names for the registry, to be included in the certificate.
export ALL_REGISTRY_DNS_NAMES=${ALL_REGISTRY_DNS_NAMES:-${LOCAL_REGISTRY_DNS_NAME}}

# variables for local registry configuration
export LOCAL_REGISTRY_PORT=${LOCAL_REGISTRY_PORT:-"5000"}
export REGISTRY_USER=${REGISTRY_USER:-ocp-user}
Expand Down Expand Up @@ -239,6 +121,10 @@ else
export BMC_DRIVER=${BMC_DRIVER:-mixed}
fi

if [[ "$PROVISIONING_NETWORK_PROFILE" == "Disabled" ]]; then
export BMC_DRIVER="redfish-virtualmedia"
fi

# Both utils.sh and 04_setup_ironic.sh use this log file, so set the
# name one time. Users should not override this.
export MIRROR_LOG_FILE=${REGISTRY_DIR}/${CLUSTER_NAME}-image_mirror-${OPENSHIFT_RELEASE_TAG}.log
Expand Down
21 changes: 11 additions & 10 deletions metal3-templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"net/url"
"os"
"strings"
"text/template"
)

Expand All @@ -27,8 +28,8 @@ type templater struct {
func main() {
var templateData templater

if len(os.Args) < 5 {
fmt.Printf("usage: <prog> TEMPLATE_FILE INTERFACE NETWORK IMAGE_URL\n")
if len(os.Args) < 7 {
fmt.Printf("usage: <prog> TEMPLATE_FILE INTERFACE NETWORK BOOTSTRAP_IP CLUSTER_IP IMAGE_URL\n")
os.Exit(1)
}

Expand All @@ -52,22 +53,22 @@ func main() {
templateData.ProvisioningDHCPRange = fmt.Sprintf("%s,%s", startIP, endIP)

// BootstrapIP
bootstrapIP, _ := cidr.Host(&ipnet.IPNet, 2)
templateData.BootstrapIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP.String(), "6385"))
templateData.BootstrapInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP.String(), "5050"))
bootstrapIP := os.Args[5]
templateData.BootstrapIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP, "6385"))
templateData.BootstrapInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(bootstrapIP, "5050"))

// ProvisioningIP
ip, _ := cidr.Host(&ipnet.IPNet, 3)
ip := os.Args[6]
size, _ := ipnet.IPNet.Mask.Size()
templateData.ProvisioningIP = fmt.Sprintf("%s/%d", ip, size)
templateData.ClusterIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip.String(), "6385"))
templateData.ClusterInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip.String(), "5050"))
templateData.ClusterIronicURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip, "6385"))
templateData.ClusterInspectorURL = fmt.Sprintf("http://%s", net.JoinHostPort(ip, "5050"))

// URL Host
if ip.To4() == nil {
if strings.Contains(ip, ":") {
templateData.ClusterProvisioningURLHost = fmt.Sprintf("[%s]", ip)
} else {
templateData.ClusterProvisioningURLHost = ip.String()
templateData.ClusterProvisioningURLHost = ip
}

t, err := template.New(templateFile).ParseFiles(templateFile)
Expand Down
Loading