clonebox 1.1.11__tar.gz → 1.1.13__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.
Files changed (59) hide show
  1. {clonebox-1.1.11/src/clonebox.egg-info → clonebox-1.1.13}/PKG-INFO +1 -1
  2. {clonebox-1.1.11 → clonebox-1.1.13}/pyproject.toml +1 -1
  3. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/cli.py +35 -13
  4. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/cloner.py +18 -10
  5. {clonebox-1.1.11 → clonebox-1.1.13/src/clonebox.egg-info}/PKG-INFO +1 -1
  6. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_cloner.py +36 -1
  7. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_network.py +10 -34
  8. {clonebox-1.1.11 → clonebox-1.1.13}/LICENSE +0 -0
  9. {clonebox-1.1.11 → clonebox-1.1.13}/README.md +0 -0
  10. {clonebox-1.1.11 → clonebox-1.1.13}/setup.cfg +0 -0
  11. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/__init__.py +0 -0
  12. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/__main__.py +0 -0
  13. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/backends/libvirt_backend.py +0 -0
  14. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/backends/qemu_disk.py +0 -0
  15. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/backends/subprocess_runner.py +0 -0
  16. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/container.py +0 -0
  17. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/dashboard.py +0 -0
  18. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/detector.py +0 -0
  19. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/di.py +0 -0
  20. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/exporter.py +0 -0
  21. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/health/__init__.py +0 -0
  22. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/health/manager.py +0 -0
  23. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/health/models.py +0 -0
  24. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/health/probes.py +0 -0
  25. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/importer.py +0 -0
  26. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/interfaces/disk.py +0 -0
  27. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/interfaces/hypervisor.py +0 -0
  28. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/interfaces/network.py +0 -0
  29. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/interfaces/process.py +0 -0
  30. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/logging.py +0 -0
  31. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/models.py +0 -0
  32. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/monitor.py +0 -0
  33. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/p2p.py +0 -0
  34. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/profiles.py +0 -0
  35. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/resource_monitor.py +0 -0
  36. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/resources.py +0 -0
  37. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/rollback.py +0 -0
  38. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/secrets.py +0 -0
  39. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/snapshots/__init__.py +0 -0
  40. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/snapshots/manager.py +0 -0
  41. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/snapshots/models.py +0 -0
  42. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/templates/profiles/ml-dev.yaml +0 -0
  43. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/templates/profiles/web-stack.yaml +0 -0
  44. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox/validator.py +0 -0
  45. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox.egg-info/SOURCES.txt +0 -0
  46. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox.egg-info/dependency_links.txt +0 -0
  47. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox.egg-info/entry_points.txt +0 -0
  48. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox.egg-info/requires.txt +0 -0
  49. {clonebox-1.1.11 → clonebox-1.1.13}/src/clonebox.egg-info/top_level.txt +0 -0
  50. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_cli.py +0 -0
  51. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_cloner_simple.py +0 -0
  52. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_container.py +0 -0
  53. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_coverage_additional.py +0 -0
  54. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_coverage_boost_final.py +0 -0
  55. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_dashboard_coverage.py +0 -0
  56. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_detector.py +0 -0
  57. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_models.py +0 -0
  58. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_profiles.py +0 -0
  59. {clonebox-1.1.11 → clonebox-1.1.13}/tests/test_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clonebox
3
- Version: 1.1.11
3
+ Version: 1.1.13
4
4
  Summary: Clone your workstation environment to an isolated VM with selective apps, paths and services
5
5
  Author: CloneBox Team
6
6
  License: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "clonebox"
7
- version = "1.1.11"
7
+ version = "1.1.13"
8
8
  description = "Clone your workstation environment to an isolated VM with selective apps, paths and services"
9
9
  readme = "README.md"
10
10
  license = {text = "Apache-2.0"}
@@ -1825,23 +1825,37 @@ def cmd_test(args):
1825
1825
  # Test 4: Check mounts (if running)
1826
1826
  if not quick and state == "running":
1827
1827
  console.print("[bold]4. Mount Points Check[/]")
1828
- all_paths = config.get("paths", {}).copy()
1829
- all_paths.update(config.get("app_data_paths", {}))
1828
+ paths = config.get("paths", {})
1829
+ app_data_paths = config.get("app_data_paths", {})
1830
1830
 
