Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Universal Extension 1.2.0 API 

UniversalExtension class

Base class for Stonebranch Universal Extension module implementations

uip can be used to access the following properties of an Extension task instance:task_variables : dictis_triggered : booltrigger_id : strinstance_id : strmonitor_id : str

...

(rc = 0, message = '', output = False, output_data = None, output_name = None, call_frame = None, **kwargs)

ParameterTypeDefaultDescription
rc

int, optional

0

This parameter represents the return code of the Dynamic Command operation and determines whether the Extension task instance is perceived as completing as Success or Failed by the Controller.
A value of 0 indicates success. All other values indicate an error condition and result in a status of Failed in the Controller. The non-zero value used to represent the error condition is implementation defined and therefore left up to the extension developer.

messagestr, optionalEmpty string

This parameter allows the extension to pass a completion message back to the Controller. If rc is set to 0, the message will be considered informational and will be logged by the Controller.
If rc is non-zero, the message will be considered an error message and will be displayed to the user on the task instance form.

output

bool, optional

False

This parameter specifies if the command produced output that should be persisted and displayed under the task instance Output tab in the Controller task instance associated with the dynamic command invocation.

output_data

str, optional

None

This parameter specifies the data that will be returned to the Controller for the command execution. It is interpreted as a UTF-8 encoded text object.

If the output attribute is True, the output_data will be persisted in the Controller as a record under table ops_exec_output, and appearing as Universal Command output type from the task instance Output tab.

output_name

str, optional

None

This attribute is used to provided a custom name for the associated output data. The output_name (if provided) will be used in the presentation of the output_data by the Controller.

Example

Panel
>>> @dynamic_command('reset_environment')
>>> def reset_environment(self, fields):
>>>     # Implementation omitted
>>>     return ExtensionResult(
...         message = "Message: Hello from dynamic command 'reset_environment'!",
...         output = True,
...         output_data = 'The environment has been reset.',
...         output_name = 'DYNAMIC_OUTPUT'
...     )

...

(rc = 0, message = '', values = None, call_frame = None, **kwargs)

ParameterTypeDefaultDescription
rc

int, optional

0

This parameter represents the return code of the 'choice' operation and determines whether the command is perceived as completing with success or failure by the Controller. A value of 0 indicates success. All other values indicate an error condition and will be ignored by the Controller for form field population. However, the Controller will log the commnd response. The non-zero value used to represent the error condition is implementation defined and therefore left up to the extension developer.

messagestr, optionalEmpty string

This parameter allows the extension to pass a completion message back to the Controller. The message will be logged by the Controller.


valueslist, optionalEmpty List

This parameter specifies a list of string values to be returned to the Controller and used to populate the associated dynamic choice field on the Extension task form.

Example

Panel
>>> @dynamic_choice_command("primary_choice_field")
>>> def primary_choice_command(self, fields):
>>>     # Implementation omitted
>>>     return ExtensionResult(
...         rc = 0,
...         message = "Values for choice field: 'primary_choice_field'",
...         values = ["Start", "Pause", "Stop", "Build", "Destroy"]
...         )

...

(rc = 0, message = '', output_fields = None, unv_output = None, call_frame = None, **kwargs)

ParameterTypeDefaultDescription
rc

int, optional

0

This parameter represents the return code of the extension_start operation. The associated Universal Task instance in the Controler can use this value to determine the completion status of the Extension instance. The value is implementation defined and therefore left up to the extension developer.

messagestr, optionalEmpty string

This parameter allows the extension to pass a completion message back to the Controller. If rc is set to 0, the message will be considered informational and will be logged by the Controller.
If rc is non-zero, the message will be considered an error message and will be displayed to the user on the task instance form.

output_fieldsdict, optionalNone

Dictionary containing output fields. 

unv_outputstr, optionalNone

The value for this parameter is considered the payload of the task execution. It appears on the task instance Output tab as Universal output type.

Example

Panel
>>> def extension_start(self, fields):
>>>     # Implementation omitted
>>>     return ExtensionResult(
...         unv_output = "extension_start() finished successfully",
...         rc = 0
...         )