xenfra 0.1.8__py3-none-any.whl → 0.1.9__py3-none-any.whl

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.
xenfra/engine.py CHANGED
@@ -44,7 +44,15 @@ class InfraEngine:
44
44
 
45
45
  def _get_connection(self, ip_address: str):
46
46
  """Establishes a Fabric connection to the server."""
47
- return fabric.Connection(host=ip_address, user="root", connect_kwargs={"password": None}) # Assumes SSH key auth
47
+ private_key_path = str(Path.home() / ".ssh" / "id_rsa")
48
+ if not Path(private_key_path).exists():
49
+ raise DeploymentError("No private SSH key found at ~/.ssh/id_rsa.", stage="Setup")
50
+
51
+ return fabric.Connection(
52
+ host=ip_address,
53
+ user="root",
54
+ connect_kwargs={"key_filename": [private_key_path]},
55
+ )
48
56
 
49
57
  def get_user_info(self):
50
58
  """Retrieves user account information."""
@@ -189,12 +197,33 @@ class InfraEngine:
189
197
  while True:
190
198
  droplet.load()
191
199
  if droplet.status == 'active':
192
- logger(" - Droplet is active. Waiting for cloud-init to complete...")
200
+ logger(" - Droplet is active. Waiting for SSH to be available...")
193
201
  break
194
202
  time.sleep(10)
195
-
203
+
196
204
  ip_address = droplet.ip_address
197
- with self._get_connection(ip_address) as conn:
205
+
206
+ # Retry SSH connection
207
+ conn = None
208
+ max_retries = 12 # 2-minute timeout for SSH
209
+ for i in range(max_retries):
210
+ try:
211
+ logger(f" - Attempting SSH connection ({i+1}/{max_retries})...")
212
+ conn = self._get_connection(ip_address)
213
+ conn.open() # Explicitly open the connection
214
+ logger(" - SSH connection established.")
215
+ break
216
+ except Exception as e:
217
+ if i < max_retries - 1:
218
+ logger(f" - SSH connection failed. Retrying in 10s...")
219
+ time.sleep(10)
220
+ else:
221
+ raise DeploymentError(f"Failed to establish SSH connection: {e}", stage="Polling")
222
+
223
+ if not conn or not conn.is_connected:
224
+ raise DeploymentError("Could not establish SSH connection.", stage="Polling")
225
+
226
+ with conn:
198
227
  for i in range(30): # 5-minute timeout for cloud-init
199
228
  if conn.run("test -f /root/setup_complete", warn=True).ok:
200
229
  logger(" - Cloud-init setup complete.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: xenfra
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: A 'Zen Mode' infrastructure engine for Python developers.
5
5
  Author: xenfra-cloud
6
6
  Author-email: xenfra-cloud <xenfracloud@gmail.com>
@@ -10,7 +10,7 @@ xenfra/db/models.py,sha256=nRqbG9cbcX8LWz2Jr4inKysAq47yALcxNl3_UYEpSoQ,1305
10
10
  xenfra/db/session.py,sha256=Q03RIiPlYBtPD-qVHlTqQtacnOPTZnOy6_f9p6lABPU,510
11
11
  xenfra/dependencies.py,sha256=pQ7bFNZHC24chMxRa_69mu2fIqcoc8DG9MD1POSGgjA,1211
12
12
  xenfra/dockerizer.py,sha256=5qzgqw2MZrBwI4IFzXPJZ6k3F3IRdFnX-KGIpv5cjXc,3126
13
- xenfra/engine.py,sha256=fzdBIW1CmOQtTETjlaMtltt0cgH8r4HN7ImH-s2Wnzk,11793
13
+ xenfra/engine.py,sha256=ZQOyThord9mEhthBxHSL7_8o_d-DsgyN_4VJ_WHCz-U,12954
14
14
  xenfra/mcp_client.py,sha256=IxkTC3NPHvPJn-2dl5BUHQ3d-A9MBiKP9fIftzhmCuA,5756
15
15
  xenfra/models.py,sha256=9Dvr1_kb29LJIR0a-uwx_tsCWt3GZeko6FKQtYY8F4g,1852
16
16
  xenfra/recipes.py,sha256=q5ilpDzGuUM6GyvlW97pOpPS9nzQAJGI4pgzSU_URik,862
@@ -19,7 +19,7 @@ xenfra/templates/Dockerfile.j2,sha256=apWts895OOoUYwj_fOa6OiylFB5m8zFEYvJ1Nki32Y
19
19
  xenfra/templates/cloud-init.sh.j2,sha256=Ln7XO4rwaHgauevMKfkxAgBFNLHPnWv-TnJl3NJbU8c,2359
20
20
  xenfra/templates/docker-compose.yml.j2,sha256=zKUT2cd_FrxXvRxE-vAAjuQk3-nLNQjRe-StkhAWRQA,860
21
21
  xenfra/utils.py,sha256=aGXjJm-pwVCHuCn5UBdrxRcYvM8aJwHQ1kihl7gcxiM,2387
22
- xenfra-0.1.8.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
23
- xenfra-0.1.8.dist-info/entry_points.txt,sha256=O6JNPm-inoMzmW29WPYl6jHHlWCrcs8ShHEo-CXvERs,49
24
- xenfra-0.1.8.dist-info/METADATA,sha256=hebQ0mFii9qF8Gs7PeVgzbBizBZ8qQ7GuFA0FycJTT4,4128
25
- xenfra-0.1.8.dist-info/RECORD,,
22
+ xenfra-0.1.9.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
23
+ xenfra-0.1.9.dist-info/entry_points.txt,sha256=O6JNPm-inoMzmW29WPYl6jHHlWCrcs8ShHEo-CXvERs,49
24
+ xenfra-0.1.9.dist-info/METADATA,sha256=qjXKY6vbu_LM2QfJtAo_kC3tL_8V4UBly4dVJ1mn9nA,4128
25
+ xenfra-0.1.9.dist-info/RECORD,,
File without changes