This repository was archived by the owner on Mar 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexamples.py
More file actions
93 lines (79 loc) · 2.47 KB
/
examples.py
File metadata and controls
93 lines (79 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import asyncio
from pylume import (
PyLume,
ImageRef,
VMRunOpts,
SharedDirectory,
VMConfig,
VMUpdateOpts
)
async def main():
"""Example usage of PyLume."""
async with PyLume(port=3000, use_existing_server=False) as pylume:
# Create a new VM
print("\n=== Creating a new VM ===")
vm_config = VMConfig(
name="lume-vm-new",
os="macOS",
cpu=2,
memory="4GB",
disk_size="64GB",
display="1024x768",
ipsw="latest"
)
await pylume.create_vm(vm_config)
# Get latest IPSW URL
print("\n=== Getting Latest IPSW URL ===")
url = await pylume.get_latest_ipsw_url()
print("Latest IPSW URL:", url)
# List available images
print("\n=== Listing Available Images ===")
images = await pylume.get_images()
print("Available Images:", images)
# List all VMs to verify creation
print("\n=== Listing All VMs ===")
vms = await pylume.list_vms()
print("VMs:", vms)
# Get specific VM details
print("\n=== Getting VM Details ===")
vm = await pylume.get_vm("lume-vm")
print("VM Details:", vm)
# Update VM settings
print("\n=== Updating VM Settings ===")
update_opts = VMUpdateOpts(
cpu=8,
memory="4GB"
)
await pylume.update_vm("lume-vm", update_opts)
# Pull an image
image_ref = ImageRef(
image="macos-sequoia-vanilla",
tag="latest",
registry="ghcr.io",
organization="trycua"
)
await pylume.pull_image(image_ref, name="lume-vm-pulled")
# Run with shared directory
run_opts = VMRunOpts(
no_display=False,
shared_directories=[
SharedDirectory(
host_path="/Users/<USER>/shared",
read_only=False
)
]
)
await pylume.run_vm("lume-vm", run_opts)
# Or simpler:
await pylume.run_vm("lume-vm")
# Clone VM
print("\n=== Cloning VM ===")
await pylume.clone_vm("lume-vm", "lume-vm-cloned")
# Stop VM
print("\n=== Stopping VM ===")
await pylume.stop_vm("lume_vm")
# Delete VM
print("\n=== Deleting VM ===")
await pylume.delete_vm("lume_vm_cloned")
if __name__ == '__main__':
asyncio.run(main())