Ejemplo n.º 1
0
class WorkflowResultsForm(ResultsForm):
    form_type = HiddenField(default="workflow_results")
    workflow_device = NoValidationSelectField("Device", choices=())
    workflow_device_compare = NoValidationSelectField("Device", choices=())
    device = NoValidationSelectField("Device", choices=())
    device_compare = NoValidationSelectField("Device", choices=())
    job = NoValidationSelectField("Job", choices=())
    job_compare = NoValidationSelectField("Job", choices=())
Ejemplo n.º 2
0
class WorkflowForm(JobForm):
    form_type = HiddenField(default="workflow")
    device_targets_mode = SelectField(
        "Device Targets Mode",
        choices=(
            ("service", "Run with Workflow Targets, service by service"),
            ("device", "Run with Workflow Targets, device by device"),
            ("ignore", "Run with Service Targets"),
        ),
    )
    start_jobs = MultipleInstanceField("Workflow Entry Point(s)",
                                       instance_type="Job")
    restart_runtime = NoValidationSelectField("Restart Runtime", choices=())
    payloads_to_exclude = NoValidationSelectMultipleField(
        "Payloads to Exclude", choices=())
Ejemplo n.º 3
0
class AnsiblePlaybookForm(ServiceForm, ValidationForm):
    form_type = HiddenField(default="AnsiblePlaybookService")
    has_targets = BooleanField("Has Target Devices")
    playbook_path = NoValidationSelectField("Playbook Path", choices=())
    arguments = SubstitutionField("Arguments (Ansible command line options)")
    pass_device_properties = BooleanField(
        "Pass Device Inventory Properties (to be used "
        "in the playbook as {{name}} or {{ip_address}})")
    options = DictField("Options (passed to ansible as -e extra args)")
    groups = {
        "Main Parameters": [
            "playbook_path",
            "arguments",
            "pass_device_properties",
            "options",
        ],
        "Validation Parameters":
        ValidationForm.group,
    }
Ejemplo n.º 4
0
class ResultForm(BaseForm):
    template = "result"
    form_type = HiddenField(default="result")
    results_runtime = NoValidationSelectField("Runtime", choices=())
Ejemplo n.º 5
0
class LogsForm(BaseForm):
    template = "log"
    form_type = HiddenField(default="log")
    filter = StringField("Filter")
    logs_runtime = NoValidationSelectField("Runtime", choices=())
Ejemplo n.º 6
0
class RestartWorkflowForm(BaseForm):
    action = "restartWorkflow"
    form_type = HiddenField(default="restart_workflow")
    start_services = MultipleInstanceField("Services", model="service")
    restart_runtime = NoValidationSelectField("Restart Runtime", choices=())
Ejemplo n.º 7
0
class RunResultsForm(ResultsForm):
    form_type = HiddenField(default="run_results")
    device = NoValidationSelectField("Device", choices=())
    device_compare = NoValidationSelectField("Device", choices=())
Ejemplo n.º 8
0
class RestartWorkflowForm(BaseForm):
    action = "restartWorkflow"
    form_type = HiddenField(default="restart_workflow")
    start_jobs = MultipleInstanceField("Workflow Entry Point(s)",
                                       instance_type="Job")
    restart_runtime = NoValidationSelectField("Restart Runtime", choices=())
Ejemplo n.º 9
0
class TreeForm(BaseForm):
    template = "tree"
    form_type = HiddenField(default="tree")
    runtimes = NoValidationSelectField("Runtime", choices=())
Ejemplo n.º 10
0
class ServiceForm(BaseForm):
    template = "service"
    form_type = HiddenField(default="service")
    id = HiddenField()
    name = StringField("Name")
    type = StringField("Service Type")
    shared = BooleanField("Shared Service")
    scoped_name = StringField("Scoped Name", [InputRequired()])
    description = StringField("Description")
    device_query = PythonField("Device Query")
    device_query_property = SelectField("Query Property Type",
                                        choices=(("name", "Name"),
                                                 ("ip_address", "IP address")))
    devices = MultipleInstanceField("Devices")
    pools = MultipleInstanceField("Pools")
    workflows = MultipleInstanceField("Workflows")
    waiting_time = IntegerField(
        "Time to Wait before next service is started (in seconds)", default=0)
    send_notification = BooleanField("Send a notification")
    send_notification_method = SelectField(
        "Notification Method",
        choices=(("mail", "Mail"), ("slack", "Slack"), ("mattermost",
                                                        "Mattermost")),
    )
    notification_header = StringField(widget=TextArea(), render_kw={"rows": 5})
    include_device_results = BooleanField("Include Device Results")
    include_link_in_summary = BooleanField("Include Result Link in Summary")
    display_only_failed_nodes = BooleanField("Display only Failed Devices")
    mail_recipient = StringField("Mail Recipients (separated by comma)")
    number_of_retries = IntegerField("Number of retries", default=0)
    time_between_retries = IntegerField("Time between retries (in seconds)",
                                        default=10)
    maximum_runs = IntegerField("Maximum number of runs", default=1)
    skip = BooleanField("Skip")
    skip_query = PythonField("Skip Query (Python)")
    skip_value = SelectField(
        "Skip Value",
        choices=(
            ("True", "True"),
            ("False", "False"),
        ),
    )
    vendor = StringField("Vendor")
    operating_system = StringField("Operating System")
    initial_payload = DictField()
    iteration_values = PythonField("Iteration Values")
    iteration_variable_name = StringField("Iteration Variable Name",
                                          default="iteration_value")
    iteration_devices = PythonField("Iteration Devices")
    iteration_devices_property = SelectField(
        "Iteration Devices Property",
        choices=(("name", "Name"), ("ip_address", "IP address")),
    )
    result_postprocessing = CodeField(widget=TextArea(), render_kw={"rows": 8})
    log_level = NoValidationSelectField(
        "Logging",
        choices=((0, "Disable logging"), *enumerate(app.log_levels, 1)),
    )
    multiprocessing = BooleanField("Multiprocessing")
    max_processes = IntegerField("Maximum number of processes", default=15)
    conversion_method = SelectField(choices=(
        ("none", "No conversion"),
        ("text", "Text"),
        ("json", "Json dictionary"),
        ("xml", "XML dictionary"),
    ))
    validation_method = SelectField(
        "Validation Method",
        choices=(
            ("none", "No validation"),
            ("text", "Validation by text match"),
            ("dict_included", "Validation by dictionary inclusion"),
            ("dict_equal", "Validation by dictionary equality"),
        ),
    )
    content_match = SubstitutionField("Content Match",
                                      widget=TextArea(),
                                      render_kw={"rows": 8})
    content_match_regex = BooleanField("Match content with Regular Expression")
    dict_match = DictSubstitutionField("Dictionary to Match Against")
    negative_logic = BooleanField("Negative logic")
    delete_spaces_before_matching = BooleanField(
        "Delete Spaces before Matching")
    run_method = SelectField(
        "Run Method",
        choices=(
            ("per_device", "Run the service once per device"),
            ("once", "Run the service once"),
        ),
    )
    query_fields = [
        "device_query",
        "skip_query",
        "iteration_values",
        "result_postprocessing",
    ]

    def validate(self):
        valid_form = super().validate()
        no_recipient_error = (self.send_notification.data
                              and self.send_notification_method.data == "mail"
                              and not self.mail_recipient.data)
        if no_recipient_error:
            self.mail_recipient.errors.append(
                "Please add at least one recipient for the mail notification.")
        bracket_error = False
        for query_field in self.query_fields:
            field = getattr(self, query_field)
            try:
                parse(field.data)
            except Exception as exc:
                bracket_error = True
                field.errors.append(f"Wrong python expression ({exc}).")
            if "{{" in field.data and "}}" in field.data:
                bracket_error = True
                field.errors.append(
                    "You cannot use variable substitution "
                    "in a field expecting a python expression.")
        conversion_validation_mismatch = (
            self.conversion_method.data == "text"
            and "dict" in self.validation_method.data
            or self.conversion_method.data in ("xml", "json")
            and "dict" not in self.validation_method.data)
        if conversion_validation_mismatch:
            self.conversion_method.errors.append(
                f"The conversion method is set to '{self.conversion_method.data}'"
                f" and the validation method to '{self.validation_method.data}' :"
                " these do not match.")
        return (valid_form and not no_recipient_error and not bracket_error
                and not conversion_validation_mismatch)
Ejemplo n.º 11
0
class WorkflowForm(ServiceForm):
    form_type = HiddenField(default="workflow")
    close_connection = BooleanField(default=False)
    start_services = MultipleInstanceField("Workflow Entry Point(s)")
    restart_runtime = NoValidationSelectField("Restart Runtime", choices=())
Ejemplo n.º 12
0
class RuntimeForm(BaseForm):
    template = "runtime"
    form_type = HiddenField(default="runtime")
    filter = StringField("Filter")
    runtimes = NoValidationSelectField("Runtime", choices=())