1831
- if all_paths:
1831
+ if paths or app_data_paths:
1832
1832
  if not _qga_ping(vm_name, conn_uri):
1833
1833
  console.print("[yellow]⚠️ QEMU guest agent not connected - cannot verify mounts[/]")
1834
1834
  else:
1835
- for idx, (host_path, guest_path) in enumerate(all_paths.items()):
1835
+ # Check bind mounts
1836
+ for idx, (host_path, guest_path) in enumerate(paths.items()):
1836
1837
  try:
1837
1838
  # Use the same QGA helper as diagnose/status
1838
1839
  is_accessible = _qga_exec(
1839
1840
  vm_name, conn_uri, f"test -d {guest_path} && echo yes || echo no", timeout=5
1840
1841
  )
1841
1842
  if is_accessible == "yes":
1842
- console.print(f"[green]✅ {guest_path}[/]")
1843
+ console.print(f"[green]✅ {guest_path} (mount)[/]")
1844
+ else:
1845
+ console.print(f"[red]❌ {guest_path} (mount inaccessible)[/]")
1846
+ except Exception:
1847
+ console.print(f"[yellow]⚠️ {guest_path} (could not check)[/]")
1848
+
1849
+ # Check copied paths
1850
+ for idx, (host_path, guest_path) in enumerate(app_data_paths.items()):
1851
+ try:
1852
+ is_accessible = _qga_exec(
1853
+ vm_name, conn_uri, f"test -d {guest_path} && echo yes || echo no", timeout=5
1854
+ )
1855
+ if is_accessible == "yes":
1856
+ console.print(f"[green]✅ {guest_path} (copied)[/]")
1843
1857
  else:
1844
- console.print(f"[red]❌ {guest_path} (not accessible)[/]")
1858
+ console.print(f"[red]❌ {guest_path} (copy missing)[/]")
1845
1859
  except Exception:
1846
1860
  console.print(f"[yellow]⚠️ {guest_path} (could not check)[/]")
1847
1861
  else:
@@ -2521,14 +2535,22 @@ def cmd_clone(args):
2521
2535
  console.print(" [cyan]clonebox-health[/] # Re-run health check")
2522
2536
 
2523
2537
  # Show mount instructions
2524
- all_paths = config.get("paths", {}).copy()
2525
- all_paths.update(config.get("app_data_paths", {}))
2526
- if all_paths:
2527
- console.print("\n[bold]📁 Mounted paths (automatic):[/]")
2528
- for idx, (host, guest) in enumerate(list(all_paths.items())[:5]):
2538
+ paths = config.get("paths", {})
2539
+ app_data_paths = config.get("app_data_paths", {})
2540
+
2541
+ if paths:
2542
+ console.print("\n[bold]📁 Mounted paths (shared live):[/]")
2543
+ for idx, (host, guest) in enumerate(list(paths.items())[:5]):
2544
+ console.print(f" [dim]{host}[/] → [cyan]{guest}[/]")
2545
+ if len(paths) > 5:
2546
+ console.print(f" [dim]... and {len(paths) - 5} more paths[/]")
2547
+
2548
+ if app_data_paths:
2549
+ console.print("\n[bold]📥 Copied paths (one-time import):[/]")
2550
+ for idx, (host, guest) in enumerate(list(app_data_paths.items())[:5]):
2529
2551
  console.print(f" [dim]{host}[/] → [cyan]{guest}[/]")
2530
- if len(all_paths) > 5:
2531
- console.print(f" [dim]... and {len(all_paths) - 5} more paths[/]")
2552
+ if len(app_data_paths) > 5:
2553
+ console.print(f" [dim]... and {len(app_data_paths) - 5} more paths[/]")
2532
2554
  except PermissionError as e:
2533
2555
  console.print(f"[red]❌ Permission Error:[/]\n{e}")
2534
2556
  console.print("\n[yellow]💡 Try running with --user flag:[/]")
@@ -263,13 +263,21 @@ class SelectiveVMCloner:
263
263
 
264
264
  return cached_path
265
265
 
266
- def _default_network_active(self) -> bool:
267
- """Check if libvirt default network is active."""
266
+ def _default_network_state(self) -> str:
268
267
  try:
