workshops/eda-workshop-lsf/templates/04-nfs_server_instanceStore_zfs.yaml [410:535]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            }

            function ck_devs_count_build_list {

              if [[ "$volume_type" == "EBS" ]]; then
                echo "Checking the total number of EBS volumes, currently ${!devs_count_ready} devices ready."
                devs_count_ready=0
                let dev_count=$(sudo nvme list | grep "${!nvme_grep_str}" | grep -v nvme0n1 | wc -l)
                if [[ $dev_count -eq ${!total_ebs_vols} ]]; then
                  if [[ ! ${!dev_list} ]]; then
                    for d in $(sudo nvme list | grep "${!nvme_grep_str}" | grep -v nvme0n1 | awk {'print $1'} | cut -f3 -d"/")
                      do echo -n "$d "
                      dev_list="${!dev_list} ${!d}"
                    done
                  fi
                  devs_count_ready=1
                else
                  devs_count_ready=0
                fi
              elif [[ "$volume_type" == "InstanceStore" ]]; then
                echo "Checking the total number of Instance Store NVMe volumes, currently ${!devs_count_ready} devices ready."
                devs_count_ready=0
                let dev_count=$(sudo nvme list | grep "${!nvme_grep_str}" | wc -l)
                if [[ $dev_count -eq ${!total_i_store_vols} ]]; then
                  if [[ ! ${!dev_list} ]]; then
                    for d in $(sudo nvme list | grep "${!nvme_grep_str}" | awk {'print $1'} | cut -f3 -d"/")
                      do echo -n "$d "
                      dev_list="${!dev_list} ${!d}"
                    done
                  fi
                  devs_count_ready=1
                else
                  devs_count_ready=0
                fi
              fi

            }

            timeout_count=0
            function ck_devs {
              devs_ready=0

              if [[ "$volume_type" == "EBS" ]]; then
                nvme_grep_str="Amazon Elastic Block Store"
                total_ebs_vols=8
                total_vols=${!total_ebs_vols}
              elif [[ "$volume_type" == "InstanceStore" ]]; then
                nvme_grep_str="Amazon EC2 NVMe Instance Storage"
                total_i_store_vols=${!instStore_devs["${!nfs_instance_type}"]}
                total_vols=${!total_i_store_vols}
              fi

              while [[ ! $(which nvme) ]]; do
                sleep 10
              done

              while [[ ! ${!devs_count_ready} ]]; do
                ck_devs_count_build_list
                sleep 10
              done

              echo "Using device list ${!dev_list}"

              while [[ ! ${!devs_ready} ]]; do
                for l in ${!dev_list}; do
                  if [[ ! -b /dev/${!l} ]]; then
                    devs_ready=0
                    ((timeout_count = $timeout_count + 1))
                    if [[ $timeout_count -gt 30 ]]; then
                      echo "All storage volumes are ready, exiting..."
                      exit
                    else
                      sleep 10
                    fi
                  else
                    devs_ready=1
                    ck_devs
                  fi
                done
              done
              echo "Devices ready."
            }

            function mk_raid {
              raid_level="0"
              full_path_dev_list=""
              for d in ${!dev_list}; do
                temp_d="/dev/${!d}"
                full_path_dev_list="${!full_path_dev_list} ${!temp_d}"
              done
              yes | sudo mdadm --create --verbose /dev/md0 --level=${!raid_level} --name=raid-vol1 --raid-devices=${!total_vols} ${!full_path_dev_list}
            }

            function mk_ext4_fs {
              mdadm_fs_dev="/dev/md0"
              mdadm_fs_name=${!mdadm_raid_fs_name}
              mdadm_fs_label=${!mdadm_raid_fs_name}
              sudo mkfs.ext4 -L ${!mdadm_fs_label} ${!mdadm_fs_dev} -E nodiscard
              sudo mkdir /${!mdadm_fs_name}
              sudo mount LABEL=${!mdadm_fs_label} /${!mdadm_fs_name}
              sudo su -c "echo 'LABEL=${!mdadm_fs_label}       /${!mdadm_fs_name}   ext4    defaults,nofail        0       2' >> /etc/fstab"
            }

            function fix_zfs_repo {
              echo "Fixing ZFS repo..."
              sudo cat /etc/yum.repos.d/zfs.repo  | while read l
              do
                if [[ "$l" == "[zfs]" ]]; then
                  let on_zfs=1
                elif [[ "$l" == "[zfs-kmod]" ]]; then
                  let on_zfs_kmod=1
                fi
                if [[ "$on_zfs" -eq 1 ]] && [[ "$l" == "enabled=1" ]]; then
                  l="enabled=0"
                  let on_zfs=0
                elif [[ "$on_zfs_kmod" -eq 1 ]] &&  [[ "$l" == "enabled=0" ]]; then
                  l="enabled=1"
                  let on_zfs_kmod=0
                fi
                echo $l
              done > /tmp/new_zfs.repo
              sudo cp /etc/yum.repos.d/zfs.repo /etc/yum.repos.d/zfs.repo.dist
              sudo mv /tmp/new_zfs.repo /etc/yum.repos.d/zfs.repo
              echo "Done fixing ZFS repo"

            }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



