class DeviceForm(ObjectForm): template = "object" form_type = HiddenField(default="device") id = HiddenField() icon = SelectField( "Icon", choices=( ("antenna", "Antenna"), ("firewall", "Firewall"), ("host", "Host"), ("optical_switch", "Optical switch"), ("regenerator", "Regenerator"), ("router", "Router"), ("server", "Server"), ("switch", "Switch"), ), ) ip_address = StringField("IP address") port = IntegerField("Port", default=22) operating_system = StringField("Operating System") os_version = StringField("OS Version") longitude = StringField("Longitude", default=0.0) latitude = StringField("Latitude", default=0.0) username = StringField("Username") password = PasswordField("Password") enable_password = PasswordField("'Enable' Password") napalm_driver = SelectField("NAPALM Driver", choices=app.NAPALM_DRIVERS, default="ios") netmiko_driver = SelectField("Netmiko Driver", choices=app.NETMIKO_DRIVERS, default="cisco_ios") scrapli_driver = SelectField("Scrapli Driver", choices=choices(app.SCRAPLI_DRIVERS), default="cisco_iosxe")
class GenericFileTransferForm(ServiceForm): form_type = HiddenField(default="generic_file_transfer_service") direction = SelectField(choices=(("get", "Get"), ("put", "Put"))) protocol = SelectField(choices=(("scp", "SCP"), ("sftp", "SFTP"))) source_file = StringField(validators=[InputRequired()], substitution=True) destination_file = StringField(validators=[InputRequired()], substitution=True) missing_host_key_policy = BooleanField() load_known_host_keys = BooleanField() look_for_keys = BooleanField() source_file_includes_globbing = BooleanField( "Source file includes glob pattern") max_transfer_size = IntegerField(default=2**30) window_size = IntegerField(default=2**30) timeout = FloatField(default=10.0) credentials = SelectField( "Credentials", choices=( ("device", "Device Credentials"), ("user", "User Credentials"), ("custom", "Custom Credentials"), ), ) custom_username = StringField("Custom Username", substitution=True) custom_password = PasswordField("Custom Password", substitution=True) def validate(self): valid_form = super().validate() invalid_direction = (self.source_file_includes_globbing.data and self.direction.data == "get") if invalid_direction: self.direction.errors.append( "Globbing only works with the 'PUT' direction") return valid_form and not invalid_direction
class ConnectionForm(ServiceForm): form_type = HiddenField(default="connection") abstract_service = True credentials = SelectField( "Credentials", choices=( ("device", "Device Credentials"), ("user", "User Credentials"), ("custom", "Custom Credentials"), ), ) custom_username = StringField("Custom Username", substitution=True) custom_password = PasswordField("Custom Password", substitution=True) use_host_keys = BooleanField("Use Host Keys - Requires: 'Custom Credentials' with 'Custom Username'") start_new_connection = BooleanField("Start New Connection") close_connection = BooleanField("Close Connection") groups = { "Connection Parameters": { "commands": [ "credentials", "custom_username", "custom_password", "use_host_keys", "start_new_connection", "close_connection", ], "default": "expanded", } }
class UserForm(BaseForm): template = "object" form_type = HiddenField(default="user") id = HiddenField() name = StringField("Name", [InputRequired()]) password = PasswordField("Password") email = StringField("Email") group = SelectField("Permissions", choices=[(g, g) for g in app.rbac["groups"]])
class UserForm(RbacForm): form_type = HiddenField(default="user") manual_rbac = BooleanField("Manually defined RBAC") theme = SelectField( "Theme", choices=[(theme, values["name"]) for theme, values in themes["themes"].items()], ) password = PasswordField("Password")
class DeviceConnectionForm(BaseForm): template = "device_connection" form_type = HiddenField(default="device_connection") address_choices = [("ip_address", "IP address"), ("name", "Name")] + [ (property, values["pretty_name"]) for property, values in app.properties["custom"]["device"].items() if values.get("is_address", False) ] address = SelectField(choices=address_choices) username = StringField("Username") password = PasswordField("Password")
class Form(BaseForm): form_type = HiddenField(default="custom") address = SelectField(choices=[("ipv4", "IPv4"), ("ipv6", "IPv6")]) connected_links = MultipleInstanceField("Links", model="link") hostname = StringField("Username", default="admin") ip_address = StringField("IP address") neighbor = InstanceField("Devices", model="device") ports = MultipleInstanceField("Port", model="port") password = PasswordField("Password") carry_customer_traffic = BooleanField("Carry Customer Traffic", default=False)
class TopologyImportForm(ServiceForm): form_type = HiddenField(default="topology_import_service") import_type = SelectField(choices=( ("librenms", "LibreNMS"), ("netbox", "Netbox"), ("opennms", "OpenNMS"), )) netbox_address = StringField(default="http://0.0.0.0:8000") netbox_token = PasswordField() opennms_address = StringField() opennms_devices = StringField() opennms_login = StringField() opennms_password = PasswordField() librenms_address = StringField(default="http://librenms.example.com") librenms_token = PasswordField() groups = { "Type of Import": { "commands": ["import_type"], "default": "expanded" }, "Netbox": { "commands": ["netbox_address", "netbox_token"], "default": "expanded", }, "OpenNMS": { "commands": [ "opennms_address", "opennms_devices", "opennms_login", "opennms_password", ], "default": "expanded", }, "LibreNMS": { "commands": ["librenms_address", "librenms_token"], "default": "expanded", }, }
class UserForm(RbacForm): form_type = HiddenField(default="user") is_admin = BooleanField(default=False) authentication = SelectField( "Authentication Method", choices=[(method, values["display_name"]) for method, values in settings["authentication"]["methods"].items()], ) theme = SelectField( "Theme", choices=[(theme, values["name"]) for theme, values in themes["themes"].items()], ) password = PasswordField("Password")
class CredentialForm(BaseForm): action = "eNMS.base.processData" form_type = HiddenField(default="credential") id = HiddenField() name = StringField("Name", [InputRequired()]) description = StringField(widget=TextArea(), render_kw={"rows": 13}) role = SelectField( "Role", choices=( ("read-write", "Read Write"), ("read-only", "Read Only"), ), ) subtype = SelectField("Type", choices=(("password", "Username / Password"), ("key", "SSH Key"))) device_pools = MultipleInstanceField("Devices", model="pool") user_pools = MultipleInstanceField("Users", model="pool") priority = IntegerField("Priority", default=1) username = StringField("Username") enable_password = PasswordField("'Enable' Password") password = PasswordField("Password") private_key = StringField(widget=TextArea(), render_kw={"rows": 10})
class RestCallForm(ServiceForm): form_type = HiddenField(default="rest_call_service") call_type = SelectField(choices=( ("GET", "GET"), ("POST", "POST"), ("PUT", "PUT"), ("DELETE", "DELETE"), ("PATCH", "PATCH"), )) rest_url = StringField(substitution=True) payload = DictField(json_only=True, substitution=True) params = DictField(substitution=True) headers = DictField(substitution=True) verify_ssl_certificate = BooleanField("Verify SSL Certificate") timeout = IntegerField(default=15) username = StringField() password = PasswordField()
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 to remote device on connect", default=False, render_kw={"help": "netmiko/jump_on_connect"}, ) jump_command = StringField( label="Command that jumps to device", default="ssh jump_server_IP", substitution=True, render_kw={"help": "netmiko/jump_command"}, ) jump_username = StringField( label="Device username", substitution=True, render_kw={"help": "netmiko/jump_username"}, ) jump_password = PasswordField( label="Device password", substitution=True, render_kw={"help": "netmiko/jump_password"}, ) exit_command = StringField( label="Command to exit device back to original device", default="exit", substitution=True, render_kw={"help": "netmiko/exit_command"}, ) expect_username_prompt = StringField( "Expected username prompt", default="username:"******"help": "netmiko/expect_username_prompt"}, ) expect_password_prompt = StringField( "Expected password prompt", default="password", substitution=True, render_kw={"help": "netmiko/expect_password_prompt"}, ) expect_prompt = StringField( "Expected prompt after login", default="admin.*$", substitution=True, render_kw={"help": "netmiko/expect_prompt"}, ) groups = { "Netmiko Parameters": { "commands": [ "driver", "use_device_driver", "enable_mode", "config_mode", "fast_cli", "timeout", "delay_factor", "global_delay_factor", ], "default": "expanded", }, **ConnectionForm.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", }, }
class LoginForm(BaseForm): form_type = HiddenField(default="login") authentication_method = SelectField("Authentication Method", choices=()) name = StringField("Name", [InputRequired()]) password = PasswordField("Password", [InputRequired()])