269
- net = self.conn.networkLookupByName("default")
270
- return net.isActive() == 1
268
+ active = self.conn.listNetworks() or []
269
+ if "default" in active:
270
+ return "active"
271
+ defined = self.conn.listDefinedNetworks() or []
272
+ if "default" in defined:
273
+ return "inactive"
274
+ return "missing"
271
275
  except Exception:
272
- return False
276
+ return "unknown"
277
+
278
+ def _default_network_active(self) -> bool:
279
+ """Check if libvirt default network is active."""
280
+ return self._default_network_state() == "active"
273
281
 
274
282
  def resolve_network_mode(self, config: VMConfig) -> str:
275
283
  """Resolve network mode based on config and session type."""
@@ -310,10 +318,9 @@ class SelectiveVMCloner:
310
318
  )
311
319
 
312
320
  # Check default network
313
- try:
314
- net = self.conn.networkLookupByName("default")
315
- checks["default_network"] = net.isActive() == 1
316
- except libvirt.libvirtError:
321
+ default_net_state = self._default_network_state()
322
+ checks["default_network"] = default_net_state == "active"
323
+ if default_net_state in {"inactive", "missing", "unknown"}:
317
324
  checks["network_error"] = (
318
325
  "Default network not found or inactive.\n"
319
326
  " For user session, CloneBox can use user-mode networking (slirp) automatically.\n"
@@ -1404,7 +1411,8 @@ fi
1404
1411
  " - chown -R 1000:1000 /home/ubuntu/.config /home/ubuntu/.cache /home/ubuntu/.local",
1405
1412
  " - chmod 700 /home/ubuntu/.config /home/ubuntu/.cache",
1406
1413
  " - systemctl set-default graphical.target",
1407
- " - systemctl enable gdm3 || systemctl enable gdm || true",
1414
+ " - systemctl enable --now gdm3 || systemctl enable --now gdm || true",
1415
+ " - systemctl start display-manager || true",
1408
1416
  ]
1409
1417
  )
1410
1418
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clonebox
3
- Version: 1.1.11
3
+ Version: 1.1.13
4
4
  Summary: Clone your workstation environment to an isolated VM with selective apps, paths and services
5
5
  Author: CloneBox Team
6
6
  License: Apache-2.0
@@ -167,7 +167,8 @@ class TestSelectiveVMClonerMethods:
167
167
  def test_check_prerequisites_returns_dict(self, mock_libvirt):
168
168
  mock_conn = MagicMock()
169
169
  mock_conn.isAlive.return_value = True
170
- mock_conn.networkLookupByName.return_value.isActive.return_value = 1
170
+ mock_conn.listNetworks.return_value = ["default"]
171
+ mock_conn.listDefinedNetworks.return_value = []
171
172
  mock_libvirt.open.return_value = mock_conn
172
173
  mock_libvirt.openAuth.return_value = mock_conn
173
174
 
@@ -272,6 +273,40 @@ class TestVMXMLGeneration:
272
273
  assert "filesystem" in xml
273
274
  assert "mount" in xml
274
275
 
276
+ @patch("clonebox.cloner.libvirt")
277
+ def test_generate_vm_xml_tuning_exclusion(self, mock_libvirt):
278
+ """Test that resource tuning elements are excluded in user session mode."""
279
+ mock_libvirt.open.return_value = MagicMock()
280
+ mock_libvirt.openAuth.return_value = MagicMock()
281
+
282
+ # 1. Test User Session (Should exclude tuning)
283
+ cloner_user = SelectiveVMCloner(user_session=True)
284
+ config = VMConfig(
285
+ name="test-vm",
286
+ ram_mb=2048,
287
+ vcpus=2,
288
+ resources={
289
+ "cpu": {"shares": 1024, "quota": 10000},
290
+ "memory": {"soft_limit": "1G"},
291
+ "disk": {"read_bps": "10M"},
292
+ }
293
+ )
294
+
295
+ xml_user = cloner_user._generate_vm_xml(config, Path("/tmp/root.qcow2"), None)
296
+
297
+ assert "cputune" not in xml_user
298
+ assert "memtune" not in xml_user
299
+ assert "iotune" not in xml_user
300
+
301
+ # 2. Test System Session (Should include tuning)
302
+ cloner_system = SelectiveVMCloner(user_session=False)
303
+
304
+ xml_system = cloner_system._generate_vm_xml(config, Path("/tmp/root.qcow2"), None)
305
+
306
+ assert "cputune" in xml_system
307
+ assert "memtune" in xml_system
308
+ assert "iotune" in xml_system
309
+
275
310
 
