[BUG] Dashboard报错:if usages['subnets']['available'] <= 0: KeyError: 'available'

Openstack版本:Liberty

系统平台:CentOS 7.2 64bit

###############################################################

1.现象:

管理员登陆Dasgboard,查看项目》网络》网络》选择一个网络》选择一个子网》查看网络ID,如下:

[BUG] Dashboard报错:if usages['subnets']['available'] <= 0: KeyError: 'available'_第1张图片

查看httpd日志报错如下:

tail -f /etc/httpd/logs/error_log
[Tue Apr 12 10:24:08.830778 2016] [:error] [pid 94866] Error while checking action permissions.
[Tue Apr 12 10:24:08.830848 2016] [:error] [pid 94866] Traceback (most recent call last):
[Tue Apr 12 10:24:08.830854 2016] [:error] [pid 94866]   File "/usr/lib/python2.7/site-packages/horizon/tables/base.py", line 1270, in _filter_action
[Tue Apr 12 10:24:08.830859 2016] [:error] [pid 94866]     return action._allowed(request, datum) and row_matched
[Tue Apr 12 10:24:08.830862 2016] [:error] [pid 94866]   File "/usr/lib/python2.7/site-packages/horizon/tables/actions.py", line 135, in _allowed
[Tue Apr 12 10:24:08.830866 2016] [:error] [pid 94866]     self.allowed(request, datum))
[Tue Apr 12 10:24:08.830873 2016] [:error] [pid 94866]   File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/project/networks/subnets/tables.py", line 103, in allowed
[Tue Apr 12 10:24:08.830883 2016] [:error] [pid 94866]     if usages['subnets']['available'] <= 0:
[Tue Apr 12 10:24:08.830899 2016] [:error] [pid 94866] KeyError: 'available'
################################################################

2.问题解决:

修改/usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/networks/subnets/tables.py源代码如下

class CreateSubnet(SubnetPolicyTargetMixin, CheckNetworkEditable,
                   tables.LinkAction):
    name = "create"
    verbose_name = _("Create Subnet")
    url = "horizon:project:networks:addsubnet"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("network", "create_subnet"),)

    def get_link_url(self, datum=None):
        network_id = self.table.kwargs['network_id']
        return reverse(self.url, args=(network_id,))

    def allowed(self, request, datum=None):
        usages = quotas.tenant_quota_usages(request)
        if usages['subnets'].get('available', 1) <= 0:
            if 'disabled' not in self.classes:
                self.classes = [c for c in self.classes] + ['disabled']
                self.verbose_name = _('Create Subnet (Quota exceeded)')
        else:
            self.verbose_name = _('Create Subnet')
            self.classes = [c for c in self.classes if c != 'disabled']

        return True


你可能感兴趣的:(openstack,dashboard,liberty)