summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-09-28 00:43:20 +0000
committerGerrit Code Review <review@openstack.org>2017-09-28 00:43:20 +0000
commit4937a2f3cc62e0e52a94a32ab2e4e3c55997d157 (patch)
tree0c95b7d7c7d1134f726d70a1715e5f3d93cdedbe
parent713eecdca621f52d0205877a2ff5bbe4d4969015 (diff)
parent2945c83a01a8e0b476b5e0ff2e423e3c2ad3f7f6 (diff)
Merge "Remove old unused code."
-rw-r--r--neutron_lbaas_dashboard/api/__init__.py1
-rw-r--r--neutron_lbaas_dashboard/api/lbaasv2.py682
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/__init__.py0
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/exceptions.py36
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/panel.py47
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tables.py189
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tabs.py33
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_detail_overview.html50
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_launch_lb_help.html15
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_create.html49
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_help.html10
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_ssl_cert_help.html13
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/detail.html15
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/index.html11
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch.html11
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch_lb.html82
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/port_config.html76
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/ssl_cert.html68
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update.html11
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_lb_step.html63
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_ssl_cert.html91
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/urls.py30
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/views.py146
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/__init__.py16
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/create_lb.py460
-rw-r--r--neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/update_lb.py191
-rw-r--r--neutron_lbaas_dashboard/enabled/_1480_project_loadbalancersv2_panel.py23
-rw-r--r--neutron_lbaas_dashboard/tests/settings.py6
28 files changed, 3 insertions, 2422 deletions
diff --git a/neutron_lbaas_dashboard/api/__init__.py b/neutron_lbaas_dashboard/api/__init__.py
index 4b9ac4a..e69de29 100644
--- a/neutron_lbaas_dashboard/api/__init__.py
+++ b/neutron_lbaas_dashboard/api/__init__.py
@@ -1 +0,0 @@
1from . import lbaasv2 # noqa
diff --git a/neutron_lbaas_dashboard/api/lbaasv2.py b/neutron_lbaas_dashboard/api/lbaasv2.py
deleted file mode 100644
index 3205c10..0000000
--- a/neutron_lbaas_dashboard/api/lbaasv2.py
+++ /dev/null
@@ -1,682 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from __future__ import absolute_import
16
17import collections
18
19from django.utils.translation import ugettext_lazy as _
20
21from horizon import messages
22
23from openstack_dashboard.api import neutron
24
25neutronclient = neutron.neutronclient
26
27
28class LBDetails(neutron.NeutronAPIDictWrapper):
29 """Wrapper for neutron load balancer vip."""
30
31 def __init__(self, vip, listener=None, pool=None, members=None,
32 monitors=None, profile_name=None, cert=None, key=None,
33 chain=None):
34 vip['pool'] = pool
35 pool['members'] = members
36 pool['monitors'] = monitors
37 # vip['cert_name'] = cert_name
38 vip['listener'] = listener
39 vip['cert'] = cert
40 vip['key'] = key
41 vip['chain'] = chain
42 vip['profile_name'] = profile_name
43 super(LBDetails, self).__init__(vip)
44
45 class AttributeDict(dict):
46
47 def __getattr__(self, attr):
48 return self[attr]
49
50 def __setattr__(self, attr, value):
51 self[attr] = value
52
53 def convert_status(self, value):
54 return "Enabled" if value else "Disabled"
55
56 def readable(self, request=None):
57
58 pFormatted = {'id': self.id,
59 'name': self.name,
60 'dns_name': self.name,
61 # 'lb_method': self.lb_method,
62 'description': self.description,
63 # 'protocol': self.protocol,
64 'address': self.vip_address,
65 # 'port': self.port,
66 'enabled': self.convert_status(self.admin_state_up),
67 'use_common_cert': False,
68 'provisioning_status': self.provisioning_status,
69 'operating_status': self.operating_status,
70 # 'monitor' : self.monitor
71 }
72
73 # status_string = 'vip: %s' % self['status'].lower()
74 pFormatted['status'] = 'na'
75
76 # if self.profile_name:
77 # try:
78 # if self.profile_name.upper() ==
79 # _construct_common_cert_profile_name(request).upper():
80 # pFormatted['use_common_cert'] = True
81 # pFormatted['cert_name'] = self.profile_name
82 # else:
83 # pFormatted['use_common_cert'] = False
84 # pFormatted['cert_name'] = self.profile_name
85 # pFormatted['cert'] = self.cert
86 # pFormatted['private_key'] = self.key
87 # pFormatted['chain_cert'] = self.chain
88 # except Exception as e:
89 # LOG.error("unable to read cert")
90
91 if self.listener is not None:
92 try:
93 listener = self.AttributeDict(self.listener)
94 pFormatted['protocol'] = listener.protocol
95 pFormatted['port'] = listener.protocol_port
96 except Exception:
97 pass
98
99 if self.pool is not None:
100 try:
101 pool = self.AttributeDict(self.pool)
102 # status_string = '%s \n pool: %s' % (pFormatted['status'],
103 # pool['status'].lower())
104 # pFormatted['status'] = status_string
105 pFormatted['pool'] = pool
106 pFormatted['pool_id'] = pool.id
107 pFormatted['lb_method'] = pool.lb_algorithm
108
109 if pool.members is not None:
110 try:
111 ips = []
112 pool_members = []
113 for m in pool.members:
114 member = self.AttributeDict(m)
115 pFormatted['instance_port'] = member.protocol_port
116
117 pool_member = member
118 pool_member.port = member.protocol_port
119 pool_members.append(pool_member)
120
121 ips.append(member.address)
122 pFormatted['pool']['members'] = pool_members
123 pFormatted['members'] = ips
124 except Exception:
125 pass # ignore
126
127 if pool.monitors is not None:
128 try:
129 for m in pool.monitors:
130 monitor = self.AttributeDict(m)
131 # monitor_status =_get_monitor_status(pool['id'],m)
132 # status_string = '%s \n monitor: %s' %
133 # (pFormatted['status'], monitor_status.lower())
134 # pFormatted['status'] = status_string
135 interval = int(monitor.delay)
136 # timeout = int(monitor.timeout)
137 retry = int(monitor.max_retries)
138 monitor_type = 'http-ecv'
139 # if monitor.name.upper() in basic_monitors:
140 # monitor_type = monitor.name
141 monitor_type = monitor.name
142 pFormatted['pool']['monitor'] = monitor_type
143 pFormatted['monitor'] = monitor_type
144 pFormatted['interval'] = interval
145 pFormatted['timeout'] = retry
146 pFormatted['send'] = monitor.url_path \
147 if hasattr(monitor, 'url_path') else ''
148 pFormatted['receive'] = monitor.response_string \
149 if hasattr(monitor, 'response_string') else ''
150 break
151 except Exception:
152 pass # ignore
153 except Exception:
154 pass # ignore
155
156 if 'cert_name' not in pFormatted:
157 pFormatted['cert_name'] = ''
158 if 'cert' not in pFormatted:
159 pFormatted['cert'] = ''
160 if 'private_key' not in pFormatted:
161 pFormatted['private_key'] = ''
162 if 'chain_cert' not in pFormatted:
163 pFormatted['chain_cert'] = ''
164 if 'pool_id' not in pFormatted:
165 pFormatted['pool_id'] = 'UNKNOWN'
166 if 'lb_method' not in pFormatted:
167 pFormatted['lb_method'] = 'UNKNOWN'
168 if 'monitor' not in pFormatted:
169 pFormatted['monitor'] = 'None'
170 # if 'monitor' not in pFormatted['pool']:
171 # pFormatted['pool']['monitor'] = 'None'
172 if 'interval' not in pFormatted:
173 pFormatted['interval'] = 1
174 if 'timeout' not in pFormatted:
175 pFormatted['timeout'] = 1
176 if 'send' not in pFormatted:
177 pFormatted['send'] = None
178 if 'receive' not in pFormatted:
179 pFormatted['receive'] = None
180 if 'members' not in pFormatted:
181 pFormatted['members'] = []
182 if 'instance_port' not in pFormatted:
183 pFormatted['instance_port'] = ''
184
185 return self.AttributeDict(pFormatted)
186
187
188class Vip(neutron.NeutronAPIDictWrapper):
189 """Wrapper for neutron load balancer vip."""
190
191 def __init__(self, apiresource):
192 super(Vip, self).__init__(apiresource)
193
194
195class Pool(neutron.NeutronAPIDictWrapper):
196 """Wrapper for neutron load balancer pool."""
197
198 def __init__(self, apiresource):
199 if 'provider' not in apiresource:
200 apiresource['provider'] = None
201 super(Pool, self).__init__(apiresource)
202
203
204class Member(neutron.NeutronAPIDictWrapper):
205 """Wrapper for neutron load balancer member."""
206
207 def __init__(self, apiresource):
208 super(Member, self).__init__(apiresource)
209
210
211class PoolStats(neutron.NeutronAPIDictWrapper):
212 """Wrapper for neutron load balancer pool stats."""
213
214 def __init__(self, apiresource):
215 super(PoolStats, self).__init__(apiresource)
216
217
218class PoolMonitor(neutron.NeutronAPIDictWrapper):
219 """Wrapper for neutron load balancer pool health monitor."""
220
221 def __init__(self, apiresource):
222 super(PoolMonitor, self).__init__(apiresource)
223
224
225def vip_create(request, **kwargs):
226 """Create a vip for a specified pool.
227
228 :param request: request context
229 :param address: virtual IP address
230 :param name: name for vip
231 :param description: description for vip
232 :param subnet_id: subnet_id for subnet of vip
233 :param protocol_port: transport layer port number for vip
234 :returns: Vip object
235 """
236 body = {'vip': {'name': kwargs['name'],
237 'description': kwargs['description'],
238 'subnet_id': kwargs['subnet_id'],
239 'protocol_port': kwargs['protocol_port'],
240 'protocol': kwargs['protocol'],
241 'pool_id': kwargs['pool_id'],
242 'session_persistence': kwargs['session_persistence'],
243 'admin_state_up': kwargs['admin_state_up']
244 }}
245 if kwargs.get('connection_limit'):
246 body['vip']['connection_limit'] = kwargs['connection_limit']
247
248 if kwargs.get('address'):
249 body['vip']['address'] = kwargs['address']
250
251 vip = neutronclient(request).create_vip(body).get('vip')
252 return Vip(vip)
253
254
255def vip_list(request, **kwargs):
256 vips = neutronclient(request).list_vips(**kwargs).get('vips')
257 return [Vip(v) for v in vips]
258
259
260def create_loadbalancer_full(request, **kwargs):
261 loadbalancer_body = {'loadbalancer': {'name': kwargs['name'],
262 'description': kwargs['description'],
263 'vip_subnet_id': kwargs['subnet_id'],
264 'admin_state_up':
265 kwargs['admin_state_up'],
266 'vip_address': kwargs['address'],
267 # 'provider': 'HAProxy'
268 }}
269
270 listener_body = {'listener': {'name': kwargs['name'],
271 'description': kwargs['description'],
272 'protocol': kwargs['protocol'],
273 'protocol_port': kwargs['protocol_port'],
274 'default_tls_container_id': None,
275 'sni_container_ids': [],
276 'connection_limit': 100,
277 'admin_state_up': kwargs['admin_state_up'],
278 'loadbalancer_id': None}}
279
280 pool_body = {'pool': {'name': kwargs['name'],
281 'description': kwargs['description'],
282 'protocol': kwargs['protocol'],
283 'lb_method': kwargs['lb_method'],
284 'admin_state_up': kwargs['admin_state_up']
285 }}
286
287 member_body = {'member': {'pool_id': kwargs['pool_id'],
288 'address': kwargs['address'],
289 'protocol_port': kwargs['protocol_port'],
290 'admin_state_up': kwargs['admin_state_up'],
291 'pool_id': None
292 }}
293 if kwargs.get('weight'):
294 member_body['member']['weight'] = kwargs['weight']
295
296 monitor_type = kwargs['type'].upper()
297
298 health_monitor_body = {'health_monitor': {'tenant_id': kwargs['tenant_id'],
299 'type': monitor_type,
300 'delay': kwargs['delay'],
301 'timeout': kwargs['timeout'],
302 'max_retries':
303 kwargs['max_retries'],
304 'admin_state_up':
305 kwargs['admin_state_up'],
306 'pool_id': None
307 }
308 }
309
310 if monitor_type in ['HTTP', 'HTTPS']:
311 health_mon = health_monitor_body['health_monitor']
312 health_mon['http_method'] = kwargs['http_method']
313 health_mon['url_path'] = kwargs['url_path']
314 health_mon['expected_codes'] = kwargs['expected_codes']
315
316 try:
317 client = neutronclient(request)
318 loadbalancer = client.\
319 create_loadbalancer(loadbalancer_body).get('loadbalancer')
320 listener_body['listener']['loadbalancer_id'] = loadbalancer['id']
321 listener = client.\
322 create_listener(listener_body).get('listener')
323 pool = client.create_lbaas_pool(pool_body).get('pool')
324 member_body['member']['pool_id'] = pool['id']
325 health_monitor_body['health_monitor']['pool_id'] = pool['id']
326 health_monitor = client.create_lbaas_healthmonitor(health_monitor_body)\
327 .get('health_monitor')
328 member = client.create_lbaas_member(member_body).get('member')
329 except Exception:
330 raise Exception(_("Could not create full loadbalancer."))
331 return [LBDetails(loadbalancer, listener, pool, member, health_monitor)]
332
333
334def list_loadbalancers(request, **kwargs):
335 vips = neutronclient(request).list_loadbalancers(**kwargs)
336 vips = [] if not vips else vips
337 vips = vips.get('loadbalancers')
338 lbaas_list = []
339
340 for vip in vips:
341 listeners = vip.get('listeners')
342 listeners = [] if not listeners else listeners
343
344 for listener in listeners:
345 listener = neutronclient(request).show_listener(listener.get('id'),
346 **kwargs)
347 if not listener:
348 continue
349 listener = listener.get('listener')
350
351 try:
352 pool = neutronclient(request).\
353 show_lbaas_pool(listener.get('default_pool_id'), **kwargs)
354 if not pool:
355 continue
356 pool = pool.get('pool')
357 if pool.get('healthmonitor_id'):
358 health_monitor = neutronclient(request).\
359 show_lbaas_healthmonitor(pool.get('healthmonitor_id'),
360 **kwargs)
361 health_monitor = health_monitor.get('healthmonitor')
362 else:
363 health_monitor = None
364 members = neutronclient(request).\
365 list_lbaas_members(listener.get('default_pool_id'),
366 **kwargs)
367 lbaas_list.append(LBDetails(vip, listener, pool,
368 members, health_monitor))
369 except Exception:
370 raise Exception(_("Could not get load balancer list."))
371 return lbaas_list
372
373
374def show_loadbalancer(request, lbaas_loadbalancer, **kwargs):
375 vip = neutronclient(request).show_loadbalancer(lbaas_loadbalancer,
376 **kwargs)
377 if not vip:
378 return
379 loadbalancer = vip.get('loadbalancer')
380 viplisteners = loadbalancer.get('listeners')
381 if not viplisteners:
382 return
383 for viplistener in viplisteners:
384 listener = neutronclient(request).\
385 show_listener(viplistener.get('id'), **kwargs)
386 if not listener:
387 continue
388 listener = listener.get('listener')
389 pool = neutronclient(request).\
390 show_lbaas_pool(listener.get('default_pool_id'), **kwargs)
391 if not pool:
392 continue
393 pool = pool.get('pool')
394 health_monitor = None
395 if pool.get('healthmonitor_id'):
396 health_monitor = neutronclient(request).\
397 show_lbaas_healthmonitor(pool.get('healthmonitor_id'),
398 **kwargs)
399 health_monitor = health_monitor.get('healthmonitor')
400 members = neutronclient(request).\
401 list_lbaas_members(listener.get('default_pool_id'), **kwargs)
402 return LBDetails(vip.get('loadbalancer'), listener, pool, members,
403 health_monitor)
404
405
406def vip_get(request, vip_id):
407 return _vip_get(request, vip_id, expand_resource=True)
408
409
410def _vip_get(request, vip_id, expand_resource=False):
411 vip = neutronclient(request).show_vip(vip_id).get('vip')
412 if expand_resource:
413 vip['subnet'] = neutron.subnet_get(request, vip['subnet_id'])
414 vip['port'] = neutron.port_get(request, vip['port_id'])
415 vip['pool'] = _pool_get(request, vip['pool_id'])
416 return Vip(vip)
417
418
419def vip_update(request, vip_id, **kwargs):
420 vip = neutronclient(request).update_vip(vip_id, kwargs).get('vip')
421 return Vip(vip)
422
423
424def vip_delete(request, vip_id):
425 neutronclient(request).delete_vip(vip_id)
426
427
428def pool_create(request, **kwargs):
429 """Create a pool for specified protocol
430
431 :param request: request context
432 :param name: name for pool
433 :param description: description for pool
434 :param subnet_id: subnet_id for subnet of pool
435 :param protocol: load balanced protocol
436 :param lb_method: load balancer method
437 :param admin_state_up: admin state (default on)
438 """
439 body = {'pool': {'name': kwargs['name'],
440 'description': kwargs['description'],
441 'subnet_id': kwargs['subnet_id'],
442 'protocol': kwargs['protocol'],
443 'lb_method': kwargs['lb_method'],
444 'admin_state_up': kwargs['admin_state_up'],
445 'provider': kwargs['provider'],
446 }}
447 pool = neutronclient(request).create_pool(body).get('pool')
448 return Pool(pool)
449
450
451def _get_vip(request, pool, vip_dict, expand_name_only=False):
452 if pool['vip_id'] is not None:
453 try:
454 if vip_dict:
455 vip = vip_dict.get(pool['vip_id'])
456 else:
457 vip = _vip_get(request, pool['vip_id'])
458 except Exception:
459 messages.warning(request, _("Unable to get VIP for pool "
460 "%(pool)s.") % {"pool": pool["id"]})
461 vip = Vip({'id': pool['vip_id'], 'name': ''})
462 if expand_name_only:
463 vip = vip.name_or_id
464 return vip
465 else:
466 return None
467
468
469def pool_list(request, **kwargs):
470 return _pool_list(request, expand_subnet=True, expand_vip=True, **kwargs)
471
472
473def _pool_list(request, expand_subnet=False, expand_vip=False, **kwargs):
474 pools = neutronclient(request).list_pools(**kwargs).get('pools')
475 if expand_subnet:
476 subnets = neutron.subnet_list(request)
477 subnet_dict = collections.OrderedDict((s.id, s) for s in subnets)
478 for p in pools:
479 subnet = subnet_dict.get(p['subnet_id'])
480 p['subnet_name'] = subnet.cidr if subnet else None
481 if expand_vip:
482 vips = vip_list(request)
483 vip_dict = collections.OrderedDict((v.id, v) for v in vips)
484 for p in pools:
485 p['vip_name'] = _get_vip(request, p, vip_dict,
486 expand_name_only=True)
487 return [Pool(p) for p in pools]
488
489
490def pool_get(request, pool_id):
491 return _pool_get(request, pool_id, expand_resource=True)
492
493
494def _pool_get(request, pool_id, expand_resource=False):
495 try:
496 pool = neutronclient(request).show_pool(pool_id).get('pool')
497 except Exception:
498 messages.warning(request, _("Unable to get pool detail."))
499 return None
500 if expand_resource:
501 # TODO(lyj): The expand resource(subnet, member etc.) attached
502 # to a pool could be deleted without cleanup pool related database,
503 # this will cause exceptions if we trying to get the deleted resources.
504 # so we need to handle the situation by showing a warning message here.
505 # we can safely remove the try/except once the neutron bug is fixed
506 # https://bugs.launchpad.net/neutron/+bug/1406854
507 try:
508 pool['subnet'] = neutron.subnet_get(request, pool['subnet_id'])
509 except Exception:
510 messages.warning(request, _("Unable to get subnet for pool "
511 "%(pool)s.") % {"pool": pool_id})
512 pool['vip'] = _get_vip(request, pool, vip_dict=None,
513 expand_name_only=False)
514 try:
515 pool['members'] = _member_list(request, expand_pool=False,
516 pool_id=pool_id)
517 except Exception:
518 messages.warning(request, _("Unable to get members for pool "
519 "%(pool)s.") % {"pool": pool_id})
520 try:
521 pool['health_monitors'] = pool_health_monitor_list(
522 request, id=pool['health_monitors'])
523 except Exception:
524 messages.warning(request,
525 _("Unable to get health monitors "
526 "for pool %(pool)s.") % {"pool": pool_id})
527 return Pool(pool)
528
529
530def pool_update(request, pool_id, **kwargs):
531 pool = neutronclient(request).update_pool(pool_id, kwargs).get('pool')
532 return Pool(pool)
533
534
535def pool_delete(request, pool):
536 neutronclient(request).delete_pool(pool)
537
538
539# not linked to UI yet
540def pool_stats(request, pool_id, **kwargs):
541 stats = neutronclient(request).retrieve_pool_stats(pool_id, **kwargs)
542 return PoolStats(stats)
543
544
545def pool_health_monitor_create(request, **kwargs):
546 """Create a health monitor
547
548 :param request: request context
549 :param type: type of monitor
550 :param delay: delay of monitor
551 :param timeout: timeout of monitor
552 :param max_retries: max retries [1..10]
553 :param http_method: http method
554 :param url_path: url path
555 :param expected_codes: http return code
556 :param admin_state_up: admin state
557 """
558 monitor_type = kwargs['type'].upper()
559 body = {'health_monitor': {'type': monitor_type,
560 'delay': kwargs['delay'],
561 'timeout': kwargs['timeout'],
562 'max_retries': kwargs['max_retries'],
563 'admin_state_up': kwargs['admin_state_up']
564 }}
565 if monitor_type in ['HTTP', 'HTTPS']:
566 body['health_monitor']['http_method'] = kwargs['http_method']
567 body['health_monitor']['url_path'] = kwargs['url_path']
568 body['health_monitor']['expected_codes'] = kwargs['expected_codes']
569 mon = neutronclient(request).create_health_monitor(body).get(
570 'health_monitor')
571
572 return PoolMonitor(mon)
573
574
575def pool_health_monitor_list(request, **kwargs):
576 monitors = neutronclient(request).list_health_monitors(
577 **kwargs).get('health_monitors')
578 return [PoolMonitor(m) for m in monitors]
579
580
581def pool_health_monitor_get(request, monitor_id):
582 return _pool_health_monitor_get(request, monitor_id, expand_resource=True)
583
584
585def _pool_health_monitor_get(request, monitor_id, expand_resource=False):
586 monitor = neutronclient(request
587 ).show_health_monitor(monitor_id
588 ).get('health_monitor')
589 if expand_resource:
590 pool_ids = [p['pool_id'] for p in monitor['pools']]
591 monitor['pools'] = _pool_list(request, id=pool_ids)
592 return PoolMonitor(monitor)
593
594
595def pool_health_monitor_update(request, monitor_id, **kwargs):
596 monitor = neutronclient(request).update_health_monitor(monitor_id, kwargs)
597 return PoolMonitor(monitor)
598
599
600def pool_health_monitor_delete(request, mon_id):
601 neutronclient(request).delete_health_monitor(mon_id)
602
603
604def member_create(request, **kwargs):
605 """Create a load balance member
606
607 :param request: request context
608 :param pool_id: pool_id of pool for member
609 :param address: IP address
610 :param protocol_port: transport layer port number
611 :param weight: weight for member
612 :param admin_state_up: admin_state
613 """
614 body = {'member': {'pool_id': kwargs['pool_id'],
615 'address': kwargs['address'],
616 'protocol_port': kwargs['protocol_port'],
617 'admin_state_up': kwargs['admin_state_up']
618 }}
619 if kwargs.get('weight'):
620 body['member']['weight'] = kwargs['weight']
621 member = neutronclient(request).create_member(body).get('member')
622 return Member(member)
623
624
625def member_list(request, **kwargs):
626 return _member_list(request, expand_pool=True, **kwargs)
627
628
629def _member_list(request, expand_pool, **kwargs):
630 members = neutronclient(request).list_members(**kwargs).get('members')
631 if expand_pool:
632 pools = _pool_list(request)
633 pool_dict = collections.OrderedDict((p.id, p) for p in pools)
634 for m in members:
635 m['pool_name'] = pool_dict.get(m['pool_id']).name_or_id
636 return [Member(m) for m in members]
637
638
639def member_get(request, member_id):
640 return _member_get(request, member_id, expand_pool=True)
641
642
643def _member_get(request, member_id, expand_pool):
644 member = neutronclient(request).show_member(member_id).get('member')
645 if expand_pool:
646 member['pool'] = _pool_get(request, member['pool_id'])
647 return Member(member)
648
649
650def member_update(request, member_id, **kwargs):
651 member = neutronclient(request).update_member(member_id, kwargs)
652 return Member(member)
653
654
655def member_delete(request, mem_id):
656 neutronclient(request).delete_member(mem_id)
657
658
659def pool_monitor_association_create(request, **kwargs):
660 """Associate a health monitor with pool
661
662 :param request: request context
663 :param monitor_id: id of monitor
664 :param pool_id: id of pool
665 """
666
667 body = {'health_monitor': {'id': kwargs['monitor_id'], }}
668
669 neutronclient(request).associate_health_monitor(
670 kwargs['pool_id'], body)
671
672
673def pool_monitor_association_delete(request, **kwargs):
674 """Disassociate a health monitor from pool
675
676 :param request: request context
677 :param monitor_id: id of monitor
678 :param pool_id: id of pool
679 """
680
681 neutronclient(request).disassociate_health_monitor(
682 kwargs['pool_id'], kwargs['monitor_id'])
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/__init__.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/__init__.py
+++ /dev/null
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/exceptions.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/exceptions.py
deleted file mode 100644
index 0155935..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/exceptions.py
+++ /dev/null
@@ -1,36 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15
16class LBaaSException(Exception):
17
18 """The base exception class for all exceptions this library raises.
19
20 """
21
22 def __init__(self, code, message=None, details=None, request_id=None,
23 url=None, method=None):
24 self.code = code
25 self.message = message or self.__class__.message
26 self.details = details
27 self.request_id = request_id
28 self.url = url
29 self.method = method
30
31 def __str__(self):
32 formatted_string = "%s (HTTP %s)" % (self.message, self.code)
33 if self.request_id:
34 formatted_string += " (Request-ID: %s)" % self.request_id
35
36 return formatted_string
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/panel.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/panel.py
deleted file mode 100644
index 224e503..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/panel.py
+++ /dev/null
@@ -1,47 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from django.utils.translation import ugettext_lazy as _
16
17import horizon
18
19from openstack_dashboard.dashboards.project import dashboard
20
21
22class LoadBalancersUI(horizon.Panel):
23 name = _("Load Balancers V2")
24 slug = 'loadbalancersv2'
25 permissions = ('openstack.services.network',)
26
27 def allowed(self, context):
28 # todo temporarily enabling panel for any user
29 # request = context['request']
30 # if not request.user.has_perms(self.permissions):
31 # return False
32 # try:
33 # if not neutron.is_service_enabled(request,
34 # config_name='enable_lb',
35 # ext_name='lbaas'):
36 # return False
37 # except Exception:
38 # LOG.error("Call to list enabled services failed. This is likely "
39 # "due to a problem communicating with the Neutron "
40 # "endpoint. Load Balancers panel will not be displayed")
41 # return False
42 # if not super(LoadBalancer, self).allowed(context):
43 # return False
44 return True
45
46
47dashboard.Project.register(LoadBalancersUI)
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tables.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tables.py
deleted file mode 100644
index 38dbb87..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tables.py
+++ /dev/null
@@ -1,189 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15
16import re
17
18from django.core import urlresolvers
19from django.template.defaultfilters import linebreaksbr
20from django.utils.http import urlencode
21from django.utils.translation import ugettext_lazy as _
22
23from horizon import tables
24
25from neutron_lbaas_dashboard import api
26
27
28class TerminateLoadBalancer(tables.BatchAction):
29 name = "terminate"
30 action_present = _("Terminate")
31 action_past = _("Scheduled termination of")
32 data_type_singular = _("Load Balancer")
33 data_type_plural = _("Load Balancers")
34 classes = ('btn-danger', 'btn-terminate')
35
36 def allowed(self, request, loadbalancer=None):
37 return True
38
39 def action(self, request, obj_id):
40 api.lbaasv2.vip_delete(request, obj_id)
41
42
43class EnableLoadBalancer(tables.BatchAction):
44 name = "enable"
45 action_present = _("Enable")
46 action_past = _("Enabled LB")
47 data_type_singular = _("Load Balancer")
48 data_type_plural = _("Load Balancers")
49 classes = ('btn-enable', "btn-action-required")
50 action_failure = "error enable"
51
52 def allowed(self, request, loadbalancer=None):
53 if loadbalancer.admin_state_up:
54 return False
55 return True
56
57 def action(self, request, obj_id):
58 api.lbaasv2.vip_set_status(request, obj_id, True)
59
60
61class DisableLoadBalancer(tables.BatchAction):
62 name = "disable"
63 action_present = _("Disable")
64 action_past = _("Disabled LB")
65 data_type_singular = _("Load Balancer")
66 data_type_plural = _("Load Balancers")
67 classes = ("btn-confirm", 'btn-disable',)
68 action_failure = "error disable"
69
70 def allowed(self, request, loadbalancer=None):
71 if loadbalancer.admin_state_up:
72 return True
73 return False
74
75 def action(self, request, obj_id):
76 api.lbaasv2.vip_set_status(request, obj_id, False)
77
78
79class LaunchLink(tables.LinkAction):
80 name = "launch"
81 verbose_name = _("Launch Load Balancer")
82 url = "horizon:project:loadbalancersv2:launch"
83 classes = ("btn-launch", "ajax-modal")
84
85 def allowed(self, request, datum):
86 return True
87
88
89class EditLoadBalancer(tables.LinkAction):
90 name = "edit"
91 verbose_name = _("Edit Load Balancer")
92 url = "horizon:project:loadbalancersv2:update"
93 classes = ("ajax-modal", "btn-edit")
94
95 def get_link_url(self, project):
96 return self._get_link_url(project, 'loadbalancer_info')
97
98 def _get_link_url(self, project, step_slug):
99 base_url = urlresolvers.reverse(self.url, args=[project.id])
100 param = urlencode({"step": step_slug})
101 return "?".join([base_url, param])
102
103 def allowed(self, request, loadbalancer):
104 # return not is_deleting(loadbalancer) when async is implemented
105 return True
106
107
108class UpdateRow(tables.Row):
109 ajax = True
110
111 def get_data(self, request, loadbalancer_id):
112 loadbalancer = api.lbaasv2.vip_update(request, loadbalancer_id)
113 return loadbalancer
114
115
116def convert_title(value):
117 return re.sub("([A-Z])", " \g<0>", value)
118
119
120def convert_camel(value):
121 if not value:
122 return value
123 if value.isupper() or value.islower():
124 return value.title()
125 else:
126 value = value.replace(' ', '')
127 return re.sub("([A-Z])", " \g<0>", value)
128
129
130def upper_case(value):
131 return value.upper()
132
133
134def convert_status(value):
135 return "Enabled" if value else "Disabled"
136
137
138def get_lb_method(value):
139 return value.pool['lb_algorithm']
140
141
142def get_protocol(value):
143 return value.listener['protocol']
144
145
146def get_monitor(value):
147 return value['pool']['monitors']['type']
148
149
150def get_lb(instance):
151 if hasattr(instance, "vip_address"):
152 return "%s:%s" % (instance.vip_address,
153 instance.listener['protocol_port'])
154 return _("Not available")
155
156
157class LoadBalancersTable(tables.DataTable):
158 vip = tables.Column(get_lb,
159 link=("horizon:project:loadbalancersv2:detail"),
160 verbose_name=_("Load Balancer"))
161 name = tables.Column("name",
162 link=("horizon:project:loadbalancersv2:detail"),
163 verbose_name=_("Name"))
164 lb_method = tables.Column(get_lb_method,
165 filters=(upper_case,),
166 verbose_name=_("Method"))
167 protocol = tables.Column(get_protocol,
168 filters=(upper_case,),
169 verbose_name=_("Protocol"))
170 monitor = tables.Column(get_monitor,
171 filters=(upper_case,),
172 verbose_name=_("Monitor"))
173 status = tables.Column("provisioning_status",
174 filters=(convert_camel, linebreaksbr),
175 verbose_name=_("Provisioning Status"))
176 operating_status = tables.Column("operating_status",
177 filters=(convert_camel, linebreaksbr),
178 verbose_name=_("Operating Status"))
179 enabled = tables.Column("admin_state_up",
180 filters=(convert_status,),
181 verbose_name=_("Admin Status"))
182
183 class Meta(object):
184 name = "loadbalancersv2"
185 verbose_name = _("Load Balancers")
186 row_class = UpdateRow
187 table_actions = (LaunchLink, TerminateLoadBalancer)
188 row_actions = (EditLoadBalancer, TerminateLoadBalancer,
189 EnableLoadBalancer, DisableLoadBalancer)
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tabs.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tabs.py
deleted file mode 100644
index 5a3543f..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/tabs.py
+++ /dev/null
@@ -1,33 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from django.utils.translation import ugettext_lazy as _
16
17from horizon import tabs
18
19
20class OverviewTab(tabs.Tab):
21 name = _("Overview")
22 slug = "overview"
23 template_name = ("project/loadbalancersv2/"
24 "_detail_overview.html")
25
26 def get_context_data(self, request):
27 return {"loadbalancer": self.tab_group.kwargs['loadbalancer']}
28
29
30class LoadBalancerDetailTabs(tabs.TabGroup):
31 slug = "loadbalancer_details"
32 tabs = (OverviewTab, )
33 sticky = True
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_detail_overview.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_detail_overview.html
deleted file mode 100644
index d0842c6..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_detail_overview.html
+++ /dev/null
@@ -1,50 +0,0 @@
1{% load i18n sizeformat %}
2
3<h3>{% trans "Load Balancer Overview" %}</h3>
4
5<div class="status row-fluid detail">
6 <h4>{% trans "Info" %}</h4>
7 <hr class="header_rule">
8 <dl>
9 <dt>{% trans "Name" %}</dt>
10 <dd>{{ loadbalancer.name }}</dd>
11 <dt>{% trans "ID" %}</dt>
12 <dd>{{ loadbalancer.id }}</dd>
13 <dt>{% trans "Address" %}</dt>
14 <dd>{{ loadbalancer.address }}</dd>
15 <dt>{% trans "Port" %}</dt>
16 <dd>{{ loadbalancer.port }}</dd>
17 <dt>{% trans "Protocol" %}</dt>
18 <dd>{{ loadbalancer.protocol }}</dd>
19 <dt>{% trans "Load Balancing Method" %}</dt>
20 <dd>{{ loadbalancer.lb_method }}</dd>
21 <dt>{% trans "Monitor" %}</dt>
22 <dd>{{ loadbalancer.pool.monitors.type }}</dd>
23 <dt>{% trans "Operating Status" %}</dt>
24 <dd>{{ loadbalancer.operating_status }}</dd>
25 <dt>{% trans "Provisioning Status" %}</dt>
26 <dd>{{ loadbalancer.provisioning_status }}</dd>
27 <dt>{% trans "Description" %}</dt>
28 <dd> - {{ loadbalancer.description }}</dd>
29 <dt>{% trans "Admin Status" %}</dt>
30 <dd>{{ loadbalancer.enabled|title }}</dd>
31{# <dt>{% trans "Load Balancing Method" %}</dt>#}
32{# <dd>{{ loadbalancer.pool.lb_method }}</dd>#}
33{# <dt>{% trans "Monitor" %}</dt>#}
34{# <dd>{{ loadbalancer.pool.monitor }}</dd>#}
35 <dt>{% trans "Certificate" %}</dt>
36 <dd> - {{ loadbalancer.cert_name }}</dd>
37 </dl>
38</div>
39
40<div class="members row-fluid detail">
41 <h4>{% trans "Members" %}</h4>
42 <hr class="header_rule">
43 <dl>
44 {% for group in loadbalancer.pool.members.members %}
45 <dt>{{ group.id }}</dt>
46 <dd> <b>IP:</b> {{ group.address }}</dd>
47 <dd> <b>Port:</b> {{ group.protocol_port }}</dd>
48 {% endfor %}
49 </dl>
50</div>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_launch_lb_help.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_launch_lb_help.html
deleted file mode 100644
index a57993d..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_launch_lb_help.html
+++ /dev/null
@@ -1,15 +0,0 @@
1{% load i18n horizon %}
2
3<p>{% blocktrans %}This wizard will walk you through setting up a new Load Balancer. A load balancer is a logical device. It is used to distribute workloads between multiple services called ’instances', based on the criteria defined as part of its configuration.{% endblocktrans %}</p>
4
5<p>{% blocktrans %}<b>Name</b>: Enter a unique name for your load balancer (e.g., my-demo-lb).{% endblocktrans %}</p>
6
7<p>{% blocktrans %}<b>Description</b>: Provide a friendly description for your records.{% endblocktrans %}</p>
8
9<p>{% blocktrans %}<b>Load Balancer Method</b>: All load balancers utilize an algorithm that defines how traffic should be directed between instances. The following algorithms are supported: ROUND_ROBIN, LEAST_CONNECTIONS, LEAST_SESSIONS.{% endblocktrans %}</p>
10
11<p>{% blocktrans %}<b>Load Balancer Protocol</b>: Load Balancing of applications using HTTP, HTTPS (Secure HTTP), TCP, and SSL (Secure TCP) protocols are supported.{% endblocktrans %}</p>
12
13<p>{% blocktrans %}<b>Load Balancer Port</b>: This is automatically assigned based on the Load Balancer Protocol selection.{% endblocktrans %}</p>
14
15<p>{% blocktrans %}<b>Instance Port</b>: The acceptable instance ports for both HTTPS/SSL and HTTP/TCP connections are 0-65535.{% endblocktrans %}</p>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_create.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_create.html
deleted file mode 100644
index a2e12fe..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_create.html
+++ /dev/null
@@ -1,49 +0,0 @@
1{% load i18n %}
2
3{% block main %}
4{#<table class="table-fixed" id="monitorContainer">#}
5{# <tbody>#}
6{# <tr>#}
7{# <td class="actions">#}
8{# <div id="monitorId">#}
9{# {% include "horizon/common/_form_fields.html" %}#}
10{# </div>#}
11{# </td>#}
12{# <td class="help_text">#}
13{# {{ step.get_help_text }}#}
14{# </td>#}
15{# </tr>#}
16{# </tbody>#}
17{#</table>#}
18 <div class="col-sm-6">
19 {% include "horizon/common/_form_fields.html" %}
20 </div>
21 <div class="col-sm-6">
22 {{ step.get_help_text }}
23 </div>
24{% endblock %}
25
26
27<script>
28 horizon.modals.addModalInitFunction(function (modal) {
29 var $monitor_type = $('#id_monitor');
30 var $interval = $('#id_interval');
31 var $timeout = $('#id_timeout');
32 var $send = $('#id_send');
33 var $receive = $('#id_receive');
34
35 $monitor_type.change(function () {
36 if ($monitor_type.val() == 'http-ecv') {
37 $interval.closest(".control-group").show();
38 $timeout.closest(".control-group").show();
39 $send.closest(".control-group").show();
40 $receive.closest(".control-group").show();
41 } else {
42 $interval.closest(".control-group").hide();
43 $timeout.closest(".control-group").hide();
44 $send.closest(".control-group").hide();
45 $receive.closest(".control-group").hide();
46 }
47 }).trigger('change');
48 });
49</script>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_help.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_help.html
deleted file mode 100644
index 356156e..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_monitor_help.html
+++ /dev/null
@@ -1,10 +0,0 @@
1{% load i18n %}
2
3<p>{% blocktrans %}When adding a load balancer, you can also specify a health check monitor to use to determine the health of your instances. Health checks routinely run against each instance within a target load balancer and the result of the health check is used to determine if the instance receives new connections.{% endblocktrans %}</p>
4
5<p>{% blocktrans %}The following health check options are currently supported:{% endblocktrans %}</p>
6
7<p>{% blocktrans %}<b>TCP</b> – Default Option – A basic TCP ping check is performed against IP Address of each instance within a target load balancer.{% endblocktrans %}</p>
8
9<p>{% blocktrans %}<b>HTTP</b> – A basic HTTP health check is performed against each instance within a target load balancer on the specified instance port.{% endblocktrans %}</p>
10
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_ssl_cert_help.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_ssl_cert_help.html
deleted file mode 100644
index c45d23b..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/_ssl_cert_help.html
+++ /dev/null
@@ -1,13 +0,0 @@
1{% load i18n %}
2
3<p>{% blocktrans %}For secure website or application using Load Balancers to offload SSL decryption requires SSL server certificate installed on the load balancer.{% endblocktrans %}</p>
4
5<p>{% blocktrans %}If you do not have individual SSL certificate requirements (including custom vanity domains) for your secure website or application, you can choose to use the common certificate that we provide.{% endblocktrans %}</p>
6
7<p>{% blocktrans %}For individual SSL certificates, if you already have a SSL certificate and want to upload it; please specify the following details:{% endblocktrans %}</p>
8
9<p>{% blocktrans %}<b>Certificate Name</b> – Supply a certificate name (i.e. my_server_cert).{% endblocktrans %}</p>
10
11<p>{% blocktrans %}<b>Private Key</b> - Copy and paste the contents of the private key file in the Private Key field.{% endblocktrans %}</p>
12
13<p>{% blocktrans %}<b>Certificate Chain</b> – Optional - Copy and paste the contents of the public key certificate chain file in the Certificate Chain field.{% endblocktrans %}</p>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/detail.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/detail.html
deleted file mode 100644
index d361da6..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/detail.html
+++ /dev/null
@@ -1,15 +0,0 @@
1{% extends 'base.html' %}
2{% load i18n sizeformat %}
3{% block title %}{% trans "Load Balancer Detail" %}{% endblock %}
4
5{% block page_header %}
6 {% include "horizon/common/_page_header.html" with title="Load Balancer Detail: "|add:loadbalancer.name %}
7{% endblock page_header %}
8
9{% block main %}
10<div class="row-fluid">
11 <div class="span12">
12 {{ tab_group.render }}
13 </div>
14</div>
15{% endblock %}
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/index.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/index.html
deleted file mode 100644
index 2a59c01..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
1{% extends 'base.html' %}
2{% load i18n %}
3{% block title %}{% trans "Load Balancers" %}{% endblock %}
4
5{% block page_header %}
6 {% include "horizon/common/_page_header.html" with title=_("Load Balancers") %}
7{% endblock page_header %}
8
9{% block main %}
10 {{ table.render }}
11{% endblock %}
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch.html
deleted file mode 100644
index fb7f968..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch.html
+++ /dev/null
@@ -1,11 +0,0 @@
1{% extends 'base.html' %}
2{% load i18n %}
3{% block title %}{% trans "Launch Load Balancer" %}{% endblock %}
4
5{% block page_header %}
6 {% include "horizon/common/_page_header.html" with title=_("Launch Load Balancer") %}
7{% endblock page_header %}
8
9{% block main %}
10 {% include 'horizon/common/_workflow.html' %}
11{% endblock %}
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch_lb.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch_lb.html
deleted file mode 100644
index e521960..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/launch_lb.html
+++ /dev/null
@@ -1,82 +0,0 @@
1{% load i18n %}
2
3{% block main %}
4{#<table class="table-fixed" id="sslCertContainer">#}
5{# <tbody>#}
6{# <tr>#}
7{# <td class="actions">#}
8{# <div class="row">#}
9{# <div class="col-sm-12">#}
10{# {% include "horizon/common/_form_fields.html" %}#}
11{# </div>#}
12{# </div>#}
13{# </td>#}
14{# <td class="help_text">#}
15{# {{ step.get_help_text }}#}
16{# </td>#}
17{# </tr>#}
18{# </tbody>#}
19{#</table>#}
20 <div class="col-sm-6">
21 {% include "horizon/common/_form_fields.html" %}
22 </div>
23 <div class="col-sm-6">
24 {{ step.get_help_text }}
25 </div>
26{% endblock %}
27
28
29<script>
30
31 horizon.modals.addModalInitFunction(function (modal) {
32 var $address = $('#id_address');
33 var $name = $('#id_name');
34 var $name_label = $('label[for="id_name"]');
35 var $protocol_type = $('#id_protocol_type');
36
37 $address.change(function () {
38 var options_all = {"HTTP": "HTTP", "HTTPS": "HTTPS", "TCP": "TCP", "SSL": "SSL"};
39 setOptions($protocol_type, options_all);
40
41 if ($address.val() == 'new') {
42 $name.removeAttr('disabled');
43 $name.removeAttr('readonly');
44 $name.attr('value', '');
45 } else {
46 var key_token = $address.val().split(':');
47 $name.attr('value', key_token[1]);
48 $name.attr('readonly', 'true');
49 }
50 }).trigger('change');
51
52 function setOptions($protocol_type, newOptions) {
53 $("#id_" + $protocol_type.val()).closest(".control-group").hide();
54 $protocol_type.empty();
55
56 $.each(newOptions, function (key, value) {
57 $protocol_type.append($("<option></option>")
58 .attr("value", value).text(key));
59 });
60 refresh($protocol_type);
61 };
62
63 function refresh($protocol_type) {
64 var $this = $protocol_type,
65 base_type = $this.val();
66 $this.find("option").each(function () {
67 if (this.value != base_type) {
68 $("#id_" + this.value).closest(".control-group").hide();
69 } else {
70 $("#id_" + this.value).closest(".control-group").show();
71 }
72 });
73 };
74
75 $protocol_type.on('change', function(evt){
76 refresh($(this));
77 //prevent the default handler in horizon.instances.js
78 evt.stopPropagation();
79 }).trigger('change');
80 });
81
82</script>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/port_config.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/port_config.html
deleted file mode 100644
index 2c73d73..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/port_config.html
+++ /dev/null
@@ -1,76 +0,0 @@
1{% load i18n %}
2
3<noscript><h3>{{ step }}</h3></noscript>
4<style>
5#target input{
6 width: auto;
7}
8</style>
9<table id='target' class="table table-bordered table-striped datatable">
10 <thead><tr><th>From</th><th>protocol</th><th>To</th><th>Action</th></tr></thead>
11 <tr>
12 <td>
13 <input type='text' class='numbers' name='from' />
14 </td>
15 <td>
16 <select name='protocol'>
17 <option value='http'>HTTP</option>
18 <option value='https'>HTTPS</option>
19 <option value='tcp'>TCP</option>
20 </select>
21 </td>
22
23 <td>
24 <input type='text' class='numbers' name='to' />
25 </td>
26 <td>
27 <a class='btn btn-small' name='add'>+</a>
28 </td>
29 </tr>
30</table>
31
32<script>
33function encode_lb_rule(from, protocol, to){
34 return from + ':' + protocol + ',' + to;
35}
36
37function generate_lb_rule(from, protocol, to){
38 var html = "<tr><td>" + from + "</td>" +
39 "<td>" + protocol + "</td>" +
40 "<td>" + to + "</td>" +
41 "<td><a class='btn btn-small btn-danger'>-</a>";
42 html = $(html);
43 html.on('click', 'a', function(){
44 $('option[value="' + encode_lb_rule(from, protocol, to) + '"]').remove();
45 $(this).closest('tr').remove();
46 });
47 return html;
48}
49
50horizon.modals.addModalInitFunction(function (modal) {
51 $("a[name='add']").on('click', function(){
52 var from = $("input[name='from']").val();
53 var protocol = $("select[name='protocol']").val();
54 var to = $("input[name='to']").val();
55 var encoded = encode_lb_rule(from, protocol, to);
56 if(from && to && $('option[value="'+encoded+'"]').length == 0){
57 $('#id_network').append($("<option></option>")
58 .attr("value", encoded)
59 .attr("selected", "selected")
60 .text(encoded));
61 generate_lb_rule(from, protocol, to).insertBefore($('#target tr:last'));
62 // clean up
63 $("input[name='from']").val('');
64 $("input[name='to']").val('');
65 }
66 });
67
68 $('input.numbers').keyup(function () {
69 this.value = this.value.replace(/[^0-9\.]/g,'');
70 });
71});
72</script>
73
74<div class="hidden">
75 {% include "horizon/common/_form_fields.html" %}
76</div>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/ssl_cert.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/ssl_cert.html
deleted file mode 100644
index a14f6d2..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/ssl_cert.html
+++ /dev/null
@@ -1,68 +0,0 @@
1{% load i18n %}
2
3{% block main %}
4{#<table class="table-fixed" id="sslCertContainer">#}
5{# <tbody>#}
6{# <tr>#}
7{# <td class="actions">#}
8{# <div id="sslCertId">#}
9{# {% include "horizon/common/_form_fields.html" %}#}
10{# </div>#}
11{# </td>#}
12{# <td class="help_text">#}
13{# {{ step.get_help_text }}#}
14{# </td>#}
15{# </tr>#}
16{# </tbody>#}
17{#</table>#}
18
19 <div class="col-sm-6">
20 {% include "horizon/common/_form_fields.html" %}
21 </div>
22 <div class="col-sm-6">
23 {{ step.get_help_text }}
24 </div>
25{% endblock %}
26
27<script>
28 horizon.modals.addModalInitFunction(function (modal) {
29 var $protocol = $('#id_source_type');
30 var $cert_name = $('#id_cert_name');
31 var $cert = $('#id_cert');
32 var $key = $('#id_private_key');
33 var $intermediate = $('#id_chain_cert');
34 var $common_cert = $('#id_use_common_cert');
35
36 $protocol.change(function () {
37 if ($protocol.val() == 'HTTPS') {
38 $common_cert.removeAttr('disabled');
39 $common_cert.attr('value', 'on');
40 $cert_name.removeAttr('disabled');
41 $cert.removeAttr('disabled');
42 $key.removeAttr('disabled');
43 $intermediate.removeAttr('disabled');
44 } else {
45 $common_cert.removeAttr('checked');
46 $common_cert.attr('disabled', 'disabled').val('');
47 $cert_name.attr('disabled', 'disabled').val('');
48 $cert.attr('disabled', 'disabled').val('');
49 $key.attr('disabled', 'disabled').val('');
50 $intermediate.attr('disabled', 'disabled').val('');
51 }
52 }).trigger('change');
53
54 $common_cert.click(function () {
55 if ($common_cert.is(':checked')) {
56 $cert_name.attr('disabled', 'disabled').val('');
57 $cert.attr('disabled', 'disabled').val('');
58 $key.attr('disabled', 'disabled').val('');
59 $intermediate.attr('disabled', 'disabled').val('');
60 } else {
61 $cert_name.removeAttr('disabled');
62 $cert.removeAttr('disabled');
63 $key.removeAttr('disabled');
64 $intermediate.removeAttr('disabled');
65 }
66 }).trigger('change');
67 });
68</script>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update.html
deleted file mode 100644
index f04c27c..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update.html
+++ /dev/null
@@ -1,11 +0,0 @@
1{% extends 'base.html' %}
2{% load i18n %}
3{% block title %}{% trans "Edit Load Balancer" %}{% endblock %}
4
5{% block page_header %}
6 {% include "horizon/common/_page_header.html" with title=_("Edit Load Balancer") %}
7{% endblock page_header %}
8
9{% block main %}
10 {% include 'horizon/common/_workflow.html' %}
11{% endblock %}
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_lb_step.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_lb_step.html
deleted file mode 100644
index 7b1ca2e..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_lb_step.html
+++ /dev/null
@@ -1,63 +0,0 @@
1<noscript><h3>{{ step }}</h3></noscript>
2{#<table class="table-fixed">#}
3{# <tbody>#}
4{# <tr>#}
5{# <td class="actions">#}
6{# {% include "horizon/common/_form_fields.html" %}#}
7{# </td>#}
8{# <td class="help_text">#}
9{# {{ step.get_help_text }}#}
10{# </td>#}
11{# </tr>#}
12{# </tbody>#}
13{#</table>#}
14 <div class="col-sm-6">
15 {% include "horizon/common/_form_fields.html" %}
16 </div>
17 <div class="col-sm-6">
18 {{ step.get_help_text }}
19 </div>
20
21<script>
22
23 horizon.modals.addModalInitFunction(function (modal) {
24 var $protocol_type = $('#id_source_type');
25 var old_value = $protocol_type.val();
26
27 if (old_value == "HTTP" || old_value == "TCP") {
28 var options_all = {"HTTP": "HTTP", "TCP": "TCP"};
29 } else {
30 var options_all = {"HTTPS": "HTTPS", "SSL": "SSL"};
31 }
32
33 setOptions($protocol_type, options_all);
34
35 function setOptions($protocol_type, newOptions) {
36 $("#id_" + $protocol_type.val()).closest(".control-group").hide();
37 $protocol_type.empty();
38
39 $.each(newOptions, function (key, value) {
40 $protocol_type.append($("<option></option>")
41 .attr("value", value).text(key));
42 });
43 $protocol_type.val(old_value);
44 refresh($protocol_type);
45 };
46
47 function refresh($protocol_type) {
48 var $this = $protocol_type,
49 base_type = $this.val();
50
51 $this.find("option").each(function () {
52 if (this.value != base_type) {
53 $("#id_" + this.value).closest(".control-group").hide();
54 } else {
55 $("#id_" + this.value).closest(".control-group").show();
56 }
57 });
58 $this.trigger('change');
59 };
60
61 });
62
63</script>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_ssl_cert.html b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_ssl_cert.html
deleted file mode 100644
index 7081d8c..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/templates/loadbalancersv2/update_ssl_cert.html
+++ /dev/null
@@ -1,91 +0,0 @@
1{% load i18n %}
2
3{% block main %}
4{#<table class="table-fixed" id="sslCertContainer">#}
5{# <tbody>#}
6{# <tr>#}
7{# <td class="actions">#}
8{# <div id="sslCertId">#}
9{# {% include "horizon/common/_form_fields.html" %}#}
10{# </div>#}
11{# </td>#}
12{# <td class="help_text">#}
13{# {{ step.get_help_text }}#}
14{# </td>#}
15{# </tr>#}
16{# </tbody>#}
17{#</table>#}
18
19 <div class="col-sm-6">
20 {% include "horizon/common/_form_fields.html" %}
21 </div>
22 <div class="col-sm-6">
23 {{ step.get_help_text }}
24 </div>
25
26 {% endblock %}
27
28<script>
29 horizon.modals.addModalInitFunction(function (modal) {
30 var $protocol = $('#id_source_type');
31 var $cert_name = $('#id_cert_name');
32 var $cert = $('#id_cert');
33 var $key = $('#id_private_key');
34 var $intermediate = $('#id_chain_cert');
35 var $common_cert = $('#id_use_common_cert');
36 var $update_cert = $('#id_update_cert');
37
38 $protocol.change(function () {
39 if ($protocol.val() == 'HTTPS') {
40 $update_cert.removeAttr('disabled');
41 $update_cert.attr('value', 'on');
42 } else {
43 $update_cert.removeAttr('checked');
44 $update_cert.attr('disabled', 'disabled').val('');
45 }
46 $common_cert.attr('disabled', 'disabled');
47 $cert_name.attr('disabled', 'disabled');
48 $cert.attr('disabled', 'disabled');
49 $key.attr('disabled', 'disabled');
50 $intermediate.attr('disabled', 'disabled');
51 }).trigger('change');
52
53 $update_cert.click(function () {
54 if ($update_cert.is(':checked')) {
55 $common_cert.removeAttr('disabled');
56 $common_cert.attr('value', 'on');
57 if ($common_cert.is(':checked')) {
58 $cert_name.attr('disabled', 'disabled');
59 $cert.attr('disabled', 'disabled');
60 $key.attr('disabled', 'disabled');
61 $intermediate.attr('disabled', 'disabled');
62 } else {
63 $cert_name.removeAttr('disabled');
64 $cert.removeAttr('disabled');
65 $key.removeAttr('disabled');
66 $intermediate.removeAttr('disabled');
67 }
68 } else {
69 $common_cert.attr('disabled', 'disabled');
70 $cert_name.attr('disabled', 'disabled');
71 $cert.attr('disabled', 'disabled');
72 $key.attr('disabled', 'disabled');
73 $intermediate.attr('disabled', 'disabled');
74 }
75 }).trigger('change');
76
77 $common_cert.click(function () {
78 if ($common_cert.is(':checked')) {
79 $cert_name.attr('disabled', 'disabled');
80 $cert.attr('disabled', 'disabled');
81 $key.attr('disabled', 'disabled');
82 $intermediate.attr('disabled', 'disabled');
83 } else {
84 $cert_name.removeAttr('disabled');
85 $cert.removeAttr('disabled');
86 $key.removeAttr('disabled');
87 $intermediate.removeAttr('disabled');
88 }
89 }).trigger('change');
90 });
91</script>
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/urls.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/urls.py
deleted file mode 100644
index c586047..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/urls.py
+++ /dev/null
@@ -1,30 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from django.conf.urls import url
16
17from .views import DetailView # noqa
18from .views import IndexView # noqa
19from .views import LaunchLoadBalancerView # noqa
20from .views import UpdateView # noqa
21
22
23INSTANCES = r'^(?P<loadbalancer_id>[^/]+)/%s$'
24
25urlpatterns = [
26 url(r'^$', IndexView.as_view(), name='index'),
27 url(r'^launch$', LaunchLoadBalancerView.as_view(), name='launch'),
28 url(r'^(?P<loadbalancer_id>[^/]+)/$', DetailView.as_view(), name='detail'),
29 url(INSTANCES % 'update', UpdateView.as_view(), name='update'),
30]
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/views.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/views.py
deleted file mode 100644
index 9c943db..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/views.py
+++ /dev/null
@@ -1,146 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from oslo_log import log as logging
16
17from django.core.urlresolvers import reverse
18from django.core.urlresolvers import reverse_lazy
19from django.utils.translation import ugettext_lazy as _
20
21from horizon import exceptions
22from horizon import tables
23from horizon import tabs
24from horizon import workflows
25
26from neutron_lbaas_dashboard import api
27
28from .tables import LoadBalancersTable # noqa
29from .tabs import LoadBalancerDetailTabs # noqa
30from .workflows import LaunchLoadBalancer # noqa
31from .workflows import UpdateLoadBalancer # noqa
32
33
34LOG = logging.getLogger(__name__)
35
36
37class IndexView(tables.DataTableView):
38 table_class = LoadBalancersTable
39 template_name = 'project/loadbalancersv2/index.html'
40
41 def get_data(self):
42 pools = []
43 try:
44 pools = api.lbaasv2.list_loadbalancers(self.request)
45 except Exception:
46 exceptions.handle(self.request,
47 _('Unable to retrieve pools list.'))
48 return pools
49
50
51class LaunchLoadBalancerView(workflows.WorkflowView):
52 workflow_class = LaunchLoadBalancer
53 template_name = "project/loadbalancersv2/launch.html"
54
55 def get_initial(self):
56 initial = super(LaunchLoadBalancerView, self).get_initial()
57 initial['project_id'] = self.request.user.tenant_id
58 initial['user_id'] = self.request.user.id
59 return initial
60
61
62class UpdateView(workflows.WorkflowView):
63 workflow_class = UpdateLoadBalancer
64 template_name = 'project/loadbalancersv2/update.html'
65 success_url = reverse_lazy("horizon:project:loadbalancersv2:index")
66
67 def get_context_data(self, **kwargs):
68 context = super(UpdateView, self).get_context_data(**kwargs)
69 context["loadbalancer_id"] = self.kwargs['loadbalancer_id']
70 return context
71
72 def get_object(self, *args, **kwargs):
73 if not hasattr(self, "_object"):
74 loadbalancer_id = self.kwargs['loadbalancer_id']
75 LOG.info("DEBUGGING - loadbalancer_id=%s" % loadbalancer_id)
76 try:
77 vip = api.lbaasv2.show_loadbalancer(self.request,
78 loadbalancer_id)
79 self._object = vip.readable(self.request)
80 except Exception as e:
81 redirect = reverse("horizon:project:loadbalancersv2:index")
82 msg = _('Unable to retrieve load balancer details. %s')\
83 % e.message
84 exceptions.handle(self.request, msg, redirect=redirect)
85 return self._object
86
87 def get_initial(self):
88 initial = super(UpdateView, self).get_initial()
89
90 initial.update({
91 'loadbalancer_id': self.kwargs['loadbalancer_id'],
92 'address': getattr(self.get_object(), 'address', ''),
93 'name': getattr(self.get_object(), 'name', ''),
94 'description': getattr(self.get_object(), 'description', ''),
95 'lb_method': getattr(self.get_object(), 'lb_method', ''),
96 'monitor': getattr(self.get_object(), 'monitor', ''),
97 'interval': getattr(self.get_object(), 'interval', ''),
98 'timeout': getattr(self.get_object(), 'timeout', ''),
99 'send': getattr(self.get_object(), 'send', ''),
100 'receive': getattr(self.get_object(), 'receive', ''),
101
102 'source_type': getattr(self.get_object(), 'protocol', ''),
103 'http': getattr(self.get_object(), 'port', ''),
104 'https': getattr(self.get_object(), 'port', ''),
105 'instance_port': getattr(self.get_object(), 'instance_port', ''),
106 'selected_members': getattr(self.get_object(), 'members', ''),
107 'cert_name': getattr(self.get_object(), 'cert_name', ''),
108 'cert': getattr(self.get_object(), 'cert', ''),
109 'private_key': getattr(self.get_object(), 'private_key', ''),
110 'chain_cert': getattr(self.get_object(), 'chain_cert', ''),
111 'enabled': getattr(self.get_object(), 'enabled', ''),
112 'use_common_cert': getattr(self.get_object(),
113 'use_common_cert', ''),
114 'port': getattr(self.get_object(), 'port', ''),
115 })
116 return initial
117
118
119class DetailView(tabs.TabView):
120 tab_group_class = LoadBalancerDetailTabs
121 template_name = 'project/loadbalancersv2/detail.html'
122
123 def get_context_data(self, **kwargs):
124 context = super(DetailView, self).get_context_data(**kwargs)
125 context["loadbalancer"] = self.get_data()
126 return context
127
128 def get_data(self):
129 if not hasattr(self, "_loadbalancer"):
130 try:
131 loadbalancer_id = self.kwargs['loadbalancer_id']
132 loadbalancer = api.lbaasv2.show_loadbalancer(self.request,
133 loadbalancer_id)
134 except Exception:
135 redirect = reverse('horizon:project:loadbalancersv2:index')
136 exceptions.handle(self.request,
137 _('Unable to retrieve details for '
138 'loadbalancer "%s".') % loadbalancer_id,
139 redirect=redirect)
140 self._loadbalancer = loadbalancer
141 return self._loadbalancer.readable(self.request)
142
143 def get_tabs(self, request, *args, **kwargs):
144 loadbalancer = self.get_data()
145 return self.tab_group_class(request, loadbalancer=loadbalancer,
146 **kwargs)
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/__init__.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/__init__.py
deleted file mode 100644
index 7c50756..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from . create_lb import * # noqa
16from update_lb import * # noqa
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/create_lb.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/create_lb.py
deleted file mode 100644
index b600258..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/create_lb.py
+++ /dev/null
@@ -1,460 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15
16from django.utils.translation import ugettext_lazy as _
17from horizon import exceptions
18from horizon import forms
19from horizon import workflows
20
21from openstack_dashboard.api import nova
22
23from neutron_lbaas_dashboard import api
24
25__create_new__ = "Create New"
26
27
28class SetLBDetailsAction(workflows.Action):
29
30 address = forms.ChoiceField(label=_("IP"),
31 help_text=_("Select from existing VIP IPs"))
32
33 name = forms.CharField(max_length=80, label=_("Name"),
34 required=True)
35
36 description = forms.CharField(widget=forms.Textarea(attrs={'rows': 2}),
37 label=_(
38 "Load Balancer Description"),
39 required=False,
40 help_text=_("Provide Load Balancer "
41 "Description."))
42
43 all_vips = None
44 is_update = False
45
46 LOAD_BALANCING_CHOICES = (
47 ("RoundRobin", _("Round Robin")),
48 ("LeastConnection", _("Least Connection")),
49 ("LeastSessions", _("Least Sessions"))
50 )
51 lb_method = forms.ChoiceField(label=_("Load Balancing Method"),
52 choices=LOAD_BALANCING_CHOICES)
53
54 PROTOCOL_CHOICES = (
55 ("HTTP", _("HTTP")),
56 ("HTTPS", _("HTTPS")),
57 ("TCP", _("TCP")),
58 ("SSL", _("SSL")),
59 )
60
61 protocol_type = forms.ChoiceField(
62 label=_("LB Protocol"), choices=PROTOCOL_CHOICES)
63
64 port = forms.IntegerField(label=_("LB Port"),
65 required=False,
66 min_value=1,
67 max_value=65535,
68 help_text=_("LB Port on which "
69 "LB is listening."))
70
71 instance_port = forms.IntegerField(label=_("Instance Port"),
72 required=False,
73 min_value=1,
74 max_value=65535,
75 help_text=_("Instance Port on which "
76 "service is running."))
77
78 def __init__(self, request, *args, **kwargs):
79 super(SetLBDetailsAction, self).__init__(request, *args, **kwargs)
80 self.all_vips = []
81 try:
82 # todo - this should be obtained in view via an initial method
83 self.all_vips = api.lbaasv2.list_loadbalancers(request)
84 except Exception:
85 pass
86
87 if len(self.fields['address'].choices) == 0:
88 del self.fields['address']
89
90 class Meta(object):
91 name = _("LB Details")
92 help_text_template = ("project/loadbalancersv2/_launch_lb_help.html")
93
94 def clean(self):
95 cleaned_data = super(SetLBDetailsAction, self).clean()
96
97 lb_method = cleaned_data['lb_method']
98 if not (lb_method == 'RoundRobin'
99 or lb_method == 'LeastConnection'
100 or lb_method == 'LeastSessions'):
101 raise forms.ValidationError(_("Please select an option for "
102 "the load balancing method."))
103
104 if not self.is_update:
105 all_vips = self.all_vips
106 ipPortCombo = []
107 for vip in all_vips:
108 vip = vip.readable()
109 ipPortCombo.append('%s:%s' % (vip.address, vip.port))
110
111 data = self.data
112 if 'address' in data \
113 and data['address'] != 'new' \
114 and data['address'] != '':
115 address = data['address']
116 selected_lb_port = data['port']
117 selected_ip_port_combo = '%s:%s' % (address.split(':')[0],
118 selected_lb_port)
119 if selected_ip_port_combo in ipPortCombo:
120 raise forms.ValidationError(_('Requested IP and port '
121 'combination already '
122 'exists %s ') %
123 selected_ip_port_combo)
124
125 instance_port = cleaned_data.get('instance_port', None)
126 if not instance_port:
127 raise forms.ValidationError(
128 _('Please provide instance port'))
129
130 return cleaned_data
131
132 def populate_address_choices(self, request, context):
133 if self.is_update:
134 return []
135 try:
136 vips = api.lbaasv2.list_loadbalancers(request)
137 if len(vips) == 0:
138 return []
139
140 distict_ips = set()
141 for vip in vips:
142 vip = vip.readable()
143 distict_ips.add(vip.address)
144
145 existing = []
146 for vip in vips:
147 vip = vip.readable()
148 if vip.address in distict_ips:
149 item = ("%s:%s:%s" %
150 (vip.address, vip.name, 443),
151 "%s" % vip.address)
152 existing.append(item)
153 distict_ips.remove(vip.address)
154
155 vip_list = []
156 if len(existing) > 0:
157 vip_list.append(('new', __create_new__))
158 vip_list.append(('Select Existing', existing))
159 return vip_list
160
161 except Exception:
162 exceptions.handle(request,
163 _('Unable to retrieve vips.'))
164 return []
165
166 def get_help_text(self):
167 extra = {}
168 return super(SetLBDetailsAction, self).get_help_text(extra)
169
170
171class SetLBDetails(workflows.Step):
172 action_class = SetLBDetailsAction
173 contributes = ("name", "description", "lb_method", "protocol_type", "port",
174 "source_id", "instance_port", "address", "monitor")
175
176 def contribute(self, data, context):
177 context = super(SetLBDetails, self).contribute(data, context)
178 return context
179
180 template_name = "project/loadbalancersv2/launch_lb.html"
181
182
183class UploadSSLAction(workflows.Action):
184 update_cert = forms.BooleanField(label='Update SSL Certificate',
185 required=False,
186 widget=forms.HiddenInput())
187
188 cert_name = forms.CharField(max_length=80,
189 label=_("Certificate Name"),
190 required=False)
191
192 cert = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}),
193 label=_("Certificate"),
194 required=False,
195 help_text=_("Certificate"))
196
197 private_key = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}),
198 label=_("Private Key"),
199 required=False,
200 help_text=_("Private Key"))
201
202 chain_cert = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}),
203 label=_("Certificate Chain (Optional)"),
204 required=False,
205 help_text=_("Intermediate Chain"
206 " Certificates"))
207
208 def clean(self):
209 cleaned_data = super(UploadSSLAction, self).clean()
210 data = self.data
211 protocol = data.get('source_type')
212 if protocol == 'HTTPS':
213 use_common_cert = data.get('use_common_cert')
214 if not use_common_cert:
215 # check to see if ssl cert is provided
216 cert_name = data.get('cert_name')
217 cert = data.get('cert')
218 private_key = data.get('private_key')
219
220 if (not cert_name) \
221 or (not cert) \
222 or (not private_key):
223 raise forms.ValidationError(
224 _('Please provide all certificate parameters.'))
225 return cleaned_data
226
227 class Meta(object):
228 name = _("SSL Certificate")
229 help_text_template = ("project/loadbalancersv2/_ssl_cert_help.html")
230
231
232class UploadSSLStep(workflows.Step):
233 action_class = UploadSSLAction
234 contributes = ("cert_name", "cert",
235 "private_key", "chain_cert", 'use_common_cert')
236 template_name = "project/loadbalancersv2/ssl_cert.html"
237
238 def contribute(self, data, context):
239 post = self.workflow.request.POST
240 context['cert_name'] = post['cert_name'] if 'cert_name' in post else ''
241 context['cert'] = post['cert'] if 'cert' in post else ''
242 context['private_key'] = post[
243 'private_key'] if 'private_key' in post else ''
244 context['chain_cert'] = post[
245 'chain_cert'] if 'chain_cert' in post else ''
246 context['use_common_cert'] = post[
247 'use_common_cert'] if 'use_common_cert' in post else ''
248 return context
249
250
251class SelectInstancesAction(workflows.MembershipAction):
252 instance_details = {}
253
254 def __init__(self, request, *args, **kwargs):
255 super(SelectInstancesAction, self).__init__(request, *args, **kwargs)
256 err_msg = _('Unable to retrieve members list. '
257 'Please try again later.')
258
259 default_role_field_name = self.get_default_role_field_name()
260 self.fields[default_role_field_name] = forms.CharField(required=False,
261 label='')
262 self.fields[default_role_field_name].initial = 'member'
263
264 role_member_field_name = self.get_member_field_name('member')
265 self.fields[role_member_field_name] = forms.MultipleChoiceField(
266 required=False, label='')
267
268 # Get list of available instances
269 all_instances = []
270 try:
271 all_instances, has_more_data = nova.server_list(request)
272 except Exception:
273 exceptions.handle(request, err_msg)
274
275 available_instances = []
276 for instance in all_instances:
277 # skip shutoff instances
278 # if instance.status == 'SHUTOFF':
279 # continue
280 instance_ip = self.get_ip(instance)
281 # skip instances which has no network
282 if not instance_ip:
283 continue
284 key = instance_ip
285 value = instance.name + ' (' + self.get_ip(instance) + ')'
286 available_instances.append((key, value))
287 self.instance_details[instance_ip] = (instance.name, instance.id)
288
289 self.fields[self.get_member_field_name('member')].\
290 choices = available_instances
291
292 def get_ip(self, instance):
293 ipaddress = None
294 for networks in instance.addresses.itervalues():
295 for ip in networks:
296 # only one IP present
297 ipaddress = ip
298 break
299 if ipaddress is not None:
300 addr = ipaddress["addr"]
301 else:
302 addr = None # '10.10.10.10'
303 return addr
304
305 def clean(self):
306 cleaned_data = super(SelectInstancesAction, self).clean()
307 members = cleaned_data.get(self.get_member_field_name('member'), None)
308 if not members:
309 raise forms.ValidationError(
310 _('Please select at least one member'))
311 return cleaned_data
312
313 class Meta(object):
314 name = _("Instances")
315 slug = "select_instances"
316
317
318class SelectInstancesStep(workflows.UpdateMembersStep):
319 action_class = SelectInstancesAction
320 help_text = _("Please select a list of instances that should handle"
321 " traffic for this target load balancer. All instances "
322 "must reside in the same Project as the target load "
323 "balancer.")
324 available_list_title = _("All Instances")
325 members_list_title = _("Selected Instances")
326 no_available_text = _("No instances found.")
327 no_members_text = _("No members enabled.")
328 show_roles = False
329 contributes = (
330 "wanted_members", "instances_details", "monitor", "instance_port")
331 template_name = "horizon/common/_workflow_step_update_members.html"
332
333 def contribute(self, data, context):
334 request = self.workflow.request
335 if data:
336 context["wanted_members"] = request.POST.getlist(
337 self.get_member_field_name('member'))
338 context["instances_details"] = self.action.instance_details
339 context["monitor"] = request.POST.get("monitor")
340 context["instance_port"] = request.POST.get("instance_port")
341 return context
342
343
344class SelectMonitorAction(workflows.Action):
345 MONITOR_CHOICES = (
346 ("tcp", _("TCP")),
347 ("ping", _("PING")),
348 ("http", _("HTTP")),
349 )
350 monitor = forms.ChoiceField(label=_("Monitor"),
351 choices=MONITOR_CHOICES)
352
353 interval = forms.IntegerField(label=_("Health Check Interval"
354 " (in seconds)"),
355 required=False,
356 min_value=1,
357 max_value=600,
358 help_text=_("Health Check Interval"
359 " (in seconds)"))
360
361 timeout = forms.IntegerField(label=_("Retry count before markdown"),
362 required=False,
363 min_value=1,
364 max_value=100,
365 help_text=_("Number of times health check "
366 "should be attempted before "
367 "marking down a member"))
368
369 send = forms.CharField(widget=forms.Textarea(attrs={'rows': 1}),
370 label=_("Send String"),
371 required=False,
372 help_text=_("Send String"))
373
374 receive = forms.CharField(widget=forms.Textarea(attrs={'rows': 1}),
375 label=_("Receive String"),
376 required=False,
377 help_text=_("Receive String"))
378
379 class Meta(object):
380 name = _("Monitor")
381 help_text_template = ("project/loadbalancersv2/_monitor_help.html")
382
383
384class SelectMonitorStep(workflows.Step):
385 action_class = SelectMonitorAction
386 contributes = ("monitor", "interval", "timeout", "send", "receive")
387 template_name = "project/loadbalancersv2/_monitor_create.html"
388
389 def contribute(self, data, context):
390 post = self.workflow.request.POST
391
392 context['interval'] = post['interval'] if 'interval' in post else ''
393 context['timeout'] = post['timeout'] if 'timeout' in post else ''
394 context['send'] = post['send'] if 'send' in post else ''
395 context['receive'] = post['receive'] if 'receive' in post else ''
396 return context
397
398
399class LaunchLoadBalancer(workflows.Workflow):
400 slug = "launch_loadbalancer"
401 name = _("Launch Load Balancer")
402 finalize_button_name = _("Launch")
403 success_message = _('Launched %(count)s named "%(name)s".')
404 failure_message = _('Unable to launch %(count)s named "%(name)s".')
405 success_url = "horizon:project:loadbalancersv2:index"
406 default_steps = (SetLBDetails,
407 UploadSSLStep,
408 SelectMonitorStep,
409 SelectInstancesStep,
410 )
411 attrs = {'data-help-text': 'LB creation may take a few minutes'}
412
413 def format_status_message(self, message):
414 name = self.context.get('name', 'unknown loadbalancer')
415 count = self.context.get('count', 1)
416 if int(count) > 1:
417 return message % {"count": _("%s loadbalancers") % count,
418 "name": name}
419 else:
420 return message % {"count": _("loadbalancer"), "name": name}
421
422 def handle(self, request, context):
423 try:
424 protocol = context['source_type']
425 address = context['address']
426 if not address\
427 or address == "new":
428 address = ''
429 else:
430 tokens = address.split(':')
431 address = tokens[0]
432
433 api.lbaasv2.\
434 create_loadbalancer_full(request,
435 address=address,
436 name=context['name'],
437 description=context['description'],
438 lb_method=context['lb_method'],
439 monitor=context['monitor'],
440 protocol=protocol,
441 port=context[protocol],
442 instance_port=context['instance_port'], # noqa
443 wanted_members=context['wanted_members'], # noqa
444 instances_details=context['instances_details'], # noqa
445 cert_name=context['cert_name'],
446 cert=context['cert'],
447 private_key=context['private_key'],
448 chain_cert=context['chain_cert'],
449 use_common_cert=True if
450 context['use_common_cert'] == 'on'
451 else False,
452 interval=context['interval'],
453 timeout=context['timeout'],
454 send=context['send'],
455 receive=context['receive'],
456 )
457 return True
458 except Exception as e:
459 exceptions.handle(request, e.message, ignore=False)
460 return False
diff --git a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/update_lb.py b/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/update_lb.py
deleted file mode 100644
index 6d88e4a..0000000
--- a/neutron_lbaas_dashboard/dashboards/project/loadbalancersv2/workflows/update_lb.py
+++ /dev/null
@@ -1,191 +0,0 @@
1# Copyright 2015, eBay Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from django.utils.translation import ugettext as _
16from neutron_lbaas_dashboard import api
17from create_lb import * # noqa
18
19INDEX_URL = "horizon:projects:loadbalancersv2:index"
20
21
22READ_ONLY = {'readonly': 'readonly'}
23
24
25class UpdateLBDetailsAction(SetLBDetailsAction):
26 address = forms.CharField(widget=forms.widgets.Input(attrs=READ_ONLY),
27 label=_('IP'),
28 required=True)
29
30 name = forms.CharField(widget=forms.widgets.Input(attrs=READ_ONLY),
31 label=_('Name'),
32 required=False)
33
34 port = forms.IntegerField(widget=forms.widgets.Input(attrs=READ_ONLY),
35 label=_("LB Port"),
36 required=False,
37 min_value=1,
38 max_value=65535,
39 help_text=_("LB Port on which "
40 "LB is listening."))
41
42 is_update = True
43
44 def __init__(self, request, context, *args, **kwargs):
45 super(UpdateLBDetailsAction, self).__init__(request, context, *args,
46 **kwargs)
47 self.fields['address'].initial = context['address']
48
49 class Meta(object):
50 name = _("LB Details")
51 help_text_template = ("project/loadbalancersv2/"
52 "_launch_lb_help.html")
53
54
55class UpdateLBDetails(SetLBDetails):
56 action_class = UpdateLBDetailsAction
57 template_name = "project/loadbalancersv2/update_lb_step.html"
58
59
60class UpdateSSLAction(UploadSSLAction):
61
62 update_cert = forms.BooleanField(label='Update SSL Certificate',
63 required=False,
64 widget=forms.CheckboxInput())
65
66 # def clean(self):
67 # cleaned_data = super(UploadSSLAction, self).clean()
68 # data = self.data
69 # protocol = data.get('source_type')
70 # if protocol == 'HTTPS':
71 # update_cert = data.get('update_cert')
72 # if update_cert:
73 # use_common_cert = data.get('use_common_cert')
74 # if not use_common_cert:
75 # # check to see if ssl cert is provided
76 # cert_name = data.get('cert_name')
77 # cert = data.get('cert')
78 # private_key = data.get('private_key')
79 #
80 # if (not cert_name) \
81 # or (not cert) \
82 # or (not private_key):
83 # raise forms.ValidationError(
84 # _('Please provide all certificate parameters.'))
85 # return cleaned_data
86
87 class Meta(object):
88 name = _("SSL Certificate")
89 help_text_template = ("project/loadbalancersv2/_ssl_cert_help.html")
90
91
92class UpdateSSLStep(UploadSSLStep):
93 action_class = UpdateSSLAction
94 contributes = ("cert_name", "cert", "private_key",
95 "chain_cert", 'use_common_cert', "update_cert")
96 template_name = "project/loadbalancersv2/update_ssl_cert.html"
97
98 def contribute(self, data, context):
99 post = self.workflow.request.POST
100 context['cert_name'] = post['cert_name'] if 'cert_name' in post else ''
101 context['cert'] = post['cert'] if 'cert' in post else ''
102 context['private_key'] = post[
103 'private_key'] if 'private_key' in post else ''
104 context['chain_cert'] = post[
105 'chain_cert'] if 'chain_cert' in post else ''
106 context['use_common_cert'] = post[
107 'use_common_cert'] if 'use_common_cert' in post else ''
108 context['update_cert'] = post[
109 'update_cert'] if 'update_cert' in post else ''
110 return context
111
112
113class UpdateInstancesAction(SelectInstancesAction):
114
115 def __init__(self, request, *args, **kwargs):
116 super(UpdateInstancesAction, self).__init__(request, *args, **kwargs)
117 err_msg = _('Unable to retrieve members list. '
118 'Please try again later.')
119
120 pre_selectd = []
121 try:
122 pre_selectd = args[0]['selected_members']
123 except Exception:
124 exceptions.handle(request, err_msg)
125 self.fields[self.get_member_field_name('member')].initial = pre_selectd
126
127 class Meta(object):
128 name = _("Instances")
129 slug = "select_instances"
130
131
132class UpdateInstancesStep(SelectInstancesStep):
133 action_class = UpdateInstancesAction
134 depends_on = ("loadbalancer_id",)
135 contributes = ("wanted_members", "selected_members",
136 "loadbalancer_id", "instances_details",
137 "monitor", "instance_port")
138
139
140class UpdateLoadBalancer(LaunchLoadBalancer):
141 slug = "update_loadbalancer"
142 name = _("Edit Load Balancer")
143 finalize_button_name = _("Update")
144 success_message = _('Updated load balancer "%s".')
145 failure_message = _('Unable to modify load balancer "%s".')
146 success_url = "horizon:project:loadbalancersv2:index"
147 default_steps = (UpdateLBDetails,
148 UpdateSSLStep,
149 SelectMonitorStep,
150 UpdateInstancesStep)
151 attrs = {'data-help-text': 'Updating LB may take a few minutes'}
152
153 def format_status_message(self, message):
154 return message % self.context.get('name', 'unknown load balancer')
155
156 def handle(self, request, context):
157
158 try:
159 protocol = context['source_type']
160
161 api.lbui.vip_create(request,
162 update=True,
163 loadbalancer_id=context['loadbalancer_id'],
164 address=context['address'],
165 name=context['name'],
166 description=context['description'],
167 lb_method=context['lb_method'],
168 monitor=context['monitor'],
169 protocol=protocol,
170 port=context['port'],
171 instance_port=context['instance_port'],
172 wanted_members=context['wanted_members'],
173 instances_details=context['instances_details'],
174 cert_name=context['cert_name'],
175 cert=context['cert'],
176 private_key=context['private_key'],
177 chain_cert=context['chain_cert'],
178 use_common_cert=True if context[
179 'use_common_cert'] == 'on' else False,
180 update_cert=True if context[
181 'update_cert'] == 'on' else False,
182 interval=context['interval'],
183 timeout=context['timeout'],
184 send=context['send'],
185 receive=context['receive'],
186 )
187
188 return True
189 except Exception as e:
190 exceptions.handle(request, e.message, ignore=False)
191 return False
diff --git a/neutron_lbaas_dashboard/enabled/_1480_project_loadbalancersv2_panel.py b/neutron_lbaas_dashboard/enabled/_1480_project_loadbalancersv2_panel.py
deleted file mode 100644
index 09e8451..0000000
--- a/neutron_lbaas_dashboard/enabled/_1480_project_loadbalancersv2_panel.py
+++ /dev/null
@@ -1,23 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13# The slug of the panel to be added to HORIZON_CONFIG. Required.
14PANEL = 'loadbalancersv2'
15# The slug of the dashboard the PANEL associated with. Required.
16PANEL_DASHBOARD = 'project'
17# The slug of the panel group the PANEL is associated with.
18PANEL_GROUP = 'network'
19
20# Python panel class of the PANEL to be added.
21ADD_PANEL = (
22 'neutron_lbaas_dashboard.dashboards.project.loadbalancersv2.panel'
23 '.LoadBalancersUI')
diff --git a/neutron_lbaas_dashboard/tests/settings.py b/neutron_lbaas_dashboard/tests/settings.py
index cb50744..602eda9 100644
--- a/neutron_lbaas_dashboard/tests/settings.py
+++ b/neutron_lbaas_dashboard/tests/settings.py
@@ -101,15 +101,15 @@ settings.update_dashboards(dashboard_modules, HORIZON_CONFIG, INSTALLED_APPS)
101HORIZON_IMAGES_ALLOW_UPLOAD = True 101HORIZON_IMAGES_ALLOW_UPLOAD = True
102 102
103AVAILABLE_REGIONS = [ 103AVAILABLE_REGIONS = [
104 ('http://localhost:5000/v2.0', 'local'), 104 ('http://localhost/identity', 'local'),
105 ('http://remote:5000/v2.0', 'remote'), 105 ('http://remote/identity', 'remote'),
106] 106]
107 107
108OPENSTACK_API_VERSIONS = { 108OPENSTACK_API_VERSIONS = {
109 "identity": 3 109 "identity": 3
110} 110}
111 111
112OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v2.0" 112OPENSTACK_KEYSTONE_URL = "http://localhost/identity"
113OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_" 113OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"
114 114
115OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True 115OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True