コード例 #1
0
class GenericFormTemplate(GatewayForm):
    """ Form to generate HTML and Javascript for the update_ip4_address_example workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'update_ip4_address_example'
    workflow_permission = 'update_ip4_address_example_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        enable_dependencies={'on_complete': ['ip4_address']},
        disable_dependencies={'on_change': ['ip4_address']},
        clear_dependencies={'on_change': ['ip4_address']})

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Address',
        required=True,
        clear_below_on_change=False,
        inputs={
            'configuration': 'configuration',
            'address': 'ip4_address'
        },
        server_outputs={
            'on_validate': {
                'state': 'address_state',
                'mac_address': 'mac_address',
                'name': 'description'
            }
        },
        server_side_output_method=get_ip4_address_endpoint,
        result_decorator=filter_allocated,
        should_cascade_clear_on_change=True,
        should_cascade_disable_on_change=True,
        enable_dependencies={
            'on_complete':
            ['address_state', 'mac_address', 'description', 'submit']
        },
        disable_dependencies={
            'on_change':
            ['address_state', 'mac_address', 'description', 'submit']
        })

    line_break = PlainHTML('<hr>')

    address_state = CustomStringField(label='Address State', readonly=True)

    mac_address = CustomStringField(label='MAC Address')

    description = CustomStringField(label='Description')

    submit = SubmitField(label='Update')
コード例 #2
0
class GenericFormTemplate(GatewayForm):
    """Form to generate HTML and Javascript for the delete_ip4_address workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """

    workflow_name = "delete_ip4_address"
    workflow_permission = "delete_ip4_address_page"
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Configuration",
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        enable_dependencies={"on_complete": ["ip4_address"]},
        disable_dependencies={"on_change": ["ip4_address"]},
        clear_dependencies={"on_change": ["ip4_address"]},
    )

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Address",
        required=True,
        inputs={"configuration": "configuration", "address": "ip4_address"},
        server_outputs={
            "on_change": {
                "state": "address_state",
                "mac_address": "mac_address",
                "name": "description",
            }
        },
        server_side_output_method=get_ip4_address_endpoint,
        result_decorator=filter_allocated,
        clear_below_on_change=False,
        should_cascade_disable_on_change=True,
        enable_dependencies={"on_complete": ["submit"]},
        disable_dependencies={
            "on_change": ["address_state", "mac_address", "description", "submit"]
        },
    )

    line_break = PlainHTML("<hr>")

    address_state = CustomStringField(label="Address State", readonly=True)

    mac_address = CustomStringField(label="MAC Address", readonly=True)

    description = CustomStringField(label="Description", readonly=True)

    submit = SubmitField(label="Delete")
コード例 #3
0
class GenericFormTemplate(GatewayForm):
    # When updating the form, remember to make the corresponding changes to the workflow pages
    workflow_name = 'add_static_ip4_address_example'
    workflow_permission = 'add_static_ip4_address_example_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        validators=[],
        is_disabled_on_start=False,
        enable_on_complete=['ip4_address'],
    )

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Address',
        required=True,
        inputs={
            'configuration': 'configuration',
            'address': 'ip4_address'
        },
        result_decorator=filter_unallocated,
        on_complete=['call_view'],
        enable_on_complete=['view', 'mac_address', 'description', 'submit'])

    mac_address = CustomStringField(label='MAC Address')

    description = CustomStringField(label='Description')

    view = View(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='View',
                one_off=True,
                on_complete=['call_zone'],
                on_change=['view_changed'],
                clear_below_on_change=False,
                enable_on_complete=['zone'])

    zone = Zone(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='Zone',
                on_change=['reset_hostname'],
                clear_below_on_change=False,
                enable_on_complete=['hostname'])

    hostname = CustomStringField(label='Hostname')

    submit = SubmitField(label='Submit')
コード例 #4
0
class GenericFormTemplate(GatewayForm):

    client_id = CustomStringField(
        default='b2756813-e562-4d21-837b-33aa1d5456b6', label='Cliend ID')

    password = PasswordField(label='Security Key',
                             default='c62ba28e-c6a8-4d40-ae50-bf45c47dbfd1')

    ip_address = IP4Address(label='IP Address',
                            default='10.244.135.248',
                            required=True,
                            result_decorator=None,
                            enable_on_complete=['submit'])

    port = CustomStringField(default='443', label='Port')
    submit = SubmitField(label='Login')
    logout = SubmitField(label='logout')
コード例 #5
0
class GenericFormTemplate(GatewayForm):
    # When updating the form, remember to make the corresponding changes to the workflow pages
    workflow_name = 'update_ip4_address_example'
    workflow_permission = 'update_ip4_address_example_page'
    configuration = Configuration(workflow_name=workflow_name,
                                  permissions=workflow_permission,
                                  label='Configuration',
                                  required=True,
                                  coerce=int,
                                  validators=[],
                                  is_disabled_on_start=False,
                                  enable_on_complete=['ip4_address'])

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Address',
        required=True,
        inputs={
            'configuration': 'configuration',
            'address': 'ip4_address'
        },
        on_change=['server_output_ip4_address'],
        server_outputs={
            'state': 'address_state',
            'mac_address': 'mac_address',
            'name': 'description'
        },
        server_side_output_method=get_ip4_address_endpoint,
        result_decorator=filter_allocated,
        enable_on_complete=[
            'address_state', 'mac_address', 'description', 'submit'
        ])

    line_break = PlainHTML('<hr>')

    address_state = CustomStringField(label='Address State', readonly=True)

    mac_address = CustomStringField(label='MAC Address')

    description = CustomStringField(label='Description')

    submit = SubmitField(label='Update')
コード例 #6
0
class GenericFormTemplate(GatewayForm):
    """
    Generic form Template

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'Debian_CVE_Analysis'
    workflow_permission = 'Debian_CVE_Analysis_page'
    # configuration = Configuration(
    #     workflow_name=workflow_name,
    #     permissions=workflow_permission,
    #     label='Configuration',
    #     required=True,
    #     coerce=int,
    #     validators=[],
    #     is_disabled_on_start=False,
    #     on_complete=[],
    #     enable_on_complete=['email', 'password', 'ip_address'],
    #     clear_below_on_change=False
    # )

    # email = CustomStringField(
    #     label='Email',
    #     default='*****@*****.**',
    #     validators=[DataRequired(), Email()]
    # )

    ip_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IP Address',
        required=True,
        #inputs={'configuration': 'configuration', 'address': 'ip_address'},
        result_decorator=None,
        enable_on_complete=[
            'ssh_user', 'password', 'cve', 'submit', 'cve_2', 'rel', "submit2"
        ])

    ssh_user = CustomStringField(
        label='SSH User',
        default='root',
        # validators=[MacAddress()]
    )

    password = PasswordField(label='Password',
                             default='abc',
                             validators=[DataRequired()])

    cve = CustomStringField(label='CVE-XXXX-XXXX',
                            default='CVE-',
                            validators=[DataRequired()])

    # url = StringField(
    #     label='URL',
    #     default='http://www.example.com',
    #     validators=[URL()]
    # )

    # file = FileField(
    #     label='File'
    # )
    #
    # boolean_checked = BooleanField(
    #     label='Use for true or false things',
    #     default='checked'
    # )
    #
    # boolean_unchecked = BooleanField(
    #     label='default for field is unchecked'
    # )
    #
    # date_time = DateTimeField(
    #     label='Date and Time:',
    #     default=datetime.datetime.now(),
    #     format='%Y-%m-%d %H:%M:%S'
    # )

    submit = SubmitField(label='Submit')

    emptyField = HiddenField(label="HiddenField")

    action = SelectField(label='Action Type',
                         choices=[('Search', 'Search'), ('Update', 'Update')])

    cve_2 = CustomStringField(label='CVE-XXXX-XXXX',
                              default='CVE-',
                              validators=[DataRequired()])

    rel = CustomStringField(label='REL',
                            default='',
                            validators=[DataRequired()])

    password2 = PasswordField(label='Admin Password',
                              default='abc',
                              validators=[DataRequired()])

    submit2 = SubmitField(label='Submit')
