![logo](assets/logo.png)
# Proxmox PCI Switcher <!-- omit in toc -->
![GitHub all releases](https://img.shields.io/github/downloads/rosineygp/proxmox-pci-switcher/total?label=snippet)
![PyPI - Downloads](https://img.shields.io/pypi/dm/proxmox-pci-switcher?label=pypi)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rosineygp_proxmox-pci-switcher&metric=alert_status)](https://sonarcloud.io/dashboard?id=rosineygp_proxmox-pci-switcher)
Switch among Guest VMs organized by `Resource Pool`.
main features:
- `ONE` GPU card, `N` OS (at once)
- Guest VM command client
- Handler power off
- Reset framebuffer
**TOC**
- [Proxmox Configuration](#proxmox-configuration)
- [Create Resource Pool](#create-resource-pool)
- [Assign Guest VM](#assign-guest-vm)
- [Install Proxmox Snippet](#install-proxmox-snippet)
- [Proxmox Config](#proxmox-config)
- [Snippet Variables](#snippet-variables)
- [Assign VM to Snippet](#assign-vm-to-snippet)
- [Guest Client Switcher](#guest-client-switcher)
- [List Resources](#list-resources)
- [Switch Resource](#switch-resource)
- [Using GUI](#using-gui)
## Proxmox Configuration
### Create Resource Pool
![Resource Pool](assets/create_resource_pool.png)
### Assign Guest VM
![Assign Guest VM](assets/assign_guest_vm.png)
## Install Proxmox Snippet
```bash
curl -fsSL https://github.com/rosineygp/proxmox-pci-switcher/releases/latest/download/pci-group-switcher.sh > pci-group-switcher.sh
# set execution permission
chmod +x pci-group-switcher.sh
# move for your snippets <storage>/<folder>
```
### Proxmox Config
#### Snippet Variables
| NAME | Default | Description |
| ---------------------- | ----------------- | ------------------------------------------------------------------ |
| _POOL_NAME * | \<auto_discovery> | The name of `Resource Pool` |
| _SHUTDOWN_TIMEOUT | 300 | Checking if resource was released (Current VM Running is down) |
| _RESET_GPU_FRAMEBUFFER | true | Reset GPU framebuffer |
| _PIN_CPU_IDS | false | Pin CPU using `taskset` (syntax equals taskset cpu-list parameter) |
| _RENICE_PRIORITY | false | Renice process using `renice` |
> All variables must be changed in `pci-group-switcher.sh` at proxmox ve.
>
> `_POOL_NAME` * By default it will scan for VMID in all Resource Pools, in case of long delays replace function call to Resource Pool name (eg. desktop, gpu, ...).
The following variables can be passed using `/etc/pve/qemu-server/<vmid>.vars` file, the script will load variables from file if it exists.
> If you need to overwrite an Default value set at `/etc/environment` the variable name without the `_` prefix. (eg. RESET_GPU_FRAMEBUFFER=false)
#### Assign VM to Snippet
```bash
qm set <vmid> -hookscript <storage>:snippets/pci-group-switcher.sh
```
> After proxmox configuration is possible to switch using proxmox api or web interface.
## Guest Client Switcher
- requirements: python 3
```bash
pip install proxmox-pci-switcher
# create config folder
mkdir -p ~/.config/proxmox-pci-switcher/
# create config file
cat <<EOF > ~/.config/proxmox-pci-switcher/config.yaml
proxmox:
host: '<ip or dns>'
user: '<user>@<method>'
password: '<password>'
api_id: '<name>' # only for api access
api_token: '<token>' # only for api access
verify_ssl: false
gui: # optional
theme: Dark # Light or Dark
pools:
- '<desktop>'
- '<gpu-nvidia>'
- '<gpu-amd>'
EOF
```
> Edit `config.yaml` with your proxmox credentials and pools.
> API access has priority over user and password access.
### List Resources
```bash
proxmox-pci-switcher list
pool(s) vmid name status type
---------- ------ --------------- -------- ------
desktop 119 catalina stopped qemu
desktop 116 win10-desktop stopped qemu
desktop 117 mini-desktop stopped qemu
desktop 103 u20-desktop running qemu
desktop 115 u20-srv-desktop stopped qemu
```
### Switch Resource
```bash
# run command directly
proxmox-pci-switcher switch win10-desktop
# create a alias for better experience
alias windows="proxmox-pci-switcher switch win10-desktop"
# and just run
windows
```
### Using GUI
```bash
proxmox-pci-switcher gui
```
![GUI](assets/gui.png)
Raw data
{
"_id": null,
"home_page": "https://github.com/rosineygp/proxmox-pci-switcher",
"name": "proxmox-pci-switcher",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Rosiney Gomes Pereira",
"author_email": "rosiney.gp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/40/28/4ad87b4e46f1e2d3911671385b5d1097858d3a5cf2862f131cff3db84512/proxmox-pci-switcher-0.15.11.tar.gz",
"platform": null,
"description": "![logo](assets/logo.png)\n\n# Proxmox PCI Switcher <!-- omit in toc -->\n\n![GitHub all releases](https://img.shields.io/github/downloads/rosineygp/proxmox-pci-switcher/total?label=snippet)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/proxmox-pci-switcher?label=pypi)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rosineygp_proxmox-pci-switcher&metric=alert_status)](https://sonarcloud.io/dashboard?id=rosineygp_proxmox-pci-switcher)\n\nSwitch among Guest VMs organized by `Resource Pool`.\n\nmain features:\n\n- `ONE` GPU card, `N` OS (at once)\n- Guest VM command client\n- Handler power off\n- Reset framebuffer\n\n**TOC**\n\n- [Proxmox Configuration](#proxmox-configuration)\n - [Create Resource Pool](#create-resource-pool)\n - [Assign Guest VM](#assign-guest-vm)\n- [Install Proxmox Snippet](#install-proxmox-snippet)\n - [Proxmox Config](#proxmox-config)\n - [Snippet Variables](#snippet-variables)\n - [Assign VM to Snippet](#assign-vm-to-snippet)\n- [Guest Client Switcher](#guest-client-switcher)\n - [List Resources](#list-resources)\n - [Switch Resource](#switch-resource)\n - [Using GUI](#using-gui)\n\n## Proxmox Configuration\n\n### Create Resource Pool\n\n![Resource Pool](assets/create_resource_pool.png)\n\n### Assign Guest VM\n\n![Assign Guest VM](assets/assign_guest_vm.png)\n\n## Install Proxmox Snippet\n\n```bash\ncurl -fsSL https://github.com/rosineygp/proxmox-pci-switcher/releases/latest/download/pci-group-switcher.sh > pci-group-switcher.sh\n\n# set execution permission\nchmod +x pci-group-switcher.sh\n\n# move for your snippets <storage>/<folder>\n```\n\n### Proxmox Config\n\n#### Snippet Variables\n\n| NAME | Default | Description |\n| ---------------------- | ----------------- | ------------------------------------------------------------------ |\n| _POOL_NAME * | \\<auto_discovery> | The name of `Resource Pool` |\n| _SHUTDOWN_TIMEOUT | 300 | Checking if resource was released (Current VM Running is down) |\n| _RESET_GPU_FRAMEBUFFER | true | Reset GPU framebuffer |\n| _PIN_CPU_IDS | false | Pin CPU using `taskset` (syntax equals taskset cpu-list parameter) |\n| _RENICE_PRIORITY | false | Renice process using `renice` |\n\n> All variables must be changed in `pci-group-switcher.sh` at proxmox ve.\n>\n> `_POOL_NAME` * By default it will scan for VMID in all Resource Pools, in case of long delays replace function call to Resource Pool name (eg. desktop, gpu, ...).\n\nThe following variables can be passed using `/etc/pve/qemu-server/<vmid>.vars` file, the script will load variables from file if it exists.\n\n> If you need to overwrite an Default value set at `/etc/environment` the variable name without the `_` prefix. (eg. RESET_GPU_FRAMEBUFFER=false)\n\n#### Assign VM to Snippet\n\n```bash\nqm set <vmid> -hookscript <storage>:snippets/pci-group-switcher.sh\n```\n\n> After proxmox configuration is possible to switch using proxmox api or web interface.\n\n## Guest Client Switcher\n\n- requirements: python 3\n\n```bash\npip install proxmox-pci-switcher\n\n# create config folder\nmkdir -p ~/.config/proxmox-pci-switcher/\n\n# create config file\ncat <<EOF > ~/.config/proxmox-pci-switcher/config.yaml\nproxmox:\n host: '<ip or dns>'\n user: '<user>@<method>'\n password: '<password>'\n api_id: '<name>' # only for api access\n api_token: '<token>' # only for api access\n verify_ssl: false\n\ngui: # optional\n theme: Dark # Light or Dark\n\npools:\n - '<desktop>'\n - '<gpu-nvidia>'\n - '<gpu-amd>'\n\nEOF\n```\n\n> Edit `config.yaml` with your proxmox credentials and pools.\n\n> API access has priority over user and password access.\n\n### List Resources\n\n```bash\nproxmox-pci-switcher list\n\npool(s) vmid name status type\n---------- ------ --------------- -------- ------\ndesktop 119 catalina stopped qemu\ndesktop 116 win10-desktop stopped qemu\ndesktop 117 mini-desktop stopped qemu\ndesktop 103 u20-desktop running qemu\ndesktop 115 u20-srv-desktop stopped qemu\n```\n\n### Switch Resource\n\n```bash\n# run command directly\nproxmox-pci-switcher switch win10-desktop\n\n# create a alias for better experience\nalias windows=\"proxmox-pci-switcher switch win10-desktop\"\n\n# and just run\nwindows\n```\n\n### Using GUI\n\n```bash\nproxmox-pci-switcher gui\n```\n\n![GUI](assets/gui.png)\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Switch among Guest VMs organized by Resource Pool",
"version": "0.15.11",
"project_urls": {
"Homepage": "https://github.com/rosineygp/proxmox-pci-switcher"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b5000470b650cf1841b87d11a14b7a5aa127b4cd2c31b4ef29628c3ce9c6116f",
"md5": "ace9b1ad9e0be7e86de8fa102d0244e3",
"sha256": "6601feddbe1c93956dc460b74d11db63cda28905ae9b1cb8027f639ff4edfec4"
},
"downloads": -1,
"filename": "proxmox_pci_switcher-0.15.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ace9b1ad9e0be7e86de8fa102d0244e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 21993,
"upload_time": "2024-04-05T18:40:37",
"upload_time_iso_8601": "2024-04-05T18:40:37.438290Z",
"url": "https://files.pythonhosted.org/packages/b5/00/0470b650cf1841b87d11a14b7a5aa127b4cd2c31b4ef29628c3ce9c6116f/proxmox_pci_switcher-0.15.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "40284ad87b4e46f1e2d3911671385b5d1097858d3a5cf2862f131cff3db84512",
"md5": "0bc43e73f8dc5e79e31c058480a85680",
"sha256": "96a17b754786e399dddd3da5e554f5174d20412417523d0dee226e1b617272db"
},
"downloads": -1,
"filename": "proxmox-pci-switcher-0.15.11.tar.gz",
"has_sig": false,
"md5_digest": "0bc43e73f8dc5e79e31c058480a85680",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 6966,
"upload_time": "2024-04-05T18:40:38",
"upload_time_iso_8601": "2024-04-05T18:40:38.630942Z",
"url": "https://files.pythonhosted.org/packages/40/28/4ad87b4e46f1e2d3911671385b5d1097858d3a5cf2862f131cff3db84512/proxmox-pci-switcher-0.15.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 18:40:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rosineygp",
"github_project": "proxmox-pci-switcher",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "proxmox-pci-switcher"
}