xenfra 0.1.8__py3-none-any.whl → 0.2.0__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 +33 -4
- xenfra/templates/cloud-init.sh.j2 +6 -10
- {xenfra-0.1.8.dist-info → xenfra-0.2.0.dist-info}/METADATA +1 -1
- {xenfra-0.1.8.dist-info → xenfra-0.2.0.dist-info}/RECORD +6 -6
- {xenfra-0.1.8.dist-info → xenfra-0.2.0.dist-info}/WHEEL +0 -0
- {xenfra-0.1.8.dist-info → xenfra-0.2.0.dist-info}/entry_points.txt +0 -0
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
|
-
|
|
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
|
|
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
|
-
|
|
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.")
|
|
@@ -27,18 +27,18 @@ dpkg --configure -a || true
|
|
|
27
27
|
# -----------------------------------------------
|
|
28
28
|
|
|
29
29
|
# 1. System Updates
|
|
30
|
-
echo "🔄 [1/
|
|
30
|
+
echo "🔄 [1/5] Refreshing Package Lists..." >> $LOG
|
|
31
31
|
apt-get update
|
|
32
32
|
apt-get install -y python3-pip git curl
|
|
33
33
|
|
|
34
34
|
# 2. Install Docker & Compose
|
|
35
|
-
echo "🐳 [2/
|
|
35
|
+
echo "🐳 [2/5] Installing Docker..." >> $LOG
|
|
36
36
|
apt-get install -y docker.io || (curl -fsSL https://get.docker.com | sh)
|
|
37
|
-
echo "🎶 [3/
|
|
37
|
+
echo "🎶 [3/5] Installing Docker Compose..." >> $LOG
|
|
38
38
|
apt-get install -y docker-compose-v2
|
|
39
39
|
|
|
40
40
|
# --- DOCKERIZED DEPLOYMENT ---
|
|
41
|
-
echo "📦 [4/
|
|
41
|
+
echo "📦 [4/5] Installing Caddy..." >> $LOG
|
|
42
42
|
apt-get install -y debian-keyring debian-archive-keyring apt-transport-https
|
|
43
43
|
curl -LsSf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
|
44
44
|
curl -LsSf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
|
|
@@ -56,15 +56,11 @@ cat << EOF > /etc/caddy/Caddyfile
|
|
|
56
56
|
EOF
|
|
57
57
|
{% endif %}
|
|
58
58
|
|
|
59
|
-
echo "🚀 [5/6] Starting application with Docker Compose..." >> $LOG
|
|
60
|
-
cd /root/app
|
|
61
|
-
docker-compose -f /root/app/docker-compose.yml up -d
|
|
62
|
-
|
|
63
59
|
{% if domain %}
|
|
64
|
-
echo "
|
|
60
|
+
echo "🚀 [5/5] Starting Caddy..." >> $LOG
|
|
65
61
|
systemctl restart caddy
|
|
66
62
|
{% else %}
|
|
67
|
-
echo "✅ [
|
|
63
|
+
echo "✅ [5/5] Skipping Caddy start (no domain specified)." >> $LOG
|
|
68
64
|
{% endif %}
|
|
69
65
|
|
|
70
66
|
# Finish
|
|
@@ -10,16 +10,16 @@ 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=
|
|
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
|
|
17
17
|
xenfra/security.py,sha256=w7aIFnHDHOH2zDjYD_LnJnSE01NeGeoAh_V8hC1HipY,2003
|
|
18
18
|
xenfra/templates/Dockerfile.j2,sha256=apWts895OOoUYwj_fOa6OiylFB5m8zFEYvJ1Nki32YM,664
|
|
19
|
-
xenfra/templates/cloud-init.sh.j2,sha256=
|
|
19
|
+
xenfra/templates/cloud-init.sh.j2,sha256=QCWG8hL1V05bAQ7BQ70QfuhIvS4tnsL8ZTCVtyi9F0A,2222
|
|
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.
|
|
23
|
-
xenfra-0.
|
|
24
|
-
xenfra-0.
|
|
25
|
-
xenfra-0.
|
|
22
|
+
xenfra-0.2.0.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
|
|
23
|
+
xenfra-0.2.0.dist-info/entry_points.txt,sha256=O6JNPm-inoMzmW29WPYl6jHHlWCrcs8ShHEo-CXvERs,49
|
|
24
|
+
xenfra-0.2.0.dist-info/METADATA,sha256=uQUHeQQz1bAm_cWLisVLjWoeRKBrEZXHfw1BBZYZTlY,4128
|
|
25
|
+
xenfra-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|