Merge "Allow member name to be set and updated"

This commit is contained in:
Zuul 2018-05-21 22:56:21 +00:00 committed by Gerrit Code Review
commit 31573a39ae
23 changed files with 95 additions and 229 deletions

View File

@ -270,7 +270,8 @@ def create_health_monitor(request, **kwargs):
http_method=data['monitor'].get('http_method'),
url_path=data['monitor'].get('url_path'),
expected_codes=data['monitor'].get('expected_codes'),
admin_state_up=data['monitor'].get('admin_state_up')
admin_state_up=data['monitor'].get('admin_state_up'),
name=data['monitor'].get('name')
)
return _get_sdk_object_dict(health_mon)
@ -305,7 +306,8 @@ def add_member(request, **kwargs):
weight=member.get('weight'),
monitor_address=monitor_address if monitor_address else None,
monitor_port=member.get('monitor_port'),
admin_state_up=member.get('admin_state_up')
admin_state_up=member.get('admin_state_up'),
name=member.get('name'),
)
index += 1
@ -506,7 +508,8 @@ def update_monitor(request, **kwargs):
http_method=data['monitor'].get('http_method'),
url_path=data['monitor'].get('url_path'),
expected_codes=data['monitor'].get('expected_codes'),
admin_state_up=data['monitor'].get('admin_state_up')
admin_state_up=data['monitor'].get('admin_state_up'),
name=data['monitor'].get('name')
)
return _get_sdk_object_dict(healthmonitor)
@ -1075,7 +1078,8 @@ class Member(generic.View):
member_id, pool_id, weight=data.get('weight'),
monitor_address=monitor_address if monitor_address else None,
monitor_port=data.get('monitor_port'),
admin_state_up=data.get('admin_state_up')
admin_state_up=data.get('admin_state_up'),
name=data.get('name'),
)
return _get_sdk_object_dict(member)

View File

@ -50,7 +50,7 @@
patterns, gettext, poolId, member) {
var ctrl = this;
ctrl.adminStateUpOptions = [
ctrl.yesNoOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
@ -64,6 +64,7 @@
ctrl.monitor_address = member.monitor_address;
ctrl.monitor_port = member.monitor_port;
ctrl.admin_state_up = member.admin_state_up;
ctrl.name = member.name;
ctrl.cancel = cancel;
ctrl.save = save;
ctrl.saving = false;
@ -79,7 +80,8 @@
weight: ctrl.weight,
monitor_address: ctrl.monitor_address,
monitor_port: ctrl.monitor_port,
admin_state_up: ctrl.admin_state_up
admin_state_up: ctrl.admin_state_up,
name: ctrl.name
}).then(onSuccess, onFailure);
}

View File

@ -42,7 +42,8 @@
weight: 1,
monitor_address: '1.1.1.1',
monitor_port: 80,
admin_state_up: true
admin_state_up: true,
name: 'member name'
});
$provide.value('horizon.app.core.openstack-service-api.lbaasv2', {
editMember: function() {
@ -84,7 +85,8 @@
weight: 1,
monitor_address: '1.1.1.1',
monitor_port: 80,
admin_state_up: true
admin_state_up: true,
name: 'member name'
});
expect($uibModalInstance.close).toHaveBeenCalled();
});

View File

@ -8,6 +8,15 @@
<p translate>Provide the details for the member.</p>
<div class="row">
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="form-group">
<label class="control-label" for="name">
<translate>Name</translate>
</label>
<input name="name" id="name" type="text" class="form-control"
ng-model="modal.name">
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="form-group"
ng-class="{ 'has-error': form.address.$invalid && form.address.$dirty }">
@ -79,13 +88,13 @@
</div>
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="col-xs-12 col-sm-8 col-md-4">
<div class="form-group">
<label class="control-label required" translate>Admin State Up</label>
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in modal.adminStateUpOptions"
ng-repeat="option in modal.yesNoOptions"
ng-model="modal.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>

