Used to represent user commands.
More...
|
|
| time_received |
| |
|
| command_raw |
| |
|
| command_dict |
| |
|
| user_id |
| |
|
| kernel_mode |
| |
|
| valid |
| |
|
| command |
| |
|
| destination |
| |
|
| pipeline |
| |
|
| full_destination |
| |
|
| parameters |
| |
Used to represent user commands.
This class is the default class used to represent commands sent to the ground station. Commands are typically passed between the command parser and the appropriate command handler, which then updates the Command instance with the results of the command. This default Command type represents simple dictionary based commands (which are probably YAML or JSON strings in their raw forms).
| def hwm.command.command.Command.__init__ |
( |
|
self, |
|
|
|
time_received, |
|
|
|
raw_command, |
|
|
|
user_id = None, |
|
|
|
kernel_mode = False |
|
) |
| |
Constructs a new Command object.
This method sets up a new command based on the raw command received.
- Parameters
-
| time_received | The time (UNIX timestamp) when the command was received. |
| raw_command | The raw command that this class will represent. Can either be a dictionary or a string. If it is a string, it will be passed through a series of parsers for the supported languages until one of them can decode the string. The resulting (or original) dictionary will then be checked against the command schemma. Currently, only JSON strings are supported. |
| user_id | The ID of the user executing the command. |
| kernel_mode | Whether or not the command is to run in kernel mode (ignores permission and session checks). |
| def hwm.command.command.Command._populate_command_attributes |
( |
|
self) | |
|
|
private |
This method populates the class's attributes using the command dictionary.
This method copies some information from the command dictionary into class attributes for programmer convenience.
It should be called after the command's schema has been validated.
- Returns
- Returns True on success or False if the command is invalid (i.e. it hasn't been validated yet or is actually invalid).
| def hwm.command.command.Command.active_user_sessions |
( |
|
self) | |
|
Returns an array of the active Sessions associated with the user who submitted the command.
- Note
- The user's active sessions are loaded by the command parser after the command has been initialized.
-
Returns an empty array if the user doesn't have any active sessions or if this is a kernel level command.
- Returns
- Returns an array of active Sessions.
| def hwm.command.command.Command.active_user_sessions |
( |
|
self, |
|
|
|
active_sessions |
|
) |
| |
Sets the active sessions for the user associated with this command.
- Parameters
-
| active_sessions | An array containing the user's active Sessions. |
| def hwm.command.command.Command.build_command_response |
( |
|
self, |
|
|
|
success, |
|
|
|
command_results = {} |
|
) |
| |
Constructs a dictionary to encapsulate the command results.
This method builds a dictionary containing the command's response. Whatever module created the command in the first
place will be responsible for converting it into the format it needs. For example, the CommandResource class will
likely convert the results into a JSON string.
- Parameters
-
| success | Whether or not the command was successful (True or False). |
| command_results | A dictionary containing the results of the command. |
- Returns
- Returns a dictionary containing the command's results.
| def hwm.command.command.Command.validate_command |
( |
|
self) | |
|
Validates the submitted command and saves it in a usable form.
This method verifies that the provided raw command dictionary conforms this Command's schema.
- Note
- Because simple YAML and JSON objects are both serialized representations of dictionaries, the JSON Draft 3 schema validator can be used to check commands that were originally in JSON or YAML (or any other such language). This default command class currently supports JSON strings and pre-converted dictionaries (typically the case when using the YAML configuration).
-
This method should be called before any actions are performed on the command (i.e. right after initialization).
-
This method sets several convenience attributes of the Command class (such as the destination and command id's) if the command conforms to the schema.
- Returns
- Returns a deferred that will be fired with the results of the command validation. If the command is invalid, a pre-fired failed deferred is returned.
The documentation for this class was generated from the following file: