Package: pyrvtools
Extract useful information from an RVTools ESX inventory file.Purpose of that moduleDid you have ever ask to an VMWare administrator to have an access to
his vCenter to run some scripts by API ? No ? Me yes and a least that
can i say : it’s not easy ! ;-)More seriously, it very often hard to get access to this kind of VM
because it’s very sensitive part of the infrastructure and because the
guys generally are not in the same team as you and they not trust you
(neither in your scripts !), so it does not help. But, to be honest,
you’ll probably do the same thing if the situation was reversed.But sometimes, they can send you an RVTools extraction (so an Excel
file) from that vCenter and you want to use it in a Python script.
You’ll prefer have to access directly to the vCenter by API call to get
fresh data but it’s better than nothing…That’s why i coded this library : to help to use this kind of inputs to
extract some useful information from it.How to install itYou can install pyRvtools by using pip :pip install pyrvtoolsHow to use itYou can search for 5 kind of major objects with that module: -
DataCenter - Clusters - Hosts - DataStores - VirtualMachineEach of them have a specific number of properties. You can iterate on
all object or focus only on one of them giving his name.Here is some examples (please refer to the list of properties below if
you’re looking for a metric):importosfrompyrvtoolsimportPyRvtoolsPATH=os.sep.join(['your_path','your_file.xls'])rvtools=PyRvtools(PATH)# For all the dataCentersfordcinrvtools.get_datacenters():print('DC:%sClusters:%s'%(dc,dc.clusters))# Only for a specific DataCenterone_dc=rvtools.get_datacenter_by_name('MY_DC')print('DC:%sClusters:%s'%(one_dc,one_dc.clusters))# For all the Clusterforclusterinrvtools.get_clusters():print('Cluster:%sHosts:%s'%(cluster,cluster.hosts))# Only for a specific Clusterone_cluster=rvtools.get_clusters_by_name('MY_CLUSTER')print('Cluster:%sHosts:%s'%(one_cluster,one_cluster.hosts))# For all the DataStoresfordsinrvtools.get_datastores():print('DS:%sHosts:%s'%(ds,ds.hosts))# Only for a specific DataStoreone_ds=rvtools.get_datastore_by_name('MY_DS')print('DS:%sHosts:%s'%(one_ds,one_ds.hosts))# For all the hostsforesxinrvtools.get_hosts():print('ESX:%sVM:%s'%(esx,esx.vm))# Only for a specific hostone_esx=rvtools.get_host_by_name('MY_ESX_NAME')print('ESX:%sVM:%s'%(one_esx,one_esx.vm))# For all the VirtualMachineforvminrvtools.get_vm():print('VM:%sDataStore:%s'%(vm,vm.datastore))# Only for a specific VMone_vm=rvtools.get_vm_by_name('MY_VM')print('VM:%sDataStore:%s'%(one_vm,one_vm.datastore))Properties of objectsCluster- datacenter
- hostsDataCenter- clusters
- hostsDataStore- capacity_mb
- free_mb
- free_percent
- hosts
- inuse_mb
- naa
- number_of_hosts
- number_of_vms
- provisioned_mb
- sioc_enable
- type
- versionHost- boot_time
- cluster
- cpu_usage_percent
- datacenter
- esx_version
- hba
- memory_mb
- memory_usage_percent
- model
- number_of_cores
- number_of_cpu
- number_of_vcpu
- number_of_vm
- vmVirtualMachine- cluster
- cpu
- datacenter
- datastore
- host
- inuse_mb
- memory
- os
- power_on
- power_state
- provisioned_mb
- unshared_mb
- vmdk
- vnetwork
- vpartitionLicenseThis library is licensed under GPL3.