Andrew Bogott has submitted this change and it was merged.
Change subject: Modify designatedashboard to recognize proxy records
......................................................................
Modify designatedashboard to recognize proxy records
We don't want users editing or deleting dns records that were
created by the proxy panel. This patch replaces the edit/delete
buttons with an 'edit proxies' button which will link directly
to the proxy panel.
Change-Id: Ia2e7323cad39b85d0d5063823b4e4abc40901a97
---
M modules/openstack/files/liberty/horizon/overrides.py
1 file changed, 86 insertions(+), 0 deletions(-)
Approvals:
Andrew Bogott: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/openstack/files/liberty/horizon/overrides.py
b/modules/openstack/files/liberty/horizon/overrides.py
index 251f607..de85e11 100644
--- a/modules/openstack/files/liberty/horizon/overrides.py
+++ b/modules/openstack/files/liberty/horizon/overrides.py
@@ -1,3 +1,13 @@
+import socket
+from urlparse import urlparse
+import logging
+
+from designatedashboard.dashboards.project.dns_domains import tables as
ddtables
+from django.core import urlresolvers
+from django.utils.translation import ugettext_lazy as _ # noqa
+from horizon import tables
+from openstack_dashboard.api import keystone
+
# -- Tidy up the instance creation panel --
from openstack_dashboard.dashboards.project.instances.workflows import
create_instance
@@ -9,3 +19,79 @@
create_instance.SetInstanceDetails,
create_instance.SetAccessControls,
create_instance.SetNetwork)
+
+
+# -- Support proxy records in the designate dashboard --
+
+
+# In the designate dashboard, we have some records that are special
+# and maanged by the proxy dashboard. We need to remove the edit/delete
+# buttons for those records and instead add a button that jumps to
+# the proxy panel.
+
+PROXYIP = None
+
+
+def recordIsProxy(request, record):
+ global PROXYIP
+ if not PROXYIP:
+ # Leap of faith: Assume the proxy-api host is also the proxy host.
+ # So, get the proxy endpoint from keystone, convert to an IP,
+ # and compare to 'record'
+
+ client = keystone.keystoneclient(request)
+ services = client.services.list()
+
+ proxyservices = [service for service in services if service.name ==
'proxy']
+ endpoints = client.endpoints.list(service=proxyservices[0].id)
+ proxyurl = endpoints[0].url
+
+ parsed_uri = urlparse(proxyurl)
+ domain = parsed_uri.hostname
+ PROXYIP = socket.gethostbyname_ex(domain)[2][0]
+
+ return record.data == PROXYIP
+
+
+# Disable the 'edit' and 'delete' button for proxies...
+class EditRecord(ddtables.EditRecord):
+ def allowed(self, request, record=None):
+ if recordIsProxy(request, record):
+ return False
+ else:
+ return record.type in ddtables.EDITABLE_RECORD_TYPES
+
+
+class DeleteRecord(ddtables.DeleteRecord):
+ def allowed(self, request, record=None):
+ if recordIsProxy(request, record):
+ return False
+ else:
+ return record.type in ddtables.EDITABLE_RECORD_TYPES
+
+
+# And put an 'edit proxies' button in their place
+class EditProxies(tables.LinkAction):
+ '''Link action for a record created by the dynamic proxy panel.'''
+ name = "edit_proxies"
+ verbose_name = _("Edit Proxies")
+ classes = ("btn-edit")
+ policy_rules = (("dns", "update_record"),)
+
+ def get_link_url(self, datum=None):
+ return "/project/proxy"
+
+ def allowed(self, request, record=None):
+ return recordIsProxy(request, record)
+
+
+class RecordsTableWithProxies(ddtables.RecordsTable):
+ class Meta(object):
+ name = "records"
+ verbose_name = _("Records")
+ table_actions = (ddtables.CreateRecord,)
+ row_actions = (EditRecord, DeleteRecord, EditProxies)
+ multi_select = False
+
+
+ddtables.RecordsTable = RecordsTableWithProxies
--
To view, visit https://gerrit.wikimedia.org/r/277943
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2e7323cad39b85d0d5063823b4e4abc40901a97
Gerrit-PatchSet: 6
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits