summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/loadbalancers/views.py
diff options
context:
space:
mode:
authorTatiana Mazur <tmazur@mirantis.com>2013-04-22 16:13:50 +0400
committerTatiana Mazur <tmazur@mirantis.com>2013-05-22 12:28:02 +0400
commitb9a9bd8427d794da51a7f0aebf4cd619376bed99 (patch)
tree3f06ecaeb563bde12830d4b868b6e0290aa248ca /openstack_dashboard/dashboards/project/loadbalancers/views.py
parent9be678c189d6515df58cad15cf6fdb2c3380dfde (diff)
downloadhorizon-b9a9bd8427d794da51a7f0aebf4cd619376bed99.tar.gz
Add "Edit Pool" button
Add option for updating pool attributes on pools table page. The following attributes can be updated: * name * description * lb_method * admin_state_up fixes bug 1160555 Change-Id: Ifadc65e9624f77d258068c67947af5e49df7c110
Diffstat (limited to 'openstack_dashboard/dashboards/project/loadbalancers/views.py')
-rw-r--r--openstack_dashboard/dashboards/project/loadbalancers/views.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/openstack_dashboard/dashboards/project/loadbalancers/views.py b/openstack_dashboard/dashboards/project/loadbalancers/views.py
index c0e399034..89a5164f7 100644
--- a/openstack_dashboard/dashboards/project/loadbalancers/views.py
+++ b/openstack_dashboard/dashboards/project/loadbalancers/views.py
@@ -18,9 +18,11 @@ import logging
import re
from django import http
+from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
+from horizon import forms
from horizon import tables
from horizon import tabs
from horizon import workflows
@@ -28,6 +30,7 @@ from horizon import workflows
from openstack_dashboard import api
from .workflows import AddPool, AddMember, AddMonitor, AddVip
+from .forms import UpdatePool
from .tabs import LoadBalancerTabs, PoolDetailsTabs, VipDetailsTabs
from .tabs import MemberDetailsTabs, MonitorDetailsTabs
from .tables import DeleteMonitorLink
@@ -150,3 +153,34 @@ class MemberDetailsView(tabs.TabView):
class MonitorDetailsView(tabs.TabView):
tab_group_class = (MonitorDetailsTabs)
template_name = 'project/loadbalancers/details_tabs.html'
+
+
+class UpdatePoolView(forms.ModalFormView):
+ form_class = UpdatePool
+ template_name = "project/loadbalancers/updatepool.html"
+ context_object_name = 'pool'
+ success_url = reverse_lazy("horizon:project:loadbalancers:index")
+
+ def get_context_data(self, **kwargs):
+ context = super(UpdatePoolView, self).get_context_data(**kwargs)
+ context["pool_id"] = self.kwargs['pool_id']
+ return context
+
+ def _get_object(self, *args, **kwargs):
+ if not hasattr(self, "_object"):
+ pool_id = self.kwargs['pool_id']
+ try:
+ self._object = api.lbaas.pool_get(self.request, pool_id)
+ except:
+ redirect = self.success_url
+ msg = _('Unable to retrieve pool details.')
+ exceptions.handle(self.request, msg, redirect=redirect)
+ return self._object
+
+ def get_initial(self):
+ pool = self._get_object()
+ return {'name': pool['name'],
+ 'pool_id': pool['id'],
+ 'description': pool['description'],
+ 'lb_method': pool['lb_method'],
+ 'admin_state': pool['admin_state_up']}