How to use the horizon.forms.IntegerField function in horizon

To help you get started, we’ve selected a few horizon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / neutron-vpnaas-dashboard / neutron_vpnaas_dashboard / dashboards / project / vpn / forms.py View on Github external
version=forms.IPv4 | forms.IPv6,
        mask=True)
    local_ep_group_id = forms.CharField(
        required=False,
        label=_("Local Endpoint Group(s)"),
        help_text=_("IPsec connection validation requires "
                    "that local endpoints are subnets"))
    peer_ep_group_id = forms.CharField(
        required=False,
        label=_("Peer Endpoint Group(s)"),
        help_text=_("IPsec connection validation requires "
                    "that peer endpoints are CIDRs"))
    psk = forms.CharField(
        widget=forms.PasswordInput(render_value=True),
        max_length=80, label=_("Pre-Shared Key (PSK) string"))
    mtu = forms.IntegerField(
        min_value=68,
        required=False,
        label=_("Maximum Transmission Unit size for the connection"),
        help_text=_("Equal to or greater than 68 if the local subnet is IPv4. "
                    "Equal to or greater than 1280 if the local subnet "
                    "is IPv6."))
    dpd_action = forms.ThemableChoiceField(
        label=_("Dead peer detection actions"),
        required=False,
        choices=[('hold', _('hold')),
                 ('clear', _('clear')),
                 ('disabled', _('disabled')),
                 ('restart', _('restart')),
                 ('restart-by-peer', _('restart-by-peer'))])
    dpd_interval = forms.IntegerField(
        min_value=1,
github openstack / manila-ui / manila_ui / overrides.py View on Github external
def get_quota_name(f, quota):
    if quota.name in MANILA_QUOTA_NAMES:
        return MANILA_QUOTA_NAMES.get(quota.name)
    else:
        return f(quota)


#
# Add manila fields to Admin/Defaults/Update Defaults
#


class ManilaUpdateDefaultQuotaAction(
        default_workflows.UpdateDefaultQuotasAction):
    shares = horizon.forms.IntegerField(min_value=-1, label=_("Shares"))
    share_networks = horizon.forms.IntegerField(min_value=-1,
                                                label=_("Share Networks"))

    class Meta(object):
        name = _("Default Quota")
        slug = 'update_default_quotas'
        help_text = _("From here you can update the default quotas "
                      "(max limits).")


class ManilaUpdateDefaultQuotasStep(default_workflows.UpdateDefaultQuotasStep):
    action_class = ManilaUpdateDefaultQuotaAction
    contributes = quotas.QUOTA_FIELDS


class ManilaUpdateDefaultQuotas(default_workflows.UpdateDefaultQuotas):
    default_steps = (ManilaUpdateDefaultQuotasStep,)
github openstack / horizon / openstack_dashboard / dashboards / admin / defaults / workflows.py View on Github external
from openstack_dashboard.api import cinder
from openstack_dashboard.api import nova
from openstack_dashboard.usage import quotas

LOG = logging.getLogger(__name__)


class UpdateDefaultQuotasAction(workflows.Action):
    ifcb_label = _("Injected File Content Bytes")
    ifpb_label = _("Length of Injected File Path")
    injected_file_content_bytes = forms.IntegerField(min_value=-1,
                                                     label=ifcb_label)
    metadata_items = forms.IntegerField(min_value=-1,
                                        label=_("Metadata Items"))
    ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
    floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
    key_pairs = forms.IntegerField(min_value=-1, label=_("Key Pairs"))
    injected_file_path_bytes = forms.IntegerField(min_value=-1,
                                                  label=ifpb_label)
    instances = forms.IntegerField(min_value=-1, label=_("Instances"))
    security_group_rules = forms.IntegerField(min_value=-1,
                                              label=_("Security Group Rules"))
    injected_files = forms.IntegerField(min_value=-1,
                                        label=_("Injected Files"))
    cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
    security_groups = forms.IntegerField(min_value=-1,
                                         label=_("Security Groups"))
    gigabytes = forms.IntegerField(
        min_value=-1,
        label=_("Total Size of Volumes and Snapshots (GiB)"))
    snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
github openstack / octavia-dashboard / octavia_dashboard / dashboards / project / loadbalancersv2 / workflows / create_lb.py View on Github external
("tcp", _("TCP")),
        ("ping", _("PING")),
        ("http", _("HTTP")),
    )
    monitor = forms.ChoiceField(label=_("Monitor"),
                                choices=MONITOR_CHOICES)

    interval = forms.IntegerField(label=_("Health Check Interval"
                                          " (in seconds)"),
                                  required=False,
                                  min_value=1,
                                  max_value=600,
                                  help_text=_("Health Check Interval"
                                              " (in seconds)"))

    timeout = forms.IntegerField(label=_("Retry count before markdown"),
                                 required=False,
                                 min_value=1,
                                 max_value=100,
                                 help_text=_("Number of times health check "
                                             "should be attempted before "
                                             "marking down a member"))

    send = forms.CharField(widget=forms.Textarea(attrs={'rows': 1}),
                           label=_("Send String"),
                           required=False,
                           help_text=_("Send String"))

    receive = forms.CharField(widget=forms.Textarea(attrs={'rows': 1}),
                              label=_("Receive String"),
                              required=False,
                              help_text=_("Receive String"))
