Browse Source

Being able to change insert headers of listener

Change-Id: I8de70e4f3edf22b316e691388413116b14697081
Story: 1713861
Task: 5368
changes/99/549999/10
Jacky Hu 4 years ago
parent
commit
05170ec174
  1. 4
      octavia_dashboard/api/rest/lbaasv2.py
  2. 2
      octavia_dashboard/static/dashboard/project/lbaasv2/listeners/details/detail.html
  3. 2
      octavia_dashboard/static/dashboard/project/lbaasv2/listeners/details/drawer.html
  4. 8
      octavia_dashboard/static/dashboard/project/lbaasv2/listeners/listeners.module.js
  5. 7
      octavia_dashboard/static/dashboard/project/lbaasv2/workflow/listener/listener.help.html
  6. 36
      octavia_dashboard/static/dashboard/project/lbaasv2/workflow/listener/listener.html
  7. 27
      octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.js
  8. 51
      octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.spec.js
  9. 6
      package.json
  10. 4
      releasenotes/notes/add-insert-headers-a6fd80c837a89536.yaml

4
octavia_dashboard/api/rest/lbaasv2.py

@ -169,7 +169,8 @@ def create_listener(request, **kwargs):
connection_limit=data['listener'].get('connection_limit'),
default_tls_container_ref=default_tls_ref,
sni_container_refs=None,
admin_state_up=data['listener'].get('admin_state_up')
admin_state_up=data['listener'].get('admin_state_up'),
insert_headers=data['listener'].get('insert_headers'),
)
if data.get('pool'):
@ -394,6 +395,7 @@ def update_listener(request, **kwargs):
connection_limit=data['listener'].get('connection_limit'),
admin_state_up=data['listener'].get('admin_state_up'),
default_pool_id=default_pool_id,
insert_headers=data['listener'].get('insert_headers'),
)
if data.get('pool'):

2
octavia_dashboard/static/dashboard/project/lbaasv2/listeners/details/detail.html

@ -51,7 +51,7 @@
item="ctrl.listener"
property-groups="[[
'id', 'name', 'description', 'project_id', 'created_at', 'updated_at',
'connection_limit', 'default_pool_id']]">
'connection_limit', 'insert_headers', 'default_pool_id']]">
</hz-resource-property-list>
</div>
</uib-tab>

2
octavia_dashboard/static/dashboard/project/lbaasv2/listeners/details/drawer.html

@ -5,5 +5,5 @@
['name', 'id', 'project_id'],
['created_at', 'updated_at', 'description'],
['protocol', 'protocol_port', 'connection_limit'],
['default_pool_id']]">
['insert_headers', 'default_pool_id']]">
</hz-resource-property-list>

8
octavia_dashboard/static/dashboard/project/lbaasv2/listeners/listeners.module.js

@ -170,7 +170,13 @@
filters: ['noName']
},
l7_policies: gettext('L7 Policies'),
insert_headers: gettext('Insert Headers'),
insert_headers: {
label: gettext('Insert Headers'),
filters: [
'json',
loadBalancerService.nullFilter
]
},
load_balancers: gettext('Load Balancers')
};
}

7
octavia_dashboard/static/dashboard/project/lbaasv2/workflow/listener/listener.help.html

@ -30,3 +30,10 @@
The ID of the pool used by the listener if no L7 policies match.
</translate>
</p>
<p>
<strong translate>Insert Headers:</strong>
<translate>
Additional headers insertion into HTTP header,
only "X-Forwarded-For" and "X-Forwarded-Port" are supported.
</translate>
</p>

36
octavia_dashboard/static/dashboard/project/lbaasv2/workflow/listener/listener.html

@ -96,6 +96,42 @@
</div>
<h4 translate>Insert Headers</h4>
<div class="row form-group">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="form-group">
<div class="themable-checkbox">
<input type="checkbox"
ng-true-value="'True'"
ng-false-value="''"
id="x_forwarded_for"
ng-model="model.spec.listener.insert_headers['X-Forwarded-For']">
<label for="x_forwarded_for">
<span translate>X-Forwarded-For</span>
</label>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="form-group">
<div class="themable-checkbox">
<input type="checkbox"
ng-true-value="'True'"
ng-false-value="''"
id="x_forwarded_port"
ng-model="model.spec.listener.insert_headers['X-Forwarded-Port']">
<label for="x_forwarded_port">
<span translate>X-Forwarded-port</span>
</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6">

