Skip to content

Commit

Permalink
Refactor install-config
Browse files Browse the repository at this point in the history
  • Loading branch information
stbenjam committed May 31, 2019
1 parent 6769a43 commit 398d4d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 84 deletions.
14 changes: 9 additions & 5 deletions ocp_install_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function generate_ocp_install_config() {

outdir="$1"

deploy_kernel=$(master_node_val 0 "driver_info.deploy_kernel")
deploy_ramdisk=$(master_node_val 0 "driver_info.deploy_ramdisk")

cat > "${outdir}/install-config.yaml" << EOF
apiVersion: v1beta4
baseDomain: ${BASE_DOMAIN}
Expand All @@ -70,12 +73,13 @@ controlPlane:
platform:
baremetal:
api_vip: ${API_VIP}
nodes:
hosts:
$(master_node_map_to_install_config $NUM_MASTERS)
master_configuration:
image_source: "http://172.22.0.1/images/$RHCOS_IMAGE_FILENAME_LATEST"
image_checksum: $(curl http://172.22.0.1/images/$RHCOS_IMAGE_FILENAME_LATEST.md5sum)
root_gb: 25
image:
source: "http://172.22.0.1/images/$RHCOS_IMAGE_FILENAME_LATEST"
checksum: $(curl http://172.22.0.1/images/$RHCOS_IMAGE_FILENAME_LATEST.md5sum)
deployKernel: ${deploy_kernel}
deployRamdisk: ${deploy_ramdisk}
pullSecret: |
$(echo $PULL_SECRET | jq -c .)
sshKey: |
Expand Down
94 changes: 15 additions & 79 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,100 +111,36 @@ function master_node_map_to_install_config() {
local num_masters
num_masters="$1"

cat <<EOF
master_nodes:
EOF

for ((master_idx=0;master_idx<$1;master_idx++)); do
name=$(master_node_val ${master_idx} "name")
mac=$(master_node_val ${master_idx} "ports[0].address")

driver=$(master_node_val ${master_idx} "driver")
if [ $driver == "ipmi" ] ; then
driver=ipmi
driver_prefix=ipmi
driver_interface=ipmitool
elif [ $driver == "idrac" ] ; then
driver=idrac
driver_prefix=drac
driver_interface=idrac
fi

name=$(master_node_val ${master_idx} "name")
mac=$(master_node_val ${master_idx} "ports[0].address")
cat <<EOF
openshift-master-$master_idx:
name: $name
port_address: "${mac}"
driver: "${driver}"
management_interface: "${driver_interface}"
power_interface: "${driver_interface}"
vendor_interface: "no-vendor"
EOF

done

cat <<EOF
properties:
EOF

for ((master_idx=0;master_idx<$1;master_idx++)); do
local_gb=$(master_node_val ${master_idx} "properties.local_gb")
cpu_arch=$(master_node_val ${master_idx} "properties.cpu_arch")

cat <<EOF
openshift-master-$master_idx:
local_gb: "${local_gb}"
cpu_arch: "${cpu_arch}"
EOF

done

cat <<EOF
root_devices:
EOF

[ -n "$ROOT_DISK" ] && ROOT_DISK_NAME="$ROOT_DISK"
for _hint in ${!ROOT_DISK_*}; do
[ -z "${!_hint}" ] && continue
hint_name=${_hint/#ROOT_DISK_/}
hint_name=${hint_name,,}
hint_value=${!_hint}
done

for ((master_idx=0;master_idx<$1;master_idx++)); do
cat <<EOF
openshift-master-$master_idx:
$hint_name: "${hint_value}"
EOF
done

cat <<EOF
driver_infos:
EOF

for ((master_idx=0;master_idx<$1;master_idx++)); do
port=$(master_node_val ${master_idx} "driver_info.${driver_prefix}_port // \"\"")
username=$(master_node_val ${master_idx} "driver_info.${driver_prefix}_username")
password=$(master_node_val ${master_idx} "driver_info.${driver_prefix}_password")
address=$(master_node_val ${master_idx} "driver_info.${driver_prefix}_address")

deploy_kernel=$(master_node_val ${master_idx} "driver_info.deploy_kernel")
deploy_ramdisk=$(master_node_val ${master_idx} "driver_info.deploy_ramdisk")

cat <<EOF
openshift-master-$master_idx:
EOF

if [ -n "$port" ]; then
cat <<EOF
${driver_prefix}_port: "${port}"
EOF
bmc_uri=${driver}://${address}
if [ -n $port ]; then
bmc_uri=$bmc_uri:${port}
fi

cat <<EOF
${driver_prefix}_username: "${username}"
${driver_prefix}_password: "${password}"
${driver_prefix}_address: "${address}"
deploy_kernel: "${deploy_kernel}"
deploy_ramdisk: "${deploy_ramdisk}"
cat << EOF
- name: ${name}
role: master
bmc:
address: ${bmc_uri}
username: ${username}
password: ${password}
bootMACAddress: ${mac}
hardwareProfile: default
EOF

done
Expand Down

0 comments on commit 398d4d0

Please sign in to comment.