Andrew Bogott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/279583
Change subject: Proxydashboard: Check for ownership of a proxy before deleting.
......................................................................
Proxydashboard: Check for ownership of a proxy before deleting.
Change-Id: I07b346131c532e0b07e2f10b47160a37a4261ca9
---
M modules/openstack/files/liberty/horizon/proxy/views.py
1 file changed, 22 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/83/279583/1
diff --git a/modules/openstack/files/liberty/horizon/proxy/views.py
b/modules/openstack/files/liberty/horizon/proxy/views.py
index 9c27efa..a6ae2f9 100644
--- a/modules/openstack/files/liberty/horizon/proxy/views.py
+++ b/modules/openstack/files/liberty/horizon/proxy/views.py
@@ -66,6 +66,12 @@
record = obj_id[:obj_id.find('.')]
domain = obj_id[obj_id.find('.') + 1:]
+ # First let's make sure that this proxy is really ours to delete.
+ fqdn = "%s.%s" % (record, domain)
+ existing_domains = [proxy.domain for proxy in get_proxy_list(request)]
+ if fqdn not in existing_domains:
+ raise Exception("Proxy \'%s\' is to be deleted but is not owned by
this view." % domain)
+
if domain == 'wmflabs.org.':
auth = identity_generic.Password(
auth_url=base.url_for(request, 'identity'),
@@ -141,6 +147,21 @@
self.backends = backends
+def get_proxy_list(request):
+ try:
+ resp = requests.get(base.url_for(request, 'proxy') + '/mapping')
+ if resp.status_code == 400 and resp.text == 'No such project':
+ proxies = []
+ elif not resp:
+ raise Exception("Got status " + str(resp.status_code))
+ else:
+ proxies = [Proxy(route['domain'], route['backends']) for route in
resp.json()['routes']]
+ except Exception:
+ proxies = []
+ exceptions.handle(request, _("Unable to retrieve proxies: " +
resp.text))
+ return proxies
+
+
class IndexView(tables.DataTableView):
table_class = ProxyTable
template_name = 'project/proxy/index.html'
@@ -148,18 +169,7 @@
def get_data(self):
resp = None
- try:
- resp = requests.get(base.url_for(self.request, 'proxy') +
'/mapping')
- if resp.status_code == 400 and resp.text == 'No such project':
- proxies = []
- elif not resp:
- raise Exception("Got status " + str(resp.status_code))
- else:
- proxies = [Proxy(route['domain'], route['backends']) for route
in resp.json()['routes']]
- except Exception:
- proxies = []
- exceptions.handle(self.request, _("Unable to retrieve proxies: " +
resp.text))
- return proxies
+ return get_proxy_list(self.request)
class CreateProxyForm(forms.SelfHandlingForm):
--
To view, visit https://gerrit.wikimedia.org/r/279583
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I07b346131c532e0b07e2f10b47160a37a4261ca9
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits