예제 #1
0
 class GroupForm(RbacForm):
     form_type = HiddenField(default="group")
예제 #2
0
class ImportService(BaseForm):
    action = "eNMS.administration.importService"
    form_type = HiddenField(default="import_service")
    service = SelectField("Service", choices=())
예제 #3
0
class DatabaseDeletionForm(BaseForm):
    action = "eNMS.administration.databaseDeletion"
    form_type = HiddenField(default="database_deletion")
    deletion_choices = [(p, p) for p in app.database["import_export_models"]]
    deletion_types = SelectMultipleField("Instances to delete",
                                         choices=deletion_choices)
예제 #4
0
파일: automation.py 프로젝트: bbrk364/eNMS
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 = StringField("Device Query",
                               python=True,
                               widget=TextArea(),
                               render_kw={"rows": 2})
    device_query_property = SelectField("Query Property Type",
                                        choices=(("name", "Name"),
                                                 ("ip_address", "IP address")))
    devices = MultipleInstanceField("Devices")
    pools = MultipleInstanceField("Pools")
    update_pools = BooleanField("Update pools before running")
    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)
    max_number_of_retries = IntegerField("Maximum number of retries",
                                         default=100)
    maximum_runs = IntegerField("Maximum number of runs", default=1)
    skip = BooleanField("Skip")
    skip_query = StringField("Skip Query (Python)",
                             python=True,
                             widget=TextArea(),
                             render_kw={"rows": 2})
    skip_value = SelectField(
        "Skip Value",
        choices=(
            ("True", "True"),
            ("False", "False"),
        ),
    )
    vendor = StringField("Vendor")
    operating_system = StringField("Operating System")
    iteration_values = StringField("Iteration Values", python=True)
    initial_payload = DictField()
    iteration_variable_name = StringField("Iteration Variable Name",
                                          default="iteration_value")
    iteration_devices = StringField("Iteration Devices", python=True)
    iteration_devices_property = SelectField(
        "Iteration Devices Property",
        choices=(("name", "Name"), ("ip_address", "IP address")),
    )
    preprocessing = StringField(type="code", python=True, widget=TextArea())
    postprocessing = StringField(type="code", python=True, widget=TextArea())
    postprocessing_mode = SelectField(choices=(
        ("always", "Always run"),
        ("success", "Run on success only"),
        ("failure", "Run on failure only"),
    ))
    log_level = SelectField(
        "Logging",
        choices=((0, "Disable logging"), *enumerate(app.log_levels, 1)),
        default=1,
        validation=False,
    )
    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 = StringField("Content Match",
                                widget=TextArea(),
                                render_kw={"rows": 8},
                                substitution=True)
    content_match_regex = BooleanField("Match content with Regular Expression")
    dict_match = DictField("Dictionary to Match Against", substitution=True)
    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"),
        ),
    )

    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.")
        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 conversion_validation_mismatch)
예제 #5
0
파일: automation.py 프로젝트: bbrk364/eNMS
class FileForm(BaseForm):
    template = "file"
    form_type = HiddenField(default="file")
    file_content = StringField(widget=TextArea(), render_kw={"rows": 8})
예제 #6
0
class ExcelImportForm(BaseForm):
    template = "topology_import"
    form_type = HiddenField(default="excel_import")
    replace = BooleanField("Replace Existing Topology")
예제 #7
0
파일: automation.py 프로젝트: gnubyte/eNMS
class RestartWorkflowForm(BaseForm):
    action = "eNMS.workflow.restartWorkflow"
    form_type = HiddenField(default="restart_workflow")
    start_services = MultipleInstanceField("Services", model="service")
    restart_runtime = SelectField("Restart Runtime", choices=(), validation=False)
예제 #8
0
class PayloadValidationForm(ServiceForm):
    form_type = HiddenField(default="payload_validation_service")
    query = StringField("Python Query", python=True)
예제 #9
0
class RestartWorkflowForm(BaseForm):
    action = "eNMS.workflow.restartWorkflow"
    form_type = HiddenField(default="restart_workflow")
    start_services = HiddenField()
    restart_runtime = SelectField("Restart Runtime", validate_choice=False)
예제 #10
0
class LoginForm(BaseForm):
    form_type = HiddenField(default="login")
    get_request_allowed = False
    authentication_method = SelectField("Authentication Method", choices=())
    name = StringField("Name", [InputRequired()])
    password = PasswordField("Password", [InputRequired()])
