clonebox 0.1.1__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,379 @@
1
+ Metadata-Version: 2.4
2
+ Name: clonebox
3
+ Version: 0.1.3
4
+ Summary: Clone your workstation environment to an isolated VM with selective apps, paths and services
5
+ Author: CloneBox Team
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/wronai/clonebox
8
+ Project-URL: Repository, https://github.com/wronai/clonebox
9
+ Project-URL: Issues, https://github.com/wronai/clonebox/issues
10
+ Keywords: vm,virtualization,libvirt,clone,workstation,qemu,kvm
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: System :: Systems Administration
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: libvirt-python>=9.0.0
29
+ Requires-Dist: rich>=13.0.0
30
+ Requires-Dist: questionary>=2.0.0
31
+ Requires-Dist: psutil>=5.9.0
32
+ Requires-Dist: pyyaml>=6.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
36
+ Requires-Dist: black>=23.0.0; extra == "dev"
37
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # CloneBox 📦
41
+
42
+ ```commandline
43
+ ╔═══════════════════════════════════════════════════════╗
44
+ ║ ____ _ ____ ║
45
+ ║ / ___|| | ___ _ __ ___| _ \ ___ __ __ ║
46
+ ║ | | | | / _ \ | '_ \ / _ \ |_) |/ _ \\ \/ / ║
47
+ ║ | |___ | || (_) || | | | __/ _ <| (_) |> < ║
48
+ ║ \____||_| \___/ |_| |_|\___|_| \_\\___//_/\_\ ║
49
+ ║ ║
50
+ ║ Clone your workstation to an isolated VM ║
51
+ ╚═══════════════════════════════════════════════════════╝
52
+ ```
53
+ **Clone your workstation environment to an isolated VM with selective apps, paths and services.**
54
+
55
+ CloneBox lets you create isolated virtual machines with only the applications, directories and services you need - using bind mounts instead of full disk cloning. Perfect for development, testing, or creating reproducible environments.
56
+
57
+ ## Features
58
+
59
+ - 🎯 **Selective cloning** - Choose exactly which paths, services and apps to include
60
+ - 🔍 **Auto-detection** - Automatically detects running services, applications, and project directories
61
+ - 🔗 **Bind mounts** - Share directories with the VM without copying data
62
+ - ☁️ **Cloud-init** - Automatic package installation and service setup
63
+ - 🖥️ **GUI support** - SPICE graphics with virt-viewer integration
64
+ - ⚡ **Fast creation** - No full disk cloning, VMs are ready in seconds
65
+
66
+ ## Installation
67
+
68
+ ### Quick Setup (Recommended)
69
+
70
+ Run the setup script to automatically install dependencies and configure the environment:
71
+
72
+ ```bash
73
+ # Clone the repository
74
+ git clone https://github.com/wronai/clonebox.git
75
+ cd clonebox
76
+
77
+ # Run the setup script
78
+ ./setup.sh
79
+ ```
80
+
81
+ The setup script will:
82
+ - Install all required packages (QEMU, libvirt, Python, etc.)
83
+ - Add your user to the necessary groups
84
+ - Configure libvirt networks
85
+ - Install clonebox in development mode
86
+
87
+ ### Manual Installation
88
+
89
+ #### Prerequisites
90
+
91
+ ```bash
92
+ # Install libvirt and QEMU/KVM
93
+ sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager virt-viewer
94
+
95
+ # Enable and start libvirtd
96
+ sudo systemctl enable --now libvirtd
97
+
98
+ # Add user to libvirt group
99
+ sudo usermod -aG libvirt $USER
100
+ newgrp libvirt
101
+
102
+ # Install genisoimage for cloud-init
103
+ sudo apt install genisoimage
104
+ ```
105
+
106
+ #### Install CloneBox
107
+
108
+ ```bash
109
+ # From source
110
+ git clone https://github.com/wronai/clonebox.git
111
+ cd clonebox
112
+ pip install -e .
113
+
114
+ # Or directly
115
+ pip install clonebox
116
+ ```
117
+ lub
118
+ ```bash
119
+ # Aktywuj venv
120
+ source .venv/bin/activate
121
+
122
+ # Interaktywny tryb (wizard)
123
+ clonebox
124
+
125
+ # Lub poszczególne komendy
126
+ clonebox detect # Pokaż wykryte usługi/apps/ścieżki
127
+ clonebox list # Lista VM
128
+ clonebox create --config ... # Utwórz VM z JSON config
129
+ clonebox start <name> # Uruchom VM
130
+ clonebox stop <name> # Zatrzymaj VM
131
+ clonebox delete <name> # Usuń VM
132
+ ```
133
+
134
+ ## Quick Start
135
+
136
+ ### Interactive Mode (Recommended)
137
+
138
+ Simply run `clonebox` to start the interactive wizard:
139
+
140
+ ```bash
141
+ clonebox
142
+ ```
143
+
144
+ The wizard will:
145
+ 1. Detect running services (Docker, PostgreSQL, nginx, etc.)
146
+ 2. Detect running applications and their working directories
147
+ 3. Detect project directories and config files
148
+ 4. Let you select what to include in the VM
149
+ 5. Create and optionally start the VM
150
+
151
+ ### Command Line
152
+
153
+ ```bash
154
+ # Create VM with specific config
155
+ clonebox create --name my-dev-vm --config '{
156
+ "paths": {
157
+ "/home/user/projects": "/mnt/projects",
158
+ "/home/user/.config": "/mnt/config"
159
+ },
160
+ "packages": ["python3", "nodejs", "docker.io"],
161
+ "services": ["docker"]
162
+ }' --ram 4096 --vcpus 4 --start
163
+
164
+ # List VMs
165
+ clonebox list
166
+
167
+ # Start/Stop VM
168
+ clonebox start my-dev-vm
169
+ clonebox stop my-dev-vm
170
+
171
+ # Delete VM
172
+ clonebox delete my-dev-vm
173
+
174
+ # Detect system state (useful for scripting)
175
+ clonebox detect --json
176
+ ```
177
+
178
+ ## Usage Examples
179
+
180
+ ### Python Development Environment
181
+
182
+ ```bash
183
+ clonebox create --name python-dev --config '{
184
+ "paths": {
185
+ "/home/user/my-python-project": "/workspace",
186
+ "/home/user/.pyenv": "/root/.pyenv"
187
+ },
188
+ "packages": ["python3", "python3-pip", "python3-venv", "build-essential"],
189
+ "services": []
190
+ }' --ram 2048 --start
191
+ ```
192
+
193
+ ### Docker Development
194
+
195
+ ```bash
196
+ clonebox create --name docker-dev --config '{
197
+ "paths": {
198
+ "/home/user/docker-projects": "/projects",
199
+ "/var/run/docker.sock": "/var/run/docker.sock"
200
+ },
201
+ "packages": ["docker.io", "docker-compose"],
202
+ "services": ["docker"]
203
+ }' --ram 4096 --start
204
+ ```
205
+
206
+ ### Full Stack (Node.js + PostgreSQL)
207
+
208
+ ```bash
209
+ clonebox create --name fullstack --config '{
210
+ "paths": {
211
+ "/home/user/my-app": "/app",
212
+ "/home/user/pgdata": "/var/lib/postgresql/data"
213
+ },
214
+ "packages": ["nodejs", "npm", "postgresql"],
215
+ "services": ["postgresql"]
216
+ }' --ram 4096 --vcpus 4 --start
217
+ ```
218
+
219
+ ## Inside the VM
220
+
221
+ After the VM boots, mount shared directories:
222
+
223
+ ```bash
224
+ # Mount shared paths (9p filesystem)
225
+ sudo mkdir -p /mnt/projects
226
+ sudo mount -t 9p -o trans=virtio,version=9p2000.L mount0 /mnt/projects
227
+
228
+ # Or add to /etc/fstab for permanent mount
229
+ echo "mount0 /mnt/projects 9p trans=virtio,version=9p2000.L 0 0" | sudo tee -a /etc/fstab
230
+ ```
231
+
232
+ ## Architecture
233
+
234
+ ```
235
+ ┌────────────────────────────────────────────────────────┐
236
+ │ HOST SYSTEM │
237
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
238
+ │ │ /home/user/ │ │ /var/www/ │ │ Docker │ │
239
+ │ │ projects/ │ │ html/ │ │ Socket │ │
240
+ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
241
+ │ │ │ │ │
242
+ │ │ 9p/virtio │ │ │
243
+ │ │ bind mounts │ │ │
244
+ │ ┌──────▼─────────────────▼─────────────────▼───────┐ │
245
+ │ │ CloneBox VM │ │
246
+ │ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ │
247
+ │ │ │ /mnt/proj │ │ /mnt/www │ │ /var/run/ │ │ │
248
+ │ │ │ │ │ │ │ docker.sock│ │ │
249
+ │ │ └────────────┘ └────────────┘ └────────────┘ │ │
250
+ │ │ │ │
251
+ │ │ cloud-init installed packages & services │ │
252
+ │ └──────────────────────────────────────────────────┘ │
253
+ └────────────────────────────────────────────────────────┘
254
+ ```
255
+
256
+ ## Quick Clone (Recommended)
257
+
258
+ The fastest way to clone your current working directory:
259
+
260
+ ```bash
261
+ # Clone current directory - generates .clonebox.yaml and asks to create VM
262
+ clonebox clone .
263
+
264
+ # Clone specific path
265
+ clonebox clone ~/projects/my-app
266
+
267
+ # Clone with custom name and auto-start
268
+ clonebox clone ~/projects/my-app --name my-dev-vm --run
269
+
270
+ # Clone and edit config before creating
271
+ clonebox clone . --edit
272
+ ```
273
+
274
+ Later, start the VM from any directory with `.clonebox.yaml`:
275
+
276
+ ```bash
277
+ # Start VM from config in current directory
278
+ clonebox start .
279
+
280
+ # Start VM from specific path
281
+ clonebox start ~/projects/my-app
282
+ ```
283
+
284
+ ### Export YAML Config
285
+
286
+ ```bash
287
+ # Export detected state as YAML (with deduplication)
288
+ clonebox detect --yaml --dedupe
289
+
290
+ # Save to file
291
+ clonebox detect --yaml --dedupe -o my-config.yaml
292
+ ```
293
+
294
+ ## Commands Reference
295
+
296
+ | Command | Description |
297
+ |---------|-------------|
298
+ | `clonebox` | Interactive VM creation wizard |
299
+ | `clonebox clone <path>` | Generate `.clonebox.yaml` from path + running processes |
300
+ | `clonebox clone . --run` | Clone and immediately start VM |
301
+ | `clonebox clone . --edit` | Clone, edit config, then create |
302
+ | `clonebox start .` | Start VM from `.clonebox.yaml` in current dir |
303
+ | `clonebox start <name>` | Start existing VM by name |
304
+ | `clonebox stop <name>` | Stop a VM (graceful shutdown) |
305
+ | `clonebox stop -f <name>` | Force stop a VM |
306
+ | `clonebox delete <name>` | Delete VM and storage |
307
+ | `clonebox list` | List all VMs |
308
+ | `clonebox detect` | Show detected services/apps/paths |
309
+ | `clonebox detect --yaml` | Output as YAML config |
310
+ | `clonebox detect --yaml --dedupe` | YAML with duplicates removed |
311
+ | `clonebox detect --json` | Output as JSON |
312
+
313
+ ## Requirements
314
+
315
+ - Linux with KVM support (`/dev/kvm`)
316
+ - libvirt daemon running
317
+ - Python 3.8+
318
+ - User in `libvirt` group
319
+
320
+ ## Troubleshooting
321
+
322
+ ### Network Issues
323
+
324
+ If you encounter "Network not found" or "network 'default' is not active" errors:
325
+
326
+ ```bash
327
+ # Run the network fix script
328
+ ./fix-network.sh
329
+
330
+ # Or manually fix:
331
+ virsh --connect qemu:///session net-destroy default 2>/dev/null
332
+ virsh --connect qemu:///session net-undefine default 2>/dev/null
333
+ virsh --connect qemu:///session net-define /tmp/default-network.xml
334
+ virsh --connect qemu:///session net-start default
335
+ ```
336
+
337
+ ### Permission Issues
338
+
339
+ If you get permission errors:
340
+
341
+ ```bash
342
+ # Ensure user is in libvirt and kvm groups
343
+ sudo usermod -aG libvirt $USER
344
+ sudo usermod -aG kvm $USER
345
+
346
+ # Log out and log back in for groups to take effect
347
+ ```
348
+
349
+ ### VM Already Exists
350
+
351
+ If you get "domain already exists" error:
352
+
353
+ ```bash
354
+ # List VMs
355
+ clonebox list
356
+
357
+ # Stop and delete the existing VM
358
+ clonebox delete <vm-name>
359
+
360
+ # Or use virsh directly
361
+ virsh --connect qemu:///session destroy <vm-name>
362
+ virsh --connect qemu:///session undefine <vm-name>
363
+ ```
364
+
365
+ ### virt-viewer not found
366
+
367
+ If GUI doesn't open:
368
+
369
+ ```bash
370
+ # Install virt-viewer
371
+ sudo apt install virt-viewer
372
+
373
+ # Then connect manually
374
+ virt-viewer --connect qemu:///session <vm-name>
375
+ ```
376
+
377
+ ## License
378
+
379
+ MIT License - see [LICENSE](LICENSE) file.