コード例 #7
0
class GenericFormTemplate(GatewayForm):
    """Form to generate HTML and Javascript for the add_static_ip4_address workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """

    workflow_name = "add_static_ip4_address"
    workflow_permission = "add_static_ip4_address_page"
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Configuration",
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        enable_dependencies={"on_complete": ["ip4_address"]},
        disable_dependencies={"on_change": ["ip4_address"]},
        clear_dependencies={
            "on_change": ["ip4_address", "view", "mac_address", "description"]
        },
    )

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Address",
        required=True,
        inputs={
            "configuration": "configuration",
            "address": "ip4_address"
        },
        result_decorator=filter_unallocated,
        on_complete=["call_view"],
        clear_below_on_change=False,
        should_cascade_disable_on_change=True,
        enable_dependencies={
            "on_complete": ["view", "mac_address", "description", "submit"]
        },
        disable_dependencies={
            "on_change": ["view", "mac_address", "description", "submit"]
        },
        display_message=True,
    )

    mac_address = CustomStringField(label="MAC Address")

    description = CustomStringField(label="Description")

    view = View(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="View",
        one_off=True,
        on_complete=["call_zone"],
        clear_below_on_change=False,
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
        enable_dependencies={"on_complete": ["zone"]},
        disable_dependencies={"on_change": ["zone"]},
        clear_dependencies={"on_change": ["zone"]},
    )

    zone = Zone(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label="Zone",
        clear_below_on_change=False,
        should_cascade_disable_on_change=True,
        should_cascade_clear_on_change=True,
        enable_dependencies={"on_complete": ["hostname"]},
        disable_dependencies={"on_change": ["hostname"]},
        clear_dependencies={"on_change": ["hostname"]},
    )

    hostname = CustomStringField(label="Hostname")

    submit = SubmitField(label="Submit")
