This application provides a proxy service that translates iLO Redfish API calls to vSphere API calls. It allows managing vSphere VMs through a minimal set of Redfish API calls.
- Power management (On, Off, Reset)
- Boot order configuration
- Virtual media (CD-ROM) management
- SSL/TLS support
- Multi-VM support through different ports
- Clone the repository:
git clone <repository-url>
cd ilo-to-vsphere-python- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Generate SSL certificates:
mkdir -p certs
openssl req -x509 -newkey rsa:4096 -nodes -out certs/server.crt -keyout certs/server.key -days 365Edit the config.py file to configure your vSphere environment, this is: set the vSphere hostname and map local ports with each of your virtual machines.
vsphere = {
'host': 'vsphere-host',
'vms': [
{'port': 3000, 'vmId': 'vm-123'},
{'port': 3001, 'vmId': 'vm-456'}
]
}Run the application:
python main.pyThe proxy will start a separate process for each VM configured in config.py, each listening on its specified port. From this moment, you can interact with the server as if you would be interacting with an iLO or any other Redfish compatible management interface.
As an example, an Ansible playbook is provided with some of the most common operations, using the community.general.redfish_command module:
- Power On VM:
ansible-playbook ilo_operations.yml -i inventory \
-e @vault.yaml --ask-vault-password \
-e power_on=1- Set Boot Order to CD-ROM:
ansible-playbook ilo_operations.yml -i inventory \
-e @vault.yaml --ask-vault-password \
-e boot_setorder=1 -e boot_device=cd- Set Boot Order to HDD:
ansible-playbook ilo_operations.yml -i inventory \
-e @vault.yaml --ask-vault-password \
-e boot_setorder=1 -e boot_device=hdd- Reboot VM:
ansible-playbook ilo_operations.yml -i inventory \
-e @vault.yaml --ask-vault-password \
-e power_reboot=1The proxy implements the following Redfish API endpoints:
/redfish/v1- Service root/redfish/v1/Systems- System collection/redfish/v1/Systems/1- System instance/redfish/v1/Managers- Manager collection/redfish/v1/Managers/1- Manager instance/redfish/v1/Managers/1/VirtualMedia- Virtual media collection/redfish/v1/Managers/1/VirtualMedia/CD- CD-ROM instance/redfish/v1/Managers/1/VirtualMedia/CD/Actions/VirtualMedia.EjectMedia- Eject the CD-ROM/redfish/v1/Managers/1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia- Mount an ISO
The proxy uses Basic Authentication. Include the Authorization header in your requests:
Authorization: Basic <base64-encoded-credentials>
These credentials will be sent to vSphere API to authenticate so make sure the user has enough permissions in the vSphere instance to make the changes.
- BootSourceOverrideEnabled only accepts "Continuous" value due to vSphere constrains
- BootSourceOverrideSupported only allows "HDD" and "CD"
- Authentication requires vCenter credentials
- SSL certificates must be in the
certs/directory
- SSL certificates should have appropriate permissions (600 for key.pem)
- vCenter credentials are transmitted with each request. They're not cached in any way.
- Error 401: Invalid credentials
- Error 400:
- Invalid BootSourceOverrideTarget
- BootSourceOverrideEnabled is not "Continuous"
- Error 500: Internal server error
- Check logs for details
- Verify vCenter connection
- Check certificate permissions
The proxy logs all requests and responses to the console for debugging purposes. Not suitable for production environments.
- Refactor the code to split it in different files
- Implement in some way the
SetOneTimeBootfunction - Implement properly
ForceOffandGracefulShutdown - Implement properly
ForceRestart,GracefulRestartandPowerReboot
MIT License