github openstack / freezer-web-ui / disaster_recovery / jobs / workflows / create.py View on Github external
help_text=_("Set a name for this job"))

    job_id = forms.CharField(
        widget=forms.HiddenInput(),
        required=False)

    schedule_start_date = forms.CharField(
        label=_("Start Date and Time"),
        required=False)

    interval_uint = forms.ChoiceField(
        label=_("Interval Unit"),
        help_text=_("Set the unit for the Interval"),
        required=False)

    interval_value = forms.IntegerField(
        label=_("Interval Value"),
        initial=1,
        min_value=1,
        help_text=_("Set the interval value"),
        required=False)

    schedule_end_date = forms.CharField(
        label=_("End Date and Time"),
        required=False)

    def __init__(self, request, context, *args, **kwargs):
        self.request = request
        self.context = context
        super(InfoConfigurationAction, self).__init__(
            request, context, *args, **kwargs)
github openstack / manila-ui / manila_ui / dashboards / identity / projects / workflows.py View on Github external
from horizon import workflows

from openstack_dashboard.api import base
from openstack_dashboard.dashboards.identity.projects \
    import workflows as project_workflows

from manila_ui.api import manila as api_manila

LOG = logging.getLogger(__name__)


class ShareQuotaAction(project_workflows.CommonQuotaAction):
    shares = forms.IntegerField(min_value=-1, label=_("Shares"))
    share_gigabytes = forms.IntegerField(
        min_value=-1, label=_("Share gigabytes"))
    share_snapshots = forms.IntegerField(
        min_value=-1, label=_("Share snapshots"))
    share_snapshot_gigabytes = forms.IntegerField(
        min_value=-1, label=_("Share snapshot gigabytes"))
    share_networks = forms.IntegerField(
        min_value=-1, label=_("Share Networks"))

    _quota_fields = api_manila.MANILA_QUOTA_FIELDS

    def _tenant_quota_update(self, request, project_id, data):
        api_manila.tenant_quota_update(request, project_id, **data)

    class Meta(object):
        name = _("Share")
        slug = 'update_share_quotas'
        help_text = _("Set maximum quotas for the project.")
        permissions = ('openstack.roles.admin', 'openstack.services.share')
github openstack / horizon / openstack_dashboard / dashboards / identity / projects / workflows.py View on Github external
from openstack_dashboard.api import cinder
from openstack_dashboard.api import keystone
from openstack_dashboard.api import nova
from openstack_dashboard.usage import quotas

INDEX_URL = "horizon:identity:projects:index"
ADD_USER_URL = "horizon:identity:projects:create_user"
PROJECT_GROUP_ENABLED = keystone.VERSIONS.active >= 3
PROJECT_USER_MEMBER_SLUG = "update_members"
PROJECT_GROUP_MEMBER_SLUG = "update_group_members"
COMMON_HORIZONTAL_TEMPLATE = "identity/projects/_common_horizontal_form.html"


class ProjectQuotaAction(workflows.Action):
    ifcb_label = _("Injected File Content (Bytes)")
    metadata_items = forms.IntegerField(min_value=-1,
                                        label=_("Metadata Items"))
    cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
    instances = forms.IntegerField(min_value=-1, label=_("Instances"))
    injected_files = forms.IntegerField(min_value=-1,
                                        label=_("Injected Files"))
    injected_file_content_bytes = forms.IntegerField(min_value=-1,
                                                     label=ifcb_label)
    volumes = forms.IntegerField(min_value=-1, label=_("Volumes"))
    snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
    gigabytes = forms.IntegerField(
        min_value=-1, label=_("Total Size of Volumes and Snapshots (GB)"))
    ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
    floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
    fixed_ips = forms.IntegerField(min_value=-1, label=_("Fixed IPs"))
    security_groups = forms.IntegerField(min_value=-1,
                                         label=_("Security Groups"))
