feat(hub): report seats_taken in WebSocket license sync and telemetry
CI Test Suite / Run Component Tests & Pipeline Verification (push) Failing after 22s
CI Test Suite / Run Component Tests & Pipeline Verification (push) Failing after 22s
This commit is contained in:
+1
-1
Submodule LOGAR-LICENSING updated: 13f67d46f7...0471798a89
+14
-1
@@ -1682,12 +1682,25 @@ def main():
|
|||||||
ca_info = enrollment.extract_license_info_from_cert(f.read())
|
ca_info = enrollment.extract_license_info_from_cert(f.read())
|
||||||
|
|
||||||
ws_url = lic_server if ("ws://" in lic_server or "wss://" in lic_server) else f"{lic_server.replace('https://', 'wss://').replace('http://', 'ws://').rstrip('/')}/ws/license"
|
ws_url = lic_server if ("ws://" in lic_server or "wss://" in lic_server) else f"{lic_server.replace('https://', 'wss://').replace('http://', 'ws://').rstrip('/')}/ws/license"
|
||||||
|
|
||||||
|
active_seats = 0
|
||||||
|
if os.path.exists(config.get("db_path", "server_logs.db")):
|
||||||
|
try:
|
||||||
|
conn_tmp = sqlite3.connect(config.get("db_path", "server_logs.db"))
|
||||||
|
row = conn_tmp.execute("SELECT COUNT(*) FROM clients WHERE status = 'active'").fetchone()
|
||||||
|
if row:
|
||||||
|
active_seats = row[0]
|
||||||
|
conn_tmp.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
success, msg, res = enrollment.enroll_and_sync_license_ws(
|
success, msg, res = enrollment.enroll_and_sync_license_ws(
|
||||||
cert_dir=cert_dir,
|
cert_dir=cert_dir,
|
||||||
license_id=ca_info.get("license_id"),
|
license_id=ca_info.get("license_id"),
|
||||||
license_authority_ws_url=ws_url,
|
license_authority_ws_url=ws_url,
|
||||||
server_fingerprint=config.get("server_fingerprint", ""),
|
server_fingerprint=config.get("server_fingerprint", ""),
|
||||||
hostname=config.get("server_name", "")
|
hostname=config.get("server_name", ""),
|
||||||
|
seats_taken=active_seats
|
||||||
)
|
)
|
||||||
|
|
||||||
if not success or not res:
|
if not success or not res:
|
||||||
|
|||||||
@@ -662,6 +662,7 @@ def enroll_and_sync_license_ws(
|
|||||||
hostname: str = "",
|
hostname: str = "",
|
||||||
comm_cert_pem: Optional[str] = None,
|
comm_cert_pem: Optional[str] = None,
|
||||||
master_root_ca_pem: Optional[str] = None,
|
master_root_ca_pem: Optional[str] = None,
|
||||||
|
seats_taken: Optional[int] = None,
|
||||||
timeout: int = 15,
|
timeout: int = 15,
|
||||||
verify_tls: bool = True
|
verify_tls: bool = True
|
||||||
) -> Tuple[bool, str, Optional[Dict[str, Any]]]:
|
) -> Tuple[bool, str, Optional[Dict[str, Any]]]:
|
||||||
@@ -752,6 +753,8 @@ def enroll_and_sync_license_ws(
|
|||||||
"server_fingerprint": server_fingerprint,
|
"server_fingerprint": server_fingerprint,
|
||||||
"hostname": hostname
|
"hostname": hostname
|
||||||
}
|
}
|
||||||
|
if seats_taken is not None:
|
||||||
|
payload["seats_taken"] = seats_taken
|
||||||
ws.send(json.dumps(payload))
|
ws.send(json.dumps(payload))
|
||||||
raw_reply = ws.recv(timeout=timeout)
|
raw_reply = ws.recv(timeout=timeout)
|
||||||
reply = json.loads(raw_reply)
|
reply = json.loads(raw_reply)
|
||||||
|
|||||||
Reference in New Issue
Block a user