[toc]
VMware 更新產品策略,提供全新簡化的產品組合。並由原先 CPU(Socket)數量計價調整為**核心(Cores)數量計價**。另外根據產品組合提供進階附加服務(Add-on Services)加購,相關產品資訊請參考官方網站。
![圖片](https://hackmd.io/_uploads/ByBidG_ha.png)
# 參考資訊
由於計價方式調整,所以官方也提供相關計價說明及工具,以便提供客戶對於目前及未來佈署環境所需授權數量的評估規劃。
目前計價重點則在於 **VCF, VVF 的核心數授權計算**和 **vSAN Add-on 容量授權計算**。
## 官方知識庫
目前有關授權計算,官方提供以下相關說明:
- [Counting Cores for VMware Cloud Foundation and vSphere Foundation and TiBs for vSAN (95927)](https://kb.vmware.com/s/article/95927)
- [License Calculator for VMware Cloud Foundation, VMware vSphere Foundation and VMware vSAN. (96426)](https://kb.vmware.com/s/article/96426)
:::info
- [**VMware KB 95927**](https://kb.vmware.com/s/article/95927) 提供的 PowerCLI 腳本 **`FoundationCoreAndTiBUsage`** 可協助客戶清點現有 vSphere 環境,以便評估計算運算(compute)訂閱數量或 vSAN 所需的 VCF/VVF 訂閱容量。
- [**VMware KB 96426**](https://kb.vmware.com/s/article/96426) 提供的 PowerShell 腳本 **`vcf-vvf-calculator.ps1`**,讓無法執行前個 PowerCLI 腳本的客戶,可以搭配手動輸入的 CSV 檔案 `sample-list.csv` 所提供的參數,執行模擬來計算運算(compute)訂閱數量或 vSAN 所需的 VCF/VVF 訂閱容量。
- 請參考原廠 KB 說明及指示,完成相關評估計算功能。
- 目前**已取消最低購置 vSAN 訂閱容量條件**。其他相關採購限制或條件皆以官方公開說明為主。
:::
# 自製工具
因為沒有 PowerShell 和 PowerCLI 這麼高檔的工具,還好終端機有提供 **BASH** 環境,就簡單地仿造 William 大神撰寫簡易工具吧!
有關[[知識庫#959275]](https://kb.vmware.com/s/article/95927) 中,表格內提及的說明範例,以及腳本程式說明,可以參考[[這裡]](#使用-BASH-和-GOVC-撰寫程式估算-VMware-vSphere-訂閱授權)。
## 腳本參考
官方腳本工具提供者為 [**William 大神**](https://williamlam.com/about),以下是作者的部落格連結。
- [Updated Inventory & Calculator Scripts for counting Cores/TiBs for VMware Cloud Foundation (VCF) and VMware vSphere Foundation (VVF)](https://williamlam.com/2024/02/updated-inventory-calculator-scripts-for-counting-cores-tibs-for-vmware-cloud-foundation-vcf-and-vmware-vsphere-foundation-vvf.html)
## 執行結果
先觀摩 William 大神的程式輸出結果。
![image](https://hackmd.io/_uploads/HknnhqH2a.png)
接著看一下仿造結果吧!
![image](https://hackmd.io/_uploads/BkQ46cr2T.png)
![image](https://hackmd.io/_uploads/BJVc6cH2a.png)
![image](https://hackmd.io/_uploads/Bku3a9r2a.png)
還行!目前只有基本除錯,而且提供快速自用,**實際使用還請以原廠提供工具輸出結果為主**。
:::info
- **Required VCF/VVF Compute Licenses Per Cluster** 該叢集所需 VCF/VVF 運算授權許可
-
| 名稱 | 說明 |
| --- | --- |
| CLUSTER | 叢集名稱 |
| NUM_HOSTS | 叢集中 ESXi 主機總數 |
| NUM_CPU_SOCKETS_PER_HOST | 每部 ESXi 主機的 CPU(socket) 數量 |
| NUM_CPU_CORES_PER_SOCKET | 每部 ESXi 主機 CPU 的核心(core) 數量 |
| FOUNDATION_LICENSE_CORE_COUNT | 該叢集所需 VCF/VVF 核心授權數量 |
- **Required vSAN Licenses Per Cluster** 該叢集所需 vSAN 存儲授權許可
| <div style="width: 150pt">名稱</div> | <div style="width: 440pt">說明</div> |
| --- | --- |
| CLUSTER | 叢集名稱 |
| NUM_HOSTS | 叢集中 ESXi 主機總數 |
| NUM_CPU_SOCKETS | 叢集中 CPU(sockets) 總數 |
| NUM_CPU_CORES | 叢集中核心(cores) 總數 |
| FOUNDATION_LICENSE_CORE_COUNT | 叢集中 VCF/VVF 產品的核心授權許可總數 |
| ENTITLED_VSAN_LICENSE_TIB_COUNT | 叢集中 VCF/VVF 產品取得的 vSAN TiB 授權容量 |
| REQUIRED_VSAN_TIB_CAPACITY | 叢集所需求的 vSAN (RAW) TiB 總容量|
| VSAN_LICENSE_TIB_COUNT | <font size="1">從需求總容量和取得的 vSAN 授權容量比較後,該叢集所需的 TiB 授權容量。<br>- 若**該數字為 0 或負數**,表示**不需要額外的授權**,且該數字表示超過多餘的授權容量。<br>- 若**該數字為正數**,表示**還需要此數字的額外授權容量**,才能滿足需求。</font> |
:::
## 程式源碼
### sample_input
手動輸入不同配置的資料,以便提供腳本檔產生出對應的 VCF/VVF 和 vSAN 所需的訂閱授權數量。
:::warning
- <font color=red>**請勿變更第一行內容**</font>。
> 雖然偷懶我也沒用到!
- 每一行代表一個 vSphere 或 vSAN 叢集資料。
- 每列的說明請參考 [**VMware KB 96426**](https://kb.vmware.com/s/article/96426),其中有完整詳細的內容說明。
- vSAN 容量單位為 TiB。
- 1 TB ~= 0.909 TiB
- 1 TiB ~= 1.100 TB
:::
```=
CLUSTER_NAME,NUMBER_OF_HOSTS,NUMBER_OF_CPU_SOCKETS,NUMBER_OF_CPU_CORES_PER_SOCKET,VSAN_ENABLED_CLUSTER,TOTAL_RAW_VSAN_TIB
CL1,4,2,18,Yes,13.9
CL2,4,2,20,Yes,11.5
CL3,3,2,16,Yes,9.6
CL4,8,2,24,Yes,460.9
CL5,7,2,24,Yes,403.3
CL6,9,2,10,Yes,230.4
CL7,10,2,20,Yes,614.5
CL8,4,2,32,Yes,230.4
```
:::info
每列內容請按照下列內容依序填入,並以 **`','`** 區隔不用帶空白(會出事!)
- 叢集名稱
- ESXi 主機數量
- 每台 ESXi 主機的 CPU(Socket) 數量
- 每個 CPU(Socket) 的核心 (Core) 數量
- 該叢集是否啟用 vSAN
> 這個參數條件沒另外寫函式判斷,就都當作是 vSAN 叢集
- 實際 vSAN RAW 容量 (TiB)
:::
### vcf_vvf_license_calculator.sh
程式撰寫,單純仿造官方程式輸出結果,至於授權數量計算就是由目前取得資訊和個人研讀認知,直接改成 BASH 腳本語法完成。
:::info
- **執行方式** ./vcf_vvf_license_calculator.sh -i [input_file] -d [vcf|vvf]
- 以下程式碼範例僅供參考,**實際使用還請以原廠提供工具輸出結果為主**。
- 若有發現邏輯錯誤,還請指正,感恩。
:::
```bash=
#!/bin/bash
#
# edited by semigod
#
# - Counting Cores for vSphere Foundation and VMware Cloud Foundation and TiBs for vSAN Add-on (95927)
# > https://kb.vmware.com/s/article/95927
# - License Calculator for VMware Cloud Foundation, VMware vSphere Foundation and VMware vSAN. (96426)
# > https://kb.vmware.com/s/article/96426
function collect_data () {
cluster_name=($(cat ${file} | sed '1d' | cut -d, -f1))
number_of_hosts=($(cat ${file} | sed '1d' | cut -d, -f2))
number_of_cpu_sockets=($(cat ${file} | sed '1d' | cut -d, -f3))
number_of_cpu_cores_per_socket=($(cat ${file} | sed '1d' | cut -d, -f4))
vsan_enabled_cluster=($(cat ${file} | sed '1d' | cut -d, -f5))
total_raw_vsan_tib=($(cat ${file} | sed '1d' | cut -d, -f6))
count_cluster=${#cluster_name[@]}
}
function entitled_vsan_capacity_tib () {
packaging_cores=$1
packaging_vsan_capacity_per_core_gib=$2
packaging_eval_vsan_capacity_gib=$((${packaging_cores} * ${packaging_vsan_capacity_per_core_gib}))
echo $(echo "scale=${scales};${packaging_eval_vsan_capacity_gib}/1024" | bc | xargs printf "%.3f")
}
function compute_header () {
case "${type}" in
vcf )
echo -e "\n Calculator Results for VMware Cloud Foundation (VCF) Instances:"
echo -e "\n Required VCF Compute License Per Cluster\n"
;;
vvf )
echo -e "\n Calculator Results for VMware vSphere Foundation (VVF) Instances:"
echo -e "\n Required VVF Compute License Per Cluster\n"
;;
esac
printf " %-6s %-9s %-24s %-24s %-29s\n" "CLUSTER" "NUM_HOSTS" "NUM_CPU_SOCKETS_PER_HOST" "NUM_CPU_CORES_PER_SOCKET" "FOUNDATION_LICENSE_CORE_COUNT"
printf " %-6s %-9s %-24s %-24s %-29s\n" "-------" "---------" "------------------------" "------------------------" "-----------------------------"
}
function compute_result () {
total_required_compute_licenses=0
licensing_cores=0
for ((i=0;i<${count_cluster};i++)); do
if [[ ${number_of_cpu_cores_per_socket[$i]} -le 16 ]]; then
license_number_of_cpu_cores_per_socket=16
else
license_number_of_cpu_cores_per_socket=${number_of_cpu_cores_per_socket[$i]}
fi
licensing_cores=$((${number_of_cpu_sockets[$i]} * ${license_number_of_cpu_cores_per_socket} * ${number_of_hosts[$i]}))
printf " %-7s %9s %24s %24s %29s\n" "${cluster_name[$i]}" "${number_of_hosts[$i]}" "${number_of_cpu_sockets[$i]}" "${number_of_cpu_cores_per_socket[$i]}" "${licensing_cores}"
total_required_compute_licenses=$((${total_required_compute_licenses} + ${licensing_cores}))
done
}
function vsan_header () {
echo -e "\n Required vSAN Licenses Per Cluster\n"
printf " %-6s %-9s %-16s %-14s %-30s %-32s %-27s %-23s %-10s\n" "CLUSTER" "NUM_HOSTS" "NUM_CPU_SOCKETS" "NUM_CPU_CORES" "FOUNDATION_LICENSE_CORE_COUNT" \
"ENTITLED_VSAN_LICENSE_TIB_COUNT" "REQUIRES_VSAN_TIB_CAPACITY" "VSAN_LICENSE_TIB_COUNT" ""
printf " %-6s %-9s %-16s %-14s %-30s %-32s %-27s %-23s %-10s\n" "-------" "---------" "---------------" "-------------" "-----------------------------" \
"-------------------------------" "--------------------------" "----------------------" ""
}
function vsan_result () {
total_required_vsan_addon_licenses=0
case "${type}" in
vcf )
for ((i=0;i<${count_cluster};i++)); do
number_of_cpu_cores=$((${number_of_cpu_sockets[$i]} * ${number_of_cpu_cores_per_socket[$i]} * ${number_of_hosts[$i]}))
total_number_of_cpu_sockets=$((${number_of_cpu_sockets[$i]} * ${number_of_hosts[$i]}))
if [[ ${number_of_cpu_cores_per_socket[$i]} -le 16 ]]; then
license_number_of_cpu_cores_per_socket=16
else
license_number_of_cpu_cores_per_socket=${number_of_cpu_cores_per_socket[$i]}
fi
licensing_cores=$((${total_number_of_cpu_sockets} * ${license_number_of_cpu_cores_per_socket}))
# licensing_cores=$((${number_of_cpu_sockets[$i]} * ${license_number_of_cpu_cores_per_socket} * ${number_of_hosts[$i]}))
vcf_vsan_capacity_per_core_gib=1024 #GiB
entitled_vsan_license_tib=$(entitled_vsan_capacity_tib ${licensing_cores} ${vcf_vsan_capacity_per_core_gib} | xargs printf "%.0f")
required_vsan_license_tib=$(echo -e "${total_raw_vsan_tib[$i]} + 0.5" | bc | xargs printf "%.0f")
required_vsan_license=$((${required_vsan_license_tib} - ${entitled_vsan_license_tib}))
printf " %-7s %9s %15s %14s %30s %32s %27.3f %23.3f %-10s\n" "${cluster_name[$i]}" "${number_of_hosts[$i]}" "${total_number_of_cpu_sockets}" "${number_of_cpu_cores}" \
"${licensing_cores}" "${entitled_vsan_license_tib}" "${total_raw_vsan_tib[$i]}" "${required_vsan_license}" "(${required_vsan_license_tib})"
total_required_vsan_addon_licenses=$((${total_required_vsan_addon_licenses} + ${required_vsan_license}))
done
;;
vvf )
for ((i=0;i<${count_cluster};i++)); do
number_of_cpu_cores=$((${number_of_cpu_sockets[$i]} * ${number_of_cpu_cores_per_socket[$i]} * ${number_of_hosts[$i]}))
total_number_of_cpu_sockets=$((${number_of_cpu_sockets[$i]} * ${number_of_hosts[$i]}))
if [[ ${number_of_cpu_cores_per_socket[$i]} -le 16 ]]; then
license_number_of_cpu_cores_per_socket=16
else
license_number_of_cpu_cores_per_socket=${number_of_cpu_cores_per_socket[$i]}
fi
licensing_cores=$((${total_number_of_cpu_sockets} * ${license_number_of_cpu_cores_per_socket}))
# licensing_cores=$((${number_of_cpu_sockets[$i]} * ${license_number_of_cpu_cores_per_socket} * ${number_of_hosts[$i]}))
vvf_vsan_capacity_per_core_gib=100 #GiB
entitled_vsan_license_tib=$(entitled_vsan_capacity_tib ${licensing_cores} ${vvf_vsan_capacity_per_core_gib} | xargs printf "%.0f")
required_vsan_license_tib=$(echo -e "${total_raw_vsan_tib[$i]} + 0.5" | bc | xargs printf "%.0f")
if [[ $(echo "${entitled_vsan_license_tib} >= ${required_vsan_license_tib}" | bc) -eq 1 ]]; then
required_vsan_license=0
else
required_vsan_license=${required_vsan_license_tib}
fi
printf " %-7s %9s %15s %14s %30s %32s %27.3f %23.3f %-10s\n" "${cluster_name[$i]}" "${number_of_hosts[$i]}" "${total_number_of_cpu_sockets}" "${number_of_cpu_cores}" \
"${licensing_cores}" "${entitled_vsan_license_tib}" "${total_raw_vsan_tib[$i]}" "${required_vsan_license}" ""
total_required_vsan_addon_licenses=$((${total_required_vsan_addon_licenses} + ${required_vsan_license}))
done
;;
esac
}
function main () {
case "${type}" in
vcf )
compute_header
compute_result
vsan_header
vsan_result
echo -e "\n Total Required VCF Compute Licenses: ${total_required_compute_licenses}"
echo -e " Total Required vSAN Add-on Licenses: ${total_required_vsan_addon_licenses}"
;;
vvf )
compute_header
compute_result
vsan_header
vsan_result
echo -e "\n Total Required VVF Compute Licenses: ${total_required_compute_licenses}"
echo -e " Total Required vSAN Add-on Licenses: ${total_required_vsan_addon_licenses}"
;;
esac
echo
}
while getopts "i:d:" opt; do
case "${opt}" in
i ) file=$OPTARG;;
d ) type=$OPTARG;;
esac
done
shift $((${OPTIND} - 1))
if [[ -z "${file}" ]]; then
echo " Usage: $(basename $0) [-i input_filename] [-d deployment_type]"
exit 0
fi
if [[ ! -f "${file}" ]]; then
echo -e "<!> Please provide the vSphere Environment Configuration File"
exit
fi
scales=5
collect_data
main
```
# 附錄
## [使用 BASH 和 GOVC 撰寫程式估算 VMware vSphere 訂閱授權](https://hackmd.io/@farmer87/kb95927_getFoundationCore)