workshops/eda-workshop-soca/templates/nfs_server_instanceStore_zfs_soca.yaml [528:653]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          }

          function ck_devs_count_build_list {

            if [[ "$volume_type" == "EBS" ]]; then
            echo "Checking the total number of EBS volumes, currently ${!devs_count_ready} devices ready."
            devs_count_ready=0
            let dev_count=$(sudo nvme list | grep "${!nvme_grep_str}" | grep -v nvme0n1 | wc -l)
            if [[ $dev_count -eq ${!total_ebs_vols} ]]; then
              if [[ ! ${!dev_list} ]]; then
                for d in $(sudo nvme list | grep "${!nvme_grep_str}" | grep -v nvme0n1 | awk {'print $1'} | cut -f3 -d"/")
                  do echo -n "$d "
                  dev_list="${!dev_list} ${!d}"
                done
              fi
              devs_count_ready=1
            else
              devs_count_ready=0
            fi
            elif [[ "$volume_type" == "InstanceStore" ]]; then
            echo "Checking the total number of Instance Store NVMe volumes, currently ${!devs_count_ready} devices ready."
            devs_count_ready=0
            let dev_count=$(sudo nvme list | grep "${!nvme_grep_str}" | wc -l)
            if [[ $dev_count -eq ${!total_i_store_vols} ]]; then
              if [[ ! ${!dev_list} ]]; then
                for d in $(sudo nvme list | grep "${!nvme_grep_str}" | awk {'print $1'} | cut -f3 -d"/")
                  do echo -n "$d "
                  dev_list="${!dev_list} ${!d}"
                done
              fi
              devs_count_ready=1
            else
              devs_count_ready=0
            fi
            fi

          }

          timeout_count=0
          function ck_devs {
            devs_ready=0

            if [[ "$volume_type" == "EBS" ]]; then
            nvme_grep_str="Amazon Elastic Block Store"
            total_ebs_vols=8
            total_vols=${!total_ebs_vols}
            elif [[ "$volume_type" == "InstanceStore" ]]; then
            nvme_grep_str="Amazon EC2 NVMe Instance Storage"
            total_i_store_vols=${!instStore_devs["${!nfs_instance_type}"]}
            total_vols=${!total_i_store_vols}
            fi

            while [[ ! $(which nvme) ]]; do
            sleep 10
            done

            while [[ ! ${!devs_count_ready} ]]; do
            ck_devs_count_build_list
            sleep 10
            done

            echo "Using device list ${!dev_list}"

            while [[ ! ${!devs_ready} ]]; do
            for l in ${!dev_list}; do
              if [[ ! -b /dev/${!l} ]]; then
                devs_ready=0
                ((timeout_count = $timeout_count + 1))
                if [[ $timeout_count -gt 30 ]]; then
                  echo "All storage volumes are ready, exiting..."
                  exit
                else
                  sleep 10
                fi
              else
                devs_ready=1
                ck_devs
              fi
            done
            done
            echo "Devices ready."
          }

          function mk_raid {
            raid_level="0"
            full_path_dev_list=""
            for d in ${!dev_list}; do
            temp_d="/dev/${!d}"
            full_path_dev_list="${!full_path_dev_list} ${!temp_d}"
            done
            yes | sudo mdadm --create --verbose /dev/md0 --level=${!raid_level} --name=raid-vol1 --raid-devices=${!total_vols} ${!full_path_dev_list}
          }

          function mk_ext4_fs {
            mdadm_fs_dev="/dev/md0"
            mdadm_fs_name=${!mdadm_raid_fs_name}
            mdadm_fs_label=${!mdadm_raid_fs_name}
            sudo mkfs.ext4 -L ${!mdadm_fs_label} ${!mdadm_fs_dev} -E nodiscard
            sudo mkdir /${!mdadm_fs_name}
            sudo mount LABEL=${!mdadm_fs_label} /${!mdadm_fs_name}
            sudo su -c "echo 'LABEL=${!mdadm_fs_label}     /${!mdadm_fs_name}   ext4    defaults,nofail     0      2' >> /etc/fstab"
          }

          function fix_zfs_repo {
            echo "Fixing ZFS repo..."
            sudo cat /etc/yum.repos.d/zfs.repo  | while read l
            do
            if [[ "$l" == "[zfs]" ]]; then
              let on_zfs=1
            elif [[ "$l" == "[zfs-kmod]" ]]; then
              let on_zfs_kmod=1
            fi
            if [[ "$on_zfs" -eq 1 ]] && [[ "$l" == "enabled=1" ]]; then
              l="enabled=0"
              let on_zfs=0
            elif [[ "$on_zfs_kmod" -eq 1 ]] &&  [[ "$l" == "enabled=0" ]]; then
              l="enabled=1"
              let on_zfs_kmod=0
            fi
            echo $l
            done > /tmp/new_zfs.repo
            sudo cp /etc/yum.repos.d/zfs.repo /etc/yum.repos.d/zfs.repo.dist
            sudo mv /tmp/new_zfs.repo /etc/yum.repos.d/zfs.repo
            echo "Done fixing ZFS repo"

          }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