예제 #11
0
파일: scheduling.py 프로젝트: gaecom/eNMS
class EventForm(BaseForm):
    template = "event"
    form_type = HiddenField(default="event")
    id = HiddenField()
    name = StringField("Name", [InputRequired()])
예제 #12
0
class UploadFilesForm(BaseForm):
    template = "upload_files"
    folder = HiddenField()
    form_type = HiddenField(default="upload_files")
예제 #13
0
class FilesForm(BaseForm):
    template = "files"
    form_type = HiddenField(default="files")
예제 #14
0
class SettingsForm(BaseForm):
    form_type = HiddenField(default="settings_panel")
    settings = JsonField("Settings")
    write_changes = BooleanField("Write changes back to 'settings.json' file")
예제 #15
0
class NapalmBackupForm(NapalmForm):
    form_type = HiddenField(default="napalm_backup_service")
    configuration_getters = SelectMultipleField(choices=(
        ("get_arp_table", "ARP table"),
        ("get_interfaces_counters", "Interfaces counters"),
        ("get_facts", "Facts"),
        ("get_environment", "Environment"),
        ("get_config", "Configuration"),
        ("get_interfaces", "Interfaces"),
        ("get_interfaces_ip", "Interface IP"),
        ("get_lldp_neighbors", "LLDP neighbors"),
        ("get_lldp_neighbors_detail", "LLDP neighbors detail"),
        ("get_mac_address_table", "MAC address"),
        ("get_ntp_servers", "NTP servers"),
        ("get_ntp_stats", "NTP statistics"),
        ("get_optics", "Transceivers"),
        ("get_snmp_information", "SNMP"),
        ("get_users", "Users"),
        ("get_network_instances", "Network instances (VRF)"),
        ("get_ntp_peers", "NTP peers"),
        ("get_bgp_config", "BGP configuration"),
        ("get_bgp_neighbors", "BGP neighbors"),
        ("get_ipv6_neighbors_table", "IPv6"),
        ("is_alive", "Is alive"),
    ))
    operational_data_getters = SelectMultipleField(choices=(
        ("get_arp_table", "ARP table"),
        ("get_interfaces_counters", "Interfaces counters"),
        ("get_facts", "Facts"),
        ("get_environment", "Environment"),
        ("get_config", "Configuration"),
        ("get_interfaces", "Interfaces"),
        ("get_interfaces_ip", "Interface IP"),
        ("get_lldp_neighbors", "LLDP neighbors"),
        ("get_lldp_neighbors_detail", "LLDP neighbors detail"),
        ("get_mac_address_table", "MAC address"),
        ("get_ntp_servers", "NTP servers"),
        ("get_ntp_stats", "NTP statistics"),
        ("get_optics", "Transceivers"),
        ("get_snmp_information", "SNMP"),
        ("get_users", "Users"),
        ("get_network_instances", "Network instances (VRF)"),
        ("get_ntp_peers", "NTP peers"),
        ("get_bgp_config", "BGP configuration"),
        ("get_bgp_neighbors", "BGP neighbors"),
        ("get_ipv6_neighbors_table", "IPv6"),
        ("is_alive", "Is alive"),
    ))
    replacements = FieldList(FormField(ReplacementForm), min_entries=3)
    groups = {
        "Create Configuration File": {
            "commands": ["configuration_getters"],
            "default": "expanded",
        },
        "Create Operational Data File": {
            "commands": ["operational_data_getters"],
            "default": "expanded",
        },
        "Search Response & Replace": {
            "commands": ["replacements"],
            "default": "expanded",
        },
        **NapalmForm.groups,
    }
예제 #16
0
class SwissArmyKnifeForm(ServiceForm):
    form_type = HiddenField(default="swiss_army_knife_service")
예제 #17
0
class LinkForm(ObjectForm):
    template = "object"
    form_type = HiddenField(default="link")
    id = HiddenField()
    color = StringField("Color")
예제 #18
0
class VisualizationForm(BaseForm):
    action = "eNMS.visualization.saveParameters"
    form_type = HiddenField(default="visualization_parameters")
    default_pools = MultipleInstanceField("Pools", model="pool")
예제 #19
0
class ExportForm(BaseForm):
    action = "eNMS.inventory.exportTopology"
    form_type = HiddenField(default="excel_export")
    export_filename = StringField("Filename")
예제 #20
0
class DeviceDataForm(BaseForm):
    template = "device_data"
    form_type = HiddenField(default="device_data")
    data_type = SelectField("Display", choices=app.configuration_properties)
