summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEddie Ramirez <eddie.ramirez@intel.com>2017-02-27 21:09:55 +0000
committerDavid Lyle <dklyle0@gmail.com>2017-09-14 23:30:57 +0000
commitd6f1d117b4a0df0609f1a98dc1028707c74d29f4 (patch)
treebfc4c0ffddb1b73ed135b35e44828a75e36fcbe9
parent5787b0adc528b57def59c8a61aed693b80ac6559 (diff)
Add server-side filtering Floating IPs
References for field selection: https://developer.openstack.org/api-ref/networking/v2/index.html?expanded=list-floating-ips-detail https://github.com/openstack/python-neutronclient/blob/master/neutronclient/neutron/v2_0/floatingip.py Co-authored-by: Eddie Ramirez <eddie.ramirez@intel.com> Co-authored-by: David Lyle <dklyle0@gmail.com> Implements blueprint: server-side-filtering Change-Id: I614f0b1d9cf685aed3e3663d512a4ccd92455093
Notes
Notes (review): Code-Review+1: Beth Elwell <e.r.elwell@gmail.com> Code-Review+2: Rob Cresswell <robert.cresswell@outlook.com> Workflow+1: Rob Cresswell <robert.cresswell@outlook.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 20 Sep 2017 11:43:25 +0000 Reviewed-on: https://review.openstack.org/438702 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--openstack_dashboard/dashboards/admin/floating_ips/tables.py22
-rw-r--r--openstack_dashboard/dashboards/project/floating_ips/tables.py16
2 files changed, 25 insertions, 13 deletions
diff --git a/openstack_dashboard/dashboards/admin/floating_ips/tables.py b/openstack_dashboard/dashboards/admin/floating_ips/tables.py
index 5216a61..7fff760 100644
--- a/openstack_dashboard/dashboards/admin/floating_ips/tables.py
+++ b/openstack_dashboard/dashboards/admin/floating_ips/tables.py
@@ -32,15 +32,6 @@ from openstack_dashboard.utils import filters
32LOG = logging.getLogger(__name__) 32LOG = logging.getLogger(__name__)
33 33
34 34
35class FloatingIPFilterAction(tables.FilterAction):
36
37 def filter(self, table, fips, filter_string):
38 """Naive case-insensitive search."""
39 q = filter_string.lower()
40 return [ip for ip in fips
41 if q in ip.ip.lower()]
42
43
44class AdminAllocateFloatingIP(project_tables.AllocateIP): 35class AdminAllocateFloatingIP(project_tables.AllocateIP):
45 url = "horizon:admin:floating_ips:allocate" 36 url = "horizon:admin:floating_ips:allocate"
46 37
@@ -72,6 +63,13 @@ class AdminSimpleDisassociateIP(project_tables.DisassociateIP):
72 return shortcuts.redirect('horizon:admin:floating_ips:index') 63 return shortcuts.redirect('horizon:admin:floating_ips:index')
73 64
74 65
66class AdminFloatingIPsFilterAction(tables.FilterAction):
67 filter_type = "server"
68 filter_choices = (
69 ('project_id', _('Project ID'), True), ) + \
70 project_tables.FLOATING_IPS_FILTER_CHOICES
71
72
75class FloatingIPsTable(project_tables.FloatingIPsTable): 73class FloatingIPsTable(project_tables.FloatingIPsTable):
76 tenant = tables.Column("tenant_name", verbose_name=_("Project")) 74 tenant = tables.Column("tenant_name", verbose_name=_("Project"))
77 ip = tables.Column("ip", 75 ip = tables.Column("ip",
@@ -83,9 +81,9 @@ class FloatingIPsTable(project_tables.FloatingIPsTable):
83 name = "floating_ips" 81 name = "floating_ips"
84 verbose_name = _("Floating IPs") 82 verbose_name = _("Floating IPs")
85 status_columns = ["status"] 83 status_columns = ["status"]
86 table_actions = (FloatingIPFilterAction, 84 table_actions = (AdminAllocateFloatingIP,
87 AdminAllocateFloatingIP, 85 AdminReleaseFloatingIP,
88 AdminReleaseFloatingIP) 86 AdminFloatingIPsFilterAction)
89 row_actions = (AdminSimpleDisassociateIP, 87 row_actions = (AdminSimpleDisassociateIP,
90 AdminReleaseFloatingIP) 88 AdminReleaseFloatingIP)
91 columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status') 89 columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status')
diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py
index 2c774da..3c5d9f3 100644
--- a/openstack_dashboard/dashboards/project/floating_ips/tables.py
+++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py
@@ -164,6 +164,20 @@ STATUS_DISPLAY_CHOICES = (
164) 164)
165 165
166 166
167FLOATING_IPS_FILTER_CHOICES = (
168 ('floating_ip_address', _('Floating IP Address ='), True),
169 ('network_id', _('Network ID ='), True),
170 ('router_id', _('Router ID ='), True),
171 ('port_id', _('Port ID ='), True),
172 ('status', _('Status ='), True, _("e.g. ACTIVE / DOWN / ERROR")),
173)
174
175
176class FloatingIPsFilterAction(tables.FilterAction):
177 filter_type = "server"
178 filter_choices = FLOATING_IPS_FILTER_CHOICES
179
180
167class FloatingIPsTable(tables.DataTable): 181class FloatingIPsTable(tables.DataTable):
168 STATUS_CHOICES = ( 182 STATUS_CHOICES = (
169 ("active", True), 183 ("active", True),
@@ -198,5 +212,5 @@ class FloatingIPsTable(tables.DataTable):
198 class Meta(object): 212 class Meta(object):
199 name = "floating_ips" 213 name = "floating_ips"
200 verbose_name = _("Floating IPs") 214 verbose_name = _("Floating IPs")
201 table_actions = (AllocateIP, ReleaseIPs) 215 table_actions = (AllocateIP, ReleaseIPs, FloatingIPsFilterAction)
202 row_actions = (AssociateIP, DisassociateIP, ReleaseIPs) 216 row_actions = (AssociateIP, DisassociateIP, ReleaseIPs)