As per latest update from VMware, new vCenter and ESXi patches are released. These patches primarily will help enable “Hypervisor-Assisted Guest mitigation”. With these patches, one of the important aspects is to make sure whether entire EVC cluster is patched/upgraded or not. In this blog post, we will take a look at the pyVmomi script, which will confirm whether EVC cluster is patched with both hypervisor & microcode patch or not. Before we take a look at the script, let me quote statement from VMware KB on EVC cluster behavior.
“The vCenter patches enable vMotion compatibility to be retained within an EVC cluster.
In order to maintain this compatibility the new features are hidden from guests within the cluster until all hosts in the cluster are properly updated. At that time, the cluster will automatically upgrade its capabilities to expose the new features.”
As per above quote, new features should be available on EVC cluster once all the hosts inside the cluster are patched. Now lets take a look at the script.
This script i.e. is_evc_cluster_patched.py is available on my git-hub repo.
from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim
# Script to confirm whether EVC cluster is patched or not for Spectre vulenerability.
""" Get arguments from CLI """
parser = argparse.ArgumentParser(
description=’Arguments for talking to vCenter’)
help=’vSpehre service to connect to’)
help=’Port to connect on’)
help=’Username to use’)
help=’Password to use’)
help=’Name of the cluster you wish to check’)
args = parser.parse_args()
if not args.password:
args.password = getpass.getpass(
prompt=’Enter vCenter password:’)
# Below method helps us to get MOR of the object (vim type) that we passed.
def get_obj(content, vimtype, name):
obj = None
container = content.viewManager.CreateContainerView(content.rootFolder, vimtype, True)
for c in container.view:
if name and c.name == name:
obj = c
args = get_args()
si= SmartConnect(host=args.host, user=args.user, pwd=args.password,sslContext=s)
cluster = get_obj(content,[vim.ClusterComputeResource],cluster_name)
print ("Cluster not found, please enter correct EVC cluster name")
print ("Cluster Name:"+cluster.name)
print ("Current EVC Mode::"+current_evcmode_key)
print ("EVC is NOT enabled on the cluster, please enable it first")
feature_capabilities = evc_state.featureCapability
for capability in feature_capabilities:
if(capability.key in ["cpuid.STIBP", "cpuid.IBPB","cpuid.IBRS"] and capability.value=="1"):
print ("No new cpubit found on EVC cluster,hence cluster is NOT fully patched/upgraded")
print ("EVC cluster is patched, enjoy!, this also confirms all the hosts inside this EVC cluster are patched as well")
If you take a look at line 81-85, these are exact same EVC vSphere API properties that we discussed in my tutorial here. Same properties I have used to confirm whether EVC cluster is patched/upgraded or not. This script takes VCIP, username, password and EVC cluster name as parameter. Let us take a look at the output.
From output, it is clear that EVC cluster is patched successfully. It does mean that all the hosts inside the clusters are patched with both microcode and hypervisor patch. If at-least one of the hosts inside this EVC cluster is NOT patched, EVC cluster is NOT going to expose new cpuids on cluster and will be called as NOT patched.
Please note that since EVC APIs got introduced from vSphere 6.0, above script will be applicable for vSphere 6.0 and 6.5. Also, microcode/BIOS support is available for few Intel/AMD CPU models, please check out VMware KB for more details on it.
Some useful resources on EVC
1. If you want to confirm each host inside the cluster (with or without EVC) is patched or not, please take a look at my latest blog post
2. Empty EVC cluster issue discussed here is fixed with latest vCenter Patches
3. Part-1: Managing EVC using pyVmomi
4. Part 2: Managing EVC using pyVmomi
5. Tutorial on getting started pyVmomi
I hope you enjoyed this post, let me know if you have any questions/doubts.
Vikas Shitole is a Staff engineer 2 at VMware India R&D. He currently focusses on vCenter server in general, vSphere with Tanzu, VCF and partly VMware cloud. He is passionate about VMware customers & automation around VMware technologies. He has been a vExpert since last 9 years (2014-22) in row for his significant community contributions around VMware. He is also part of BU driven vExpert sub-programs i.e. vExpert App modernization, vExpert VMware Cloud on AWS & vExpert PRO as well. He is author of 2 VMware flings & holds multiple technology certifications. He has been speaker at International conferences such as VMworld Europe, VMworld USA & was designated VMworld 2018 blogger as well.
In addition, he is passionate cricketer, bicycle rider & aspiring Ironman 70.3. He also enjoys learning about fitness & nutrition.