@@ -107,6 +107,10 @@ def command(self) -> str:
107107 def _windows_tool (cls ) -> Optional [Type [Tool ]]:
108108 return WindowsLscpu
109109
110+ @classmethod
111+ def _vmware_esxi_tool (cls ) -> Optional [Type [Tool ]]:
112+ return VMWareESXiLscpu
113+
110114 @classmethod
111115 def _freebsd_tool (cls ) -> Optional [Type [Tool ]]:
112116 return BSDLscpu
@@ -438,3 +442,40 @@ def calculate_vcpu_count(self, force_run: bool = False) -> int:
438442 * self .get_cluster_count ()
439443 * self .get_thread_per_core_count ()
440444 )
445+
446+
447+ class VMWareESXiLscpu (Lscpu ):
448+ # CPU Threads: 208
449+ __cpu_threads = re .compile (r"CPU Threads:[ ]+([\d]+)?" , re .M )
450+ # CPU Packages: 2
451+ __cpu_packages = re .compile (r"CPU Packages:[ ]+([\d]+)?" , re .M )
452+ # CPU Cores: 104
453+ __cpu_cores = re .compile (r"CPU Cores:[ ]+([\d]+)?" , re .M )
454+
455+ @property
456+ def command (self ) -> str :
457+ return "esxcli"
458+
459+ def get_core_count (self , force_run : bool = False ) -> int :
460+ result = self .run ("hardware cpu global get" , force_run )
461+ matched = self .__cpu_threads .findall (result .stdout )
462+ assert_that (
463+ len (matched ),
464+ f"cpu thread should have exact one line, but got { matched } " ,
465+ ).is_equal_to (1 )
466+ self ._core_count = int (matched [0 ])
467+ return self ._core_count
468+
469+ def calculate_vcpu_count (self , force_run : bool = False ) -> int :
470+ result = self .run ("hardware cpu global get" , force_run )
471+ matched_cpu_packages = self .__cpu_packages .findall (result .stdout )
472+ assert_that (
473+ len (matched_cpu_packages ),
474+ f"cpu packages should have exact one line, but got { matched_cpu_packages } " ,
475+ ).is_equal_to (1 )
476+ matched_cpu_cores = self .__cpu_cores .findall (result .stdout )
477+ assert_that (
478+ len (matched_cpu_cores ),
479+ f"cpu cores should have exact one line, but got { matched_cpu_cores } " ,
480+ ).is_equal_to (1 )
481+ return int (matched_cpu_packages [0 ]) * int (matched_cpu_cores [0 ])
0 commit comments