xenfra-sdk 0.2.3__py3-none-any.whl → 0.2.5__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_sdk/db/models.py
CHANGED
|
@@ -12,6 +12,8 @@ class Project(SQLModel, table=True):
|
|
|
12
12
|
Project model storing deployment state in the SDK's local database.
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
+
__tablename__ = "projects"
|
|
16
|
+
|
|
15
17
|
id: Optional[int] = Field(default=None, primary_key=True)
|
|
16
18
|
droplet_id: int = Field(unique=True, index=True)
|
|
17
19
|
name: str
|
xenfra_sdk/engine.py
CHANGED
|
@@ -73,6 +73,10 @@ class InfraEngine:
|
|
|
73
73
|
"""Retrieves a list of all Droplets."""
|
|
74
74
|
return self.manager.get_all_droplets()
|
|
75
75
|
|
|
76
|
+
def list_domains(self):
|
|
77
|
+
"""Retrieves a list of all domains from DigitalOcean."""
|
|
78
|
+
return self.manager.get_all_domains()
|
|
79
|
+
|
|
76
80
|
def destroy_server(self, droplet_id: int, db_session: Session = None):
|
|
77
81
|
"""
|
|
78
82
|
Idempotent droplet destruction.
|
|
@@ -109,21 +113,29 @@ class InfraEngine:
|
|
|
109
113
|
statement = select(Project)
|
|
110
114
|
return session.exec(statement).all()
|
|
111
115
|
|
|
112
|
-
def sync_with_provider(self, db_session: Session = None):
|
|
113
|
-
"""Reconciles the local database with the live state from DigitalOcean."""
|
|
116
|
+
def sync_with_provider(self, user_id: int, db_session: Session = None):
|
|
117
|
+
"""Reconciles the local database with the live state from DigitalOcean for a specific user."""
|
|
114
118
|
session = db_session or self.db_session
|
|
115
119
|
|
|
116
120
|
# 1. Get live and local states
|
|
121
|
+
# Filter by 'xenfra' tag to only manage droplets created by us
|
|
117
122
|
live_droplets = self.manager.get_all_droplets(tag_name="xenfra")
|
|
118
|
-
|
|
123
|
+
|
|
124
|
+
# Filter local projects by user_id
|
|
125
|
+
statement = select(Project).where(Project.user_id == user_id)
|
|
126
|
+
local_projects = session.exec(statement).all()
|
|
119
127
|
|
|
120
128
|
live_map = {d.id: d for d in live_droplets}
|
|
121
129
|
local_map = {p.droplet_id: p for p in local_projects}
|
|
122
130
|
|
|
123
131
|
# 2. Reconcile
|
|
124
|
-
# Add new servers found on DO to our DB
|
|
132
|
+
# Add new servers found on DO to our DB if they match our naming/tagging convention
|
|
125
133
|
for droplet_id, droplet in live_map.items():
|
|
126
134
|
if droplet_id not in local_map:
|
|
135
|
+
# We only add it if it's NOT in our DB yet.
|
|
136
|
+
# Note: In a multi-tenant environment, we'd need a way to know WHICH user
|
|
137
|
+
# owns a tagged droplet if it's not in our DB. For now, we assume the
|
|
138
|
+
# calling user potentially owns it if they are syncing.
|
|
127
139
|
new_project = Project(
|
|
128
140
|
droplet_id=droplet.id,
|
|
129
141
|
name=droplet.name,
|
|
@@ -131,16 +143,20 @@ class InfraEngine:
|
|
|
131
143
|
status=droplet.status,
|
|
132
144
|
region=droplet.region["slug"],
|
|
133
145
|
size=droplet.size_slug,
|
|
146
|
+
user_id=user_id,
|
|
134
147
|
)
|
|
135
148
|
session.add(new_project)
|
|
136
149
|
|
|
137
150
|
# Remove servers from our DB that no longer exist on DO
|
|
138
|
-
for
|
|
139
|
-
if
|
|
151
|
+
for droplet_id, project in local_map.items():
|
|
152
|
+
if droplet_id not in live_map:
|
|
140
153
|
session.delete(project)
|
|
141
154
|
|
|
142
155
|
session.commit()
|
|
143
|
-
|
|
156
|
+
|
|
157
|
+
# Return refreshed list for this user
|
|
158
|
+
statement = select(Project).where(Project.user_id == user_id)
|
|
159
|
+
return session.exec(statement).all()
|
|
144
160
|
|
|
145
161
|
def stream_logs(self, droplet_id: int, db_session: Session = None):
|
|
146
162
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: xenfra-sdk
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Xenfra SDK: Core engine and utilities for the Xenfra platform.
|
|
5
5
|
Author: xenfra-cloud
|
|
6
6
|
Author-email: xenfra-cloud <xenfracloud@gmail.com>
|
|
@@ -26,7 +26,7 @@ Requires-Dist: pytest>=8.0.0 ; extra == 'dev'
|
|
|
26
26
|
Requires-Dist: pytest-mock>=3.12.0 ; extra == 'dev'
|
|
27
27
|
Requires-Dist: pytest-cov>=4.0.0 ; extra == 'dev'
|
|
28
28
|
Requires-Dist: pytest-asyncio>=0.21.0 ; extra == 'dev'
|
|
29
|
-
Requires-Python: >=3.
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
30
|
Project-URL: Homepage, https://github.com/xenfra-cloud/xenfra-sdk
|
|
31
31
|
Project-URL: Issues, https://github.com/xenfra-cloud/xenfra-sdk/issues
|
|
32
32
|
Provides-Extra: dev
|
|
@@ -5,12 +5,12 @@ xenfra_sdk/client.py,sha256=88M-ram8wDVfVEPpa3q1z4hXToBg4kSOgsIBOLXxsBo,3597
|
|
|
5
5
|
xenfra_sdk/client_with_hooks.py,sha256=iN-xTGdeSPizktM6UG-aZEsuwQc5OgosNYUf1_Tq4Dc,10046
|
|
6
6
|
xenfra_sdk/config.py,sha256=gaT4k5iJgW9guNVmlnYkCFGDSU1_er4LRZA2CgfKmJ0,588
|
|
7
7
|
xenfra_sdk/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
xenfra_sdk/db/models.py,sha256=
|
|
8
|
+
xenfra_sdk/db/models.py,sha256=nbnlNiFShUo9uxrcVLHUezlNtF_NATS85pPYTKBriIE,714
|
|
9
9
|
xenfra_sdk/db/session.py,sha256=0MA0404QU9eUabDgTqi-wNIUP0DpIKKG-OvB4Jzf7rc,885
|
|
10
10
|
xenfra_sdk/dependencies.py,sha256=WHGfIrEYkss5yuBd_uOFrB6lPBWM2X0mEuG26ILAjXI,1211
|
|
11
11
|
xenfra_sdk/detection.py,sha256=t8FA_AaNphvv-G0dGL6hLYqOdC9an6-QnVrtFoiTd7M,13993
|
|
12
12
|
xenfra_sdk/dockerizer.py,sha256=KuVGcS5RacR91fGo_6pPlQ4wvJYqnenz0C6x9JoLPWU,7291
|
|
13
|
-
xenfra_sdk/engine.py,sha256=
|
|
13
|
+
xenfra_sdk/engine.py,sha256=haeU7YhAOgRFb8HG6BKhYmCBFnIHfS5YZpljBW4okvU,36581
|
|
14
14
|
xenfra_sdk/exceptions.py,sha256=aMVtDVlzG7-FT2G_b-pJSuuey22B4YvC-b-L37GaImM,477
|
|
15
15
|
xenfra_sdk/manifest.py,sha256=49wfCr0VK9AJBCF8HGOJ_K0ru8iUbjRDczH3MPzPJBc,6613
|
|
16
16
|
xenfra_sdk/mcp_client.py,sha256=NZtQz_qK_8i504rVPXlE1vPdzt75hg8Lkp4d8BA8dk0,5777
|
|
@@ -33,6 +33,6 @@ xenfra_sdk/templates/cloud-init.sh.j2,sha256=xOwf-VERYXnL8vNMU13SnrmRX0H-hEh3l1A
|
|
|
33
33
|
xenfra_sdk/templates/docker-compose-multi.yml.j2,sha256=PWSPdWsGb-sWJ-XCutMdHiz-uhChIwEN6QMaZ0_Spxs,911
|
|
34
34
|
xenfra_sdk/templates/docker-compose.yml.j2,sha256=TQ__p3-TYAUbU0RNeZCxTjJ9gt81-Rry1B1QnuPzBzc,935
|
|
35
35
|
xenfra_sdk/utils.py,sha256=d8eCjjV32QwqoJa759CEcETnnsjG5qVKDLQ84yYtlus,3898
|
|
36
|
-
xenfra_sdk-0.2.
|
|
37
|
-
xenfra_sdk-0.2.
|
|
38
|
-
xenfra_sdk-0.2.
|
|
36
|
+
xenfra_sdk-0.2.5.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
|
|
37
|
+
xenfra_sdk-0.2.5.dist-info/METADATA,sha256=Kvjh7DUxezPgF6MUP1qv9xQL1slb-b5ycvBNHft1GXI,3982
|
|
38
|
+
xenfra_sdk-0.2.5.dist-info/RECORD,,
|
|
File without changes
|