View File

@ -40,11 +40,6 @@
var ctrl = this;
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
ctrl.redirectUrlError = gettext('The redirect url must be a valid http or https url.');
ctrl.positionError = gettext('The position must be a number between 1 and 2147483647.');

View File

@ -28,8 +28,9 @@
ctrl = $controller('L7PolicyDetailsController');
}));
it('should define adminStateUpOptions', function() {
expect(ctrl.adminStateUpOptions).toBeDefined();
it('should define error messages', function() {
expect(ctrl.redirectUrlError).toBeDefined();
expect(ctrl.positionError).toBeDefined();
});
});

View File

@ -91,7 +91,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.l7policy.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>

View File

@ -1,49 +0,0 @@
/*
* Copyright 2018 Walmart.
*
* 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')
.controller('L7RuleDetailsController', L7RuleDetailsController);
L7RuleDetailsController.$inject = [
'horizon.dashboard.project.lbaasv2.patterns',
'horizon.framework.util.i18n.gettext'
];
/**
* @ngdoc controller
* @name L7RuleDetailsController
* @description
* The `L7RuleDetailsController` controller provides functions for
* configuring the l7rule step of the LBaaS wizard.
* @param patterns The LBaaS v2 patterns constant.
* @param gettext The horizon gettext function for translation.
* @returns undefined
*/
function L7RuleDetailsController(patterns, gettext) {
var ctrl = this;
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
}
})();

View File

