Commit 89674dbf authored by Michael Johnson's avatar Michael Johnson

Remove old unused code.

The octavia-dashboard repo had legacy code that is not used in the current
version of the dashboard.  This patch removes that code.

Change-Id: Icf410babf285e2b5c55dd717f18a27b7cdc3eba3
parent d77592cd
[run]
branch = True
source = neutron_lbaas_dashboard
omit = neutron_lbaas_dashboard/openstack/*
source = octavia_dashboard
[report]
ignore_errors = True
This diff is collapsed.
# Copyright 2015, eBay Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class LBaaSException(Exception):
"""The base exception class for all exceptions this library raises.
"""
def __init__(self, code, message=None, details=None, request_id=None,
url=None, method=None):
self.code = code
self.message = message or self.__class__.message
self.details = details
self.request_id = request_id
self.url = url
self.method = method
def __str__(self):
formatted_string = "%s (HTTP %s)" % (self.message, self.code)
if self.request_id:
formatted_string += " (Request-ID: %s)" % self.request_id
return formatted_string
# Copyright 2015, eBay Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.dashboards.project import dashboard
class LoadBalancersUI(horizon.Panel):
name = _("Load Balancers V2")
slug = 'loadbalancersv2'
permissions = ('openstack.services.network',)
def allowed(self, context):
# todo temporarily enabling panel for any user
# request = context['request']
# if not request.user.has_perms(self.permissions):
# return False
# try:
# if not neutron.is_service_enabled(request,
# config_name='enable_lb',
# ext_name='lbaas'):
# return False
# except Exception:
# LOG.error("Call to list enabled services failed. This is likely "
# "due to a problem communicating with the Neutron "
# "endpoint. Load Balancers panel will not be displayed")
# return False
# if not super(LoadBalancer, self).allowed(context):
# return False
return True
dashboard.Project.register(LoadBalancersUI)
# Copyright 2015, eBay Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import re
from django.core import urlresolvers
from django.template.defaultfilters import linebreaksbr
from django.utils.http import urlencode
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from octavia_dashboard import api
class TerminateLoadBalancer(tables.BatchAction):
name = "terminate"
action_present = _("Terminate")
action_past = _("Scheduled termination of")
data_type_singular = _("Load Balancer")
data_type_plural = _("Load Balancers")
classes = ('btn-danger', 'btn-terminate')
def allowed(self, request, loadbalancer=None):
return True
def action(self, request, obj_id):
api.lbaasv2.vip_delete(request, obj_id)
class EnableLoadBalancer(tables.BatchAction):
name = "enable"
action_present = _("Enable")
action_past = _("Enabled LB")
data_type_singular = _("Load Balancer")
data_type_plural = _("Load Balancers")
classes = ('btn-enable', "btn-action-required")
action_failure = "error enable"
def allowed(self, request, loadbalancer=None):
if loadbalancer.admin_state_up:
return False
return True
def action(self, request, obj_id):
api.lbaasv2.vip_set_status(request, obj_id, True)
class DisableLoadBalancer(tables.BatchAction):
name = "disable"
action_present = _("Disable")
action_past = _("Disabled LB")
data_type_singular = _("Load Balancer")
data_type_plural = _("Load Balancers")
classes = ("btn-confirm", 'btn-disable',)
action_failure = "error disable"
def allowed(self, request, loadbalancer=None):
if loadbalancer.admin_state_up:
return True
return False
def action(self, request, obj_id):
api.lbaasv2.vip_set_status(request, obj_id, False)
class LaunchLink(tables.LinkAction):
name = "launch"
verbose_name = _("Launch Load Balancer")
url = "horizon:project:loadbalancersv2:launch"
classes = ("btn-launch", "ajax-modal")
def allowed(self, request, datum):
return True
class EditLoadBalancer(tables.LinkAction):
name = "edit"
verbose_name = _("Edit Load Balancer")
url = "horizon:project:loadbalancersv2:update"
classes = ("ajax-modal", "btn-edit")
def get_link_url(self, project):
return self._get_link_url(project, 'loadbalancer_info')
def _get_link_url(self, project, step_slug):
base_url = urlresolvers.reverse(self.url, args=[project.id])
param = urlencode({"step": step_slug})
return "?".join([base_url, param])
def allowed(self, request, loadbalancer):
# return not is_deleting(loadbalancer) when async is implemented
return True
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, loadbalancer_id):
loadbalancer = api.lbaasv2.vip_update(request, loadbalancer_id)
return loadbalancer
def convert_title(value):
return re.sub("([A-Z])", " \g<0>", value)
def convert_camel(value):
if not value:
return value
if value.isupper() or value.islower():
return value.title()
else:
value = value.replace(' ', '')
return re.sub("([A-Z])", " \g<0>", value)
def upper_case(value):
return value.upper()
def convert_status(value):
return "Enabled" if value else "Disabled"
def get_lb_method(value):
return value.pool['lb_algorithm']
def get_protocol(value):
return value.listener['protocol']
def get_monitor(value):
return value['pool']['monitors']['type']
def get_lb(instance):
if hasattr(instance, "vip_address"):
return "%s:%s" % (instance.vip_address,
instance.listener['protocol_port'])
return _("Not available")
class LoadBalancersTable(tables.DataTable):
vip = tables.Column(get_lb,
link=("horizon:project:loadbalancersv2:detail"),
verbose_name=_("Load Balancer"))
name = tables.Column("name",
link=("horizon:project:loadbalancersv2:detail"),
verbose_name=_("Name"))
lb_method = tables.Column(get_lb_method,
filters=(upper_case,),
verbose_name=_("Method"))
protocol = tables.Column(get_protocol,
filters=(upper_case,),
verbose_name=_("Protocol"))
monitor = tables.Column(get_monitor,
filters=(upper_case,),
verbose_name=_("Monitor"))
status = tables.Column("provisioning_status",
filters=(convert_camel, linebreaksbr),
verbose_name=_("Provisioning Status"))
operating_status = tables.Column("operating_status",
filters=(convert_camel, linebreaksbr),
verbose_name=_("Operating Status"))
enabled = tables.Column("admin_state_up",
filters=(convert_status,),
verbose_name=_("Admin Status"))
class Meta(object):
name = "loadbalancersv2"
verbose_name = _("Load Balancers")
row_class = UpdateRow
table_actions = (LaunchLink, TerminateLoadBalancer)
row_actions = (EditLoadBalancer, TerminateLoadBalancer,
EnableLoadBalancer, DisableLoadBalancer)
# Copyright 2015, eBay Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tabs
class OverviewTab(tabs.Tab):
name = _("Overview")
slug = "overview"
template_name = ("project/loadbalancersv2/"
"_detail_overview.html")
def get_context_data(self, request):
return {"loadbalancer": self.tab_group.kwargs['loadbalancer']}
class LoadBalancerDetailTabs(tabs.TabGroup):
slug = "loadbalancer_details"
tabs = (OverviewTab, )
sticky = True
{% load i18n sizeformat %}
<h3>{% trans "Load Balancer Overview" %}</h3>
<div class="status row-fluid detail">
<h4>{% trans "Info" %}</h4>
<hr class="header_rule">
<dl>
<dt>{% trans "Name" %}</dt>
<dd>{{ loadbalancer.name }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ loadbalancer.id }}</dd>
<dt>{% trans "Address" %}</dt>
<dd>{{ loadbalancer.address }}</dd>
<dt>{% trans "Port" %}</dt>
<dd>{{ loadbalancer.port }}</dd>
<dt>{% trans "Protocol" %}</dt>
<dd>{{ loadbalancer.protocol }}</dd>
<dt>{% trans "Load Balancing Method" %}</dt>
<dd>{{ loadbalancer.lb_method }}</dd>
<dt>{% trans "Monitor" %}</dt>
<dd>{{ loadbalancer.pool.monitors.type }}</dd>
<dt>{% trans "Operating Status" %}</dt>
<dd>{{ loadbalancer.operating_status }}</dd>
<dt>{% trans "Provisioning Status" %}</dt>
<dd>{{ loadbalancer.provisioning_status }}</dd>
<dt>{% trans "Description" %}</dt>
<dd> - {{ loadbalancer.description }}</dd>
<dt>{% trans "Admin Status" %}</dt>
<dd>{{ loadbalancer.enabled|title }}</dd>
{# <dt>{% trans "Load Balancing Method" %}</dt>#}
{# <dd>{{ loadbalancer.pool.lb_method }}</dd>#}
{# <dt>{% trans "Monitor" %}</dt>#}
{# <dd>{{ loadbalancer.pool.monitor }}</dd>#}
<dt>{% trans "Certificate" %}</dt>
<dd> - {{ loadbalancer.cert_name }}</dd>
</dl>
</div>
<div class="members row-fluid detail">
<h4>{% trans "Members" %}</h4>
<hr class="header_rule">
<dl>
{% for group in loadbalancer.pool.members.members %}
<dt>{{ group.id }}</dt>
<dd> <b>IP:</b> {{ group.address }}</dd>
<dd> <b>Port:</b> {{ group.protocol_port }}</dd>
{% endfor %}
</dl>
</div>
{% load i18n horizon %}
<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>
<p>{% blocktrans %}<b>Name</b>: Enter a unique name for your load balancer (e.g., my-demo-lb).{% endblocktrans %}</p>
<p>{% blocktrans %}<b>Description</b>: Provide a friendly description for your records.{% endblocktrans %}</p>
<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>
<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>
<p>{% blocktrans %}<b>Load Balancer Port</b>: This is automatically assigned based on the Load Balancer Protocol selection.{% endblocktrans %}</p>
<p>{% blocktrans %}<b>Instance Port</b>: The acceptable instance ports for both HTTPS/SSL and HTTP/TCP connections are 0-65535.{% endblocktrans %}</p>
{% load i18n %}
{% block main %}
{#<table class="table-fixed" id="monitorContainer">#}
{# <tbody>#}
{# <tr>#}
{# <td class="actions">#}
{# <div id="monitorId">#}
{# {% include "horizon/common/_form_fields.html" %}#}
{# </div>#}
{# </td>#}
{# <td class="help_text">#}
{# {{ step.get_help_text }}#}
{# </td>#}
{# </tr>#}
{# </tbody>#}
{#</table>#}
<div class="col-sm-6">
{% include "horizon/common/_form_fields.html" %}
</div>
<div class="col-sm-6">
{{ step.get_help_text }}
</div>
{% endblock %}
<script>
horizon.modals.addModalInitFunction(function (modal) {
var $monitor_type = $('#id_monitor');
var $interval = $('#id_interval');
var $timeout = $('#id_timeout');
var $send = $('#id_send');
var $receive = $('#id_receive');
$monitor_type.change(function () {
if ($monitor_type.val() == 'http-ecv') {
$interval.closest(".control-group").show();
$timeout.closest(".control-group").show();
$send.closest(".control-group").show();
$receive.closest(".control-group").show();
} else {
$interval.closest(".control-group").hide();
$timeout.closest(".control-group").hide();
$send.closest(".control-group").hide();
$receive.closest(".control-group").hide();
}
}).trigger('change');
});
</script>
{% load i18n %}
<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>
<p>{% blocktrans %}The following health check options are currently supported:{% endblocktrans %}</p>
<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>
<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>
{% load i18n %}
<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>
<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>
<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>
<p>{% blocktrans %}<b>Certificate Name</b> – Supply a certificate name (i.e. my_server_cert).{% endblocktrans %}</p>
<p>{% blocktrans %}<b>Private Key</b> - Copy and paste the contents of the private key file in the Private Key field.{% endblocktrans %}</p>
<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>
{% extends 'base.html' %}
{% load i18n sizeformat %}
{% block title %}{% trans "Load Balancer Detail" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title="Load Balancer Detail: "|add:loadbalancer.name %}
{% endblock page_header %}
{% block main %}
<div class="row-fluid">
<div class="span12">
{{ tab_group.render }}
</div>
</div>
{% endblock %}
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Load Balancers" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Load Balancers") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
{% endblock %}
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Launch Load Balancer" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Launch Load Balancer") %}
{% endblock page_header %}
{% block main %}
{% include 'horizon/common/_workflow.html' %}
{% endblock %}
{% load i18n %}
{% block main %}
{#<table class="table-fixed" id="sslCertContainer">#}
{# <tbody>#}
{# <tr>#}
{# <td class="actions">#}
{# <div class="row">#}
{# <div class="col-sm-12">#}
{# {% include "horizon/common/_form_fields.html" %}#}
{# </div>#}
{# </div>#}
{# </td>#}
{# <td class="help_text">#}
{# {{ step.get_help_text }}#}
{# </td>#}
{# </tr>#}
{# </tbody>#}
{#</table>#}
<div class="col-sm-6">
{% include "horizon/common/_form_fields.html" %}
</div>
<div class="col-sm-6">
{{ step.get_help_text }}
</div>
{% endblock %}
<script>
horizon.modals.addModalInitFunction(function (modal) {
var $address = $('#id_address');
var $name = $('#id_name');
var $name_label = $('label[for="id_name"]');
var $protocol_type = $('#id_protocol_type');
$address.change(function () {
var options_all = {"HTTP": "HTTP", "HTTPS": "HTTPS", "TCP": "TCP", "SSL": "SSL"};
setOptions($protocol_type, options_all);
if ($address.val() == 'new') {
$name.removeAttr('disabled');
$name.removeAttr('readonly');
$name.attr('value', '');
} else {
var key_token = $address.val().split(':');
$name.attr('value', key_token[1]);
$name.attr('readonly', 'true');
}
}).trigger('change');
function setOptions($protocol_type, newOptions) {
$("#id_" + $protocol_type.val()).closest(".control-group").hide();
$protocol_type.empty();
$.each(newOptions, function (key, value) {
$protocol_type.append($("<option></option>")
.attr("value", value).text(key));
});
refresh($protocol_type);
};
function refresh($protocol_type) {
var $this = $protocol_type,
base_type = $this.val();
$this.find("option").each(function () {
if (this.value != base_type) {
$("#id_" + this.value).closest(".control-group").hide();
} else {
$("#id_" + this.value).closest(".control-group").show();
}
});
};
$protocol_type.on('change', function(evt){
refresh($(this));
//prevent the default handler in horizon.instances.js
evt.stopPropagation();
}).trigger('change');
});
</script>
{% load i18n %}
<noscript><h3>{{ step }}</h3></noscript>
<style>
#target input{
width: auto;
}
</style>
<table id='target' class="table table-bordered table-striped datatable">
<thead><tr><th>From</th><th>protocol</th><th>To</th><th>Action</th></tr></thead>
<tr>
<td>
<input type='text' class='numbers' name='from' />
</td>
<td>
<select name='protocol'>
<option value='http'>HTTP</option>
<option value='https'>HTTPS</option>
<option value='tcp'>TCP</option>
</select>
</td>
<td>
<input type='text' class='numbers' name='to' />
</td>
<td>
<a class='btn btn-small' name='add'>+</a>
</td>
</tr>
</table>
<script>
function encode_lb_rule(from, protocol, to){
return from + ':' + protocol + ',' + to;
}
function generate_lb_rule(from, protocol, to){
var html = "<tr><td>" + from + "</td>" +
"<td>" + protocol + "</td>" +
"<td>" + to + "</td>" +
"<td><a class='btn btn-small btn-danger'>-</a>";
html = $(html);
html.on('click', 'a', function(){
$('option[value="' + encode_lb_rule(from, protocol, to) + '"]').remove();
$(this).closest('tr').remove();
});
return html;
}
horizon.modals.addModalInitFunction(function (modal) {
$("a[name='add']").on('click', function(){
var from = $("input[name='from']").val();
var protocol = $("select[name='protocol']").val();
var to = $("input[name='to']").val();
var encoded = encode_lb_rule(from, protocol, to);
if(from && to && $('option[value="'+encoded+'"]').length == 0){
$('#id_network').append($("<option></option>")
.attr("value", encoded)
.attr("selected", "selected")
.text(encoded));
generate_lb_rule(from, protocol, to).insertBefore($('#target tr:last'));
// clean up
$("input[name='from']").val('');
$("input[name='to']").val('');
}
});
$('input.numbers').keyup(function () {
this.value = this.value.replace(/[^0-9\.]/g,'');
});
});
</script>
<div class="hidden">
{% include "horizon/common/_form_fields.html" %}
</div>