Commit d49b14ac authored by Michael Johnson's avatar Michael Johnson Committed by Jacky Hu

Convert octavia-dashboard to use Octavia v2 API

This patch coverts the Octavia dasboard over to use the openstack SDK
and the new Octavia v2 API.

It's octavia-dashboard, now with less neutron-lbaas (ok, no neutron-lbaas)

Change-Id: I71fd67128210c3ff365838414920a1de1883ebd2
parent ec394cd7
This diff is collapsed.
......@@ -701,8 +701,8 @@ msgstr ""
msgid "Subnet ID"
msgstr "Subnetz-ID"
msgid "Tenant ID"
msgstr "Mandanten-ID"
msgid "Project ID"
msgstr "Projekt-ID"
msgid ""
"The Available Instances table contains existing compute instances that can "
......
......@@ -696,8 +696,8 @@ msgstr ""
msgid "Subnet ID"
msgstr "Subnet ID (ID subnet)"
msgid "Tenant ID"
msgstr "Tenant ID"
msgid "Project ID"
msgstr "Project ID"
msgid ""
"The Available Instances table contains existing compute instances that can "
......
......@@ -449,8 +449,8 @@ msgstr "サブネット<span class=\"hz-icon-required fa fa-asterisk\"></span>"
msgid "Subnet ID"
msgstr "サブネット ID"
msgid "Tenant ID"
msgstr "テナント ID"
msgid "Project ID"
msgstr "プロジェクト ID"
msgid "The URL path is not valid."
msgstr "URLは有効ではありません。"
......
......@@ -628,8 +628,8 @@ msgstr ""
msgid "Subnet ID"
msgstr "ID подсети"
msgid "Tenant ID"
msgstr "ИД арендатора"
msgid "Project ID"
msgstr "ID проекта"
msgid "The IP address is not valid."
msgstr "IP адрес не действителен."
......
......@@ -672,8 +672,8 @@ msgstr ""
msgid "Subnet ID"
msgstr "子网ID"
msgid "Tenant ID"
msgstr "租户ID"
msgid "Project ID"
msgstr "项目ID"
msgid ""
"The Available Instances table contains existing compute instances that can "
......
......@@ -41,7 +41,6 @@
deleteLoadBalancer: deleteLoadBalancer,
createLoadBalancer: createLoadBalancer,
editLoadBalancer: editLoadBalancer,
getLoadBalancerStatusTree: getLoadBalancerStatusTree,
getListeners: getListeners,
getListener: getListener,
createListener: createListener,
......@@ -148,21 +147,6 @@
});
}
/**
* @name horizon.app.core.openstack-service-api.lbaasv2.getLoadBalancerStatusTree
* @description
* Get the status tree for a load balancer
* @param {string} id
* Specifies the id of the load balancer to request the status tree for.
*/
function getLoadBalancerStatusTree(id) {
return apiService.get('/api/lbaas/loadbalancers/' + id + '/statuses/')
.error(function () {
toastService.add('error', gettext('Unable to retrieve load balancer status tree.'));
});
}
// Listeners
/**
......
......@@ -59,13 +59,6 @@
error: 'Unable to delete load balancer.',
testInput: [ '1234' ]
},
{
func: 'getLoadBalancerStatusTree',
method: 'get',
path: '/api/lbaas/loadbalancers/1234/statuses/',
error: 'Unable to retrieve load balancer status tree.',
testInput: [ '1234' ]
},
{
func: 'getListeners',
method: 'get',
......
......@@ -73,7 +73,7 @@
poolId = pool.id;
return $q.all([
statePromise,
qExtensions.booleanAsPromise(!pool.healthmonitor_id),
qExtensions.booleanAsPromise(!pool.health_monitor_id),
policy.ifAllowed({ rules: [['neutron', 'create_health_monitor']] })
]);
}
......
......@@ -89,7 +89,7 @@
it('should not allow creating a health monitor if one already exists', function() {
loadBalancerState.resolve();
init('active', '1', loadBalancerState.promise);
expect(allowed({ healthmonitor_id: '1234' })).toBe(false);
expect(allowed({ health_monitor_id: '1234' })).toBe(false);
});
it('should redirect after create', function() {
......
......@@ -33,8 +33,8 @@
<dd>{$ ctrl.healthmonitor.admin_state_up | yesno $}</dd>
<dt translate>Monitor ID</dt>
<dd>{$ ::ctrl.healthmonitor.id $}</dd>
<dt translate>Tenant ID</dt>
<dd>{$ ::ctrl.healthmonitor.tenant_id $}</dd>
<dt translate>Project ID</dt>
<dd>{$ ::ctrl.healthmonitor.project_id $}</dd>
</dl>
</div>
</div>
......
......@@ -33,8 +33,8 @@
</dd>
<dt translate>Listener ID</dt>
<dd>{$ ::ctrl.listener.id $}</dd>
<dt translate>Tenant ID</dt>
<dd>{$ ::ctrl.listener.tenant_id $}</dd>
<dt translate>Project ID</dt>
<dd>{$ ::ctrl.listener.project_id $}</dd>
</dl>
</div>
</div>
......
......@@ -25,8 +25,7 @@
'horizon.dashboard.project.lbaasv2.members.actions.rowActions',
'$routeParams',
'$q',
'horizon.dashboard.project.lbaasv2.loadbalancers.service',
'horizon.dashboard.project.lbaasv2.members.service'
'horizon.dashboard.project.lbaasv2.loadbalancers.service'
];
/**
......@@ -41,12 +40,11 @@
* @param $routeParams The angular $routeParams service.
* @param $q The angular service for promises.
* @param loadBalancersService The LBaaS v2 load balancers service.
* @param membersService The LBaaS v2 members service.
* @returns undefined
*/
function MemberDetailController(
api, rowActions, $routeParams, $q, loadBalancersService, membersService
api, rowActions, $routeParams, $q, loadBalancersService
) {
var ctrl = this;
......@@ -85,15 +83,6 @@
function success(property) {
return angular.bind(null, function setProp(property, response) {
ctrl[property] = response.data;
if (property === 'member') {
membersService.associateMemberStatuses(
ctrl.loadbalancerId,
ctrl.listenerId,
ctrl.poolId,
[ctrl.member]);
}
}, property);
}
......
......@@ -17,7 +17,7 @@
'use strict';
describe('LBaaS v2 Member Detail Controller', function() {
var $controller, lbaasv2API, membersService, apiFail, qAllFail, actions;
var $controller, lbaasv2API, apiFail, qAllFail, actions;
function fakePromise(data, reject) {
return {
......@@ -81,13 +81,11 @@
beforeEach(inject(function($injector) {
lbaasv2API = $injector.get('horizon.app.core.openstack-service-api.lbaasv2');
actions = $injector.get('horizon.dashboard.project.lbaasv2.members.actions.rowActions');
membersService = $injector.get('horizon.dashboard.project.lbaasv2.members.service');
spyOn(lbaasv2API, 'getMember').and.callFake(fakeAPI);
spyOn(lbaasv2API, 'getPool').and.callFake(fakeAPI);
spyOn(lbaasv2API, 'getListener').and.callFake(fakeAPI);
spyOn(lbaasv2API, 'getLoadBalancer').and.callFake(loadbalancerAPI);
spyOn(actions, 'init').and.callThrough();
spyOn(membersService, 'associateMemberStatuses');
$controller = $injector.get('$controller');
}));
......@@ -106,12 +104,6 @@
expect(actions.init).toHaveBeenCalledWith('loadbalancerId', 'poolId');
});
it('should invoke the "associateMemberStatuses" method', function() {
var ctrl = createController();
expect(membersService.associateMemberStatuses).toHaveBeenCalledWith(
ctrl.loadbalancerId, ctrl.listenerId, ctrl.poolId, [ctrl.member]);
});
it('should throw error on API fail', function() {
apiFail = true;
var init = function() {
......
......@@ -29,8 +29,8 @@
<dd>{$ ctrl.member.admin_state_up | yesno $}</dd>
<dt translate>Member ID</dt>
<dd>{$ ::ctrl.member.id $}</dd>
<dt translate>Tenant ID</dt>
<dd>{$ ::ctrl.member.tenant_id $}</dd>
<dt translate>Project ID</dt>
<dd>{$ ::ctrl.member.project_id $}</dd>
</dl>
</div>
</div>
......
/*
* Copyright 2016 IBM Corp.
*
* 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.
*/
(function () {
'use strict';
angular
.module('horizon.dashboard.project.lbaasv2.members')
.factory('horizon.dashboard.project.lbaasv2.members.service', membersService);
membersService.$inject = [
'horizon.app.core.openstack-service-api.lbaasv2'
];
/**
* @ngdoc service
* @name horizon.dashboard.project.lbaasv2.members.service
* @description General service for LBaaS v2 members.
* @param api The LBaaS V2 service API.
* @returns The members service.
*/
function membersService(api) {
var service = {
associateMemberStatuses: associateMemberStatuses
};
return service;
////////////
/**
* @ngdoc method
* @name horizon.dashboard.project.lbaasv2.members.service.associateMemberStatuses
* @description Associates the list of specified members with their corresponding statuses
* that are retrieved from the load balancer status tree.
* @param loadBalancerId The load balancer ID.
* @param listenerId The listener ID that the members belong to.
* @param poolId The pool ID that the members belong to.
* @param members The list of members to associate with their corresponding health statuses.
* @returns None
*/
function associateMemberStatuses(loadBalancerId, listenerId, poolId, members) {
api.getLoadBalancerStatusTree(loadBalancerId).then(function(response) {
// Collect the member status data for all specified members
var memberStatusData = [];
var listeners = response.data.statuses.loadbalancer.listeners;
for (var listenerIndex = 0; listenerIndex < listeners.length; listenerIndex++) {
var listener = listeners[listenerIndex];
if (listener.id === listenerId) {
var pools = listener.pools;
for (var poolIndex = 0; poolIndex < pools.length; poolIndex++) {
var pool = pools[poolIndex];
if (pool.id === poolId) {
memberStatusData = pool.members;
break;
}
}
break;
}
}
// Attach the status properties to each member object
members.forEach(mapStatusToMember);
function mapStatusToMember(member) {
for (var memberIndex = 0; memberIndex < memberStatusData.length; memberIndex++) {
var memberWithStatuses = memberStatusData[memberIndex];
if (memberWithStatuses.id === member.id) {
member.operating_status = memberWithStatuses.operating_status;
member.provisioning_status = memberWithStatuses.provisioning_status;
break;
}
}
}
});
}
}
}());
/*
* Copyright 2016 IBM Corp.
*
* 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.
*/
(function() {
'use strict';
describe('LBaaS v2 Members Service', function() {
var service, $q, scope;
beforeEach(module('horizon.framework.widgets.toast'));
beforeEach(module('horizon.framework.conf'));
beforeEach(module('horizon.framework.util'));
beforeEach(module('horizon.app.core.openstack-service-api'));
beforeEach(module('horizon.dashboard.project.lbaasv2'));
beforeEach(module(function($provide) {
$provide.value('horizon.app.core.openstack-service-api.lbaasv2', {
getLoadBalancerStatusTree: function() {
var deferred = $q.defer();
var response = {
data: {
statuses: {
loadbalancer: {
id: 'loadbalancer1',
listeners: [
{
id: 'listener0',
pools: []
},
{
id: 'listener1',
pools: [
{
id: 'pool0',
members: []
},
{
id: 'pool1',
members: [
{
id: 'member1',
operating_status: 'ONLINE',
provisioning_status: 'ACTIVE'
},
{
id: 'member2',
operating_status: 'OFFLINE',
provisioning_status: 'INACTIVE'
}
]
}
]
}
]
}
}
}
};
deferred.resolve(response);
return deferred.promise;
}
});
}));
beforeEach(inject(function ($injector) {
service = $injector.get('horizon.dashboard.project.lbaasv2.members.service');
$q = $injector.get('$q');
scope = $injector.get('$rootScope').$new();
}));
it('should define service attributes', function() {
expect(service.associateMemberStatuses).toBeDefined();
});
it('should correctly associate member health statuses', function() {
var members = [
{ id: 'member1' },
{ id: 'member2' }
];
service.associateMemberStatuses('loadbalancer1', 'listener1', 'pool1', members);
scope.$apply();
expect(members.length).toBe(2);
expect(members[0].operating_status).toBe('ONLINE');
expect(members[0].provisioning_status).toBe('ACTIVE');
expect(members[1].operating_status).toBe('OFFLINE');
expect(members[1].provisioning_status).toBe('INACTIVE');
});
});
})();
......@@ -25,8 +25,7 @@
'horizon.dashboard.project.lbaasv2.members.actions.rowActions',
'horizon.dashboard.project.lbaasv2.members.actions.batchActions',
'$routeParams',
'horizon.dashboard.project.lbaasv2.loadbalancers.service',
'horizon.dashboard.project.lbaasv2.members.service'
'horizon.dashboard.project.lbaasv2.loadbalancers.service'
];
/**
......@@ -41,12 +40,11 @@
* @param batchActions The members batch actions service.
* @param $routeParams The angular $routeParams service.
* @param loadBalancersService The LBaaS v2 load balancers service.
* @param membersService The LBaaS v2 members service.
* @returns undefined
*/
function MembersTableController(
api, rowActions, batchActions, $routeParams, loadBalancersService, membersService
api, rowActions, batchActions, $routeParams, loadBalancersService
) {
var ctrl = this;
ctrl.items = [];
......@@ -76,11 +74,6 @@
function success(response) {
ctrl.src = response.data.items;
ctrl.loading = false;
membersService.associateMemberStatuses(
ctrl.loadbalancerId,
ctrl.listenerId,
ctrl.poolId,
ctrl.src);
}
function fail(/*response*/) {
......
......@@ -18,7 +18,7 @@
'use strict';
describe('LBaaS v2 Members Table Controller', function() {
var controller, lbaasv2API, membersService, scope;
var controller, lbaasv2API, scope;
var items = [{ foo: 'bar' }];
var apiFail = false;
......@@ -47,10 +47,8 @@
beforeEach(inject(function($injector) {
lbaasv2API = $injector.get('horizon.app.core.openstack-service-api.lbaasv2');
membersService = $injector.get('horizon.dashboard.project.lbaasv2.members.service');
controller = $injector.get('$controller');
spyOn(lbaasv2API, 'getMembers').and.callFake(fakeAPI);
spyOn(membersService, 'associateMemberStatuses');
}));
function createController() {
......@@ -85,12 +83,6 @@
expect(ctrl.src.length).toBe(1);
});
it('should invoke the "associateMemberStatuses" method', function() {
var ctrl = createController();
expect(membersService.associateMemberStatuses).toHaveBeenCalledWith(
ctrl.loadbalancerId, ctrl.listenerId, ctrl.poolId, ctrl.src);
});
it('should show error if loading fails', function() {
apiFail = true;
var ctrl = createController();
......
......@@ -27,17 +27,17 @@
<dd>{$ ctrl.pool.admin_state_up | yesno $}</dd>
<dt translate>Health Monitor ID</dt>
<dd>
<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 ng-href="project/load_balancer/{$ ::ctrl.loadbalancer.id $}/listeners/{$ ::ctrl.listener.id $}/pools/{$ ::ctrl.pool.id $}/healthmonitors/{$ ::ctrl.pool.health_monitor_id $}" ng-if="ctrl.pool.health_monitor_id">
{$ ::ctrl.pool.health_monitor_id $}
</a>
<span ng-if="!ctrl.pool.healthmonitor_id">
<span ng-if="!ctrl.pool.health_monitor_id">
{$ 'None' | translate $}
</span>
</dd>
<dt translate>Pool ID</dt>
<dd>{$ ::ctrl.pool.id $}</dd>
<dt translate>Tenant ID</dt>
<dd>{$ ::ctrl.pool.tenant_id $}</dd>
<dt translate>Project ID</dt>
<dd>{$ ::ctrl.pool.project_id $}</dd>
</dl>
</div>
</div>
......
......@@ -4,4 +4,5 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0
Babel!=2.4.0,>=2.3.4 # BSD
openstacksdk>=0.9.18 # Apache-2.0
python-barbicanclient!=4.5.0,!=4.5.1,>=4.0.0 # Apache-2.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment