Skip to content

Instantly share code, notes, and snippets.

@em2er
em2er / vapi_vm_tags.py
Last active August 2, 2021 06:46
Read categories and tags for all VM in vCenter using vSphere Automation SDK
from vmware.vapi.vsphere.client import create_vsphere_client
client = create_vsphere_client(
server='my-company-vcenter.com',
username='my_login',
password='my_password',
session=None)
cat_dict = {}
for id in client.tagging.Category.list():
@em2er
em2er / vmware_tags_rest_api.py
Last active February 15, 2024 09:51
Getting categories and tags for all VM in VMWare vCenter using REST API
from requests import Session
from typing import List, Dict
VALUE_KEY = 'value'
class VMTagReader:
def __init__(self, vcenter_url: str, login: str, password: str):
self.host = vcenter_url
self.session = Session()