예제 #21
0
파일: automation.py 프로젝트: bbrk364/eNMS
class NetmikoForm(ConnectionForm):
    form_type = HiddenField(default="netmiko")
    abstract_service = True
    driver = SelectField(choices=app.NETMIKO_DRIVERS)
    use_device_driver = BooleanField(default=True)
    enable_mode = BooleanField("Enable mode (run in enable mode or as root)",
                               default=True)
    config_mode = BooleanField("Config mode", default=False)
    fast_cli = BooleanField()
    timeout = FloatField(default=10.0)
    delay_factor = FloatField(
        ("Delay Factor (Changing from default of 1"
         " will nullify Netmiko Timeout setting)"),
        default=1.0,
    )
    global_delay_factor = FloatField(
        ("Global Delay Factor (Changing from default of 1"
         " will nullify Netmiko Timeout setting)"),
        default=1.0,
    )
    jump_on_connect = BooleanField("Jump on remote device on connect",
                                   default=False)
    jump_command = StringField(
        label="Command that jumps to device",
        default="ssh jump_server_IP",
        substitution=True,
    )
    jump_username = StringField(label="Device username", substitution=True)
    jump_password = PasswordField(label="Device password", substitution=True)
    exit_command = StringField(
        label="Command to exit device back to original device",
        default="exit",
        substitution=True,
    )
    expect_username_prompt = StringField("Expected username prompt",
                                         default="username:"******"Expected password prompt",
                                         default="password",
                                         substitution=True)
    expect_prompt = StringField("Expected prompt after login",
                                default="admin.*$",
                                substitution=True)
    groups = {
        "Jump on connect Parameters": {
            "commands": [
                "jump_on_connect",
                "jump_command",
                "expect_username_prompt",
                "jump_username",
                "expect_password_prompt",
                "jump_password",
                "expect_prompt",
                "exit_command",
            ],
            "default":
            "hidden",
        },
        "Netmiko Parameters": {
            "commands": [
                "driver",
                "use_device_driver",
                "enable_mode",
                "config_mode",
                "fast_cli",
                "timeout",
                "delay_factor",
                "global_delay_factor",
            ],
            "default":
            "expanded",
        },
        "Connection Parameters": ConnectionForm.group,
    }
예제 #22
0
class LinkForm(ObjectForm):
    action = "eNMS.base.processData"
    form_type = HiddenField(default="link")
    source = InstanceField("Source", model="device")
    destination = InstanceField("Destination", model="device")
    color = StringField("Color")
예제 #23
0
파일: automation.py 프로젝트: bbrk364/eNMS
class RunForm(BaseForm):
    template = "object"
    form_type = HiddenField(default="run")
    id = HiddenField()
예제 #24
0
class MattermostNotificationForm(ServiceForm):
    form_type = HiddenField(default="mattermost_notification_service")
    channel = StringField(substitution=True)
    body = StringField(widget=TextArea(),
                       render_kw={"rows": 5},
                       substitution=True)
예제 #25
0
파일: automation.py 프로젝트: bbrk364/eNMS
class WorkflowEdgeForm(BaseForm):
    template = "object"
    form_type = HiddenField(default="workflow_edge")
    id = HiddenField()
    label = StringField()
