Remove neutron-lbaas checks and rename "slug"

This patch removes the dependency on neutron-lbaas being enabled in neutron
and it renames the "slug" from ngloadbalancersv2 to load_balancer.  These
changes should allow co-installation of the neutron-lbaas-dashboard with
octavia-dashboard (however, they will both show up as "Load Balancers" in the
menu).

Change-Id: I4b02f67ba10e6339316fd17fcaf522f7339993ca
This commit is contained in:
Michael Johnson 2017-08-24 14:14:02 -07:00
parent 89674dbf29
commit 8eae426c16
34 changed files with 57 additions and 74 deletions

View File

@ -35,7 +35,7 @@ Howto
install on the horizon machine or within horizon's python virtual
environment.
2. Copy ``_1481_project_ng_loadbalancersv2_panel.py`` in
2. Copy ``_1482_project_load_balancer_panel.py`` in
``octavia_dashboard/enabled`` directory
to ``openstack_dashboard/local/enabled``.

View File

@ -1,5 +1,5 @@
OCTAVIA_DASHBOARD_DIR=$DEST/octavia-dashboard
OCTAVIA_DASHBOARD_ENABLE_FILE_NAME=_1481_project_ng_loadbalancersv2_panel.py
OCTAVIA_DASHBOARD_ENABLE_FILE_NAME=_1482_project_load_balancer_panel.py
OCTAVIA_DASHBOARD_ENABLE_FILE_PATH=$OCTAVIA_DASHBOARD_DIR/octavia_dashboard/enabled/$OCTAVIA_DASHBOARD_ENABLE_FILE_NAME

View File

@ -18,27 +18,10 @@ from django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.api import neutron
LOG = logging.getLogger(__name__)
class NGLoadBalancers(horizon.Panel):
name = _("Load Balancers")
slug = 'ngloadbalancersv2'
slug = 'load_balancer'
permissions = ('openstack.services.network',)
def allowed(self, context):
request = context['request']
try:
if not neutron.is_service_enabled(request,
config_name='enable_lb',
ext_name='lbaasv2'):
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 v2 panel will not be "
"displayed")
return False
return super(NGLoadBalancers, self).allowed(context)

View File

@ -14,7 +14,7 @@
from django.conf.urls import url
from octavia_dashboard.dashboards.project.ngloadbalancersv2 import views
from octavia_dashboard.dashboards.project.load_balancer import views
urlpatterns = [

View File

@ -16,5 +16,5 @@ from horizon.views import HorizonTemplateView
class IndexView(HorizonTemplateView):
template_name = 'project/ngloadbalancersv2/index.html'
template_name = 'project/load_balancer/index.html'
page_title = 'Load Balancers'

View File

@ -13,7 +13,7 @@
# limitations under the License.
# The slug of the panel to be added to HORIZON_CONFIG. Required.
PANEL = 'ngloadbalancersv2'
PANEL = 'load_balancer'
# The slug of the dashboard the PANEL is associated with. Required.
PANEL_DASHBOARD = 'project'
# The slug of the panel group the PANEL is associated with.
@ -21,7 +21,7 @@ PANEL_GROUP = 'network'
# Python panel class of the PANEL to be added.
ADD_PANEL = (
'octavia_dashboard.dashboards.project.ngloadbalancersv2.panel'
'octavia_dashboard.dashboards.project.load_balancer.panel'
'.NGLoadBalancers')
ADD_INSTALLED_APPS = ['octavia_dashboard']

View File

@ -80,7 +80,7 @@
function onCreate(response) {
var healthMonitorId = response.data.id;
$location.path('project/ngloadbalancersv2/' + loadbalancerId + '/listeners/' +
$location.path('project/load_balancer/' + loadbalancerId + '/listeners/' +
listenerId + '/pools/' + poolId + '/healthmonitors/' + healthMonitorId);
}

View File

@ -98,7 +98,7 @@
init('loadbalancer1', 'listener1', loadBalancerState.promise).create.allowed({id: 'pool1'});
service.create.perform();
expect($location.path).toHaveBeenCalledWith(
'project/ngloadbalancersv2/loadbalancer1/listeners/listener1/pools/pool1/' +
'project/load_balancer/loadbalancer1/listeners/listener1/pools/pool1/' +
'healthmonitors/healthmonitor1');
});

