~ubuntu-branches/ubuntu/utopic/horizon/utopic-updates

« back to all changes in this revision

Viewing changes to openstack_dashboard/dashboards/project/firewalls/forms.py

  • Committer: Package Import Robot
  • Author(s): James Page, Chris Johnston, James Page
  • Date: 2014-10-03 17:54:18 UTC
  • mfrom: (0.4.1) (1.1.44) (70.1.2 utopic)
  • Revision ID: package-import@ubuntu.com-20141003175418-1jomx0azdvnl5fxz
Tags: 1:2014.2~rc1-0ubuntu1
[ Chris Johnston ]
* d/theme/css/ubuntu.css: Fix Ubuntu theme for Instances "more" dropdown
  (LP: #1308651).

[ James Page ]
* New upstream release candidate:
  - d/p/*: Refresh.
* d/watch: Use tarballs.openstack.org for upstream releases. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
    def __init__(self, request, *args, **kwargs):
74
74
        super(UpdateRule, self).__init__(request, *args, **kwargs)
75
75
 
76
 
        protocol = kwargs['initial']['protocol'].upper()
 
76
        protocol = kwargs['initial']['protocol']
 
77
        protocol = protocol.upper() if protocol else 'ANY'
77
78
        action = kwargs['initial']['action'].upper()
78
79
 
79
80
        protocol_choices = [(protocol, protocol)]
80
 
        for tup in [('TCP', _('TCP')), ('UDP', _('UDP')), ('ICMP', _('ICMP'))]:
 
81
        for tup in [('TCP', _('TCP')), ('UDP', _('UDP')), ('ICMP', _('ICMP')),
 
82
                    ('ANY', _('ANY'))]:
81
83
            if tup[0] != protocol:
82
84
                protocol_choices.append(tup)
83
85
        self.fields['protocol'].choices = protocol_choices
91
93
    def handle(self, request, context):
92
94
        rule_id = self.initial['rule_id']
93
95
        name_or_id = context.get('name') or rule_id
 
96
        if context['protocol'] == 'ANY':
 
97
            context['protocol'] = None
94
98
        for f in ['source_ip_address', 'destination_ip_address',
95
99
                  'source_port', 'destination_port']:
96
100
            if not context[f]:
143
147
                                  label=_("Description"),
144
148
                                  required=False)
145
149
    firewall_policy_id = forms.ChoiceField(label=_("Policy"))
146
 
    admin_state_up = forms.BooleanField(label=_("Admin State Up"),
147
 
                                        required=False)
 
150
    # TODO(amotoki): make UP/DOWN translatable
 
151
    admin_state_up = forms.ChoiceField(choices=[(True, 'UP'), (False, 'DOWN')],
 
152
                                       label=_("Admin State"))
148
153
 
149
154
    failure_url = 'horizon:project:firewalls:index'
150
155
 
174
179
    def handle(self, request, context):
175
180
        firewall_id = self.initial['firewall_id']
176
181
        name_or_id = context.get('name') or firewall_id
 
182
        context['admin_state_up'] = (context['admin_state_up'] == 'True')
177
183
        try:
178
184
            firewall = api.fwaas.firewall_update(request, firewall_id,
179
185
                                                 **context)