aboutsummaryrefslogtreecommitdiff
path: root/rwa/support/sessionservice/session.py
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-07-02 18:44:13 +0000
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-07-02 18:44:13 +0000
commit37e3f27c179fb07ed95f73b21f1b10b6e367c46e (patch)
tree37c1004a88efcbfd17200ec4f2f389473697f681 /rwa/support/sessionservice/session.py
parent7bd7f73994db1fa2169ff435a41f7fb4c2313058 (diff)
parent651d0b73df96fa467c1de207ac8055f4e0fd58a7 (diff)
downloadRWA.Support.SessionService-37e3f27c179fb07ed95f73b21f1b10b6e367c46e.tar.gz
RWA.Support.SessionService-37e3f27c179fb07ed95f73b21f1b10b6e367c46e.tar.bz2
RWA.Support.SessionService-37e3f27c179fb07ed95f73b21f1b10b6e367c46e.zip
Merge branch 'refactor/id-system' into 'master'
Refactor ID system See merge request remotewebapp/rwa.support.sessionservice!14
Diffstat (limited to 'rwa/support/sessionservice/session.py')
-rw-r--r--rwa/support/sessionservice/session.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/rwa/support/sessionservice/session.py b/rwa/support/sessionservice/session.py
index b704b08..d3aa57c 100644
--- a/rwa/support/sessionservice/session.py
+++ b/rwa/support/sessionservice/session.py
@@ -51,6 +51,10 @@ def get_desktop_dir():
return output.strip().replace("\n", "")
+def combine(host_uuid: str, session_id: int):
+ return f"{host_uuid}-{session_id}"
+
+
class Session:
#: Session is running
STATUS_RUNNING = "running"
@@ -58,14 +62,16 @@ class Session:
#: Remote has joined the session
STATUS_JOINED = "active"
- def __init__(self, host: str, trigger_port: int, mockup_session: bool = False):
- self.host = host
- self.BASE_URL = self.host + API_PATH
+ def __init__(self, host_object: dict, trigger_port: int, mockup_session: bool = False):
+ self.host_object = host_object
+ self.host_url = self.host_object["url"]
+ self.host_uuid = self.host_object["id"]
+ self.BASE_URL = self.host_url + API_PATH
self.REGISTER_URL = self.BASE_URL + "register/"
self.STOP_URL = self.BASE_URL + "stop/"
self.STATUS_URL = self.BASE_URL + "status/"
self.MARK_JOB_AS_DONE_URL = self.BASE_URL + "jobs/mark_as_done/"
- logging.info(f"Load API config: {self.host}")
+ logging.info(f"Load API config: {self.host_url}")
self.trigger_token = secrets.token_urlsafe(20)
self.trigger_port = trigger_port
@@ -79,6 +85,10 @@ class Session:
self.status_text = self.STATUS_RUNNING
@property
+ def combined_id(self):
+ return combine(self.host_uuid, self.session_id)
+
+ @property
def pid(self) -> int:
return self.vnc_pid
@@ -296,8 +306,13 @@ class Session:
@property
def client_meta(self) -> Dict[str, Union[str, int]]:
- return {"id": self.pid, "session_id": self.session_id, "url": self.web_url, "pin": self.pin}
+ return {
+ "host_uuid": self.host_uuid,
+ "session_id": self.session_id,
+ "url": self.web_url,
+ "pin": self.pin,
+ }
@property
def status(self) -> Dict[str, Union[str, int]]:
- return {"id": self.pid, "status": self.status_text}
+ return {"host_uuid": self.host_uuid, "session_id": self.session_id, "status": self.status_text}