View File

@ -106,7 +106,7 @@
$route.reload();
} else {
// Success, go back to pool details page
var path = 'project/ngloadbalancersv2/' + loadbalancerId +
var path = 'project/load_balancer/' + loadbalancerId +
'/listeners/' + listenerId +
'/pools/' + poolId;
$location.path(path);

View File

@ -143,7 +143,7 @@
});
it('should return to pool details after delete', function() {
var path = 'project/ngloadbalancersv2/1/listeners/2/pools/3';
var path = 'project/load_balancer/1/listeners/2/pools/3';
spyOn($location, 'path');
spyOn(toast, 'add');
service.perform(monitor);

View File

@ -3,10 +3,10 @@
<div ng-if="!ctrl.loading && !ctrl.error">
<div class="page-header">
<ol class="breadcrumb">
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
<li><a href="project/load_balancer/"><translate>Load Balancers</translate></a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
<li class="active">{$ ::(ctrl.healthmonitor.name || ctrl.healthmonitor.id) $}</li>
<actions allowed="ctrl.actions" type="row" item="ctrl.healthmonitor"
ng-if="ctrl.healthmonitor" class="actions_column pull-right"></actions>

View File

@ -57,7 +57,7 @@
var basePath = $windowProvider.$get().STATIC_URL + 'dashboard/project/lbaasv2/';
$provide.constant('horizon.dashboard.project.lbaasv2.basePath', basePath);
var loadbalancers = '/project/ngloadbalancersv2';
var loadbalancers = '/project/load_balancer';
var listener = loadbalancers + '/:loadbalancerId/listeners/:listenerId';
var pool = listener + '/pools/:poolId';
var member = pool + '/members/:memberId';

View File

@ -105,7 +105,7 @@
});
it('should route URLs', function () {
var loadbalancers = '/project/ngloadbalancersv2';
var loadbalancers = '/project/load_balancer';
var listener = loadbalancers + '/:loadbalancerId/listeners/:listenerId';
var pool = listener + '/pools/:poolId';
var member = pool + '/members/:memberId';

View File

@ -100,7 +100,7 @@
function onCreate(response) {
var id = response.data.id;
$location.path('project/ngloadbalancersv2/' + loadBalancerId + '/listeners/' + id);
$location.path('project/load_balancer/' + loadBalancerId + '/listeners/' + id);
}
}

View File

@ -98,7 +98,7 @@
it('should redirect after create', function() {
spyOn($location, 'path').and.callThrough();
actions[0].service.perform();
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2/1234/listeners/5678');
expect($location.path).toHaveBeenCalledWith('project/load_balancer/1234/listeners/5678');
});
});

View File

@ -115,11 +115,11 @@
} else {
// If the user is on the listeners table then just reload the page, otherwise they
// are on the details page and we return to the table.
var regex = new RegExp('project\/ngloadbalancersv2\/' + loadbalancerId + '(\/)?$');
var regex = new RegExp('project\/load_balancer\/' + loadbalancerId + '(\/)?$');
if (regex.test($location.path())) {
$route.reload();
} else {
$location.path('project/ngloadbalancersv2/' + loadbalancerId);
$location.path('project/load_balancer/' + loadbalancerId);
}
}
}

View File

@ -144,7 +144,7 @@
});
it('should reload table after delete', function() {
path = 'project/ngloadbalancersv2/1';
path = 'project/load_balancer/1';
spyOn($route, 'reload');
service.perform(items);
$scope.$apply();
@ -152,12 +152,12 @@
});
it('should return to table after delete if on detail page', function() {
path = 'project/ngloadbalancersv2/1/listeners/2';
path = 'project/load_balancer/1/listeners/2';
spyOn($location, 'path');
spyOn(toast, 'add');
service.perform(items[0]);
$scope.$apply();
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2/1');
expect($location.path).toHaveBeenCalledWith('project/load_balancer/1');
expect(toast.add).toHaveBeenCalledWith('success', 'Deleted listeners: First.');
});

View File

