CLI interface to control SURF VMs
Project description
🏄♂️ Surf Controller
🌊 Overview
Surf Controller is a powerful CLI tool for managing your cloud workspaces with ease! It provides a user-friendly interface to monitor, pause, and resume your virtual machines (VMs) effortlessly.
🚀 Features
- 📊 Interactive CLI interface
- 🔄 Real-time VM status updates
- ⏸️ Pause and ▶️ resume VMs with a single keystroke
- 📋 Multi-select functionality for batch operations
- 📜 Live log viewing
🛠️ Installation
config dir
By default, your ~/.surf_controller/ dir will be used for data.
You can modify this by specifying SURF_CONTROLLER_CONFIG_DIR in your env, eg
export SURF_CONTROLLER_CONFIG_DIR=/srv/shared/
You can do this for the server for all users with
sudo vim /etc/profile.d/shared_env.sh
install as tool
Use uv to install surf-controller globally or add it to your local environment. You can install it with curl -LsSf https://astral.sh/uv/install.sh | sh . Of course, you can also use pip to install it (but then you might also need to install python etc, something uv also takes care of).
Here are three different commands you could use, the first one (uv tools) is recommended to install it globally.
Dont run all three, pick one.
option 1
install globally
uv tools install surf-controller
option 2
install in a .venv
uv add surf-controller
option 3
Install with pip if you get nervous from new tools
pip install surf-controller
All three commands install the surfcontroller command; if you dont know what to pick, use uv
🔑 First-time Setup of tokens
You can find the SURF API documentation here: API Documentation
On your profile you can create your own API token.
You can obtain the CSRF tokens by authorizing directly with the Surf API. Use the green lock icon in the top right corner to authorize with your API-token and obtain the CSRF token by executing a request.
Copy both tokens and use them during configuration.
Run the configuration by starting the controller:
surfcontroller
On first run, Surf Controller will:
- 📁 Create a configuration directory in your SURF_CONTROLLER_CONFIG_DIR folder (defaults to ~)
- 📄 Copy a default configuration file into your configdir
- 🔒 Prompt you for API and CSRF tokens and stores them in your configdir
🎮 Usage
Run the controller:
surfcontroller
🕹️ Controls
navigate / select
j: Move cursor downk: Move cursor upJ: Next pageK: Previous pageEnter: Select/deselect VMa: toggle Select all VMsf: toggle Filter VMs (by username)R: toggle Filter Running VMs (show only running)1-9: Toggle custom filters+: Add custom filtern: rename usernamel: toggle view logs
Actions
p: Pause selected VMsr: Resume selected VMse: Batch update End Date for selected VMsE: Toggle Pause Exclusion (Shift+e)c: Bulk Create VMs (Wizard)d: Bulk Delete selected VMs (with confirmation)u: Update VM lists: ssh into selected VM (select just one VM)
✨ New in v1.0
- Bulk Creation Wizard: Press
cto launch a step-by-step wizard for creating multiple VMs from a user list and template. - Bulk Deletion: Press
dto delete multiple VMs at once. Includes a safety confirmation dialog. - Batch End Date Update: Press
eto update the expiration date for multiple VMs simultaneously. - Running Filter: Press
Rto quickly see only your running VMs. - UI Improvements:
- Progress Bars: Visual progress tracking for batch operations.
- Status Indicators: Clear "OK" (Green) or "FAILED" (Red) status for actions.
- Responsive Footer: Command bar adapts to screen width.
- Persistent Filters: Custom filters are saved between sessions.
Note that adding to the exclusion list only adds the id of the vm to exclusions.json. The actual shutting down of the VM is done from a VM we control on the Surf cloud, so toggling this on your computer doesnt impact the actual pausing at 21:00.
📝 Configuration
Edit ~/.surf_controller/config.toml to customize your settings.
🤝 Contributing
Contributions are welcome!
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Thanks to https://claude.ai/ for help with the curses implementation
📅 Scheduler & Web GUI
The project includes a Docker-based scheduler for automating nightly VM pauses and managing exclusions via a Web GUI.
Setup
- Navigate to the
scheduler/directory:cd scheduler
- Create a
.envfile from the sample:cp .env.sample .env
Edit.envto set your desiredWEB_USERNAMEandWEB_PASSWORD. - Start the scheduler:
docker-compose up -d --build
How it works
- Web GUI: Accessible at
http://localhost:5001. Use it to view VM status, toggle exclusions, and manually trigger the pause job. - Nightly Job: A cron job runs every night at 21:00 to pause all non-excluded VMs.
- Configuration: The scheduler mounts your local
~/.surf_controllerdirectory, so it shares the same tokens and exclusions as the CLI tool. - Installation: The Docker image installs the
surf-controllerpackage directly from the source code in the parent directory, ensuring it always runs the latest version of your code.
🚀 Deployment
To deploy the scheduler to a remote machine, you can use the automated deployment script:
python3 scheduler/deploy.py
This script will:
- Configure Environment: Check/create
scheduler/.env, generate a secureWEB_PASSWORDif needed, and prompt for theDEPLOY_HOST. - Build & Push: Build the Docker image for
linux/amd64and push it to Docker Hub. - Deploy Files: SCP the
.envanddocker-compose.deploy.ymlto the remote server. - Restart Service: SSH into the remote server and restart the Docker service.
Prerequisites:
- SSH access to the remote host (default
rgrouls@145.38.185.245) via key-based authentication. - Docker installed and running locally.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file surf_controller-1.1-py3-none-any.whl.
File metadata
- Download URL: surf_controller-1.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e7d99244c74f78157dc86a9d52ae9f1ad6467dbf0f0edce1062f7ff4d7e2825
|
|
| MD5 |
df7f0fec0714745a2f8e8277475df657
|
|
| BLAKE2b-256 |
51ce861bb07eee38fa51b2e93b6f9dfd3c499e42e2b7494519306bdcde93a865
|