Inventory library for VMware (Vsphere Release)
Inventory library for VMware (Vsphere Release)
- List all Datacenter
- List all Cluster
- List all Datastores
- List all Virtual Machines
- Command line client
Requires:
- Python 3.7+
- Admin access to Vcenter
pip install git+https://github.com/multi-cloud-explorer/mce-lib-vpshere.git
Connect with URL:
export MCE_VCENTER_URL=https://user1:pass@127.0.0.1:8989/sdk?timeout=120
with Client() as cli:
vm = cli.get_vm_by_name("DC0_H0_VM0")
print(vm.name)
Connect with host/port:
with Client(host="127.0.0.1", port=8989, username="user1", password="pass") as cli:
vm = cli.get_vm_by_name("DC0_H0_VM0")
print(vm.name)
Display Vcenter Infos:
from pprint import pprint
from mce_lib_vsphere.core import Client
client = Client('https://user1:pass@127.0.0.1:8989/sdk')
client.connect()
si, content = client.connect()
pprint(client.vcenter_infos())
{
'apiType': 'VirtualCenter',
'apiVersion': '6.5',
'build': '5973321',
'licenseProductName': 'VMware VirtualCenter Server',
'licenseProductVersion': '6.0',
'osType': 'linux-amd64',
'version': '6.5.0'
}
client.disconnect()
# conftest.py
pytest_plugins = ['mce_lib_vsphere.pytest.plugin']
# test_yourtest.py
import pytest
from pyVmomi import vim
from mce_lib_vsphere import core
def test_get_all_vms(vsphere_server, vcsim_settings):
url = vsphere_server
with core.Client(host=url) as client:
client.connect()
objects = client.get_all_vms()
- Publish to Pypi repository
- Sphinx doc
- Terraform templates ou Pulumi code for IAC
- Contrib doc