request-vm-on-golem 0.1.0__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,296 @@
1
+ Metadata-Version: 2.1
2
+ Name: request-vm-on-golem
3
+ Version: 0.1.0
4
+ Summary: VM on Golem Requestor CLI - Create and manage virtual machines on the Golem Network
5
+ Home-page: https://github.com/cryptobench/vm-on-golem
6
+ Keywords: golem,vm,cloud,decentralized,cli
7
+ Author: Phillip Jensen
8
+ Author-email: phillip+vm-on-golem@golemgrid.com
9
+ Requires-Python: >=3.9,<4.0
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: System :: Distributed Computing
22
+ Classifier: Topic :: System :: Systems Administration
23
+ Requires-Dist: aiohttp (>=3.7.4,<4.0.0)
24
+ Requires-Dist: aiosqlite (>=0.17.0,<0.18.0)
25
+ Requires-Dist: asyncssh (>=2.7.0,<3.0.0)
26
+ Requires-Dist: click (>=8.0.1,<9.0.0)
27
+ Requires-Dist: colorlog (>=6.7.0,<7.0.0)
28
+ Requires-Dist: cryptography (>=3.4.7,<4.0.0)
29
+ Requires-Dist: pydantic (>=1.8.2,<2.0.0)
30
+ Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
31
+ Requires-Dist: tabulate (>=0.9.0,<0.10.0)
32
+ Project-URL: Repository, https://github.com/cryptobench/vm-on-golem
33
+ Description-Content-Type: text/markdown
34
+
35
+ # VM on Golem Requestor
36
+
37
+ A sophisticated command-line interface for managing virtual machines on the Golem Network. The requestor works in tandem with provider nodes to create and manage VMs with secure SSH access.
38
+
39
+ ## Architecture Overview
40
+
41
+ ```mermaid
42
+ graph TB
43
+ subgraph Requestor
44
+ CLI[CLI Interface]
45
+ DB[Local Database]
46
+ SSH[SSH Manager]
47
+ PC[Provider Client]
48
+ end
49
+
50
+ subgraph Provider
51
+ API[Provider API]
52
+ VM[VM Manager]
53
+ Proxy[SSH Proxy]
54
+ RT[Resource Tracker]
55
+ end
56
+
57
+ CLI --> PC
58
+ PC --> API
59
+ SSH --> Proxy
60
+ VM --> RT
61
+ ```
62
+
63
+ ## How It Works
64
+
65
+ ### 1. VM Creation Flow
66
+
67
+ ```mermaid
68
+ sequenceDiagram
69
+ participant User
70
+ participant CLI
71
+ participant SSH
72
+ participant Provider
73
+ participant VM
74
+
75
+ User->>CLI: Create VM Command
76
+ CLI->>SSH: Generate SSH Key
77
+ SSH-->>CLI: Key Pair
78
+ CLI->>Provider: Create VM Request + Public Key
79
+ Provider->>VM: Launch with Cloud-Init
80
+ Provider->>Proxy: Configure SSH Port
81
+ Provider-->>CLI: VM Details + Port
82
+ CLI->>DB: Save VM State
83
+ CLI-->>User: Connection Info
84
+ ```
85
+
86
+ When you create a VM:
87
+ 1. The requestor generates an SSH key pair or uses your system's existing keys
88
+ 2. The provider receives the public key and injects it during VM creation via cloud-init
89
+ 3. The provider allocates a dedicated port and configures SSH forwarding
90
+ 4. Connection details are stored locally for future access
91
+
92
+ ### 2. SSH Connection Flow
93
+
94
+ ```mermaid
95
+ sequenceDiagram
96
+ participant User
97
+ participant CLI
98
+ participant DB
99
+ participant Proxy
100
+ participant VM
101
+
102
+ User->>CLI: SSH Command
103
+ CLI->>DB: Get VM Details
104
+ DB-->>CLI: Connection Info
105
+ CLI->>Proxy: SSH Connection
106
+ Proxy->>VM: Forward Connection
107
+ VM-->>User: Interactive Shell
108
+ ```
109
+
110
+ The SSH connection process:
111
+ 1. The CLI retrieves stored VM details from the local database
112
+ 2. The provider's proxy system forwards your SSH connection to the VM
113
+ 3. All traffic is securely routed through the allocated port
114
+
115
+ ## Installation
116
+
117
+ ```bash
118
+ # Install using pip
119
+ pip install golem-vm-requestor
120
+
121
+ # Or install from source
122
+ git clone https://github.com/golem/vm-on-golem.git
123
+ cd vm-on-golem/requestor-server
124
+ pip install -e .
125
+ ```
126
+
127
+ ## Usage
128
+
129
+ ### Provider Discovery
130
+
131
+ List available providers with their resources:
132
+
133
+ ```bash
134
+ golem vm providers
135
+ ```
136
+
137
+ Example output:
138
+ ```
139
+ ────────────────────────────────────────────────
140
+ 🌍 Available Providers (3 total)
141
+ ────────────────────────────────────────────────
142
+ Provider ID Country CPU Memory Storage
143
+ provider-1 🌍 SE 💻 4 🧠 8GB 💾 40GB
144
+ provider-2 🌍 US 💻 8 🧠 16GB 💾 80GB
145
+ provider-3 🌍 DE 💻 2 🧠 4GB 💾 20GB
146
+ ────────────────────────────────────────────────
147
+ ```
148
+
149
+ ### Creating a VM
150
+
151
+ ```bash
152
+ golem vm create my-webserver --provider-id provider-1 --cpu 2 --memory 4 --storage 20
153
+ ```
154
+
155
+ The system will:
156
+ 1. Verify provider availability
157
+ 2. Check resource requirements
158
+ 3. Set up SSH access
159
+ 4. Deploy and configure the VM
160
+ 5. Save connection details locally
161
+
162
+ Example output:
163
+ ```
164
+ ────────────────────────────────────────────────
165
+ 🎉 VM Deployed Successfully!
166
+ ────────────────────────────────────────────────
167
+
168
+ VM Details
169
+ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
170
+ 🏷️ Name : my-webserver
171
+ 💻 Resources : 2 CPU, 4GB RAM, 20GB Storage
172
+ 🟢 Status : running
173
+
174
+ Connection Details
175
+ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
176
+ 🌐 IP Address : 192.168.1.100
177
+ 🔌 Port : 50800
178
+
179
+ Quick Connect
180
+ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
181
+ 🔑 SSH Command : ssh -i ~/.golem/ssh/id_rsa -p 50800 ubuntu@192.168.1.100
182
+ ────────────────────────────────────────────────
183
+ ```
184
+
185
+ ### Managing VMs
186
+
187
+ List your VMs:
188
+ ```bash
189
+ golem vm list
190
+ ```
191
+
192
+ Example output:
193
+ ```
194
+ ────────────────────────────────────────────────
195
+ 📋 Your VMs (2 total)
196
+ ────────────────────────────────────────────────
197
+ Name Status IP Address Resources
198
+ my-webserver ● running 192.168.1.100 2 CPU, 4GB RAM
199
+ my-database ● stopped 192.168.1.101 4 CPU, 8GB RAM
200
+ ────────────────────────────────────────────────
201
+ ```
202
+
203
+ Other commands:
204
+ ```bash
205
+ # SSH into a VM
206
+ golem vm ssh my-webserver
207
+
208
+ # Stop a VM
209
+ golem vm stop my-webserver
210
+
211
+ # Start a VM
212
+ golem vm start my-webserver
213
+
214
+ # Destroy a VM
215
+ golem vm destroy my-webserver
216
+ ```
217
+
218
+ ## Configuration
219
+
220
+ The requestor uses a hierarchical configuration system:
221
+
222
+ 1. Environment Variables:
223
+ ```bash
224
+ # Discovery Service
225
+ export GOLEM_REQUESTOR_DISCOVERY_URL="http://discovery.golem.network:7465"
226
+
227
+ # Base Directory (default: ~/.golem)
228
+ export GOLEM_REQUESTOR_BASE_DIR="/path/to/golem/dir"
229
+
230
+ # Individual Paths (override base dir)
231
+ export GOLEM_REQUESTOR_SSH_KEY_DIR="/path/to/keys"
232
+ export GOLEM_REQUESTOR_DB_PATH="/path/to/database.db"
233
+
234
+ # Environment Mode
235
+ export GOLEM_REQUESTOR_ENVIRONMENT="production" # or "development"
236
+ ```
237
+
238
+ 2. Directory Structure:
239
+ ```
240
+ ~/.golem/
241
+ ├── ssh/ # SSH keys
242
+ │ ├── id_rsa # Private key
243
+ │ └── id_rsa.pub # Public key
244
+ └── vms.db # SQLite database
245
+ ```
246
+
247
+ ## Technical Details
248
+
249
+ ### SSH Key Management
250
+
251
+ The system intelligently handles SSH keys:
252
+ 1. Uses existing system SSH keys if available
253
+ 2. Generates and manages Golem-specific keys if needed
254
+ 3. Ensures proper key permissions (0600 for private, 0644 for public)
255
+ 4. Supports key reuse across VMs
256
+
257
+ ### State Management
258
+
259
+ Local state is maintained in SQLite:
260
+ - VM details and configuration
261
+ - Provider information
262
+ - Connection parameters
263
+ - VM status tracking
264
+
265
+ ### Provider Integration
266
+
267
+ The requestor communicates with providers through:
268
+ 1. Discovery service for provider location
269
+ 2. Direct API calls for VM management
270
+ 3. SSH proxy system for secure access
271
+ 4. Resource tracking for capacity management
272
+
273
+ ## Error Handling
274
+
275
+ The system provides clear error messages and recovery steps:
276
+
277
+ ```
278
+ Error: Unable to establish SSH connection (VM may be starting up)
279
+ Solution: Wait a few moments and try again. The VM is likely still initializing.
280
+
281
+ Error: Provider is no longer available (they may have gone offline)
282
+ Solution: Choose a different provider or wait for the original to come back online.
283
+
284
+ Error: VM not found in local database
285
+ Solution: The VM may have been manually removed. Use 'golem vm list' to see available VMs.
286
+ ```
287
+
288
+ ## Contributing
289
+
290
+ 1. Fork the repository
291
+ 2. Create a feature branch
292
+ 3. Make your changes
293
+ 4. Run the tests
294
+ 5. Submit a pull request
295
+
296
+
@@ -0,0 +1,261 @@
1
+ # VM on Golem Requestor
2
+
3
+ A sophisticated command-line interface for managing virtual machines on the Golem Network. The requestor works in tandem with provider nodes to create and manage VMs with secure SSH access.
4
+
5
+ ## Architecture Overview
6
+
7
+ ```mermaid
8
+ graph TB
9
+ subgraph Requestor
10
+ CLI[CLI Interface]
11
+ DB[Local Database]
12
+ SSH[SSH Manager]
13
+ PC[Provider Client]
14
+ end
15
+
16
+ subgraph Provider
17
+ API[Provider API]
18
+ VM[VM Manager]
19
+ Proxy[SSH Proxy]
20
+ RT[Resource Tracker]
21
+ end
22
+
23
+ CLI --> PC
24
+ PC --> API
25
+ SSH --> Proxy
26
+ VM --> RT
27
+ ```
28
+
29
+ ## How It Works
30
+
31
+ ### 1. VM Creation Flow
32
+
33
+ ```mermaid
34
+ sequenceDiagram
35
+ participant User
36
+ participant CLI
37
+ participant SSH
38
+ participant Provider
39
+ participant VM
40
+
41
+ User->>CLI: Create VM Command
42
+ CLI->>SSH: Generate SSH Key
43
+ SSH-->>CLI: Key Pair
44
+ CLI->>Provider: Create VM Request + Public Key
45
+ Provider->>VM: Launch with Cloud-Init
46
+ Provider->>Proxy: Configure SSH Port
47
+ Provider-->>CLI: VM Details + Port
48
+ CLI->>DB: Save VM State
49
+ CLI-->>User: Connection Info
50
+ ```
51
+
52
+ When you create a VM:
53
+ 1. The requestor generates an SSH key pair or uses your system's existing keys
54
+ 2. The provider receives the public key and injects it during VM creation via cloud-init
55
+ 3. The provider allocates a dedicated port and configures SSH forwarding
56
+ 4. Connection details are stored locally for future access
57
+
58
+ ### 2. SSH Connection Flow
59
+
60
+ ```mermaid
61
+ sequenceDiagram
62
+ participant User
63
+ participant CLI
64
+ participant DB
65
+ participant Proxy
66
+ participant VM
67
+
68
+ User->>CLI: SSH Command
69
+ CLI->>DB: Get VM Details
70
+ DB-->>CLI: Connection Info
71
+ CLI->>Proxy: SSH Connection
72
+ Proxy->>VM: Forward Connection
73
+ VM-->>User: Interactive Shell
74
+ ```
75
+
76
+ The SSH connection process:
77
+ 1. The CLI retrieves stored VM details from the local database
78
+ 2. The provider's proxy system forwards your SSH connection to the VM
79
+ 3. All traffic is securely routed through the allocated port
80
+
81
+ ## Installation
82
+
83
+ ```bash
84
+ # Install using pip
85
+ pip install golem-vm-requestor
86
+
87
+ # Or install from source
88
+ git clone https://github.com/golem/vm-on-golem.git
89
+ cd vm-on-golem/requestor-server
90
+ pip install -e .
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ ### Provider Discovery
96
+
97
+ List available providers with their resources:
98
+
99
+ ```bash
100
+ golem vm providers
101
+ ```
102
+
103
+ Example output:
104
+ ```
105
+ ────────────────────────────────────────────────
106
+ 🌍 Available Providers (3 total)
107
+ ────────────────────────────────────────────────
108
+ Provider ID Country CPU Memory Storage
109
+ provider-1 🌍 SE 💻 4 🧠 8GB 💾 40GB
110
+ provider-2 🌍 US 💻 8 🧠 16GB 💾 80GB
111
+ provider-3 🌍 DE 💻 2 🧠 4GB 💾 20GB
112
+ ────────────────────────────────────────────────
113
+ ```
114
+
115
+ ### Creating a VM
116
+
117
+ ```bash
118
+ golem vm create my-webserver --provider-id provider-1 --cpu 2 --memory 4 --storage 20
119
+ ```
120
+
121
+ The system will:
122
+ 1. Verify provider availability
123
+ 2. Check resource requirements
124
+ 3. Set up SSH access
125
+ 4. Deploy and configure the VM
126
+ 5. Save connection details locally
127
+
128
+ Example output:
129
+ ```
130
+ ────────────────────────────────────────────────
131
+ 🎉 VM Deployed Successfully!
132
+ ────────────────────────────────────────────────
133
+
134
+ VM Details
135
+ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
136
+ 🏷️ Name : my-webserver
137
+ 💻 Resources : 2 CPU, 4GB RAM, 20GB Storage
138
+ 🟢 Status : running
139
+
140
+ Connection Details
141
+ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
142
+ 🌐 IP Address : 192.168.1.100
143
+ 🔌 Port : 50800
144
+
145
+ Quick Connect
146
+ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
147
+ 🔑 SSH Command : ssh -i ~/.golem/ssh/id_rsa -p 50800 ubuntu@192.168.1.100
148
+ ────────────────────────────────────────────────
149
+ ```
150
+
151
+ ### Managing VMs
152
+
153
+ List your VMs:
154
+ ```bash
155
+ golem vm list
156
+ ```
157
+
158
+ Example output:
159
+ ```
160
+ ────────────────────────────────────────────────
161
+ 📋 Your VMs (2 total)
162
+ ────────────────────────────────────────────────
163
+ Name Status IP Address Resources
164
+ my-webserver ● running 192.168.1.100 2 CPU, 4GB RAM
165
+ my-database ● stopped 192.168.1.101 4 CPU, 8GB RAM
166
+ ────────────────────────────────────────────────
167
+ ```
168
+
169
+ Other commands:
170
+ ```bash
171
+ # SSH into a VM
172
+ golem vm ssh my-webserver
173
+
174
+ # Stop a VM
175
+ golem vm stop my-webserver
176
+
177
+ # Start a VM
178
+ golem vm start my-webserver
179
+
180
+ # Destroy a VM
181
+ golem vm destroy my-webserver
182
+ ```
183
+
184
+ ## Configuration
185
+
186
+ The requestor uses a hierarchical configuration system:
187
+
188
+ 1. Environment Variables:
189
+ ```bash
190
+ # Discovery Service
191
+ export GOLEM_REQUESTOR_DISCOVERY_URL="http://discovery.golem.network:7465"
192
+
193
+ # Base Directory (default: ~/.golem)
194
+ export GOLEM_REQUESTOR_BASE_DIR="/path/to/golem/dir"
195
+
196
+ # Individual Paths (override base dir)
197
+ export GOLEM_REQUESTOR_SSH_KEY_DIR="/path/to/keys"
198
+ export GOLEM_REQUESTOR_DB_PATH="/path/to/database.db"
199
+
200
+ # Environment Mode
201
+ export GOLEM_REQUESTOR_ENVIRONMENT="production" # or "development"
202
+ ```
203
+
204
+ 2. Directory Structure:
205
+ ```
206
+ ~/.golem/
207
+ ├── ssh/ # SSH keys
208
+ │ ├── id_rsa # Private key
209
+ │ └── id_rsa.pub # Public key
210
+ └── vms.db # SQLite database
211
+ ```
212
+
213
+ ## Technical Details
214
+
215
+ ### SSH Key Management
216
+
217
+ The system intelligently handles SSH keys:
218
+ 1. Uses existing system SSH keys if available
219
+ 2. Generates and manages Golem-specific keys if needed
220
+ 3. Ensures proper key permissions (0600 for private, 0644 for public)
221
+ 4. Supports key reuse across VMs
222
+
223
+ ### State Management
224
+
225
+ Local state is maintained in SQLite:
226
+ - VM details and configuration
227
+ - Provider information
228
+ - Connection parameters
229
+ - VM status tracking
230
+
231
+ ### Provider Integration
232
+
233
+ The requestor communicates with providers through:
234
+ 1. Discovery service for provider location
235
+ 2. Direct API calls for VM management
236
+ 3. SSH proxy system for secure access
237
+ 4. Resource tracking for capacity management
238
+
239
+ ## Error Handling
240
+
241
+ The system provides clear error messages and recovery steps:
242
+
243
+ ```
244
+ Error: Unable to establish SSH connection (VM may be starting up)
245
+ Solution: Wait a few moments and try again. The VM is likely still initializing.
246
+
247
+ Error: Provider is no longer available (they may have gone offline)
248
+ Solution: Choose a different provider or wait for the original to come back online.
249
+
250
+ Error: VM not found in local database
251
+ Solution: The VM may have been manually removed. Use 'golem vm list' to see available VMs.
252
+ ```
253
+
254
+ ## Contributing
255
+
256
+ 1. Fork the repository
257
+ 2. Create a feature branch
258
+ 3. Make your changes
259
+ 4. Run the tests
260
+ 5. Submit a pull request
261
+
@@ -0,0 +1,44 @@
1
+ [tool.poetry]
2
+ name = "request-vm-on-golem"
3
+ version = "0.1.0"
4
+ description = "VM on Golem Requestor CLI - Create and manage virtual machines on the Golem Network"
5
+ authors = ["Phillip Jensen <phillip+vm-on-golem@golemgrid.com>"]
6
+ readme = "README.md"
7
+ homepage = "https://github.com/cryptobench/vm-on-golem"
8
+ repository = "https://github.com/cryptobench/vm-on-golem"
9
+ keywords = ["golem", "vm", "cloud", "decentralized", "cli"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Environment :: Console",
13
+ "Intended Audience :: Developers",
14
+ "Intended Audience :: System Administrators",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3.9",
17
+ "Topic :: System :: Distributed Computing",
18
+ "Topic :: System :: Systems Administration"
19
+ ]
20
+ packages = [
21
+ { include = "requestor" }
22
+ ]
23
+
24
+ [tool.poetry.dependencies]
25
+ python = "^3.9"
26
+ click = "^8.0.1"
27
+ pydantic = "^1.8.2"
28
+ cryptography = "^3.4.7"
29
+ asyncssh = "^2.7.0"
30
+ aiohttp = "^3.7.4"
31
+ aiosqlite = "^0.17.0"
32
+ tabulate = "^0.9.0"
33
+ colorlog = "^6.7.0"
34
+ python-dotenv = "^1.0.0"
35
+
36
+ [tool.poetry.group.dev.dependencies]
37
+ pytest = "^7.0.0"
38
+
39
+ [build-system]
40
+ requires = ["poetry-core"]
41
+ build-backend = "poetry.core.masonry.api"
42
+
43
+ [tool.poetry.scripts]
44
+ golem = "requestor.run:main"
@@ -0,0 +1,7 @@
1
+ """
2
+ VM on Golem Requestor Node
3
+
4
+ A simple CLI tool for managing VMs on the Golem Network.
5
+ """
6
+
7
+ __version__ = "0.1.0"
@@ -0,0 +1 @@
1
+ """CLI interface for VM on Golem."""