@ -1,37 +0,0 @@
/*
* Copyright 2018 Walmart.
*
* 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('L7Rule Details Step', function() {
beforeEach(module('horizon.framework.util'));
beforeEach(module('horizon.dashboard.project.lbaasv2'));
describe('L7RuleDetailsController', function() {
var ctrl;
beforeEach(inject(function($controller) {
ctrl = $controller('L7RuleDetailsController');
}));
it('should define adminStateUpOptions', function() {
expect(ctrl.adminStateUpOptions).toBeDefined();
});
});
});
})();

View File

@ -1,4 +1,4 @@
<div ng-controller="L7RuleDetailsController as ctrl">
<div>
<p translate>Provide the details for the l7 rule.</p>
<div class="row">
@ -9,7 +9,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.l7rule.invert"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>
@ -47,7 +47,21 @@
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="col-xs-12 col-sm-8 col-md-6" ng-if="model.spec.l7rule.type === 'FILE_TYPE'">
<div class="form-group required">
<label class="control-label" for="compare_type">
<translate>Compare Type</translate>
<span class="hz-icon-required fa fa-asterisk"></span>
</label>
<select class="form-control" name="compare_type" id="compare_type"
ng-options="compare_type for compare_type in model.l7ruleFileTypeCompareTypes"
ng-model="model.spec.l7rule.compare_type"
ng-required="true">
</select>
</div>
</div>
<div class="col-xs-12 col-sm-8 col-md-6" ng-if="model.spec.l7rule.type !== 'FILE_TYPE'">
<div class="form-group required">
<label class="control-label" for="compare_type">
<translate>Compare Type</translate>
@ -79,7 +93,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.l7rule.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>

View File

@ -40,11 +40,6 @@
var ctrl = this;
ctrl.protocolChange = protocolChange;
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
// Error text for invalid fields
ctrl.portNumberError = gettext('The port must be a number between 1 and 65535.');
ctrl.portUniqueError = gettext(

View File

@ -140,7 +140,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.listener.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>

View File

@ -40,11 +40,6 @@
var ctrl = this;
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
// Error text for invalid fields
ctrl.ipError = gettext('The IP address is not valid.');

View File

@ -60,7 +60,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.loadbalancer.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>

View File

@ -45,11 +45,6 @@
var ctrl = this;
var memberCounter = 0;
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
// Error text for invalid fields
ctrl.portError = gettext('The port must be a number between 1 and 65535.');
ctrl.weightError = gettext('The weight must be a number between 1 and 256.');
@ -123,7 +118,8 @@
weight: 1,
monitor_address: null,
monitor_port: null,
admin_state_up: true
admin_state_up: true,
name: null
});
}

View File

@ -112,7 +112,7 @@
Can be toggled using the chevron button.
Ensure colspan is greater or equal to number of column-headers.
-->
<td class="detail" colspan="8">
<td class="detail" colspan="9">
<div class="row">
<dl class="col-lg-5 col-md-5 col-sm-5">
@ -146,7 +146,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="row.admin_state_up"
ng-disabled="row.allocatedMember"
uib-btn-radio="option.value">{$ ::option.label $}</label>
@ -154,12 +154,24 @@
</div>
</dd>
</dl>
<dl class="col-lg-5 col-md-5 col-sm-5">
<dt class="control-label required" translate>Name</dt>
<dd class="form-group">
<div class="form-field">
<input type="text"
id="name"
ng-model="row.name"
ng-disabled="row.allocatedMember"
>
</div>
</dd>
</dl>
</div>
</td>
</tr>
<tr table-status table="table" column-count="8"></tr>
<tr table-status table="table" column-count="9"></tr>
<tr>
<td colspan="6">

View File

@ -57,7 +57,8 @@
novaAPI,
lbaasv2API,
barbicanAPI,
serviceCatalog
serviceCatalog,
gettext
) {
var ports, keymanagerPromise;
@ -86,7 +87,8 @@
listenerProtocols: ['HTTP', 'TCP', 'TERMINATED_HTTPS', 'HTTPS'],
l7policyActions: ['REJECT', 'REDIRECT_TO_URL', 'REDIRECT_TO_POOL'],
l7ruleTypes: ['HOST_NAME', 'PATH', 'FILE_TYPE', 'HEADER', 'COOKIE'],
l7ruleCompareTypes: ['REGEX', 'STARTS_WITH', 'ENDS_WITH', 'CONTAINS', 'EQUAL_TO'],
l7ruleCompareTypes: ['REGEX', 'EQUAL_TO', 'STARTS_WITH', 'ENDS_WITH', 'CONTAINS'],
l7ruleFileTypeCompareTypes: ['REGEX', 'EQUAL_TO'],
poolProtocols: ['HTTP', 'HTTPS', 'PROXY', 'TCP'],
methods: ['LEAST_CONNECTIONS', 'ROUND_ROBIN', 'SOURCE_IP'],
types: ['SOURCE_IP', 'HTTP_COOKIE', 'APP_COOKIE'],
@ -95,6 +97,10 @@
'TRACE', 'OPTIONS', 'PATCH', 'CONNECT'],
certificates: [],
listenerPorts: [],
yesNoOptions: [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
],
/**
* api methods for UI controllers
@ -505,7 +511,7 @@
var members = [];
angular.forEach(finalSpec.members, function cleanMember(member) {
if (member.address && member.protocol_port) {
var propsToRemove = ['name', 'description', 'addresses', 'allocatedMember'];
var propsToRemove = ['description', 'addresses', 'allocatedMember'];
propsToRemove.forEach(function deleteProperty(prop) {
if (angular.isDefined(member[prop])) {
delete member[prop];
@ -795,6 +801,7 @@
monitor_address: member.monitor_address,
monitor_port: member.monitor_port,
admin_state_up: member.admin_state_up,
name: member.name,
allocatedMember: true
});
});
@ -813,6 +820,7 @@
spec.expected_codes = monitor.expected_codes;
spec.url_path = monitor.url_path;
spec.admin_state_up = monitor.admin_state_up;
spec.name = monitor.name;
}
function onGetHealthMonitor(response) {

View File

@ -1499,7 +1499,7 @@
expect(finalSpec.members[0].weight).toBe(1);
expect(finalSpec.members[0].id).toBe('1');
expect(finalSpec.members[0].addresses).toBeUndefined();
expect(finalSpec.members[0].name).toBeUndefined();
expect(finalSpec.members[0].name).toBe('foo');
expect(finalSpec.members[0].allocatedMember).toBeUndefined();
expect(finalSpec.members[1].id).toBe('external-member-0');
expect(finalSpec.members[1].address).toBe('2.3.4.5');
@ -1746,7 +1746,7 @@
expect(finalSpec.members[0].weight).toBe(1);
expect(finalSpec.members[0].id).toBe('1');
expect(finalSpec.members[0].addresses).toBeUndefined();
expect(finalSpec.members[0].name).toBeUndefined();
expect(finalSpec.members[0].name).toBe('foo');
expect(finalSpec.members[0].allocatedMember).toBeUndefined();
expect(finalSpec.members[1].id).toBe('external-member-0');
expect(finalSpec.members[1].address).toBe('2.3.4.5');
@ -1995,7 +1995,7 @@
expect(finalSpec.members[0].weight).toBe(1);
expect(finalSpec.members[0].id).toBe('1');
expect(finalSpec.members[0].addresses).toBeUndefined();
expect(finalSpec.members[0].name).toBeUndefined();
expect(finalSpec.members[0].name).toBe('foo');
expect(finalSpec.members[0].allocatedMember).toBeUndefined();
expect(finalSpec.members[1].id).toBe('external-member-0');
expect(finalSpec.members[1].address).toBe('2.3.4.5');

View File

@ -55,11 +55,6 @@
}
});
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
// Error text for invalid fields
/* eslint-disable max-len */
ctrl.intervalError = gettext('The health check interval must be greater than or equal to the timeout.');