276
311
  class TestVMCreation:
277
312
  """Test VM creation (with mocked libvirt)."""
@@ -54,10 +54,8 @@ class TestNetworkMode:
54
54
  mock_conn = MagicMock()
55
55
  mock_libvirt.open.return_value = mock_conn
56
56
  mock_libvirt.openAuth.return_value = mock_conn
57
- mock_net = MagicMock()
58
- mock_net.isActive.return_value = 1
59
- mock_conn.networkLookupByName.return_value = mock_net
60
- mock_libvirt.open.return_value = mock_conn
57
+ mock_conn.listNetworks.return_value = ["default"]
58
+ mock_conn.listDefinedNetworks.return_value = []
61
59
 
62
60
  cloner = SelectiveVMCloner(user_session=True)
63
61
  config = VMConfig(network_mode="auto")
@@ -68,18 +66,9 @@ class TestNetworkMode:
68
66
  @patch("clonebox.cloner.libvirt")
69
67
  def test_resolve_network_mode_auto_user_no_default(self, mock_libvirt):
70
68
  """Test auto mode with user session and no default network falls back to user."""
71
- # Handle missing libvirt module in test environment
72
- try:
73
- import libvirt as real_libvirt
74
-
75
- libvirt_error = real_libvirt.libvirtError
76
- except ImportError:
77
-
78
- class libvirt_error(Exception):
79
- pass
80
-
81
69
  mock_conn = MagicMock()
82
- mock_conn.networkLookupByName.side_effect = libvirt_error("No network")
70
+ mock_conn.listNetworks.return_value = []
71
+ mock_conn.listDefinedNetworks.return_value = []
83
72
  mock_libvirt.open.return_value = mock_conn
84
73
  mock_libvirt.openAuth.return_value = mock_conn
85
74
 
@@ -134,10 +123,8 @@ class TestNetworkMode:
134
123
  mock_conn = MagicMock()
135
124
  mock_libvirt.open.return_value = mock_conn
136
125
  mock_libvirt.openAuth.return_value = mock_conn
137
- mock_net = MagicMock()
138
- mock_net.isActive.return_value = 1
139
- mock_conn.networkLookupByName.return_value = mock_net
140
- mock_libvirt.open.return_value = mock_conn
126
+ mock_conn.listNetworks.return_value = ["default"]
127
+ mock_conn.listDefinedNetworks.return_value = []
141
128
 
142
129
  cloner = SelectiveVMCloner()
143
130
  assert cloner._default_network_active() is True
@@ -149,10 +136,8 @@ class TestNetworkMode:
149
136
  mock_conn = MagicMock()
150
137
  mock_libvirt.open.return_value = mock_conn
151
138
  mock_libvirt.openAuth.return_value = mock_conn
152
- mock_net = MagicMock()
153
- mock_net.isActive.return_value = 0
154
- mock_conn.networkLookupByName.return_value = mock_net
155
- mock_libvirt.open.return_value = mock_conn
139
+ mock_conn.listNetworks.return_value = []
140
+ mock_conn.listDefinedNetworks.return_value = ["default"]
156
141
 
157
142
  cloner = SelectiveVMCloner()
158
143
  assert cloner._default_network_active() is False
@@ -160,18 +145,9 @@ class TestNetworkMode:
160
145
  @patch("clonebox.cloner.libvirt")
161
146
  def test_default_network_active_not_found(self, mock_libvirt):
162
147
  """Test _default_network_active returns False when network not found."""
163
- # Handle missing libvirt module in test environment
164
- try:
165
- import libvirt as real_libvirt
166
-
167
- libvirt_error = real_libvirt.libvirtError
168
- except ImportError:
169
-
170
- class libvirt_error(Exception):
171
- pass
172
-
173
148
  mock_conn = MagicMock()
174
- mock_conn.networkLookupByName.side_effect = libvirt_error("Not found")
149
+ mock_conn.listNetworks.return_value = []
150
+ mock_conn.listDefinedNetworks.return_value = []
175
151
  mock_libvirt.open.return_value = mock_conn
176
152
  mock_libvirt.openAuth.return_value = mock_conn
177
153
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes