From a27ed69f1e97294a4672b3f815495baaedbf01ee Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 22 May 2019 08:48:46 -0700 Subject: [PATCH] Fix 403 issue when creating load balancers The Octavia dashboard code was attempting to access flavor profile information when creating a load balancer. Flavor profiles are administrator only objects that cannot be accessed by users with the default RBAC. This patch removes the code attempting to access the flavor profile as it is not necessary. Change-Id: Ic11d8b84f61c1fd8c97a81f2e47745a339396336 Story: 2005759 Task: 33467 --- .../loadbalancer/loadbalancer.controller.js | 17 +----------- .../loadbalancer.controller.spec.js | 23 +++------------- .../project/lbaasv2/workflow/model.service.js | 9 ------- .../lbaasv2/workflow/model.service.spec.js | 27 +------------------ ...or-no-flavor-profile-c3e82325f16d5ab8.yaml | 7 +++++ 5 files changed, 12 insertions(+), 71 deletions(-) create mode 100644 releasenotes/notes/fix-flavor-no-flavor-profile-c3e82325f16d5ab8.yaml diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.js b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.js index aec12e4f..b1289ce7 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.js @@ -97,27 +97,15 @@ }, { label: gettext('Flavor Description'), value: 'description' - }, { - label: gettext('Provider'), - value: function(flavor) { - var flavorProfile = $scope.model.flavorProfiles[flavor.flavor_profile_id]; - return flavorProfile ? flavorProfile.provider_name : ''; - } }]; ctrl.flavorOptions = []; ctrl.flavorShorthand = function(flavor) { - var flavorProfile = $scope.model.flavorProfiles[flavor.flavor_profile_id]; - - var providerText = - flavorProfile - ? flavorProfile.provider_name - : ''; var flavorText = flavor.name || flavor.id.substring(0, 10) + '...'; var flavorDescription = flavor.description || ''; - return flavorText + ' (' + providerText + '): ' + flavorDescription; + return flavorText + ': ' + flavorDescription; }; ctrl.setFlavor = function(option) { @@ -157,9 +145,6 @@ $scope.$watchCollection('model.flavors', function() { ctrl._checkLoaded(); }); - $scope.$watchCollection('model.flavorProfiles', function() { - ctrl._checkLoaded(); - }); $scope.$watch('model.initialized', function() { ctrl._checkLoaded(); }); diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.spec.js b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.spec.js index 1c0a0c15..313a8fca 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.spec.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/loadbalancer/loadbalancer.controller.spec.js @@ -75,13 +75,6 @@ is_enabled: true } }, - flavorProfiles: { - '79e16118-daba-4255-9d1d-9cc7812e18a1': { - id: '79e16118-daba-4255-9d1d-9cc7812e18a1', - name: 'flavor_profile_1', - provider_name: 'amphora' - } - }, subnets: [{}, {}], spec: { loadbalancer: { @@ -123,13 +116,13 @@ it('should create flavor shorthand text', function() { expect(ctrl.flavorShorthand(mockFlavors[0])).toBe( - 'flavor_1 (amphora): Flavor 1 description' + 'flavor_1: Flavor 1 description' ); expect(ctrl.flavorShorthand(mockFlavors[1])).toBe( - 'flavor_2 (): ' + 'flavor_2: ' ); expect(ctrl.flavorShorthand(mockFlavors[2])).toBe( - '94306089-5... (): ' + '94306089-5...: ' ); }); @@ -162,10 +155,6 @@ scope.$apply(); expect(ctrl._checkLoaded).toHaveBeenCalled(); - scope.model.flavorProfiles = {}; - scope.$apply(); - expect(ctrl._checkLoaded).toHaveBeenCalled(); - scope.model.initialized = true; scope.$apply(); @@ -239,12 +228,6 @@ expect(ctrl.flavorColumns[2].label).toBe('Flavor Description'); expect(ctrl.flavorColumns[2].value).toBe('description'); - - expect(ctrl.flavorColumns[3].label).toBe('Provider'); - var flavorLabel3 = ctrl.flavorColumns[3].value(mockFlavors[0]); - expect(flavorLabel3).toBe('amphora'); - flavorLabel3 = ctrl.flavorColumns[3].value(mockFlavors[1]); - expect(flavorLabel3).toBe(''); }); }); diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.js b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.js index 5a450428..42c1cbeb 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.js @@ -86,7 +86,6 @@ members: [], networks: {}, flavors: {}, - flavorProfiles: {}, listenerProtocols: ['HTTP', 'TCP', 'TERMINATED_HTTPS', 'HTTPS'], l7policyActions: ['REJECT', 'REDIRECT_TO_URL', 'REDIRECT_TO_POOL'], l7ruleTypes: ['HOST_NAME', 'PATH', 'FILE_TYPE', 'HEADER', 'COOKIE'], @@ -267,7 +266,6 @@ model.context.submit = createLoadBalancer; return $q.all([ lbaasv2API.getFlavors().then(onGetFlavors), - lbaasv2API.getFlavorProfiles().then(onGetFlavorProfiles), neutronAPI.getSubnets().then(onGetSubnets), neutronAPI.getPorts().then(onGetPorts), neutronAPI.getNetworks().then(onGetNetworks), @@ -288,12 +286,6 @@ }); } - function onGetFlavorProfiles(response) { - angular.forEach(response.data.items, function(value) { - model.flavorProfiles[value.id] = value; - }); - } - function initCreateListener(keymanagerPromise) { model.context.submit = createListener; return $q.all([ @@ -355,7 +347,6 @@ model.context.submit = editLoadBalancer; return $q.all([ lbaasv2API.getFlavors().then(onGetFlavors), - lbaasv2API.getFlavorProfiles().then(onGetFlavorProfiles), lbaasv2API.getLoadBalancer(model.context.id).then(onGetLoadBalancer), neutronAPI.getSubnets().then(onGetSubnets), neutronAPI.getNetworks().then(onGetNetworks) diff --git a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.spec.js b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.spec.js index ae1a18d2..97e54e6b 100644 --- a/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.spec.js +++ b/octavia_dashboard/static/dashboard/project/lbaasv2/workflow/model.service.spec.js @@ -18,7 +18,7 @@ describe('LBaaS v2 Workflow Model Service', function() { var model, $q, scope, listenerResources, barbicanEnabled, - certificatesError, mockNetworks, mockFlavors, mockFlavorProfiles; + certificatesError, mockNetworks, mockFlavors; var includeChildResources = true; beforeEach(module('horizon.framework.util.i18n')); @@ -105,16 +105,6 @@ id: 'f2' } }; - mockFlavorProfiles = { - p1: { - name: 'flavor_profile_1', - id: 'p1' - }, - p2: { - name: 'flavor_profile_2', - id: 'p2' - } - }; }); beforeEach(module(function($provide) { @@ -276,19 +266,6 @@ deferred.resolve({data: {items: flavors}}); return deferred.promise; }, - getFlavorProfiles: function() { - var flavorProfiles = [{ - name: 'flavor_profile_1', - id: 'p1' - }, { - name: 'flavor_profile_2', - id: 'p2' - }]; - - var deferred = $q.defer(); - deferred.resolve({data: {items: flavorProfiles}}); - return deferred.promise; - }, createLoadBalancer: function(spec) { return spec; }, @@ -534,7 +511,6 @@ expect(model.subnets.length).toBe(2); expect(model.networks).toEqual(mockNetworks); expect(model.flavors).toEqual(mockFlavors); - expect(model.flavorProfiles).toEqual(mockFlavorProfiles); expect(model.members.length).toBe(2); expect(model.certificates.length).toBe(2); expect(model.listenerPorts.length).toBe(0); @@ -792,7 +768,6 @@ expect(model.subnets.length).toBe(2); expect(model.networks).toEqual(mockNetworks); expect(model.flavors).toEqual(mockFlavors); - expect(model.flavorProfiles).toEqual(mockFlavorProfiles); expect(model.members.length).toBe(0); expect(model.certificates.length).toBe(0); expect(model.listenerPorts.length).toBe(0); diff --git a/releasenotes/notes/fix-flavor-no-flavor-profile-c3e82325f16d5ab8.yaml b/releasenotes/notes/fix-flavor-no-flavor-profile-c3e82325f16d5ab8.yaml new file mode 100644 index 00000000..094f8bb8 --- /dev/null +++ b/releasenotes/notes/fix-flavor-no-flavor-profile-c3e82325f16d5ab8.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue in the Octavia dashboard where users receive a 403 + error when attempting to create a load balancer. This was due to + the dashboard attempting to access the flavor profile information + which is an administrator only object by default.