| 200 | |
| 201 | |
| 202 | class CLISessionGenerator: |
| 203 | def generate_session_id(self, host_id, tty, timestamp): |
| 204 | return self._generate_checksum(host_id, tty, timestamp) |
| 205 | |
| 206 | def generate_cache_key(self, host_id, tty): |
| 207 | return self._generate_checksum(host_id, tty) |
| 208 | |
| 209 | def _generate_checksum(self, *args): |
| 210 | checksum = _get_checksum() |
| 211 | str_to_hash = "" |
| 212 | for arg in args: |
| 213 | if arg is not None: |
| 214 | str_to_hash += str(arg) |
| 215 | checksum.update(str_to_hash.encode('utf-8')) |
| 216 | return checksum.hexdigest()[:_SESSION_ID_LENGTH] |
| 217 | |
| 218 | |
| 219 | class CLISessionOrchestrator: |
no outgoing calls