@ -3,8 +3,8 @@
<div ng-if="!ctrl.loading && !ctrl.error">
<div class="page-header">
<ol class="breadcrumb">
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/load_balancer/"><translate>Load Balancers</translate></a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li class="active">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</li>
<actions allowed="ctrl.actions" type="row" item="ctrl.listener" ng-if="ctrl.listener"
class="actions_column pull-right"></actions>
@ -24,7 +24,7 @@
<dd>{$ ctrl.listener.admin_state_up | yesno $}</dd>
<dt translate>Default Pool ID</dt>
<dd>
<a ng-href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.listener.default_pool_id $}" ng-if="ctrl.listener.default_pool_id">
<a ng-href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.listener.default_pool_id $}" ng-if="ctrl.listener.default_pool_id">
{$ ::ctrl.listener.default_pool_id $}
</a>
<span ng-if="!ctrl.listener.default_pool_id">

View File

@ -68,7 +68,7 @@
duration="200">
</span>
</td>
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/{$ ::table.loadbalancerId $}/listeners/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
<td class="rsp-p1"><a ng-href="project/load_balancer/{$ ::table.loadbalancerId $}/listeners/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
<td class="rsp-p1">{$ ::item.description | noValue $}</td>
<td class="rsp-p1">{$ ::item.protocol$}</td>
<td class="rsp-p1">{$ ::item.protocol_port$}</td>

View File

@ -86,7 +86,7 @@
}
function onCreate(response) {
$location.path('project/ngloadbalancersv2/' + response.data.id);
$location.path('project/load_balancer/' + response.data.id);
}
}

View File

@ -76,7 +76,7 @@
it('should redirect after create', function() {
spyOn($location, 'path').and.callThrough();
actions[0].service.perform();
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2/1');
expect($location.path).toHaveBeenCalledWith('project/load_balancer/1');
});
});

View File

@ -142,10 +142,10 @@
} else {
// If the user is on the load balancers table then just reload the page, otherwise they
// are on the details page and we return to the table.
if (/\/ngloadbalancersv2(\/)?$/.test($location.path())) {
if (/\/load_balancer(\/)?$/.test($location.path())) {
$route.reload();
} else {
$location.path('project/ngloadbalancersv2');
$location.path('project/load_balancer');
}
}
}

View File

@ -156,7 +156,7 @@
});
it('should reload table after delete', function() {
path = 'project/ngloadbalancersv2';
path = 'project/load_balancer';
spyOn($route, 'reload');
service.perform(items);
$scope.$apply();
@ -164,12 +164,12 @@
});
it('should return to table after delete if on detail page', function() {
path = 'project/ngloadbalancersv2/1';
path = 'project/load_balancer/1';
spyOn($location, 'path');
spyOn(toast, 'add');
service.perform(items[0]);
$scope.$apply();
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2');
expect($location.path).toHaveBeenCalledWith('project/load_balancer');
expect(toast.add).toHaveBeenCalledWith('success', 'Deleted load balancers: First.');
});

View File

@ -3,7 +3,7 @@
<div ng-if="!ctrl.loading && !ctrl.error">
<div class="page-header">
<ol class="breadcrumb">
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
<li><a href="project/load_balancer/"><translate>Load Balancers</translate></a></li>
<li class="active">{$ ctrl.loadbalancer.name || ctrl.loadbalancer.id $}</li>
<actions allowed="ctrl.actions" type="row" item="ctrl.loadbalancer"
ng-if="ctrl.loadbalancer" class="actions_column pull-right"></actions>

View File

@ -72,7 +72,7 @@
duration="200">
</span>
</td>
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
<td class="rsp-p1"><a ng-href="project/load_balancer/{$ ::item.id $}">{$ ::(item.name || item.id) $}</a></td>
<td class="rsp-p1">{$ ::item.description | noValue $}</td>
<td class="rsp-p1">{$ ::item.operating_status | decode:table.operatingStatus $}</td>
<td class="rsp-p1">{$ ::item.provisioning_status | decode:table.provisioningStatus $}</td>

View File

