Credential Server
A running example of the credential server can be found in userhost.py
at the root directory of source code.
The Client
-
class railgun.userhost.client.UserHostClient(host, port)[source]
Client to communicate with user host server.
-
acquire(expires=10)[source]
Get a free user, which will expire in expires seconds.
| Parameters: | expires (int) – Seconds before the user is exipred and recycled for
next request. |
| Returns: | The user name if available, None otherwise. |
-
release(user)[source]
Release the acquired user immediately.
| Parameters: | user (str) – The name of acquired user. |
| Returns: | True if succeeded, False otherwise. |
The Server
-
class railgun.userhost.server.UserHostServer(userpool)[source]
User credential server that assigns system accounts for each runner
task. This server runs single threaded, and will not block if all users
are assigned.
-
run(port, interface='', backlog=100)[source]
Run the user credential server.
| Parameters: |
- port (int) – The port of the user credential server.
- interface (str) – The interface for the server to listen.
- backlog (int) – The TCP backlog size.
|
The Pool
-
class railgun.userhost.userpool.UserPool(users)[source]
Manages the available account.
-
acquire(expires=10)[source]
Get a free user, which will expire in expires seconds.
| Parameters: | expires (int) – Seconds before the user is exipred and recycled for
next request. |
| Returns: | The user name if available, None otherwise. |
-
current_time()[source]
Get the current timestamp.
-
release(user)[source]
Release the acquired user immediately.
| Parameters: | user (str) – The name of acquired user. |