예제 #26
0
class ServiceForm(BaseForm):
    template = "service"
    form_type = HiddenField(default="service")
    get_request_allowed = False
    id = HiddenField()
    name = StringField("Name")
    type = StringField("Service Type")
    access_groups = StringField("Groups")
    shared = BooleanField("Shared")
    scoped_name = StringField("Scoped Name", [InputRequired()])
    description = StringField("Description")
    device_query = StringField(
        "Device Query", python=True, widget=TextArea(), render_kw={"rows": 2}
    )
    device_query_property = SelectField(
        "Query Property Type", choices=(("name", "Name"), ("ip_address", "IP address"))
    )
    target_devices = MultipleInstanceField("Devices")
    disable_result_creation = BooleanField("Save only failed results")
    target_pools = MultipleInstanceField("Pools")
    update_target_pools = BooleanField("Update target pools before running")
    update_pools_after_running = BooleanField("Update pools after running")
    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)")
    reply_to = StringField("Reply-to Email Address")
    number_of_retries = IntegerField("Number of retries", default=0)
    time_between_retries = IntegerField("Time between retries (in seconds)", default=10)
    max_number_of_retries = IntegerField("Maximum number of retries", default=100)
    credential_type = SelectField(
        "Type of Credentials",
        choices=(
            ("any", "Any"),
            ("read-write", "Read Write"),
            ("read-only", "Read Only"),
        ),
    )
    maximum_runs = IntegerField("Maximum number of runs", default=1)
    skip_query = StringField(
        "Skip Query (Python)", python=True, widget=TextArea(), render_kw={"rows": 2}
    )
    skip_value = SelectField(
        "Skip Value",
        choices=(
            ("success", "Success"),
            ("failure", "Failure"),
            ("discard", "Discard"),
        ),
    )
    vendor = StringField("Vendor")
    operating_system = StringField("Operating System")
    iteration_values = StringField("Iteration Values", python=True)
    initial_payload = DictField()
    iteration_variable_name = StringField(
        "Iteration Variable Name", default="iteration_value"
    )
    iteration_devices = StringField("Iteration Devices", python=True)
    iteration_devices_property = SelectField(
        "Iteration Devices Property",
        choices=(("name", "Name"), ("ip_address", "IP address")),
    )
    preprocessing = StringField(type="code", python=True, widget=TextArea())
    postprocessing = StringField(type="code", python=True, widget=TextArea())
    postprocessing_mode = SelectField(
        choices=(
            ("always", "Always run"),
            ("success", "Run on success only"),
            ("failure", "Run on failure only"),
        )
    )
    default_access = SelectField(
        choices=(
            ("creator", "Creator only"),
            ("public", "Public (all users)"),
            ("admin", "Admin Users only"),
        )
    )
    log_level = SelectField(
        "Logging",
        choices=((0, "Disable logging"), *enumerate(app.log_levels, 1)),
        default=1,
        validation=False,
    )
    multiprocessing = BooleanField("Multiprocessing")
    max_processes = IntegerField("Maximum number of processes", default=15)
    validation_condition = SelectField(
        choices=(
            ("none", "No validation"),
            ("success", "Run on success only"),
            ("failure", "Run on failure only"),
            ("always", "Always run"),
        )
    )
    conversion_method = SelectField(
        choices=(
            ("none", "No conversion"),
            ("text", "Text"),
            ("json", "Json dictionary"),
            ("xml", "XML dictionary"),
        )
    )
    validation_method = SelectField(
        "Validation Method",
        choices=(
            ("text", "Validation by text match"),
            ("dict_included", "Validation by dictionary inclusion"),
            ("dict_equal", "Validation by dictionary equality"),
        ),
    )
    content_match = StringField(
        "Content Match", widget=TextArea(), render_kw={"rows": 8}, substitution=True
    )
    content_match_regex = BooleanField('"Content Match" is a regular expression')
    dict_match = DictField("Dictionary to Match Against", substitution=True)
    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"),
        ),
    )

    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."
            )
        forbidden_name_error = self.scoped_name.data in ("Start", "End", "Placeholder")
        if forbidden_name_error:
            self.name.errors.append("This name is not allowed.")
        conversion_validation_mismatch = self.validation_condition.data != "none" and (
            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.label}"
                f" and the validation method to {self.validation_method.label} :"
                " these do not match."
            )
        empty_validation = self.validation_condition.data != "none" and (
            self.validation_method.data == "text"
            and not self.content_match.data
            or self.validation_method.data == "dict_included"
            and self.dict_match.data == "{}"
        )
        if empty_validation:
            self.content_match.errors.append(
                f"The validation method is set to '{self.validation_method.data}'"
                f" and the matching value is empty: these do no match."
            )
        too_many_threads_error = (
            self.max_processes.data > app.settings["automation"]["max_process"]
        )
        if too_many_threads_error:
            self.max_processes.errors.append(
                "The number of threads used for multiprocessing must be "
                f"less than {app.settings['automation']['max_process']}."
            )
        return (
            valid_form
            and not conversion_validation_mismatch
            and not empty_validation
            and not forbidden_name_error
            and not no_recipient_error
            and not too_many_threads_error
        )
예제 #27
0
class SettingsForm(BaseForm):
    form_type = HiddenField(default="settings_panel")
    action = "eNMS.administration.saveSettings"
    settings = JsonField("Settings")
    write_changes = BooleanField("Write changes back to 'settings.json' file")
예제 #28
0
class WorkflowEdgeForm(BaseForm):
    action = "eNMS.base.processData"
    form_type = HiddenField(default="workflow_edge")
    id = HiddenField()
    label = StringField()
    color = StringField()
예제 #29
0
class AdminForm(BaseForm):
    template = "administration"
    form_type = HiddenField(default="administration")
예제 #30
0
class UnixCommandForm(ServiceForm):
    form_type = HiddenField(default="unix_command_service")
    command = StringField(substitution=True)