py-pve-cloud 3.4.2__tar.gz → 3.4.4__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.
- {py_pve_cloud-3.4.2/src/py_pve_cloud.egg-info → py_pve_cloud-3.4.4}/PKG-INFO +1 -1
- py_pve_cloud-3.4.4/src/pve_cloud/_version.py +1 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/cli/pxrpc.py +76 -13
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4/src/py_pve_cloud.egg-info}/PKG-INFO +1 -1
- py_pve_cloud-3.4.2/src/pve_cloud/_version.py +0 -1
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/LICENSE.md +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/README.md +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/pyproject.toml +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/setup.cfg +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/cli/pvcli.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/cli/pvclu.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/lib/backup_rpc.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/lib/inventory.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/lib/ssh.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/alchemy.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/alembic.ini +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/env.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/04398db10434_external_cp_extra_sans.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/0ad803c51325_machine_type_refactor.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/24a548bfce3e_len_rules_enforcements.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/27724e407e2b_proxy_fqdn.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/3c95509a5de9_fix.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/7496c3f3b2e8_fix_secrets_constraint.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/7868bcd05006_migrate_old.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/7dea8c4ee39f_init.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/944a8fd5d5bc_ext_ctrl_plns.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/9de11ef8ba39_vm_vars_and_cloud_secrets.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/d9b711555be8_ext_control_plane.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/e60b9cc63413_ingress_generic.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/e6ae1e138c1f_change_scope_cloud.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/ee4924ac4f60_secrets_plural_type.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/fdcb5aa33b76_slop_firewall_seperation.py +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/py_pve_cloud.egg-info/SOURCES.txt +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/py_pve_cloud.egg-info/dependency_links.txt +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/py_pve_cloud.egg-info/entry_points.txt +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/py_pve_cloud.egg-info/requires.txt +0 -0
- {py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/py_pve_cloud.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.4.4"
|
|
@@ -12,6 +12,7 @@ from concurrent.futures import ProcessPoolExecutor
|
|
|
12
12
|
from contextlib import asynccontextmanager, contextmanager
|
|
13
13
|
from enum import StrEnum
|
|
14
14
|
|
|
15
|
+
import asyncssh
|
|
15
16
|
import dns.rcode
|
|
16
17
|
import dns.resolver
|
|
17
18
|
import dns.tsigkeyring
|
|
@@ -95,8 +96,9 @@ class RemoteProxmoxApi(rpyc.Service):
|
|
|
95
96
|
@rpyc.service
|
|
96
97
|
class PxrpcService(rpyc.Service):
|
|
97
98
|
|
|
98
|
-
# functions for constructor
|
|
99
|
-
|
|
99
|
+
# functions for constructor, only for when the service is launched
|
|
100
|
+
# as a real remote service on a proxmox host!
|
|
101
|
+
def _get_cluster_vars(self):
|
|
100
102
|
result_vars = subprocess.run(
|
|
101
103
|
["cat", "/etc/pve/cloud/cluster_vars.yaml"],
|
|
102
104
|
capture_output=True,
|
|
@@ -108,7 +110,7 @@ class PxrpcService(rpyc.Service):
|
|
|
108
110
|
|
|
109
111
|
return cluster_vars
|
|
110
112
|
|
|
111
|
-
def
|
|
113
|
+
def _get_pg_conn_str(self, cluster_vars):
|
|
112
114
|
# needs to be cat because of proxmox fs
|
|
113
115
|
result_pass = subprocess.run(
|
|
114
116
|
["cat", "/etc/pve/cloud/secrets/patroni.pass"],
|
|
@@ -120,7 +122,7 @@ class PxrpcService(rpyc.Service):
|
|
|
120
122
|
|
|
121
123
|
return f"postgresql+psycopg2://postgres:{patroni_pass}@{cluster_vars['pve_haproxy_floating_ip_internal']}:5000/pve_cloud?sslmode=disable"
|
|
122
124
|
|
|
123
|
-
def
|
|
125
|
+
def _get_internal_bind_key(self):
|
|
124
126
|
result_key = subprocess.run(
|
|
125
127
|
["cat", "/etc/pve/cloud/secrets/internal.key"],
|
|
126
128
|
capture_output=True,
|
|
@@ -130,37 +132,45 @@ class PxrpcService(rpyc.Service):
|
|
|
130
132
|
|
|
131
133
|
return re.search(r'secret\s+"([^"]+)";', result_key.stdout).group(1)
|
|
132
134
|
|
|
135
|
+
# rpyc doesnt have a clean shutdown methodology
|
|
136
|
+
# this is the cleanest i found without triggerin eof on the clients side
|
|
137
|
+
@rpyc.exposed
|
|
138
|
+
def shutdown(self):
|
|
139
|
+
os.kill(MASTER_PID, signal.SIGTERM) # this triggers the shutdown handler
|
|
140
|
+
|
|
133
141
|
def __init__(self, cluster_vars=None, patroni_cstr=None, internal_bind_key=None):
|
|
134
142
|
super().__init__()
|
|
135
143
|
|
|
136
144
|
if cluster_vars:
|
|
137
145
|
self.cluster_vars = cluster_vars
|
|
138
146
|
else:
|
|
139
|
-
self.cluster_vars = self.
|
|
147
|
+
self.cluster_vars = self._get_cluster_vars()
|
|
140
148
|
|
|
141
149
|
if internal_bind_key:
|
|
142
150
|
self.internal_bind_key = internal_bind_key
|
|
143
151
|
else:
|
|
144
|
-
self.internal_bind_key = self.
|
|
152
|
+
self.internal_bind_key = self._get_internal_bind_key()
|
|
145
153
|
|
|
146
154
|
if patroni_cstr:
|
|
147
155
|
self.patroni_cstr = patroni_cstr
|
|
148
156
|
else:
|
|
149
|
-
self.patroni_cstr = self.
|
|
157
|
+
self.patroni_cstr = self._get_pg_conn_str(
|
|
150
158
|
self.cluster_vars
|
|
151
159
|
) # we need postgres for almost anything
|
|
152
160
|
|
|
161
|
+
# return initted cluster vars
|
|
162
|
+
@rpyc.exposed
|
|
163
|
+
def get_cluster_vars(self):
|
|
164
|
+
return self.cluster_vars
|
|
165
|
+
|
|
166
|
+
# after initialization these functions can be called from anywhere
|
|
167
|
+
# either via the local wrapper on cloud connecitons that are not tunneled
|
|
168
|
+
# via a jump host, and also for true remote launches.
|
|
153
169
|
@rpyc.exposed
|
|
154
170
|
def e2e_return(self):
|
|
155
171
|
print(f"e2e return on pid {os.getpid()}")
|
|
156
172
|
return self.patroni_cstr
|
|
157
173
|
|
|
158
|
-
# rpyc doesnt have a clean shutdown methodology
|
|
159
|
-
# this is the cleanest i found without triggerin eof on the clients side
|
|
160
|
-
@rpyc.exposed
|
|
161
|
-
def shutdown(self):
|
|
162
|
-
os.kill(MASTER_PID, signal.SIGTERM) # this triggers the shutdown handler
|
|
163
|
-
|
|
164
174
|
@rpyc.exposed
|
|
165
175
|
def resolve_k8s_master(self, nameservers, a_rs_hostname):
|
|
166
176
|
resolver = dns.resolver.Resolver()
|
|
@@ -606,3 +616,56 @@ async def launch_pxrpc_async(
|
|
|
606
616
|
list(
|
|
607
617
|
pool.map(exit_worker, range(NUM_WORKERS))
|
|
608
618
|
) # list/() is critical to yield the generator
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
# make methods async callable for generic invoke
|
|
622
|
+
# this is so we can call pxrpc methods generically for a locally
|
|
623
|
+
# initialized instance
|
|
624
|
+
class PxrpcAsyncWrapper:
|
|
625
|
+
|
|
626
|
+
def __init__(self, pxservice):
|
|
627
|
+
self.pxservice = pxservice
|
|
628
|
+
|
|
629
|
+
def __getattr__(self, method_name):
|
|
630
|
+
async def async_wrapper(*args, **kwargs):
|
|
631
|
+
return getattr(self.pxservice, method_name)(*args, **kwargs)
|
|
632
|
+
|
|
633
|
+
return async_wrapper
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
async def get_cstr_cvars(online_pve_host):
|
|
637
|
+
async with asyncssh.connect(
|
|
638
|
+
online_pve_host, username="root", known_hosts=None
|
|
639
|
+
) as conn:
|
|
640
|
+
cmd = await conn.run("cat /etc/pve/cloud/secrets/patroni.pass", check=True)
|
|
641
|
+
patroni_pass = cmd.stdout.rstrip()
|
|
642
|
+
|
|
643
|
+
# fetch cluster vars to get internal proxy ip
|
|
644
|
+
cmd = await conn.run("cat /etc/pve/cloud/cluster_vars.yaml", check=True)
|
|
645
|
+
cluster_vars = yaml.safe_load(cmd.stdout)
|
|
646
|
+
validate_cluster_vars(cluster_vars)
|
|
647
|
+
|
|
648
|
+
cmd = await conn.run("cat /etc/pve/cloud/secrets/internal.key", check=True)
|
|
649
|
+
internal_key = re.search(r'secret\s+"([^"]+)";', cmd.stdout).group(1)
|
|
650
|
+
|
|
651
|
+
# build the connection string
|
|
652
|
+
patroni_cstr = f"postgresql+psycopg2://postgres:{patroni_pass}@{cluster_vars['pve_haproxy_floating_ip_internal']}:5000/pve_cloud?sslmode=disable"
|
|
653
|
+
|
|
654
|
+
return patroni_cstr, cluster_vars, internal_key
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
# pve cloud context aware async get function for the pxrpc functions.
|
|
658
|
+
# this will either return a local wrapper or a remotely launched instance
|
|
659
|
+
# of our pxrpc service. This serves as a generic function launch endpoint
|
|
660
|
+
# to be able to interact with a proxmox cloud, regardless of configuration
|
|
661
|
+
# (local access / remote via jump host). This currently only exists as an async
|
|
662
|
+
# implementation.
|
|
663
|
+
@asynccontextmanager
|
|
664
|
+
async def get_simple_pxrpc(online_pve_host, jump_host):
|
|
665
|
+
if not jump_host:
|
|
666
|
+
cstr, cluster_vars, internal_key = await get_cstr_cvars(online_pve_host)
|
|
667
|
+
yield PxrpcAsyncWrapper(PxrpcService(cluster_vars, cstr, internal_key))
|
|
668
|
+
return
|
|
669
|
+
|
|
670
|
+
async with launch_pxrpc_async(jump_host, online_pve_host) as pxrpc:
|
|
671
|
+
yield pxrpc
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "3.4.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/3c95509a5de9_fix.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{py_pve_cloud-3.4.2 → py_pve_cloud-3.4.4}/src/pve_cloud/orm/migrations/versions/7dea8c4ee39f_init.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|