コード例 #8
0
class GenericFormTemplate(GatewayForm):
    """ Form to generate HTML and Javascript for the add_static_ip4_address workflow

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'add_static_ip4_address'
    workflow_permission = 'add_static_ip4_address_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        clear_below_on_change=False,
        is_disabled_on_start=False,
        enable_dependencies={'on_complete': ['ip4_address']},
        disable_dependencies={'on_change': ['ip4_address']},
        clear_dependencies={
            'on_change': ['ip4_address', 'view', 'mac_address', 'description']
        })

    ip4_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Address',
        required=True,
        inputs={
            'configuration': 'configuration',
            'address': 'ip4_address'
        },
        result_decorator=filter_unallocated,
        on_complete=['call_view'],
        clear_below_on_change=False,
        should_cascade_disable_on_change=True,
        enable_dependencies={
            'on_complete': ['view', 'mac_address', 'description', 'submit']
        },
        disable_dependencies={
            'on_change': ['view', 'mac_address', 'description', 'submit']
        },
        display_message=True)

    mac_address = CustomStringField(label='MAC Address')

    description = CustomStringField(label='Description')

    view = View(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='View',
                one_off=True,
                on_complete=['call_zone'],
                clear_below_on_change=False,
                should_cascade_disable_on_change=True,
                should_cascade_clear_on_change=True,
                enable_dependencies={'on_complete': ['zone']},
                disable_dependencies={'on_change': ['zone']},
                clear_dependencies={'on_change': ['zone']})

    zone = Zone(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='Zone',
                clear_below_on_change=False,
                should_cascade_disable_on_change=True,
                should_cascade_clear_on_change=True,
                enable_dependencies={'on_complete': ['hostname']},
                disable_dependencies={'on_change': ['hostname']},
                clear_dependencies={'on_change': ['hostname']})

    hostname = CustomStringField(label='Hostname')

    submit = SubmitField(label='Submit')
コード例 #9
0
class GenericFormTemplate(GatewayForm):
    """
    Generic form Template

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'unit_tests_example'
    workflow_permission = 'unit_tests_example_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        validators=[],
        is_disabled_on_start=False,
        on_complete=[],
        enable_on_complete=['email', 'password', 'ip_address'],
        clear_below_on_change=False)

    email = CustomStringField(label='Email',
                              default='*****@*****.**',
                              validators=[DataRequired(),
                                          Email()])

    password = PasswordField(label='Password',
                             default='abc',
                             validators=[DataRequired()])

    ip_address = IP4Address(workflow_name=workflow_name,
                            permissions=workflow_permission,
                            label='IP Address',
                            required=True,
                            inputs={
                                'configuration': 'configuration',
                                'address': 'ip_address'
                            },
                            result_decorator=None,
                            enable_on_complete=[
                                'mac_address', 'url', 'file',
                                'boolean_checked', 'boolean_unchecked',
                                'date_time', 'submit'
                            ])

    mac_address = CustomStringField(label='MAC Address',
                                    default='11:11:11:11:11:11',
                                    validators=[MacAddress()])

    url = StringField(label='URL',
                      default='http://www.example.com',
                      validators=[URL()])

    file = FileField(label='File')

    boolean_checked = BooleanField(label='Use for true or false things',
                                   default='checked')

    boolean_unchecked = BooleanField(label='default for field is unchecked')

    date_time = DateTimeField(label='Date and Time:',
                              default=datetime.datetime.now(),
                              format='%Y-%m-%d %H:%M:%S')

    submit = SubmitField(label='Submit')