27
octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.js

@ -152,7 +152,8 @@
connection_limit: -1,
admin_state_up: true,
default_pool: null,
default_pool_id: null
default_pool_id: null,
insert_headers: {}
},
l7policy: {
id: null,
@ -455,15 +456,22 @@
// Listener requires protocol and port
delete finalSpec.listener;
delete finalSpec.certificates;
} else if (finalSpec.listener.protocol !== 'TERMINATED_HTTPS') {
// Remove certificate containers if not using TERMINATED_HTTPS
delete finalSpec.certificates;
} else {
var containers = [];
angular.forEach(finalSpec.certificates, function(cert) {
containers.push(cert.id);
});
finalSpec.certificates = containers;
for (var header in finalSpec.listener.insert_headers) {
if (!finalSpec.listener.insert_headers[header]) {
delete finalSpec.listener.insert_headers[header];
}
}
if (finalSpec.listener.protocol !== 'TERMINATED_HTTPS') {
// Remove certificate containers if not using TERMINATED_HTTPS
delete finalSpec.certificates;
} else {
var containers = [];
angular.forEach(finalSpec.certificates, function(cert) {
containers.push(cert.id);
});
finalSpec.certificates = containers;
}
}
}
@ -735,6 +743,7 @@
spec.connection_limit = listener.connection_limit;
spec.admin_state_up = listener.admin_state_up;
spec.default_pool_id = listener.default_pool_id;
spec.insert_headers = listener.insert_headers;
}
function setL7PolicySpec(l7policy) {

51
octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.spec.js

@ -34,7 +34,11 @@
protocol_port: 80,
connection_limit: 999,
load_balancers: [ { id: '1234' } ],
sni_container_refs: ['container2']
sni_container_refs: ['container2'],
insert_headers: {
'X-Forwarded-For': 'True',
'X-Forwarded-Port': 'True'
}
},
pool: {
admin_state_up: true,
@ -1173,7 +1177,7 @@
it('has the right number of properties', function() {
expect(Object.keys(model.spec).length).toBe(11);
expect(Object.keys(model.spec.loadbalancer).length).toBe(5);
expect(Object.keys(model.spec.listener).length).toBe(9);
expect(Object.keys(model.spec.listener).length).toBe(10);
expect(Object.keys(model.spec.l7policy).length).toBe(8);
expect(Object.keys(model.spec.l7rule).length).toBe(7);
expect(Object.keys(model.spec.pool).length).toBe(7);
@ -2442,6 +2446,49 @@
});
describe('Model visible resources (edit listener, no insert headers)', function() {
beforeEach(function() {
delete listenerResources.listener.insert_headers;
delete listenerResources.pool;
model.initialize('listener', '1234');
scope.$apply();
});
it('should only show listener details', function() {
expect(model.context.resource).toEqual('listener');
});
});
describe('Model visible resources (edit listener, no x forwared for)', function() {
beforeEach(function() {
listenerResources.listener.insert_headers['X-Forwarded-For'] = '';
delete listenerResources.pool;
model.initialize('listener', '1234');
scope.$apply();
});
it('should only show listener details', function() {
model.submit();
expect(model.context.resource).toEqual('listener');
});
});
describe('Model visible resources (edit listener, no x forwared port)', function() {
beforeEach(function() {
delete listenerResources.listener.insert_headers['X-Forwarded-Port'];
delete listenerResources.pool;
model.initialize('listener', '1234');
scope.$apply();
});
it('should only show listener details', function() {
expect(model.context.resource).toEqual('listener');
});
});
describe('Model visible resources (edit listener, no pool)', function() {
beforeEach(function() {

6
package.json

@ -8,10 +8,12 @@
"OpenStack",
"octavia",
"octavia-dashboard",
"load-balancer"],
"load-balancer"
],
"repository": {
"type": "git",
"url": "https://git.openstack.org/openstack/octavia-dashboard"},
"url": "https://git.openstack.org/openstack/octavia-dashboard"
},
"bugs": "https://storyboard.openstack.org/#!/project/909",
"license": "Apache 2.0",
"devDependencies": {

4
releasenotes/notes/add-insert-headers-a6fd80c837a89536.yaml

@ -0,0 +1,4 @@
---
features:
- |
Adds the ability to set the insertion headers on listeners.
Loading…
Cancel
Save