vLab Infrastructure Common
This library centralizes logic for working with virtual infrastructure providers.
VMware
Builds upon the pyVmomi API bindings for vSphere to create more human friendly objects like:
vCenter
It’s called vCenter because that’s the host you’ll connect to. This object focuses more on interacting with Virtual Machines, than configuring the system.
Here’s an example of what using the vCenter object is like:
from vlab_inf_common.vmware import vCenter, vim
vc = vCenter(user='Alice', password='iLoveDogs', host='some-vcenter-server.corp')
vc.networks
{'front-end': 'vim.Network:network-14'} # mapping of name -> object
vc.create_vm_folder(path='/some/new/path') # recursively creates the whole path
vms = vc.get_by_type(vim.VirtualMachine)
vms
(ManagedObject) [
'vim.VirtualMachine:vm-15'
]
Ova
This object abstracts use of an OVA file when creating new Virtual Machines. It handles both local paths and URLs for the OVA file location. Deploying the OVA is a single method call (once you’ve obtained a spec and lease).
Here’s an example of using the Ova object:
from vlab_inf_common.vmware import Ova
ova = Ova('https://some-server/myMachine.ova')
ova.networks
['eth0']
ova.vmdks
['disk-1.vmdk', 'disk-2.vmdk']
hasattr(ova, 'ovf') # b/c the ovf XML is too long to put in an example
True
Here’s an example using Ova and vCenter to deploy a new Virtual Machine It’s a bit long, but pyVmomi doesn’t make it easy…
import time
from vlab_inf_common.vmware import Ova, vCenter, vim
vc = vCenter(user='Alice', password='iLoveDogs', host='some-vsphere-server.corp')
ova = Ova('/some/path/myMachine.ova')
my_folder = vc.get_vm_folder('/users/alice')
network_map = vim.OvfManager.NetworkMapping()
network_map.name = ova.networks[0]
network_map.network = vc.networks['front-end'] # assuming you have a network named 'frond-end'
resouce_pool = vc.resource_pool['users'] # assuming your pool name is 'users'
datastore = vc.datastores['general'] # another assumption!
host = list(vc.host_systems.values())[0] # if you don't care which host you upload to
spec_params = vim.OvfManager.CreateImportSpecParams(entityName='myNewVM', networkMapping=[network_map])
spec = vc.ovf_manager.CreateImportSpec(ovfDescriptor=ova.ovf,
resourcePool=resouce_pool, datastore=datastore, cisp=spec_params)
lease = resource_pool.ImportVApp(spec.importSpec, folder=my_folder, host=host)
for _ in range(30):
if lease.state != 'ready':
time.sleep(1)
else:
break
print('starting deploy')
ova.deploy(spec, lease, host.name)
print('Upload complete')
ova.close()
FAQ
How do I deal with self-signed TLS certs in vCenter?
Set the environment variable INF_VCENTER_VERIFY_CERT to anything, and we’ll use the default context created by the Python ssl lib. By default, we’ll ignore self-signed certs.
Metadata
Release files for vlab-inf-common 2021.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vlab_inf_common-2021.5.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for vlab_inf_common-2021.5.3-py2.py3-none-any.whl |
Release files / vlab_inf_common-2021.5.3-py2.py3-none-any.whl
| Download URL | vlab_inf_common-2021.5.3-py2.py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2ba94c1c4fa91e39e7dd3488b80fc82b8213a3d166890e163d4e97c3726ca8d0
|
|
BLAKE2b-256 checksum How to use checksums |
fb07bd09934e1fbf14c66adb07befea53e8c8d45d27a15961508283a3b446dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5
|
Security for vlab-inf-common 2021.5.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.