diff --git a/requirements.txt b/requirements.txt index 3168fb9..4995392 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,3 @@ oslo.log>=3.30.0 # Apache-2.0 python-swiftclient>=2.2.0 python-troveclient>=1.2.0 horizon>=17.1.0 # Apache-2.0 -netaddr>=0.7.18 # BSD diff --git a/trove_dashboard/content/databases/workflows/create_instance.py b/trove_dashboard/content/databases/workflows/create_instance.py index c982916..25470fd 100644 --- a/trove_dashboard/content/databases/workflows/create_instance.py +++ b/trove_dashboard/content/databases/workflows/create_instance.py @@ -15,7 +15,6 @@ from django.conf import settings from django.urls import reverse from django.utils.translation import ugettext_lazy as _ -import netaddr from horizon import exceptions from horizon import forms @@ -293,29 +292,19 @@ class AddAccessAction(workflows.Action): """ is_public = forms.BooleanField(label=_("Is Public"), required=False) - allowed_cidrs = forms.CharField(label=_("Allowed CIDRs"), - required=False, - help_text=_("Comma-separated CIDRs " - "to connect through.")) + allowed_cidrs = forms.MultiIPField(label=_("Allowed CIDRs"), + required=False, + version=forms.IPv4 | forms.IPv6, + mask=True, + widget=forms.TextInput(), + help_text=_("Comma-separated CIDRs " + "to connect through.")) class Meta(object): name = _("Database Access") permissions = TROVE_ADD_PERMS help_text_template = "project/databases/_launch_access_help.html" - def clean(self): - cleaned_data = super(AddAccessAction, self).clean() - if cleaned_data.get('allowed_cidrs'): - cidrs = cleaned_data.get('allowed_cidrs').split(',') - for cidr in cidrs: - try: - netaddr.IPNetwork(cidr) - except netaddr.AddrFormatError: - msg = _('Invalid Allowed CIDR provided.') - self._errors["allowed_cidrs"] = self.error_class([msg]) - - return cleaned_data - class DatabaseAccess(workflows.Step): action_class = AddAccessAction