コード例 #10
0
class GenericFormTemplate(GatewayForm):
    """
    Generic form Template

    Note:
        When updating the form, remember to make the corresponding changes to the workflow pages
    """
    workflow_name = 'add_dual_stack_host'
    workflow_permission = 'add_dual_stack_host_page'
    configuration = Configuration(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='Configuration',
        required=True,
        coerce=int,
        validators=[],
        is_disabled_on_start=False,
        on_complete=['call_view'],
        enable_dependencies={'on_complete': ['view']},
        disable_dependencies={'on_change': ['view']},
        clear_dependencies={'on_change': ['view']},
        clear_below_on_change=False)

    view = View(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='View',
                required=True,
                one_off=True,
                on_complete=['call_zone'],
                clear_below_on_change=False,
                enable_dependencies={'on_complete': ['zone']},
                disable_dependencies={'on_change': ['zone']},
                clear_dependencies={'on_change': ['zone']},
                should_cascade_disable_on_change=True,
                should_cascade_clear_on_change=True)

    zone = Zone(workflow_name=workflow_name,
                permissions=workflow_permission,
                label='Zone',
                required=True,
                clear_below_on_change=False,
                enable_dependencies={
                    'on_complete': ['hostname', 'ip_address', 'ip6_address']
                },
                disable_dependencies={
                    'on_change': ['hostname', 'ip_address', 'ip6_address']
                },
                clear_dependencies={
                    'on_change': ['hostname', 'ip_address', 'ip6_address']
                },
                should_cascade_disable_on_change=True,
                should_cascade_clear_on_change=True)

    hostname = CustomStringField(label='Hostname', required=True)

    ip_address = IP4Address(
        workflow_name=workflow_name,
        permissions=workflow_permission,
        label='IPv4 Address',
        required=True,
        inputs={
            'configuration': 'configuration',
            'address': 'ip_address'
        },
        result_decorator=filter_reserved,
        enable_dependencies={'on_complete': ['submit', 'ip6_address']},
        disable_dependencies={'on_change': ['submit', 'ip6_address']},
        should_cascade_disable_on_change=True)

    ip6_address = IP6Address(workflow_name=workflow_name,
                             permissions=workflow_permission,
                             label='IPv6 Address',
                             required=True,
                             inputs={
                                 'configuration': 'configuration',
                                 'ip6_address': 'ip6_address'
                             },
                             result_decorator=None,
                             disable_dependencies={
                                 'on_change':
                                 ['hostname', 'submit', 'ip_address']
                             },
                             enable_on_complete=['submit'])

    add_device = CustomBooleanField(label='Add Device',
                                    is_disabled_on_start=False)

    submit = SubmitField(label='Submit')

    # Button with JS to clear the form
    clear_button = PlainHTML(
        '<button type="button" onclick="clearForm();" class="clearForm">Clear Form</button>'
    )