github openstack / horizon / openstack_dashboard / dashboards / admin / defaults / workflows.py View on Github external
class UpdateDefaultQuotasAction(workflows.Action):
    ifcb_label = _("Injected File Content Bytes")
    ifpb_label = _("Length of Injected File Path")
    injected_file_content_bytes = forms.IntegerField(min_value=-1,
                                                     label=ifcb_label)
    metadata_items = forms.IntegerField(min_value=-1,
                                        label=_("Metadata Items"))
    ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
    floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
    key_pairs = forms.IntegerField(min_value=-1, label=_("Key Pairs"))
    injected_file_path_bytes = forms.IntegerField(min_value=-1,
                                                  label=ifpb_label)
    instances = forms.IntegerField(min_value=-1, label=_("Instances"))
    security_group_rules = forms.IntegerField(min_value=-1,
                                              label=_("Security Group Rules"))
    injected_files = forms.IntegerField(min_value=-1,
                                        label=_("Injected Files"))
    cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
    security_groups = forms.IntegerField(min_value=-1,
                                         label=_("Security Groups"))
    gigabytes = forms.IntegerField(
        min_value=-1,
        label=_("Total Size of Volumes and Snapshots (GiB)"))
    snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
    volumes = forms.IntegerField(min_value=-1, label=_("Volumes"))

    def __init__(self, request, *args, **kwargs):
        super(UpdateDefaultQuotasAction, self).__init__(request,
                                                        *args,
                                                        **kwargs)
github openstack / horizon / openstack_dashboard / dashboards / admin / defaults / workflows.py View on Github external
LOG = logging.getLogger(__name__)


class UpdateDefaultQuotasAction(workflows.Action):
    ifcb_label = _("Injected File Content Bytes")
    ifpb_label = _("Length of Injected File Path")
    injected_file_content_bytes = forms.IntegerField(min_value=-1,
                                                     label=ifcb_label)
    metadata_items = forms.IntegerField(min_value=-1,
                                        label=_("Metadata Items"))
    ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
    floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
    key_pairs = forms.IntegerField(min_value=-1, label=_("Key Pairs"))
    injected_file_path_bytes = forms.IntegerField(min_value=-1,
                                                  label=ifpb_label)
    instances = forms.IntegerField(min_value=-1, label=_("Instances"))
    security_group_rules = forms.IntegerField(min_value=-1,
                                              label=_("Security Group Rules"))
    injected_files = forms.IntegerField(min_value=-1,
                                        label=_("Injected Files"))
    cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
    security_groups = forms.IntegerField(min_value=-1,
                                         label=_("Security Groups"))
    gigabytes = forms.IntegerField(
        min_value=-1,
        label=_("Total Size of Volumes and Snapshots (GiB)"))
    snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
    volumes = forms.IntegerField(min_value=-1, label=_("Volumes"))

    def __init__(self, request, *args, **kwargs):
        super(UpdateDefaultQuotasAction, self).__init__(request,
                                                        *args,
github openstack / horizon / openstack_dashboard / dashboards / settings / user / forms.py View on Github external
for catalog in found_catalogs]
        if any(result):
            continue
        processed_catalogs |= set(found_catalogs)
        languages.append(
            (lang_code,
             _get_language_display_name(lang_code, lang_label))
        )
    return sorted(languages)


class UserSettingsForm(forms.SelfHandlingForm):
    max_value = getattr(settings, 'API_RESULT_LIMIT', 1000)
    language = forms.ChoiceField(label=_("Language"))
    timezone = forms.ChoiceField(label=_("Timezone"))
    pagesize = forms.IntegerField(label=_("Items Per Page"),
                                  min_value=1,
                                  max_value=max_value)
    instance_log_length = forms.IntegerField(
        label=_("Log Lines Per Instance"), min_value=1,
        help_text=_("Number of log lines to be shown per instance"))

    @staticmethod
    def _sorted_zones():
        d = datetime(datetime.today().year, 1, 1)
        zones = [(tz, pytz.timezone(tz).localize(d).strftime('%z'))
                 for tz in pytz.common_timezones]
        zones.sort(key=lambda zone: int(zone[1]))
        return zones

    def __init__(self, *args, **kwargs):
        super(UserSettingsForm, self).__init__(*args, **kwargs)