aboutsummaryrefslogtreecommitdiff
path: root/rwa/support/sessionservice/session.py
diff options
context:
space:
mode:
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}