

def __init__(self, request, *args, **kwargs):
    super(RemoveRuleFromPolicy, self).__init__(request, *args, **kwargs)
    try:
        tenant_id = request.user.tenant_id
        all_rules = api.fwaas.rule_list_for_tenant(request, tenant_id)
        current_rules = []
        for r in kwargs['initial']['firewall_rules']:
            r_obj = [rule for rule in all_rules if (r == rule.id)][0]
            current_rules.append(r_obj)
        current_choices = [(r.id, r.name_or_id) for r in current_rules]
    except Exception as e:
        msg = (_('Failed to retrieve current rules in policy %(name)s: %(reason)s') % {
            'name': self.initial['name'],
            'reason': e,
        })
        LOG.error(msg)
        redirect = reverse(self.failure_url)
        exceptions.handle(request, msg, redirect=redirect)
    self.fields['firewall_rule_id'].choices = current_choices

dataset/ETHPy150Open openstack/horizon/openstack_dashboard/dashboards/project/firewalls/forms.py RemoveRuleFromPolicy.__init__/original