View File

@ -3,6 +3,16 @@
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4">
<div class="form-group">
<label class="control-label" for="name">
<translate>Name</translate>
</label>
<input name="name" id="name" type="text" class="form-control"
ng-model="model.spec.monitor.name">
</div>
</div>
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4">
<div class="form-group required">
<label class="control-label" for="type">
@ -133,7 +143,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.monitor.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>

View File

@ -1,49 +0,0 @@
/*
* Copyright 2017 Walmart.
*
* 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')
.controller('PoolDetailsController', PoolDetailsController);
PoolDetailsController.$inject = [
'horizon.dashboard.project.lbaasv2.patterns',
'horizon.framework.util.i18n.gettext'
];
/**
* @ngdoc controller
* @name PoolDetailsController
* @description
* The `PoolDetailsController` controller provides functions for
* configuring the pool step of the LBaaS wizard.
* @param patterns The LBaaS v2 patterns constant.
* @param gettext The horizon gettext function for translation.
* @returns undefined
*/
function PoolDetailsController(patterns, gettext) {
var ctrl = this;
ctrl.adminStateUpOptions = [
{ label: gettext('Yes'), value: true },
{ label: gettext('No'), value: false }
];
}
})();

View File

@ -1,37 +0,0 @@
/*
* Copyright 2017 Walmart.
*
* 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('Pool Details Step', function() {
beforeEach(module('horizon.framework.util'));
beforeEach(module('horizon.dashboard.project.lbaasv2'));
describe('PoolDetailsController', function() {
var ctrl;
beforeEach(inject(function($controller) {
ctrl = $controller('PoolDetailsController');
}));
it('should define adminStateUpOptions', function() {
expect(ctrl.adminStateUpOptions).toBeDefined();
});
});
});
})();

View File

@ -1,4 +1,4 @@
<div ng-controller="PoolDetailsController as ctrl">
<div>
<p translate>Provide the details for the pool.</p>
<div class="row">
@ -88,7 +88,7 @@
<div class="form-field">
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="option in ctrl.adminStateUpOptions"
ng-repeat="option in model.yesNoOptions"
ng-model="model.spec.pool.admin_state_up"
uib-btn-radio="option.value">{$ ::option.label $}</label>
</div>