@ -3,10 +3,10 @@
<div ng-if="!ctrl.loading && !ctrl.error">
<div class="page-header">
<ol class="breadcrumb">
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
<li><a href="project/load_balancer/"><translate>Load Balancers</translate></a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</a></li>
<li class="active">{$ ::(ctrl.member.name || ctrl.member.id) $}</li>
<actions allowed="ctrl.actions" type="row" item="ctrl.member"
ng-if="ctrl.member" class="actions_column pull-right"></actions>

View File

@ -62,7 +62,7 @@
ng-model="tCtrl.selections[item.id].checked"
hz-select="item">
</td>
<td class="rsp-p1"><a ng-href="project/ngloadbalancersv2/{$ ::table.loadbalancerId $}/listeners/{$ ::table.listenerId $}/pools/{$ ::table.poolId $}/members/{$ ::item.id $}">{$ ::item.id $}</a></td>
<td class="rsp-p1"><a ng-href="project/load_balancer/{$ ::table.loadbalancerId $}/listeners/{$ ::table.listenerId $}/pools/{$ ::table.poolId $}/members/{$ ::item.id $}">{$ ::item.id $}</a></td>
<td class="rsp-p1">{$ ::item.address $}</td>
<td class="rsp-p1">{$ ::item.protocol_port $}</td>
<td class="rsp-p1">{$ ::item.operating_status | decode:table.operatingStatus $}</td>

View File

@ -81,7 +81,7 @@
function onCreate(response) {
var poolId = response.data.id;
$location.path('project/ngloadbalancersv2/' + loadbalancerId + '/listeners/' +
$location.path('project/load_balancer/' + loadbalancerId + '/listeners/' +
listenerId + '/pools/' + poolId);
}

View File

@ -104,7 +104,7 @@
init('1234', defer.promise).create.allowed({id: '5678'});
createPoolService.create.perform();
expect($location.path).toHaveBeenCalledWith(
'project/ngloadbalancersv2/1234/listeners/5678/pools/9012');
'project/load_balancer/1234/listeners/5678/pools/9012');
});
});

View File

@ -103,7 +103,7 @@
$route.reload();
} else {
// Success, go back to listener details page
var path = 'project/ngloadbalancersv2/' + loadbalancerId + '/listeners/' + listenerId;
var path = 'project/load_balancer/' + loadbalancerId + '/listeners/' + listenerId;
$location.path(path);
}
}

View File

@ -146,7 +146,7 @@
spyOn(toast, 'add');
service.perform(pool);
$scope.$apply();
expect($location.path).toHaveBeenCalledWith('project/ngloadbalancersv2/1/listeners/2');
expect($location.path).toHaveBeenCalledWith('project/load_balancer/1/listeners/2');
expect(toast.add).toHaveBeenCalledWith('success', 'Deleted pool: Pool1.');
});

View File

@ -3,9 +3,9 @@
<div ng-if="!ctrl.loading && !ctrl.error">
<div class="page-header">
<ol class="breadcrumb">
<li><a href="project/ngloadbalancersv2/"><translate>Load Balancers</translate></a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
<li><a href="project/load_balancer/"><translate>Load Balancers</translate></a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}">{$ ::(ctrl.loadbalancer.name || ctrl.loadbalancer.id) $}</a></li>
<li><a href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}">{$ ::(ctrl.listener.name || ctrl.listener.id) $}</a></li>
<li class="active">{$ ::(ctrl.pool.name || ctrl.pool.id) $}</li>
<actions allowed="ctrl.actions" type="row" item="ctrl.pool"
ng-if="ctrl.pool" class="actions_column pull-right"></actions>
@ -27,7 +27,7 @@
<dd>{$ ctrl.pool.admin_state_up | yesno $}</dd>
<dt translate>Health Monitor ID</dt>
<dd>
<a ng-href="project/ngloadbalancersv2/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}/healthmonitors/{$ ::ctrl.pool.healthmonitor_id $}" ng-if="ctrl.pool.healthmonitor_id">
<a ng-href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}/healthmonitors/{$ ::ctrl.pool.healthmonitor_id $}" ng-if="ctrl.pool.healthmonitor_id">
{$ ::ctrl.pool.healthmonitor_id $}
</a>
<span ng-if="!ctrl.pool.healthmonitor_id">