diff --git a/openstack_dashboard/dashboards/project/l3routers/ports/tables.py b/openstack_dashboard/dashboards/project/l3routers/ports/tables.py index 369a8db..9a4192e 100644 --- a/openstack_dashboard/dashboards/project/l3routers/ports/tables.py +++ b/openstack_dashboard/dashboards/project/l3routers/ports/tables.py @@ -15,6 +15,7 @@ import logging from django.core.urlresolvers import reverse +from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy @@ -89,22 +90,37 @@ def delete(self, request, obj_id): exceptions.handle(request, msg, redirect=redirect) +DISPLAY_CHOICES = ( + ("UP", pgettext_lazy("Admin state of a Port", u"UP")), + ("DOWN", pgettext_lazy("Admin state of a Port", u"DOWN")), +) +STATUS_DISPLAY_CHOICES = ( + ("ACTIVE", pgettext_lazy("current status of port", u"Active")), + ("BUILD", pgettext_lazy("current status of port", u"Build")), + ("DOWN", pgettext_lazy("current status of port", u"Down")), + ("ERROR", pgettext_lazy("current status of port", u"Error")), +) + + class PortsTable(tables.DataTable): - name = tables.Column("name", + name = tables.Column("name_or_id", verbose_name=_("Name"), link="horizon:project:networking:ports:detail") fixed_ips = tables.Column(project_tables.get_fixed_ips, verbose_name=_("Fixed IPs")) - status = tables.Column("status", verbose_name=_("Status")) + status = tables.Column("status", + verbose_name=_("Status"), + display_choices=STATUS_DISPLAY_CHOICES) device_owner = tables.Column(get_device_owner, verbose_name=_("Type")) admin_state = tables.Column("admin_state", - verbose_name=_("Admin State")) + verbose_name=_("Admin State"), + display_choices=DISPLAY_CHOICES) def get_object_display(self, port): return port.id - class Meta: + class Meta(object): name = "interfaces" verbose_name = _("Interfaces") table_actions = (AddInterface, RemoveInterface) diff --git a/openstack_dashboard/dashboards/project/l3routers/tables.py b/openstack_dashboard/dashboards/project/l3routers/tables.py index 59eed27..c46e236 100644 --- a/openstack_dashboard/dashboards/project/l3routers/tables.py +++ b/openstack_dashboard/dashboards/project/l3routers/tables.py @@ -16,6 +16,7 @@ from django.core.urlresolvers import reverse from django.template import defaultfilters as filters +from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from neutronclient.common import exceptions as q_ext @@ -23,8 +24,10 @@ from horizon import exceptions from horizon import messages from horizon import tables + from openstack_dashboard import api from openstack_dashboard import policy +from openstack_dashboard.usage import quotas LOG = logging.getLogger(__name__) @@ -77,6 +80,20 @@ class CreateRouter(tables.LinkAction): icon = "plus" policy_rules = (("network", "create_router"),) + def allowed(self, request, datum=None): + usages = quotas.tenant_quota_usages(request) + # when Settings.OPENSTACK_NEUTRON_NETWORK['enable_quotas'] = False + # usages['routers'] is empty + if usages.get('routers', {}).get('available', 1) <= 0: + if "disabled" not in self.classes: + self.classes = [c for c in self.classes] + ["disabled"] + self.verbose_name = _("Create Router (Quota exceeded)") + else: + self.verbose_name = _("Create Router") + self.classes = [c for c in self.classes if c != "disabled"] + + return True + class EditRouter(policy.PolicyTargetMixin, tables.LinkAction): name = "update" @@ -160,14 +177,32 @@ def get_external_network(router): return "-" +class RoutersFilterAction(tables.FilterAction): + + def filter(self, table, routers, filter_string): + """Naive case-insensitive search.""" + query = filter_string.lower() + return [router for router in routers + if query in router.name.lower()] + + class RoutersTable(tables.DataTable): + STATUS_DISPLAY_CHOICES = ( + ("active", pgettext_lazy("current status of router", u"Active")), + ("error", pgettext_lazy("current status of router", u"Error")), + ) + ADMIN_STATE_DISPLAY_CHOICES = ( + ("UP", pgettext_lazy("Admin state of a Router", u"UP")), + ("DOWN", pgettext_lazy("Admin state of a Router", u"DOWN")), + ) + name = tables.Column("name", verbose_name=_("Name"), link="horizon:project:l3routers:detail") status = tables.Column("status", - filters=(filters.title,), verbose_name=_("Status"), - status=True) + status=True, + display_choices=STATUS_DISPLAY_CHOICES) distributed = tables.Column("distributed", filters=(filters.yesno, filters.capfirst), verbose_name=_("Distributed")) @@ -177,6 +212,9 @@ class RoutersTable(tables.DataTable): verbose_name=_("HA mode")) ext_net = tables.Column(get_external_network, verbose_name=_("External Network")) + admin_state = tables.Column("admin_state", + verbose_name=_("Admin State"), + display_choices=ADMIN_STATE_DISPLAY_CHOICES) def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs): super(RoutersTable, self).__init__( @@ -192,10 +230,11 @@ def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs): def get_object_display(self, obj): return obj.name - class Meta: + class Meta(object): name = "Routers" verbose_name = _("Routers") status_columns = ["status"] row_class = UpdateRow - table_actions = (CreateRouter, DeleteRouter) + table_actions = (CreateRouter, DeleteRouter, + RoutersFilterAction) row_actions = (SetGateway, ClearGateway, EditRouter, DeleteRouter) diff --git a/openstack_dashboard/dashboards/project/lbaas/tables.py b/openstack_dashboard/dashboards/project/lbaas/tables.py index 3e89aed..16ac56b 100644 --- a/openstack_dashboard/dashboards/project/lbaas/tables.py +++ b/openstack_dashboard/dashboards/project/lbaas/tables.py @@ -165,7 +165,7 @@ class UpdateMonitorLink(policy.PolicyTargetMixin, tables.LinkAction): policy_rules = (("network", "update_health_monitor"),) def get_link_url(self, monitor): - base_url = reverse("horizon:project:loadbalancers:updatemonitor", + base_url = reverse("horizon:project:lbaas:updatemonitor", kwargs={'monitor_id': monitor.id}) return base_url diff --git a/openstack_dashboard/dashboards/project/networking_topology/networks/__init__.py b/openstack_dashboard/dashboards/project/networking_topology/networks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/openstack_dashboard/dashboards/project/networking_topology/networks/tables.py b/openstack_dashboard/dashboards/project/networking_topology/networks/tables.py new file mode 100644 index 0000000..04cf858 --- /dev/null +++ b/openstack_dashboard/dashboards/project/networking_topology/networks/tables.py @@ -0,0 +1,29 @@ +# Copyright 2015 Cisco Systems. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.utils.translation import ugettext_lazy as _ + +from contrail_openstack_dashboard.openstack_dashboard.dashboards.project.networking import tables + + +class DeleteNetwork(tables.DeleteNetwork): + redirect_url = "horizon:project:networking_topology:network" + + +class NetworksTable(tables.NetworksTable): + class Meta(object): + name = "networks" + verbose_name = _("Networks") + table_actions = (DeleteNetwork,) + row_actions = (DeleteNetwork,) diff --git a/openstack_dashboard/dashboards/project/networking_topology/subnets/__init__.py b/openstack_dashboard/dashboards/project/networking_topology/subnets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/openstack_dashboard/dashboards/project/networking_topology/subnets/tables.py b/openstack_dashboard/dashboards/project/networking_topology/subnets/tables.py new file mode 100644 index 0000000..7ef13f4 --- /dev/null +++ b/openstack_dashboard/dashboards/project/networking_topology/subnets/tables.py @@ -0,0 +1,30 @@ +# Copyright 2015 Cisco Systems. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from django.utils.translation import ugettext_lazy as _ + +from contrail_openstack_dashboard.openstack_dashboard.dashboards.project.networking.subnets import tables + + +class DeleteSubnet(tables.DeleteSubnet): + failure_url = 'horizon:project:networking_topology:network' + + +class SubnetsTable(tables.SubnetsTable): + class Meta(object): + name = "subnets" + verbose_name = _("Subnets") + row_actions = (DeleteSubnet, ) + table_actions = (DeleteSubnet, ) diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_container.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_container.html index 8077cd3..35f6771 100644 --- a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_container.html +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_container.html @@ -22,10 +22,11 @@ [[/console_id]] {% endif %} - [[add_interface_label]] + [[#type]]
+ [[/type]] diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_instance.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_instance.html new file mode 100644 index 0000000..84ecd62 --- /dev/null +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_instance.html @@ -0,0 +1,23 @@ +{% extends "horizon/client_side/template.html" %} +{% load horizon %} + +{% block id %}balloon_instance{% endblock %} + +{% block template %} +{% jstemplate %} +
+
[[ips_label]]
+
+ + + + [[#ips]] + + + + + [[/ips]] + +
[[ip_address]][[subnet_id]]
+{% endjstemplate %} +{% endblock %} diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_net.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_net.html new file mode 100644 index 0000000..c4d17a5 --- /dev/null +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_net.html @@ -0,0 +1,38 @@ +{% extends "horizon/client_side/template.html" %} +{% load horizon %} + +{% block id %}balloon_net{% endblock %} + +{% block template %} +{% jstemplate %} +
+
[[subnets_label]]
+
+ + + [[add_subnet_label]] + +
+
+ + + + [[#subnet]] + + + + + + [[/subnet]] + +
+ + [[id]] + + [[cidr]] + +
+{% endjstemplate %} +{% endblock %} diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_port.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_port.html index 1f4a7c7..e30caee 100644 --- a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_port.html +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/client_side/_balloon_port.html @@ -5,8 +5,17 @@ {% block template %} {% jstemplate %} +
+
[[interfaces_label]]
+
+ + + [[add_interface_label]] + +
+
- + [[#port]] @@ -22,7 +31,9 @@ diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/create_router.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/create_router.html index 352e1dd..620a465 100644 --- a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/create_router.html +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/create_router.html @@ -2,10 +2,6 @@ {% load i18n %} {% block title %}{% trans "Create Router" %}{% endblock %} -{% block page_header %} - {% include "horizon/common/_page_header.html" with title=_("Create a Router") %} -{% endblock page_header %} - {% block main %} {% include 'project/networking_topology/_create_router.html' %} {% endblock %} diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/iframe.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/iframe.html index 9915d38..650aaf0 100644 --- a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/iframe.html +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/iframe.html @@ -1,3 +1,5 @@ +{% load firstof from future %} + @@ -6,7 +8,7 @@ {% include "horizon/_messages.html" %} - {% firstof table.render interfaces_table.render tab_group.render%} + {% firstof subnets_table.render table.render interfaces_table.render tab_group.render %} {% include "project/networking_topology/_post_massage.html" %} diff --git a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/index.html b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/index.html index 1dd4c78..30d137d 100644 --- a/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/index.html +++ b/openstack_dashboard/dashboards/project/networking_topology/templates/networking_topology/index.html @@ -3,10 +3,6 @@ {% load url from future %} {% block title %}{% trans "Network Topology" %}{% endblock %} -{% block page_header %} - {% include "horizon/common/_page_header.html" with title=_("Network Topology") %} -{% endblock page_header %} - {% block main %}
[[interfaces_label]]
[[#is_interface]] - + [[/is_interface]]